From 8333f45c9b6cd1901f57815eaf0cf6f726feffd0 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 23 Oct 2024 16:13:18 -0300 Subject: [PATCH] clib: Fix build with old libpci on Linux --- clib/clib_pci.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/clib/clib_pci.c b/clib/clib_pci.c index 89ea4c8..6730b1f 100644 --- a/clib/clib_pci.c +++ b/clib/clib_pci.c @@ -33,7 +33,9 @@ uint8_t pci_mechanism = 0, pci_device_count = 0; static struct pci_access *pacc; static struct pci_dev *pdev; static uint32_t last_addr = -1; +# ifdef _WIN32 static const char win_notice[] = "NOTICE: These are dummy configuration registers generated by libpci, as it cannot access the real ones under Windows. It does not reflect the device's actual configuration."; +# endif #endif /* Configuration functions. */ @@ -144,6 +146,7 @@ pci_init_dev(uint8_t bus, uint8_t dev, uint8_t func) if (!pacc->devices) { libpci_scan_bus(pacc); +#if defined(_WIN32) && PCI_LIB_VERSION > 0x030800 /* Generate additional configuration values not generated by libpci's emulated configuration space code on Windows. */ if ((pacc->method == PCI_ACCESS_WIN32_CFGMGR32) && !pacc->backend_data) { /* backend_data is NULL if no usable raw access method was found */ @@ -180,6 +183,7 @@ pci_init_dev(uint8_t bus, uint8_t dev, uint8_t func) } } } +#endif } for (pdev = pacc->devices; pdev; pdev = pdev->next) { @@ -194,17 +198,9 @@ int pci_init() { #ifdef PCI_LIB_VERSION -# ifndef _WIN32 - if (iopl(3)) { - perror("iopl"); - goto pci_init_fail; - } -# endif - pacc = pci_alloc(); if (!pacc) { printf("Failed to allocate pci_access structure.\n"); -pci_init_fail: pci_mechanism = 0; return pci_mechanism; }