]> mj.ucw.cz Git - pciutils.git/blob - lib/types.h
807bf378a5de2d330f1d8273880ae425e035e10e
[pciutils.git] / lib / types.h
1 /*
2  *      The PCI Library -- Types and Format Strings
3  *
4  *      Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
5  *
6  *      Can be freely distributed and used under the terms of the GNU GPL.
7  */
8
9 #include <sys/types.h>
10
11 #ifndef PCI_HAVE_Uxx_TYPES
12
13 #ifdef PCI_OS_WINDOWS
14 typedef unsigned char byte;
15 typedef char u8;
16 typedef unsigned short word;
17 typedef short u16;
18 typedef unsigned long u32;
19 #else
20 typedef u_int8_t byte;
21 typedef u_int8_t u8;
22 typedef u_int16_t word;
23 typedef u_int16_t u16;
24 typedef u_int32_t u32;
25 #endif
26
27 #ifdef PCI_HAVE_64BIT_ADDRESS
28 #include <limits.h>
29 #if ULONG_MAX > 0xffffffff
30 typedef unsigned long u64;
31 #define PCI_U64_FMT "l"
32 #else
33 typedef unsigned long long u64
34 #define PCI_U64_FMT "ll"
35 #endif
36 #endif
37
38 #endif  /* PCI_HAVE_Uxx_TYPES */
39
40 #ifdef PCI_HAVE_64BIT_ADDRESS
41 typedef u64 pciaddr_t;
42 #define PCIADDR_T_FMT "%016" PCI_U64_FMT "x"
43 #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x"
44 #else
45 typedef 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