]> mj.ucw.cz Git - pciutils.git/blob - lib/types.h
Added more parts of the Windows port.
[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 __int8 u8;
15 typedef unsigned __int16 u16;
16 typedef unsigned __int32 u32;
17 #else
18 typedef u_int8_t u8;
19 typedef u_int16_t u16;
20 typedef u_int32_t u32;
21 #endif
22
23 typedef u8 byte;
24 typedef u16 word;
25
26 #ifdef PCI_HAVE_64BIT_ADDRESS
27 #include <limits.h>
28 #if ULONG_MAX > 0xffffffff
29 typedef unsigned long u64;
30 #define PCI_U64_FMT "l"
31 #else
32 typedef unsigned long long u64
33 #define PCI_U64_FMT "ll"
34 #endif
35 #endif
36
37 #endif  /* PCI_HAVE_Uxx_TYPES */
38
39 #ifdef PCI_HAVE_64BIT_ADDRESS
40 typedef u64 pciaddr_t;
41 #define PCIADDR_T_FMT "%016" PCI_U64_FMT "x"
42 #define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x"
43 #else
44 typedef u32 pciaddr_t;
45 #define PCIADDR_T_FMT "%08x"
46 #define PCIADDR_PORT_FMT "%04x"
47 #endif
48
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"
54 #else
55 #define PCIIRQ_FMT "%d"
56 #endif