2 * The PCI Library -- System-Dependent Stuff
4 * Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
10 #define UNUSED __attribute__((unused))
11 #define NONRET __attribute__((noreturn))
22 #define strcasecmp strcmpi
25 #ifdef PCI_HAVE_LINUX_BYTEORDER_H
27 #include <asm/byteorder.h>
28 #define cpu_to_le16 __cpu_to_le16
29 #define cpu_to_le32 __cpu_to_le32
30 #define le16_to_cpu __le16_to_cpu
31 #define le32_to_cpu __le32_to_cpu
37 #define BYTE_ORDER __BYTE_ORDER
38 #define BIG_ENDIAN __BIG_ENDIAN
42 #include <sys/byteorder.h>
43 #if defined(__i386) && defined(LITTLE_ENDIAN)
44 # define BYTE_ORDER LITTLE_ENDIAN
45 #elif defined(__sparc) && defined(BIG_ENDIAN)
46 # define BYTE_ORDER BIG_ENDIAN
48 #define BIG_ENDIAN 4321
52 #define BYTE_ORDER 1234
54 #define BYTE_ORDER 4321
56 #endif /* BYTE_ORDER */
57 #endif /* PCI_OS_SUNOS */
61 #include <sys/param.h>
64 #define BIG_ENDIAN 4321
65 #define LITTLE_ENDIAN 1234
66 #define BYTE_ORDER LITTLE_ENDIAN
67 #define snprintf _snprintf
71 #if BYTE_ORDER == BIG_ENDIAN
72 #define cpu_to_le16 swab16
73 #define cpu_to_le32 swab32
74 #define le16_to_cpu swab16
75 #define le32_to_cpu swab32
77 static inline word swab16(word w)
79 return (w << 8) | ((w >> 8) & 0xff);
82 static inline u32 swab32(u32 w)
84 return ((w & 0xff000000) >> 24) |
85 ((w & 0x00ff0000) >> 8) |
86 ((w & 0x0000ff00) << 8) |
87 ((w & 0x000000ff) << 24);
90 #define cpu_to_le16(x) (x)
91 #define cpu_to_le32(x) (x)
92 #define le16_to_cpu(x) (x)
93 #define le32_to_cpu(x) (x)