1 #ifndef __TYPES_H__
2 #define __TYPES_H__
3 
4 #include <xen/stdbool.h>
5 #include <xen/stdint.h>
6 
7 /* Linux inherited types which are being phased out */
8 typedef uint8_t u8;
9 typedef uint16_t u16;
10 typedef uint32_t u32;
11 typedef uint64_t u64;
12 
13 #include <asm/types.h>
14 
15 typedef __SIZE_TYPE__ size_t;
16 
17 typedef signed long ssize_t;
18 
19 typedef __PTRDIFF_TYPE__ ptrdiff_t;
20 typedef __UINTPTR_TYPE__ uintptr_t;
21 
22 /*
23  * Users of this macro are expected to pass a positive value.
24  *
25  * XXX: should become an unsigned quantity
26  */
27 #define BITS_TO_LONGS(bits) \
28     (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
29 #define DECLARE_BITMAP(name,bits) \
30     unsigned long name[BITS_TO_LONGS(bits)]
31 
32 #ifndef NULL
33 #define NULL ((void*)0)
34 #endif
35 
36 #define INT8_MIN        (-127-1)
37 #define INT16_MIN       (-32767-1)
38 #define INT32_MIN       (-2147483647-1)
39 
40 #define INT8_MAX        (127)
41 #define INT16_MAX       (32767)
42 #define INT32_MAX       (2147483647)
43 
44 #define UINT8_MAX       (255)
45 #define UINT16_MAX      (65535)
46 #define UINT32_MAX      (4294967295U)
47 #define UINT64_MAX      (18446744073709551615ULL)
48 
49 #define INT_MAX         ((int)(~0U>>1))
50 #define INT_MIN         (-INT_MAX - 1)
51 #define UINT_MAX        (~0U)
52 #define LONG_MAX        ((long)(~0UL>>1))
53 #define LONG_MIN        (-LONG_MAX - 1)
54 #define ULONG_MAX       (~0UL)
55 
56 typedef uint16_t __le16;
57 typedef uint16_t __be16;
58 typedef uint32_t __le32;
59 typedef uint32_t __be32;
60 typedef uint64_t __le64;
61 typedef uint64_t __be64;
62 
63 #define test_and_set_bool(b)   xchg(&(b), true)
64 #define test_and_clear_bool(b) xchg(&(b), false)
65 
66 #endif /* __TYPES_H__ */
67