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 v2+
8 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <sys/types.h>
13 #ifndef PCI_HAVE_Uxx_TYPES
16 /* On Windows compilers, use <windows.h> */
21 typedef unsigned __int64 u64;
22 #define PCI_U64_FMT_X "I64x"
23 #define PCI_U64_FMT_U "I64u"
26 /* Use standard types in C99 and newer */
33 #define PCI_U64_FMT_X PRIx64
34 #define PCI_U64_FMT_U PRIu64
37 #endif /* PCI_HAVE_Uxx_TYPES */
39 #ifdef PCI_HAVE_64BIT_ADDRESS
40 typedef u64 pciaddr_t;
41 #define PCIADDR_T_FMT "%08" PCI_U64_FMT_X
42 #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT_X
44 typedef u32 pciaddr_t;
45 #define PCIADDR_T_FMT "%08x"
46 #define PCIADDR_PORT_FMT "%04x"
49 #ifdef PCI_ARCH_SPARC64
50 /* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */
51 #undef PCIADDR_PORT_FMT
52 #define PCIADDR_PORT_FMT PCIADDR_T_FMT
53 #define PCIIRQ_FMT "%08x"
55 #define PCIIRQ_FMT "%d"
58 #if defined(__GNUC__) && __GNUC__ > 2
59 #define PCI_PRINTF(x,y) __attribute__((format(printf, x, y)))
60 #define PCI_NONRET __attribute((noreturn))
61 #define PCI_PACKED __attribute((packed))
63 #define PCI_PRINTF(x,y)