xref: /haiku/headers/posix/stdint.h (revision 239222b2369c39dc52df52b0a7cdd6cc0a91bc92)
1 /*
2  * Copyright 2003-2008, Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _STDINT_H_
6 #define _STDINT_H_
7 
8 
9 /* ToDo: this is a compiler and architecture dependent header */
10 
11 /* Exact-width integer types */
12 typedef signed char int8_t;
13 typedef unsigned char uint8_t;
14 
15 typedef signed short int16_t;
16 typedef unsigned short uint16_t;
17 
18 typedef signed int int32_t;
19 typedef unsigned int uint32_t;
20 
21 typedef signed long long int64_t;
22 typedef unsigned long long uint64_t;
23 
24 /* Minimum-width integer types */
25 typedef int8_t int_least8_t;
26 typedef uint8_t uint_least8_t;
27 
28 typedef int16_t int_least16_t;
29 typedef uint16_t uint_least16_t;
30 
31 typedef int32_t int_least32_t;
32 typedef uint32_t uint_least32_t;
33 
34 typedef int64_t int_least64_t;
35 typedef uint64_t uint_least64_t;
36 
37 /* Fastest minimum-width integer types */
38 typedef int32_t int_fast8_t;
39 typedef uint32_t uint_fast8_t;
40 
41 typedef int32_t int_fast16_t;
42 typedef uint32_t uint_fast16_t;
43 
44 typedef int32_t int_fast32_t;
45 typedef uint32_t uint_fast32_t;
46 
47 typedef int64_t int_fast64_t;
48 typedef uint64_t uint_fast64_t;
49 
50 /* Integer types capable of holding object pointers */
51 typedef int32_t intptr_t;
52 typedef uint32_t uintptr_t;
53 
54 /* Greatest-width integer types */
55 typedef signed long long intmax_t;
56 typedef unsigned long long uintmax_t;
57 
58 /* Limits of exact-width integer types */
59 #define INT8_MIN 	(-128)
60 #define INT8_MAX 	(127)
61 #define UINT8_MAX	(255U)
62 
63 #define INT16_MIN 	(-32768)
64 #define INT16_MAX 	(32767)
65 #define UINT16_MAX	(65535U)
66 
67 #define INT32_MAX	(2147483647)
68 #define INT32_MIN 	(-INT32_MAX-1)
69 #define UINT32_MAX	(4294967295U)
70 
71 #define INT64_MAX	(9223372036854775807LL)
72 #define INT64_MIN	(-INT64_MAX-1)
73 #define UINT64_MAX	(18446744073709551615ULL)
74 
75 /* Limits of minimum-width integer types */
76 #define INT_LEAST8_MIN  	INT8_MIN
77 #define INT_LEAST8_MAX  	INT8_MAX
78 #define UINT_LEAST8_MAX 	UINT8_MAX
79 
80 #define INT_LEAST16_MIN 	INT16_MIN
81 #define INT_LEAST16_MAX 	INT16_MAX
82 #define UINT_LEAST16_MAX	UINT16_MAX
83 
84 #define INT_LEAST32_MIN 	INT32_MIN
85 #define INT_LEAST32_MAX 	INT32_MAX
86 #define UINT_LEAST32_MAX	UINT32_MAX
87 
88 #define INT_LEAST64_MIN 	INT64_MIN
89 #define INT_LEAST64_MAX 	INT64_MAX
90 #define UINT_LEAST64_MAX	UINT64_MAX
91 
92 /* Limits of fastest minimum-width integer types */
93 #define INT_FAST8_MIN  	INT8_MIN
94 #define INT_FAST8_MAX  	INT8_MAX
95 #define UINT_FAST8_MAX 	UINT8_MAX
96 
97 #define INT_FAST16_MIN 	INT16_MIN
98 #define INT_FAST16_MAX 	INT16_MAX
99 #define UINT_FAST16_MAX	UINT16_MAX
100 
101 #define INT_FAST32_MIN 	INT32_MIN
102 #define INT_FAST32_MAX 	INT32_MAX
103 #define UINT_FAST32_MAX	UINT32_MAX
104 
105 #define INT_FAST64_MIN 	INT64_MIN
106 #define INT_FAST64_MAX 	INT64_MAX
107 #define UINT_FAST64_MAX	UINT64_MAX
108 
109 /* Limits of Integer types capable of holding object pointers */
110 #define INTPTR_MIN	INT32_MIN
111 #define INTPTR_MAX	INT32_MAX
112 #define UINTPTR_MAX	UINT32_MAX
113 
114 /* Limits of Greatest-width integer types */
115 #define INTMAX_MIN	INT64_MIN
116 #define INTMAX_MAX	INT64_MAX
117 #define UINTMAX_MAX	UINT64_MAX
118 
119 /* Limits of other integer types */
120 #define PTDIFF_MIN INT32_MIN
121 #define PTDIFF_MAX INT32_MAX
122 
123 #define SIG_ATOMIC_MIN INT32_MIN
124 #define SIG_ATOMIC_MAX INT32_MAX
125 
126 #define SIZE_MAX 	UINT32_MAX
127 
128 #define WINT_MIN 	0
129 #define WINT_MAX 	((wint_t)-1)
130 
131 
132 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
133 
134 /* Macros of Integer Constant Expressions */
135 #define INT8_C(value) 	value
136 #define INT16_C(value) 	value
137 #define INT32_C(value) 	value
138 #define INT64_C(value) 	value ## LL
139 
140 #define UINT8_C(value) 	value ## U
141 #define UINT16_C(value) value ## U
142 #define UINT32_C(value) value ## U
143 #define UINT64_C(value) value ## ULL
144 
145 /* Macros for greatest-width integer constant expressions */
146 #define INTMAX_C(value) 	value ## LL
147 #define UINTMAX_C(value) 	value ## ULL
148 
149 #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
150 
151 
152 /* BSD compatibility */
153 typedef uint8_t u_int8_t;
154 typedef uint16_t u_int16_t;
155 typedef uint32_t u_int32_t;
156 typedef uint64_t u_int64_t;
157 
158 #endif	/* _STDINT_H_ */
159