-
Notifications
You must be signed in to change notification settings - Fork 0
/
cstdint.h
117 lines (96 loc) · 2.8 KB
/
cstdint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef UUID_B6BA276BE4584C6984F223B4F0C5267F
#define UUID_B6BA276BE4584C6984F223B4F0C5267F
#include <limits.h>
#include "platform.h"
#if TL_STDC >= 199901L || _MSC_VER > 1600
#include <stdint.h>
#elif TL_GCC
#include <inttypes.h>
#else /* !TL_GCC */
#if !TL_EXCLUDE_STDINT
#if CHAR_BIT == 8 && UCHAR_MAX == 0xff
typedef unsigned char uint8_t;
typedef signed char int8_t;
#else
#error "Only 8-bit chars supported"
#endif
typedef unsigned int uint_fast8_t;
typedef int int_fast8_t;
#if USHRT_MAX == 0xffff
typedef unsigned short uint16_t;
typedef short int16_t;
#elif UINT_MAX == 0xffff
typedef unsigned int uint16_t;
typedef int int16_t;
#else
#error "No suitable 16-bit type"
#endif
#if USHRT_MAX == 0xffffffff
typedef unsigned short uint32_t;
typedef short int32_t;
#elif UINT_MAX == 0xffffffff
typedef unsigned int uint32_t;
typedef int int32_t;
#elif ULONG_MAX == 0xffffffff
typedef unsigned long uint32_t;
typedef long int32_t;
#else
#error "No suitable 32-bit type"
#endif
/* We found a 32-bit type above, int should do */
#if TL_X86 || TL_X86_64
/* long should match the register size */
typedef unsigned long uint_fast16_t;
typedef long int_fast16_t;
typedef unsigned long uint_fast32_t;
typedef long int_fast32_t;
#elif UINT_MAX < 0xffffffff
/* Have to use long for 32-bit */
typedef unsigned int uint_fast16_t;
typedef int int_fast16_t;
typedef unsigned long uint_fast32_t;
typedef long int_fast32_t;
#else
/* Be conservative with space */
typedef unsigned int uint_fast16_t;
typedef int int_fast16_t;
typedef unsigned int uint_fast32_t;
typedef int int_fast32_t;
#endif
#define IS_64(x) ((x) > 0xffffffff && (x) == 0xffffffffffffffff)
#if IS_64(ULONG_MAX)
typedef unsigned long uint64_t;
typedef long int64_t;
#elif defined(ULLONG_MAX) && IS_64(ULLONG_MAX)
typedef unsigned long long uint64_t;
typedef long long int64_t;
#else
#error "No suitable 64-bit type"
#endif
#if defined(ULLONG_MAX)
typedef unsigned long long uintmax_t;
typedef long long intmax_t;
#else
typedef unsigned long uintmax_t;
typedef long intmax_t;
#endif
typedef uint64_t uint_fast64_t;
typedef int64_t int_fast64_t;
typedef ptrdiff_t intptr_t;
#endif
#define TL_BITS_IN(t) (sizeof(t)*CHAR_BIT)
#endif /* !TL_GCC */
// TODO: Use deterministic selection of these types
typedef uint8_t u8;
typedef int8_t i8;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
typedef size_t usize;
typedef ptrdiff_t isize;
typedef double f64;
typedef float f32;
#endif // UUID_B6BA276BE4584C6984F223B4F0C5267F