X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcommon_init.c;h=f7b59bd3f046b640878951a27cda7933282e51b2;hb=6bd2f7f92eae713663f4e13f6e2cb23526607b8c;hp=6b83d972d0e40fe815af048dc8b5455264c0db14;hpb=4c1c607c602e5e8d9277b9c01edfa7a8d10333cd;p=android-x86%2Fexternal-libpciaccess.git diff --git a/src/common_init.c b/src/common_init.c index 6b83d97..f7b59bd 100644 --- a/src/common_init.c +++ b/src/common_init.c @@ -28,6 +28,9 @@ * * \author Ian Romanick */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include @@ -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; }