]> git.ipfire.org Git - thirdparty/pciutils.git/blame - lib/types.h
lspci: add VirtIO SharedMemory capability support
[thirdparty/pciutils.git] / lib / types.h
CommitLineData
489233b4
MM
1/*
2 * The PCI Library -- Types and Format Strings
3 *
884a1634 4 * Copyright (c) 1997--2022 Martin Mares <mj@ucw.cz>
489233b4 5 *
61829219
MM
6 * Can be freely distributed and used under the terms of the GNU GPL v2+
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
489233b4
MM
9 */
10
11#include <sys/types.h>
e52b479a 12#include <stddef.h>
489233b4
MM
13
14#ifndef PCI_HAVE_Uxx_TYPES
15
16#ifdef PCI_OS_WINDOWS
e4ec9322
PR
17/* On Windows compilers, use <windows.h> */
18#include <windows.h>
09156b3b
MM
19typedef BYTE u8;
20typedef WORD u16;
21typedef DWORD u32;
3f30d0d1
MM
22typedef unsigned __int64 u64;
23#define PCI_U64_FMT_X "I64x"
c3d1d465 24#define PCI_U64_FMT_U "I64u"
3f30d0d1 25
0128c5b1 26#else
3f30d0d1 27/* Use standard types in C99 and newer */
e49ed044 28#include <stdint.h>
3f30d0d1 29#include <inttypes.h>
e49ed044
MM
30typedef uint8_t u8;
31typedef uint16_t u16;
32typedef uint32_t u32;
3f30d0d1
MM
33typedef uint64_t u64;
34#define PCI_U64_FMT_X PRIx64
c3d1d465 35#define PCI_U64_FMT_U PRIu64
489233b4
MM
36#endif
37
38#endif /* PCI_HAVE_Uxx_TYPES */
39
40#ifdef PCI_HAVE_64BIT_ADDRESS
41typedef u64 pciaddr_t;
3f30d0d1
MM
42#define PCIADDR_T_FMT "%08" PCI_U64_FMT_X
43#define PCIADDR_PORT_FMT "%04" PCI_U64_FMT_X
489233b4
MM
44#else
45typedef u32 pciaddr_t;
46#define PCIADDR_T_FMT "%08x"
47#define PCIADDR_PORT_FMT "%04x"
48#endif
49
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"
55#else
56#define PCIIRQ_FMT "%d"
57#endif
4f6b38ca 58
17c39b8a 59#if defined(__GNUC__) && __GNUC__ > 2
4f6b38ca 60#define PCI_PRINTF(x,y) __attribute__((format(printf, x, y)))
884a1634 61#define PCI_NONRET __attribute((noreturn))
aa5a16ef 62#define PCI_PACKED __attribute((packed))
4f6b38ca
MM
63#else
64#define PCI_PRINTF(x,y)
884a1634 65#define PCI_NONRET
aa5a16ef 66#define PCI_PACKED
4f6b38ca 67#endif