1 /* $OpenBSD: stdint.h,v 1.4 2006/12/10 22:17:55 deraadt Exp $ */
4 * Copyright (c) 1997, 2005 Todd C. Miller <Todd.Miller@courtesan.com>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef _SYS_STDINT_H_
20 #define _SYS_STDINT_H_
22 #include <arch/types.h>
23 //#include <sys/cdefs.h>
24 //#include <machine/_types.h>
26 #ifndef __BIT_TYPES_DEFINED__
27 #define __BIT_TYPES_DEFINED__
30 /* 7.18.1.2 Minimum-width integer types */
31 typedef int8_t int_least8_t;
32 typedef uint8_t uint_least8_t;
33 typedef int16_t int_least16_t;
34 typedef uint16_t uint_least16_t;
35 typedef int32_t int_least32_t;
36 typedef uint32_t uint_least32_t;
37 typedef int64_t int_least64_t;
38 typedef uint64_t uint_least64_t;
40 /* 7.18.1.3 Fastest minimum-width integer types */
41 typedef int8_t int_fast8_t;
42 typedef uint8_t uint_fast8_t;
43 typedef int16_t int_fast16_t;
44 typedef uint16_t uint_fast16_t;
45 typedef int32_t int_fast32_t;
46 typedef uint32_t uint_fast32_t;
47 typedef int64_t int_fast64_t;
48 typedef uint64_t uint_fast64_t;
50 /* 7.18.1.5 Greatest-width integer types */
51 typedef int64_t intmax_t;
52 typedef uint64_t uintmax_t;
54 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
56 * 7.18.2 Limits of specified-width integer types.
58 * The following object-like macros specify the minimum and maximum limits
59 * of integer types corresponding to the typedef names defined above.
62 /* 7.18.2.1 Limits of exact-width integer types */
63 #define INT8_MIN (-0x7f - 1)
64 #define INT16_MIN (-0x7fff - 1)
65 #define INT32_MIN (-0x7fffffff - 1)
66 #define INT64_MIN (-0x7fffffffffffffffLL - 1)
69 #define INT16_MAX 0x7fff
70 #define INT32_MAX 0x7fffffff
71 #define INT64_MAX 0x7fffffffffffffffLL
73 #define UINT8_MAX 0xff
74 #define UINT16_MAX 0xffff
75 #define UINT32_MAX 0xffffffffU
76 #define UINT64_MAX 0xffffffffffffffffULL
78 /* 7.18.2.2 Limits of minimum-width integer types */
79 #define INT_LEAST8_MIN INT8_MIN
80 #define INT_LEAST16_MIN INT16_MIN
81 #define INT_LEAST32_MIN INT32_MIN
82 #define INT_LEAST64_MIN INT64_MIN
84 #define INT_LEAST8_MAX INT8_MAX
85 #define INT_LEAST16_MAX INT16_MAX
86 #define INT_LEAST32_MAX INT32_MAX
87 #define INT_LEAST64_MAX INT64_MAX
89 #define UINT_LEAST8_MAX UINT8_MAX
90 #define UINT_LEAST16_MAX UINT16_MAX
91 #define UINT_LEAST32_MAX UINT32_MAX
92 #define UINT_LEAST64_MAX UINT64_MAX
94 /* 7.18.2.3 Limits of fastest minimum-width integer types */
95 #define INT_FAST8_MIN INT8_MIN
96 #define INT_FAST16_MIN INT16_MIN
97 #define INT_FAST32_MIN INT32_MIN
98 #define INT_FAST64_MIN INT64_MIN
100 #define INT_FAST8_MAX INT8_MAX
101 #define INT_FAST16_MAX INT16_MAX
102 #define INT_FAST32_MAX INT32_MAX
103 #define INT_FAST64_MAX INT64_MAX
105 #define UINT_FAST8_MAX UINT8_MAX
106 #define UINT_FAST16_MAX UINT16_MAX
107 #define UINT_FAST32_MAX UINT32_MAX
108 #define UINT_FAST64_MAX UINT64_MAX
110 /* 7.18.2.4 Limits of integer types capable of holding object pointers */
112 #define INTPTR_MIN INT64_MIN
113 #define INTPTR_MAX INT64_MAX
114 #define UINTPTR_MAX UINT64_MAX
116 #define INTPTR_MIN INT32_MIN
117 #define INTPTR_MAX INT32_MAX
118 #define UINTPTR_MAX UINT32_MAX
121 /* 7.18.2.5 Limits of greatest-width integer types */
122 #define INTMAX_MIN INT64_MIN
123 #define INTMAX_MAX INT64_MAX
124 #define UINTMAX_MAX UINT64_MAX
127 * 7.18.3 Limits of other integer types.
129 * The following object-like macros specify the minimum and maximum limits
130 * of integer types corresponding to types specified in other standard
134 /* Limits of ptrdiff_t */
135 #define PTRDIFF_MIN INTPTR_MIN
136 #define PTRDIFF_MAX INTPTR_MAX
138 /* Limits of sig_atomic_t */
139 #define SIG_ATOMIC_MIN INT32_MIN
140 #define SIG_ATOMIC_MAX INT32_MAX
142 /* Limits of size_t (also in limits.h) */
144 #define SIZE_MAX UINTPTR_MAX
147 /* Limits of wchar_t */
148 #define WCHAR_MIN INT32_MIN
149 #define WCHAR_MAX INT32_MAX
151 /* Limits of wint_t */
152 #define WINT_MIN INT32_MIN
153 #define WINT_MAX INT32_MAX
155 #endif /* __cplusplus || __STDC_LIMIT_MACROS */
157 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
159 * 7.18.4 Macros for integer constants.
161 * The following function-like macros expand to integer constants
162 * suitable for initializing objects that have integer types corresponding
163 * to types defined in <stdint.h>. The argument in any instance of
164 * these macros shall be a decimal, octal, or hexadecimal constant with
165 * a value that does not exceed the limits for the corresponding type.
168 /* 7.18.4.1 Macros for minimum-width integer constants. */
169 #define INT8_C(_c) (_c)
170 #define INT16_C(_c) (_c)
171 #define INT32_C(_c) (_c)
172 #define INT64_C(_c) __CONCAT(_c, LL)
174 #define UINT8_C(_c) (_c)
175 #define UINT16_C(_c) (_c)
176 #define UINT32_C(_c) __CONCAT(_c, U)
177 #define UINT64_C(_c) __CONCAT(_c, ULL)
179 /* 7.18.4.2 Macros for greatest-width integer constants. */
180 #define INTMAX_C(_c) __CONCAT(_c, LL)
181 #define UINTMAX_C(_c) __CONCAT(_c, ULL)
183 #endif /* __cplusplus || __STDC_CONSTANT_MACROS */
185 #endif /* _SYS_STDINT_H_ */