From 489233b45bc68e94b2d065f696ed22bc6e6eec02 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 13 Aug 2004 20:36:33 +0000 Subject: [PATCH] Include file splits and namespace cleanups. git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-60 --- ChangeLog | 23 +++++++++++++++ Makefile | 2 +- README.Windows | 14 ++++----- common.c | 6 ++-- lib/Makefile | 22 ++++++-------- lib/access.c | 16 +++++------ lib/configure | 36 +++++++++++------------ lib/fbsd-device.c | 2 +- lib/generic.c | 2 +- lib/i386-ports.c | 8 +++--- lib/internal.h | 71 ++------------------------------------------- lib/nbsd-libpci.c | 2 +- lib/pci.h | 48 +------------------------------ lib/pread.h | 6 ++-- lib/proc.c | 2 +- lib/sysdep.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++ lib/sysfs.c | 2 +- lib/types.h | 57 ++++++++++++++++++++++++++++++++++++ pciutils.h | 18 ++++-------- 19 files changed, 220 insertions(+), 190 deletions(-) create mode 100644 lib/sysdep.h create mode 100644 lib/types.h diff --git a/ChangeLog b/ChangeLog index aa1c2f7..ee027df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,28 @@ 2004-08-13 Martin Mares + * lib/types.h: If PCI_HAVE_Uxx_TYPES is defined, libpci doesn't define + its own u8, u16, u32, byte and word types and uses what the user + has supplied instead. With this change, all namespace clashes should + be gone. + + * Makefile, lib/Makefile: Updated dependencies. + + * pciutils.h: Include lib/sysdep.h and move NONRET et al. there. + + * lib/sysdep.h: No need to include on FreeBSD, because + it is included unconditionally in lib/types.h. + + * Moved system-dependent stuff from lib/internal.h to lib/sysdep.h, + which is also used by the utilities. Also moved type declarations + from lib/pci.h to lib/types.h. + + * All files: Prepend a "PCI_" prefix in front of all configuration + defines to avoid namespace clashes. CAVEAT: If there is any libpci + application using the (undocumented) defines, it has to be updated. + + * lib/Makefile: Killed HAVE_OWN_HEADER_H, since we stopped sharing + headers with the kernel a couple of years ago. + * lib/sysfs.c (sysfs_get_resources): We have 7 resources, not 6. * lspci.c (show_rom): Use the same logic for printing disabled diff --git a/Makefile b/Makefile index 6bcc1ed..fd41109 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ MANDIR:=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; INSTALL=install DIRINSTALL=install -d PCILIB=lib/libpci.a -PCIINC=lib/config.h lib/header.h lib/pci.h +PCIINC=lib/config.h lib/header.h lib/pci.h lib/types.h lib/sysdep.h ifeq ($(shell uname),NetBSD) PCILIB=libpciutils.a diff --git a/README.Windows b/README.Windows index 3eca690..81b41f3 100644 --- a/README.Windows +++ b/README.Windows @@ -4,14 +4,14 @@ However, you need to configure the package manually: lib/config.mk: -ARCH_I386=1 -HAVE_PM_INTEL_CONF=1 -OS_WINDOWS=1 +PCI_ARCH_I386=1 +PCI_HAVE_PM_INTEL_CONF=1 +PCI_OS_WINDOWS=1 lib/config.h: -#define ARCH_I386 -#define OS_WINDOWS -#define HAVE_PM_INTEL_CONF -#define PATH_PCI_IDS "pci.ids" +#define PCI_ARCH_I386 +#define PCI_OS_WINDOWS +#define PCI_HAVE_PM_INTEL_CONF +#define PCI_PATH_IDS "pci.ids" #define PCILIB_VERSION "2.1.99-test5" diff --git a/common.c b/common.c index 9181e4e..2bfd1b8 100644 --- a/common.c +++ b/common.c @@ -49,13 +49,13 @@ parse_generic_option(int i, struct pci_access *pacc, char *optarg) { switch (i) { -#ifdef HAVE_PM_LINUX_PROC +#ifdef PCI_HAVE_PM_LINUX_PROC case 'P': pacc->method_params[PCI_ACCESS_PROC_BUS_PCI] = optarg; pacc->method = PCI_ACCESS_PROC_BUS_PCI; break; #endif -#ifdef HAVE_PM_INTEL_CONF +#ifdef PCI_HAVE_PM_INTEL_CONF case 'H': if (!strcmp(optarg, "1")) pacc->method = PCI_ACCESS_I386_TYPE1; @@ -65,7 +65,7 @@ parse_generic_option(int i, struct pci_access *pacc, char *optarg) die("Unknown hardware configuration type %s", optarg); break; #endif -#ifdef HAVE_PM_DUMP +#ifdef PCI_HAVE_PM_DUMP case 'F': pacc->method_params[PCI_ACCESS_DUMP] = optarg; pacc->method = PCI_ACCESS_DUMP; diff --git a/lib/Makefile b/lib/Makefile index b0a2de8..44296ca 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -4,31 +4,31 @@ include config.mk OBJS=access.o generic.o dump.o names.o filter.o -INCL=internal.h pci.h config.h +INCL=internal.h pci.h config.h header.h sysdep.h types.h PCILIB=libpci.a -ifdef HAVE_PM_LINUX_SYSFS +ifdef PCI_HAVE_PM_LINUX_SYSFS OBJS += sysfs.o endif -ifdef HAVE_PM_LINUX_PROC +ifdef PCI_HAVE_PM_LINUX_PROC OBJS += proc.o endif -ifdef HAVE_PM_INTEL_CONF +ifdef PCI_HAVE_PM_INTEL_CONF OBJS += i386-ports.o endif -ifdef HAVE_PM_DUMP +ifdef PCI_HAVE_PM_DUMP OBJS += dump.o endif -ifdef HAVE_PM_SYSCALLS +ifdef PCI_HAVE_PM_SYSCALLS OBJS += syscalls.o endif -ifdef HAVE_PM_FBSD_DEVICE +ifdef PCI_HAVE_PM_FBSD_DEVICE OBJS += fbsd-device.o CFLAGS += -I/usr/src/sys ifdef FREEBSD_SYS @@ -36,19 +36,15 @@ CFLAGS += -I${FREEBSD_SYS} endif endif -ifdef HAVE_PM_AIX_DEVICE +ifdef PCI_HAVE_PM_AIX_DEVICE OBJS += aix-device.o endif -ifdef HAVE_PM_NBSD_LIBPCI +ifdef PCI_HAVE_PM_NBSD_LIBPCI OBJS += nbsd-libpci.o PCILIB=libpciutils.a endif -ifdef HAVE_OWN_HEADER_H -INCL += header.h -endif - all: $(PCILIB) $(PCILIB): $(OBJS) diff --git a/lib/access.c b/lib/access.c index eee22d2..5683eac 100644 --- a/lib/access.c +++ b/lib/access.c @@ -15,39 +15,39 @@ static struct pci_methods *pci_methods[PCI_ACCESS_MAX] = { NULL, -#ifdef HAVE_PM_LINUX_SYSFS +#ifdef PCI_HAVE_PM_LINUX_SYSFS &pm_linux_sysfs, #else NULL, #endif -#ifdef HAVE_PM_LINUX_PROC +#ifdef PCI_HAVE_PM_LINUX_PROC &pm_linux_proc, #else NULL, #endif -#ifdef HAVE_PM_INTEL_CONF +#ifdef PCI_HAVE_PM_INTEL_CONF &pm_intel_conf1, &pm_intel_conf2, #else NULL, NULL, #endif -#ifdef HAVE_PM_FBSD_DEVICE +#ifdef PCI_HAVE_PM_FBSD_DEVICE &pm_fbsd_device, #else NULL, #endif -#ifdef HAVE_PM_AIX_DEVICE +#ifdef PCI_HAVE_PM_AIX_DEVICE &pm_aix_device, #else NULL, #endif -#ifdef HAVE_PM_NBSD_LIBPCI +#ifdef PCI_HAVE_PM_NBSD_LIBPCI &pm_nbsd_libpci, #else NULL, #endif -#ifdef HAVE_PM_DUMP +#ifdef PCI_HAVE_PM_DUMP &pm_dump, #else NULL, @@ -61,7 +61,7 @@ pci_alloc(void) int i; bzero(a, sizeof(*a)); - a->id_file_name = PATH_PCI_IDS; + a->id_file_name = PCI_PATH_IDS; for(i=0; iconfig) pci_methods[i]->config(a); diff --git a/lib/configure b/lib/configure index 8ff9040..dd70651 100755 --- a/lib/configure +++ b/lib/configure @@ -30,8 +30,8 @@ rel=${4:-$rel} echo " $host $rel" c=config.h -echo >$c "#define ARCH_`echo $cpu | tr 'a-z' 'A-Z'`" -echo >>$c "#define OS_`echo $sys | tr 'a-z' 'A-Z'`" +echo >$c "#define PCI_ARCH_`echo $cpu | tr 'a-z' 'A-Z'`" +echo >>$c "#define PCI_OS_`echo $sys | tr 'a-z' 'A-Z'`" echo_n "Looking for access methods..." @@ -39,28 +39,28 @@ case $sys in linux*) case $rel in 2.[1-9]*|[3-9]*) echo_n "sysfs proc" - echo >>$c '#define HAVE_PM_LINUX_SYSFS' - echo >>$c '#define HAVE_PM_LINUX_PROC' - echo >>$c '#define HAVE_LINUX_BYTEORDER_H' - echo >>$c '#define PATH_PROC_BUS_PCI "/proc/bus/pci"' - echo >>$c '#define PATH_SYS_BUS_PCI "/sys/bus/pci"' + echo >>$c '#define PCI_HAVE_PM_LINUX_SYSFS' + echo >>$c '#define PCI_HAVE_PM_LINUX_PROC' + echo >>$c '#define PCI_HAVE_LINUX_BYTEORDER_H' + echo >>$c '#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci"' + echo >>$c '#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci"' ok=1 ;; esac case $cpu in i386) echo_n " i386-ports" - echo >>$c '#define HAVE_PM_INTEL_CONF' + echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' ok=1 ;; alpha|ia64|sparc|sparc64|ppc|ppc64) - echo >>$c '#define HAVE_64BIT_ADDRESS' + echo >>$c '#define PCI_HAVE_64BIT_ADDRESS' ;; esac ;; sunos) case $cpu in i386) echo_n " i386-ports" - echo >>$c "#define HAVE_PM_INTEL_CONF" + echo >>$c "#define PCI_HAVE_PM_INTEL_CONF" ok=1 ;; *) @@ -72,24 +72,24 @@ case $sys in freebsd) echo_n " fbsd-device" - echo >>$c '#define HAVE_PM_FBSD_DEVICE' - echo >>$c '#define PATH_FBSD_DEVICE "/dev/pci"' + echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE' + echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"' ok=1 ;; aix) echo_n " aix-device" - echo >>$c '#define HAVE_PM_AIX_DEVICE' + echo >>$c '#define PCI_HAVE_PM_AIX_DEVICE' ok=1 ;; netbsd) echo_n " nbsd-libpci" - echo >>$c '#define HAVE_PM_NBSD_LIBPCI' - echo >>$c '#define PATH_NBSD_DEVICE "/dev/pci0"' + echo >>$c '#define PCI_HAVE_PM_NBSD_LIBPCI' + echo >>$c '#define PCI_PATH_NBSD_DEVICE "/dev/pci0"' ok=1 ;; gnu) echo_n " i386-ports" - echo >>$c '#define HAVE_PM_INTEL_CONF' + echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' ok=1 ;; *) @@ -98,11 +98,11 @@ case $sys in ;; esac -echo >>$c '#define HAVE_PM_DUMP' +echo >>$c '#define PCI_HAVE_PM_DUMP' echo " dump" if [ -z "$ok" ] ; then echo "WARNING: No real configuration access method is available." fi -echo >>$c "#define PATH_PCI_IDS \"$sharedir/pci.ids\"" +echo >>$c "#define PCI_PATH_IDS \"$sharedir/pci.ids\"" echo >>$c "#define PCILIB_VERSION \"$version\"" sed '/^#define [^ ]*$/!d;s/^#define \(.*\)/\1=1/' <$c >config.mk diff --git a/lib/fbsd-device.c b/lib/fbsd-device.c index c0af6a1..833af56 100644 --- a/lib/fbsd-device.c +++ b/lib/fbsd-device.c @@ -29,7 +29,7 @@ static void fbsd_config(struct pci_access *a) { - a->method_params[PCI_ACCESS_FBSD_DEVICE] = PATH_FBSD_DEVICE; + a->method_params[PCI_ACCESS_FBSD_DEVICE] = PCI_PATH_FBSD_DEVICE; } static int diff --git a/lib/generic.c b/lib/generic.c index 0402ad1..a47bc15 100644 --- a/lib/generic.c +++ b/lib/generic.c @@ -122,7 +122,7 @@ pci_generic_fill_info(struct pci_dev *d, int flags) else { u32 y = pci_read_long(d, PCI_BASE_ADDRESS_0 + (++i)*4); -#ifdef HAVE_64BIT_ADDRESS +#ifdef PCI_HAVE_64BIT_ADDRESS d->base_addr[i-1] = x | (((pciaddr_t) y) << 32); #else if (y) diff --git a/lib/i386-ports.c b/lib/i386-ports.c index f225d24..9307ce9 100644 --- a/lib/i386-ports.c +++ b/lib/i386-ports.c @@ -10,13 +10,13 @@ #include "internal.h" -#if defined(OS_LINUX) +#if defined(PCI_OS_LINUX) #include "i386-io-linux.h" -#elif defined(OS_GNU) +#elif defined(PCI_OS_GNU) #include "i386-io-hurd.h" -#elif defined(OS_SUNOS) +#elif defined(PCI_OS_SUNOS) #include "i386-io-sunos.h" -#elif defined(OS_WINDOWS) +#elif defined(PCI_OS_WINDOWS) #include "i386-io-windows.h" #else #error Do not know how to access I/O ports on this OS. diff --git a/lib/internal.h b/lib/internal.h index a591f50..cae1800 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -1,5 +1,5 @@ /* - * The PCI Library -- Internal Include File + * The PCI Library -- Internal Stuff * * Copyright (c) 1997--2004 Martin Mares * @@ -7,74 +7,7 @@ */ #include "pci.h" - -#ifdef __GNUC__ -#define UNUSED __attribute__((unused)) -#else -#define UNUSED -#define inline -#endif - -#ifdef HAVE_LINUX_BYTEORDER_H - -#include -#define cpu_to_le16 __cpu_to_le16 -#define cpu_to_le32 __cpu_to_le32 -#define le16_to_cpu __le16_to_cpu -#define le32_to_cpu __le32_to_cpu - -#else - -#ifdef OS_LINUX -#include -#define BYTE_ORDER __BYTE_ORDER -#define BIG_ENDIAN __BIG_ENDIAN -#endif - -#ifdef OS_FREEBSD -#include -#endif - -#ifdef OS_SUNOS -#include -#define BIG_ENDIAN 4321 -#ifdef _LITTLE_ENDIAN -#define BYTE_ORDER 1234 -#else -#define BYTE_ORDER 4321 -#endif -#endif - -#ifdef OS_WINDOWS -#include -#endif - -#if BYTE_ORDER == BIG_ENDIAN -#define cpu_to_le16 swab16 -#define cpu_to_le32 swab32 -#define le16_to_cpu swab16 -#define le32_to_cpu swab32 - -static inline word swab16(word w) -{ - return (w << 8) | ((w >> 8) & 0xff); -} - -static inline u32 swab32(u32 w) -{ - return ((w & 0xff000000) >> 24) | - ((w & 0x00ff0000) >> 8) | - ((w & 0x0000ff00) << 8) | - ((w & 0x000000ff) << 24); -} -#else -#define cpu_to_le16(x) (x) -#define cpu_to_le32(x) (x) -#define le16_to_cpu(x) (x) -#define le32_to_cpu(x) (x) -#endif - -#endif +#include "sysdep.h" struct pci_methods { char *name; diff --git a/lib/nbsd-libpci.c b/lib/nbsd-libpci.c index 6507287..c930501 100644 --- a/lib/nbsd-libpci.c +++ b/lib/nbsd-libpci.c @@ -25,7 +25,7 @@ static void nbsd_config(struct pci_access *a) { - a->method_params[PCI_ACCESS_NBSD_LIBPCI] = PATH_NBSD_DEVICE; + a->method_params[PCI_ACCESS_NBSD_LIBPCI] = PCI_PATH_NBSD_DEVICE; } static int diff --git a/lib/pci.h b/lib/pci.h index 1083cb7..c01e6b1 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -11,53 +11,7 @@ #include "config.h" #include "header.h" - -/* - * Types and format strings - */ - -#include - -#ifdef OS_WINDOWS -typedef unsigned char byte; -typedef char u8; -typedef unsigned short word; -typedef short u16; -typedef unsigned long u32; -#else -typedef u_int8_t byte; -typedef u_int8_t u8; -typedef u_int16_t word; -typedef u_int16_t u16; -typedef u_int32_t u32; -#endif - -#ifdef HAVE_64BIT_ADDRESS -#include -#if ULONG_MAX > 0xffffffff -typedef unsigned long u64; -#define PCIADDR_T_FMT "%016lx" -#define PCIADDR_PORT_FMT "%04lx" -#else -typedef unsigned long long u64; -#define PCIADDR_T_FMT "%016llx" -#define PCIADDR_PORT_FMT "%04llx" -#endif -typedef u64 pciaddr_t; -#else -typedef u32 pciaddr_t; -#define PCIADDR_T_FMT "%08x" -#define PCIADDR_PORT_FMT "%04x" -#endif - -#ifdef ARCH_SPARC64 -/* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */ -#undef PCIADDR_PORT_FMT -#define PCIADDR_PORT_FMT PCIADDR_T_FMT -#define PCIIRQ_FMT "%08x" -#else -#define PCIIRQ_FMT "%d" -#endif +#include "types.h" /* * PCI Access Structure diff --git a/lib/pread.h b/lib/pread.h index 4637078..0e64326 100644 --- a/lib/pread.h +++ b/lib/pread.h @@ -37,7 +37,7 @@ static _syscall5(int, pread, unsigned int, fd, void *, buf, size_t, size, u32, w static _syscall5(int, pwrite, unsigned int, fd, void *, buf, size_t, size, u32, where_lo, u32, where_hi); static int do_read(struct pci_dev *d UNUSED, int fd, void *buf, size_t size, int where) { return pread(fd, buf, size, where, 0); } static int do_write(struct pci_dev *d UNUSED, int fd, void *buf, size_t size, int where) { return pwrite(fd, buf, size, where, 0); } -#define HAVE_DO_READ +#define PCI_HAVE_DO_READ #else /* In all other cases we use lseek/read/write instead to be safe */ @@ -57,10 +57,10 @@ static int do_write(struct pci_dev *d UNUSED, int fd, void *buf, size_t size, in } make_rw_glue(read) make_rw_glue(write) -#define HAVE_DO_READ +#define PCI_HAVE_DO_READ #endif -#ifndef HAVE_DO_READ +#ifndef PCI_HAVE_DO_READ #define do_read(d,f,b,l,p) pread(f,b,l,p) #define do_write(d,f,b,l,p) pwrite(f,b,l,p) #endif diff --git a/lib/proc.c b/lib/proc.c index ebc66e4..f493e49 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -21,7 +21,7 @@ static void proc_config(struct pci_access *a) { - a->method_params[PCI_ACCESS_PROC_BUS_PCI] = PATH_PROC_BUS_PCI; + a->method_params[PCI_ACCESS_PROC_BUS_PCI] = PCI_PATH_PROC_BUS_PCI; } static int diff --git a/lib/sysdep.h b/lib/sysdep.h new file mode 100644 index 0000000..70a407a --- /dev/null +++ b/lib/sysdep.h @@ -0,0 +1,73 @@ +/* + * The PCI Library -- System-Dependent Stuff + * + * Copyright (c) 1997--2004 Martin Mares + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#define NONRET __attribute__((noreturn)) +#else +#define UNUSED +#define NONRET +#define inline +#endif + +#ifdef PCI_HAVE_LINUX_BYTEORDER_H + +#include +#define cpu_to_le16 __cpu_to_le16 +#define cpu_to_le32 __cpu_to_le32 +#define le16_to_cpu __le16_to_cpu +#define le32_to_cpu __le32_to_cpu + +#else + +#ifdef PCI_OS_LINUX +#include +#define BYTE_ORDER __BYTE_ORDER +#define BIG_ENDIAN __BIG_ENDIAN +#endif + +#ifdef PCI_OS_SUNOS +#include +#define BIG_ENDIAN 4321 +#ifdef _LITTLE_ENDIAN +#define BYTE_ORDER 1234 +#else +#define BYTE_ORDER 4321 +#endif +#endif + +#ifdef PCI_OS_WINDOWS +#include +#endif + +#if BYTE_ORDER == BIG_ENDIAN +#define cpu_to_le16 swab16 +#define cpu_to_le32 swab32 +#define le16_to_cpu swab16 +#define le32_to_cpu swab32 + +static inline word swab16(word w) +{ + return (w << 8) | ((w >> 8) & 0xff); +} + +static inline u32 swab32(u32 w) +{ + return ((w & 0xff000000) >> 24) | + ((w & 0x00ff0000) >> 8) | + ((w & 0x0000ff00) << 8) | + ((w & 0x000000ff) << 24); +} +#else +#define cpu_to_le16(x) (x) +#define cpu_to_le32(x) (x) +#define le16_to_cpu(x) (x) +#define le32_to_cpu(x) (x) +#endif + +#endif diff --git a/lib/sysfs.c b/lib/sysfs.c index 74f6992..2c0a46f 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -25,7 +25,7 @@ static void sysfs_config(struct pci_access *a) { - a->method_params[PCI_ACCESS_SYS_BUS_PCI] = PATH_SYS_BUS_PCI; + a->method_params[PCI_ACCESS_SYS_BUS_PCI] = PCI_PATH_SYS_BUS_PCI; } static inline char * diff --git a/lib/types.h b/lib/types.h new file mode 100644 index 0000000..807bf37 --- /dev/null +++ b/lib/types.h @@ -0,0 +1,57 @@ +/* + * The PCI Library -- Types and Format Strings + * + * Copyright (c) 1997--2004 Martin Mares + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include + +#ifndef PCI_HAVE_Uxx_TYPES + +#ifdef PCI_OS_WINDOWS +typedef unsigned char byte; +typedef char u8; +typedef unsigned short word; +typedef short u16; +typedef unsigned long u32; +#else +typedef u_int8_t byte; +typedef u_int8_t u8; +typedef u_int16_t word; +typedef u_int16_t u16; +typedef u_int32_t u32; +#endif + +#ifdef PCI_HAVE_64BIT_ADDRESS +#include +#if ULONG_MAX > 0xffffffff +typedef unsigned long u64; +#define PCI_U64_FMT "l" +#else +typedef unsigned long long u64 +#define PCI_U64_FMT "ll" +#endif +#endif + +#endif /* PCI_HAVE_Uxx_TYPES */ + +#ifdef PCI_HAVE_64BIT_ADDRESS +typedef u64 pciaddr_t; +#define PCIADDR_T_FMT "%016" PCI_U64_FMT "x" +#define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x" +#else +typedef u32 pciaddr_t; +#define PCIADDR_T_FMT "%08x" +#define PCIADDR_PORT_FMT "%04x" +#endif + +#ifdef PCI_ARCH_SPARC64 +/* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */ +#undef PCIADDR_PORT_FMT +#define PCIADDR_PORT_FMT PCIADDR_T_FMT +#define PCIIRQ_FMT "%08x" +#else +#define PCIIRQ_FMT "%d" +#endif diff --git a/pciutils.h b/pciutils.h index dcedbe6..6787ea8 100644 --- a/pciutils.h +++ b/pciutils.h @@ -1,42 +1,36 @@ /* * The PCI Utilities -- Declarations * - * Copyright (c) 1997--2003 Martin Mares + * Copyright (c) 1997--2004 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "lib/pci.h" +#include "lib/sysdep.h" #define PCIUTILS_VERSION PCILIB_VERSION -#if !defined(__GNUC__) -#define NONRET -#define inline -#else -#define NONRET __attribute__((noreturn)) -#endif - void die(char *msg, ...) NONRET; void *xmalloc(unsigned int howmuch); void *xrealloc(void *ptr, unsigned int howmuch); int parse_generic_option(int i, struct pci_access *pacc, char *optarg); -#ifdef HAVE_PM_LINUX_PROC +#ifdef PCI_HAVE_PM_LINUX_PROC #define GENOPT_PROC "P:" -#define GENHELP_PROC "-P \tUse specified directory instead of " PATH_PROC_BUS_PCI "\n" +#define GENHELP_PROC "-P \tUse specified directory instead of " PCI_PATH_PROC_BUS_PCI "\n" #else #define GENOPT_PROC #define GENHELP_PROC #endif -#ifdef HAVE_PM_INTEL_CONF +#ifdef PCI_HAVE_PM_INTEL_CONF #define GENOPT_INTEL "H:" #define GENHELP_INTEL "-H \tUse direct hardware access ( = 1 or 2)\n" #else #define GENOPT_INTEL #define GENHELP_INTEL #endif -#ifdef HAVE_PM_DUMP +#ifdef PCI_HAVE_PM_DUMP #define GENOPT_DUMP "F:" #define GENHELP_DUMP "-F \tRead configuration data from given file\n" #else -- 2.39.5