2 * The PCI Library -- Types and Format Strings
4 * Copyright (c) 1997--2022 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
11 #ifndef PCI_HAVE_Uxx_TYPES
14 /* On Windows compilers, use <windows.h> */
19 typedef unsigned __int64 u64;
20 #define PCI_U64_FMT_X "I64x"
21 #define PCI_U64_FMT_U "I64u"
23 #elif defined(PCI_HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
24 /* Use standard types in C99 and newer */
31 #define PCI_U64_FMT_X PRIx64
32 #define PCI_U64_FMT_U PRIu64
35 /* Hope for POSIX types from <sys/types.h> */
37 typedef u_int16_t u16;
38 typedef u_int32_t u32;
40 /* u64 will be unsigned (long) long */
42 #if ULONG_MAX > 0xffffffff
43 typedef unsigned long u64;
44 #define PCI_U64_FMT_X "lx"
45 #define PCI_U64_FMT_U "lu"
47 typedef unsigned long long u64;
48 #define PCI_U64_FMT_X "llx"
49 #define PCI_U64_FMT_U "llu"
54 #endif /* PCI_HAVE_Uxx_TYPES */
56 #ifdef PCI_HAVE_64BIT_ADDRESS
57 typedef u64 pciaddr_t;
58 #define PCIADDR_T_FMT "%08" PCI_U64_FMT_X
59 #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT_X
61 typedef u32 pciaddr_t;
62 #define PCIADDR_T_FMT "%08x"
63 #define PCIADDR_PORT_FMT "%04x"
66 #ifdef PCI_ARCH_SPARC64
67 /* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */
68 #undef PCIADDR_PORT_FMT
69 #define PCIADDR_PORT_FMT PCIADDR_T_FMT
70 #define PCIIRQ_FMT "%08x"
72 #define PCIIRQ_FMT "%d"
75 #if defined(__GNUC__) && __GNUC__ > 2
76 #define PCI_PRINTF(x,y) __attribute__((format(printf, x, y)))
77 #define PCI_NONRET __attribute((noreturn))
78 #define PCI_PACKED __attribute((packed))
80 #define PCI_PRINTF(x,y)