2 * The PCI Library -- System-Dependent Stuff
4 * Copyright (c) 1997--2020 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL v2+
8 * SPDX-License-Identifier: GPL-2.0-or-later
12 #define UNUSED __attribute__((unused))
13 #define NONRET __attribute__((noreturn))
14 #define FORMAT_CHECK(x,y,z) __attribute__((format(x,y,z)))
18 #define FORMAT_CHECK(x,y,z)
26 #define strcasecmp _strcmpi
27 #define strncasecmp _strnicmp
28 #if defined(_MSC_VER) && _MSC_VER < 1900
29 #define snprintf _snprintf
30 #define vsnprintf _vsnprintf
34 #ifdef PCI_HAVE_LINUX_BYTEORDER_H
36 #include <asm/byteorder.h>
37 #define cpu_to_le16 __cpu_to_le16
38 #define cpu_to_le32 __cpu_to_le32
39 #define le16_to_cpu __le16_to_cpu
40 #define le32_to_cpu __le32_to_cpu
46 #define BYTE_ORDER __BYTE_ORDER
47 #define BIG_ENDIAN __BIG_ENDIAN
51 #include <sys/byteorder.h>
52 #if defined(__i386) && defined(LITTLE_ENDIAN)
53 # define BYTE_ORDER LITTLE_ENDIAN
54 #elif defined(__sparc) && defined(BIG_ENDIAN)
55 # define BYTE_ORDER BIG_ENDIAN
57 #define BIG_ENDIAN 4321
61 #define BYTE_ORDER 1234
63 #define BYTE_ORDER 4321
65 #endif /* BYTE_ORDER */
66 #endif /* PCI_OS_SUNOS */
70 #include <sys/param.h>
73 #define BIG_ENDIAN 4321
74 #define LITTLE_ENDIAN 1234
75 #define BYTE_ORDER LITTLE_ENDIAN
84 #define BIG_ENDIAN 4321
85 #define LITTLE_ENDIAN 1234
86 #define BYTE_ORDER LITTLE_ENDIAN
90 #include <machine/endian.h>
93 #if !defined(BYTE_ORDER)
94 #error "BYTE_ORDER not defined for your platform"
97 #if BYTE_ORDER == BIG_ENDIAN
98 #define cpu_to_le16 swab16
99 #define cpu_to_le32 swab32
100 #define le16_to_cpu swab16
101 #define le32_to_cpu swab32
103 static inline word swab16(word w)
105 return (w << 8) | ((w >> 8) & 0xff);
108 static inline u32 swab32(u32 w)
110 return ((w & 0xff000000) >> 24) |
111 ((w & 0x00ff0000) >> 8) |
112 ((w & 0x0000ff00) << 8) |
113 ((w & 0x000000ff) << 24);
116 #define cpu_to_le16(x) (x)
117 #define cpu_to_le32(x) (x)
118 #define le16_to_cpu(x) (x)
119 #define le32_to_cpu(x) (x)