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>
14 #ifndef PCI_HAVE_Uxx_TYPES
17 /* On Windows compilers, use <windows.h> */
22 typedef unsigned __int64 u64;
23 #define PCI_U64_FMT_X "I64x"
24 #define PCI_U64_FMT_U "I64u"
27 /* Use standard types in C99 and newer */
34 #define PCI_U64_FMT_X PRIx64
35 #define PCI_U64_FMT_U PRIu64
38 #endif /* PCI_HAVE_Uxx_TYPES */
40 #ifdef PCI_HAVE_64BIT_ADDRESS
41 typedef u64 pciaddr_t;
42 #define PCIADDR_T_FMT "%08" PCI_U64_FMT_X
43 #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT_X
45 typedef u32 pciaddr_t;
46 #define PCIADDR_T_FMT "%08x"
47 #define PCIADDR_PORT_FMT "%04x"
50 #ifdef PCI_ARCH_SPARC64
51 /* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */
52 #undef PCIADDR_PORT_FMT
53 #define PCIADDR_PORT_FMT PCIADDR_T_FMT
54 #define PCIIRQ_FMT "%08x"
56 #define PCIIRQ_FMT "%d"
59 #if defined(__GNUC__) && __GNUC__ > 2
60 #define PCI_PRINTF(x,y) __attribute__((format(printf, x, y)))
61 #define PCI_NONRET __attribute((noreturn))
62 #define PCI_PACKED __attribute((packed))
64 #define PCI_PRINTF(x,y)