OSDN Git Service

linux_sysfs.c: Include <limits.h> for PATH_MAX
[android-x86/external-libpciaccess.git] / src / common_init.c
index 6b83d97..f7b59bd 100644 (file)
@@ -28,6 +28,9 @@
  *
  * \author Ian Romanick <idr@us.ibm.com>
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <stdlib.h>
 #include <errno.h>
@@ -39,7 +42,7 @@ _pci_hidden struct pci_system * pci_sys;
 
 /**
  * Initialize the PCI subsystem for access.
- * 
+ *
  * \return
  * Zero on success or an errno value on failure.  In particular, if no
  * platform-specific initializers are available, \c ENOSYS will be returned.
@@ -51,8 +54,8 @@ int
 pci_system_init( void )
 {
     int err = ENOSYS;
-    
-#ifdef linux
+
+#ifdef __linux__
     err = pci_system_linux_sysfs_create();
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
     err = pci_system_freebsd_create();
@@ -62,6 +65,10 @@ pci_system_init( void )
     err = pci_system_openbsd_create();
 #elif defined(__sun)
     err = pci_system_solx_devfs_create();
+#elif defined(__GNU__) || defined(__CYGWIN__)
+    err = pci_system_x86_create();
+#else
+# error "Unsupported OS"
 #endif
 
     return err;
@@ -77,7 +84,7 @@ pci_system_init_dev_mem(int fd)
 
 /**
  * Shutdown all access to the PCI subsystem.
- * 
+ *
  * \sa pci_system_init
  */
 void
@@ -91,6 +98,7 @@ pci_system_cleanup( void )
        return;
     }
 
+    pci_io_cleanup();
 
     if ( pci_sys->devices ) {
        for ( i = 0 ; i < pci_sys->num_devices ; i++ ) {
@@ -100,7 +108,7 @@ pci_system_cleanup( void )
 
            free( (char *) pci_sys->devices[i].device_string );
            free( (char *) pci_sys->devices[i].agp );
-           
+
            pci_sys->devices[i].device_string = NULL;
            pci_sys->devices[i].agp = NULL;
 
@@ -108,17 +116,16 @@ pci_system_cleanup( void )
                (*pci_sys->methods->destroy_device)( & pci_sys->devices[i].base );
            }
        }
-       
+
        free( pci_sys->devices );
        pci_sys->devices = NULL;
        pci_sys->num_devices = 0;
     }
 
-
     if ( pci_sys->methods->destroy != NULL ) {
        (*pci_sys->methods->destroy)();
     }
-    
+
     free( pci_sys );
     pci_sys = NULL;
 }