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 < 1800
30 #define strtoull strtoul
32 #define strtoull _strtoui64
35 #if defined(_MSC_VER) && _MSC_VER < 1900
36 #define snprintf _snprintf
37 #define vsnprintf _vsnprintf
41 #ifdef PCI_HAVE_LINUX_BYTEORDER_H
43 #include <asm/byteorder.h>
44 #define cpu_to_le16 __cpu_to_le16
45 #define cpu_to_le32 __cpu_to_le32
46 #define le16_to_cpu __le16_to_cpu
47 #define le32_to_cpu __le32_to_cpu
53 #define BYTE_ORDER __BYTE_ORDER
54 #define BIG_ENDIAN __BIG_ENDIAN
58 #include <sys/byteorder.h>
59 #if defined(__i386) && defined(LITTLE_ENDIAN)
60 # define BYTE_ORDER LITTLE_ENDIAN
61 #elif defined(__sparc) && defined(BIG_ENDIAN)
62 # define BYTE_ORDER BIG_ENDIAN
64 #define BIG_ENDIAN 4321
68 #define BYTE_ORDER 1234
70 #define BYTE_ORDER 4321
72 #endif /* BYTE_ORDER */
73 #endif /* PCI_OS_SUNOS */
77 #include <sys/param.h>
80 #define BIG_ENDIAN 4321
81 #define LITTLE_ENDIAN 1234
82 #define BYTE_ORDER LITTLE_ENDIAN
91 #define BIG_ENDIAN 4321
92 #define LITTLE_ENDIAN 1234
93 #define BYTE_ORDER LITTLE_ENDIAN
96 #if !defined(BYTE_ORDER)
97 #error "BYTE_ORDER not defined for your platform"
100 #if BYTE_ORDER == BIG_ENDIAN
101 #define cpu_to_le16 swab16
102 #define cpu_to_le32 swab32
103 #define le16_to_cpu swab16
104 #define le32_to_cpu swab32
106 static inline word swab16(word w)
108 return (w << 8) | ((w >> 8) & 0xff);
111 static inline u32 swab32(u32 w)
113 return ((w & 0xff000000) >> 24) |
114 ((w & 0x00ff0000) >> 8) |
115 ((w & 0x0000ff00) << 8) |
116 ((w & 0x000000ff) << 24);
119 #define cpu_to_le16(x) (x)
120 #define cpu_to_le32(x) (x)
121 #define le16_to_cpu(x) (x)
122 #define le32_to_cpu(x) (x)