]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Include file splits and namespace cleanups.
authorMartin Mares <mj@ucw.cz>
Fri, 13 Aug 2004 20:36:33 +0000 (20:36 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:18:24 +0000 (14:18 +0200)
git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-60

19 files changed:
ChangeLog
Makefile
README.Windows
common.c
lib/Makefile
lib/access.c
lib/configure
lib/fbsd-device.c
lib/generic.c
lib/i386-ports.c
lib/internal.h
lib/nbsd-libpci.c
lib/pci.h
lib/pread.h
lib/proc.c
lib/sysdep.h [new file with mode: 0644]
lib/sysfs.c
lib/types.h [new file with mode: 0644]
pciutils.h

index aa1c2f7f4d79d019603340c737c15d9a92a92c31..ee027dfd21e9b4283533997b469a5a5bb0777cf3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2004-08-13  Martin Mares  <mj@ucw.cz>
 
+       * 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 <sys/types.h> 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
index 6bcc1ed60166c981bb4fcb54473acd27165759bc..fd4110998859d9ad0184c688a6fa7e67fa5e558f 100644 (file)
--- 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
index 3eca690b1fac30208c451d83fde74100a0f7e0dc..81b41f385bb6ca78f52e6065356bb758f7a2ddfd 100644 (file)
@@ -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"
index 9181e4e14ddcd55a4335b94abf44618662d207da..2bfd1b8b9c17bf3821a73a7962ed1a79acf053ef 100644 (file)
--- 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;
index b0a2de828413f25cc1ae4428ead1e6bd475f53c3..44296ca8595009add49aee6b181f8751d8c644a5 100644 (file)
@@ -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)
index eee22d2d8b07221675436eec5b15d90805befbb5..5683eac8dd96a7b3e1b9c493024e155c227af2dc 100644 (file)
 
 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; i<PCI_ACCESS_MAX; i++)
     if (pci_methods[i] && pci_methods[i]->config)
       pci_methods[i]->config(a);
index 8ff9040cc34eb3c53864d582670e9f47ffe503f5..dd706515ee8e9d58f93012d85d2689d1b48cddeb 100755 (executable)
@@ -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
index c0af6a11a14fad4f1283b9701d336ba2be16caba..833af56bde12bb5b55daf8a4c2c4f0a6c558b845 100644 (file)
@@ -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
index 0402ad1efadb778390ad1fda98fa5b3359e05cb8..a47bc15dcd17dbf667cef1a90b61343157e62132 100644 (file)
@@ -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)
index f225d248179958ae10c1580c5872f4a6ca743128..9307ce9ea14191080cde2ab9ddc68d8191368923 100644 (file)
 
 #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.
index a591f5051b68eecea470b87daaf547fd5fffc021..cae18007578f9362b6a87ab4be6fe4db397b8fb4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     The PCI Library -- Internal Include File
+ *     The PCI Library -- Internal Stuff
  *
  *     Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
  *
@@ -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 <asm/byteorder.h>
-#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 <endian.h>
-#define BYTE_ORDER __BYTE_ORDER
-#define BIG_ENDIAN __BIG_ENDIAN
-#endif
-
-#ifdef OS_FREEBSD
-#include <sys/types.h>
-#endif
-
-#ifdef OS_SUNOS
-#include <sys/byteorder.h>
-#define BIG_ENDIAN 4321
-#ifdef _LITTLE_ENDIAN
-#define BYTE_ORDER 1234
-#else
-#define BYTE_ORDER 4321
-#endif
-#endif
-
-#ifdef OS_WINDOWS
-#include <sys/param.h>
-#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;
index 650728796bce27c1063857af5725b42aa28a46e0..c9305017f4b0941de6651c82ed7d7616adf02072 100644 (file)
@@ -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
index 1083cb79ea36f506d1df8be1d318a545f3854bfb..c01e6b179bf27e7bc9444ac52452e043b65a211c 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
 
 #include "config.h"
 #include "header.h"
-
-/*
- *     Types and format strings
- */
-
-#include <sys/types.h>
-
-#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 <limits.h>
-#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
index 46370780588cca73b1853b7874f36b90cd427660..0e64326af5e497511e84f0e0f6f442419bfb7aa7 100644 (file)
@@ -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
index ebc66e4c9e200b1b92f395170da1244bad98a482..f493e491e771684c0ebd0e87843d3319bf89f7cb 100644 (file)
@@ -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 (file)
index 0000000..70a407a
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ *     The PCI Library -- System-Dependent Stuff
+ *
+ *     Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ *
+ *     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 <asm/byteorder.h>
+#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 <endian.h>
+#define BYTE_ORDER __BYTE_ORDER
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifdef PCI_OS_SUNOS
+#include <sys/byteorder.h>
+#define BIG_ENDIAN 4321
+#ifdef _LITTLE_ENDIAN
+#define BYTE_ORDER 1234
+#else
+#define BYTE_ORDER 4321
+#endif
+#endif
+
+#ifdef PCI_OS_WINDOWS
+#include <sys/param.h>
+#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
index 74f6992bb87947bbbe3924028f7dadc2426e8581..2c0a46f7763aa2764660873da73ca040e8f3fe12 100644 (file)
@@ -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 (file)
index 0000000..807bf37
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *     The PCI Library -- Types and Format Strings
+ *
+ *     Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include <sys/types.h>
+
+#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 <limits.h>
+#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
index dcedbe683f256404962b134cf66c24d0bac093b2..6787ea800969791452f1dbdf23873abd2499d230 100644 (file)
@@ -1,42 +1,36 @@
 /*
  *     The PCI Utilities -- Declarations
  *
- *     Copyright (c) 1997--2003 Martin Mares <mj@ucw.cz>
+ *     Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
  *
  *     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 <dir>\tUse specified directory instead of " PATH_PROC_BUS_PCI "\n"
+#define GENHELP_PROC "-P <dir>\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 <mode>\tUse direct hardware access (<mode> = 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 <file>\tRead configuration data from given file\n"
 #else