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
95 #define BIG_ENDIAN 4321
96 #define LITTLE_ENDIAN 1234
97 #define BYTE_ORDER LITTLE_ENDIAN
100 #ifdef PCI_OS_AMIGAOS
101 #include <machine/endian.h>
104 #if !defined(BYTE_ORDER)
105 #error "BYTE_ORDER not defined for your platform"
108 #if BYTE_ORDER == BIG_ENDIAN
109 #define cpu_to_le16 swab16
110 #define cpu_to_le32 swab32
111 #define le16_to_cpu swab16
112 #define le32_to_cpu swab32
114 static inline word swab16(word w)
116 return (w << 8) | ((w >> 8) & 0xff);
119 static inline u32 swab32(u32 w)
121 return ((w & 0xff000000) >> 24) |
122 ((w & 0x00ff0000) >> 8) |
123 ((w & 0x0000ff00) << 8) |
124 ((w & 0x000000ff) << 24);
127 #define cpu_to_le16(x) (x)
128 #define cpu_to_le32(x) (x)
129 #define le16_to_cpu(x) (x)
130 #define le32_to_cpu(x) (x)