From 94d1b5e030cb7c1caf151c5dede18929444ee983 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 11 Feb 2008 21:10:49 +0100 Subject: [PATCH] Use DNS on all architectures except AIX. --- lib/Makefile | 5 +---- lib/configure | 6 ++++++ lib/names-cache.c | 31 ++++++++++++++++++++++++------- lib/names-net.c | 18 +++++++++++++++--- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 1a0678c..87a87fd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -3,7 +3,7 @@ include config.mk -OBJS=access.o generic.o dump.o names.o filter.o names-hash.o names-parse.o +OBJS=access.o generic.o dump.o names.o filter.o names-hash.o names-parse.o names-net.o names-cache.o INCL=internal.h pci.h config.h header.h sysdep.h types.h PCILIB=libpci.a @@ -46,9 +46,6 @@ OBJS += nbsd-libpci.o PCILIB=libpciutils.a endif -# FIXME: Conditions -OBJS += names-net.o names-cache.o - all: $(PCILIB) $(PCILIBPC) $(PCILIB): $(OBJS) diff --git a/lib/configure b/lib/configure index b368c98..f26e51d 100755 --- a/lib/configure +++ b/lib/configure @@ -57,6 +57,7 @@ case $sys in ;; esac echo >>$c '#define PCI_HAVE_64BIT_ADDRESS' + echo >>$c '#define PCI_USE_DNS' ;; sunos) case $cpu in @@ -69,16 +70,19 @@ case $sys in ;; esac echo >>$c '#define PCI_HAVE_STDINT_H' + echo >>$c '#define PCI_USE_DNS' ;; freebsd) echo_n " fbsd-device" echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE' echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"' + echo >>$c '#define PCI_USE_DNS' ;; openbsd) echo_n " obsd-device" echo >>$c '#define PCI_HAVE_PM_OBSD_DEVICE' echo >>$c '#define PCI_PATH_OBSD_DEVICE "/dev/pci"' + echo >>$c '#define PCI_USE_DNS' ;; aix) echo_n " aix-device" @@ -89,6 +93,7 @@ case $sys in ;; netbsd) echo_n " nbsd-libpci" + echo >>$c '#define PCI_USE_DNS' echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI' echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"' echo >>$m 'PCILIB=lib/libpciutils.a' @@ -97,6 +102,7 @@ case $sys in gnu) echo_n " i386-ports" echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' + echo >>$c '#define PCI_USE_DNS' ;; *) echo " Unfortunately, your OS is not supported by the PCI Library" diff --git a/lib/names-cache.c b/lib/names-cache.c index 2811fe4..09f29b2 100644 --- a/lib/names-cache.c +++ b/lib/names-cache.c @@ -17,6 +17,8 @@ #include "internal.h" #include "names.h" +#ifdef PCI_USE_DNS + static const char cache_version[] = "#PCI-CACHE-1.0"; int @@ -96,13 +98,6 @@ pci_id_cache_load(struct pci_access *a, int flags) return 1; } -void -pci_id_cache_dirty(struct pci_access *a) -{ - if (a->id_cache_status >= 1) - a->id_cache_status = 2; -} - void pci_id_cache_flush(struct pci_access *a) { @@ -149,6 +144,28 @@ pci_id_cache_flush(struct pci_access *a) fclose(f); } +#else + +int pci_id_cache_load(struct pci_access *a UNUSED, int flags UNUSED) +{ + a->id_cache_status = 1; + return 0; +} + +void pci_id_cache_flush(struct pci_access *a) +{ + a->id_cache_status = 0; +} + +#endif + +void +pci_id_cache_dirty(struct pci_access *a) +{ + if (a->id_cache_status >= 1) + a->id_cache_status = 2; +} + void pci_set_id_cache(struct pci_access *a, char *name, int to_be_freed) { diff --git a/lib/names-net.c b/lib/names-net.c index 167cd1f..112e1ad 100644 --- a/lib/names-net.c +++ b/lib/names-net.c @@ -8,13 +8,16 @@ #include #include -#include -#include -#include #include "internal.h" #include "names.h" +#ifdef PCI_USE_DNS + +#include +#include +#include + char *pci_id_net_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4) { @@ -88,6 +91,15 @@ char return NULL; } +#else + +char *pci_id_net_lookup(struct pci_access *a UNUSED, int cat UNUSED, int id1 UNUSED, int id2 UNUSED, int id3 UNUSED, int id4 UNUSED) +{ + return NULL; +} + +#endif + void pci_set_net_domain(struct pci_access *a, char *name, int to_be_freed) { -- 2.39.2