Merge from vendor branch OPENSSL:
[dragonfly.git] / sys / i386 / include / stdint.h
1 /*-
2  * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
3  * Copyright (c) 2001 The NetBSD Foundation, Inc.  All rights reserved.
4  * Copyright (c) 1990, 1993 The Regents of the University of California. 
5  *              All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Klaus Klein.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  *
38  * $FreeBSD: src/sys/i386/include/_stdint.h,v 1.1 2002/07/29 17:41:07 mike Exp $
39  * $DragonFly: src/sys/i386/include/Attic/stdint.h,v 1.2 2005/04/21 16:36:35 joerg Exp $
40  */
41
42 #ifndef _MACHINE_STDINT_H_
43 #define _MACHINE_STDINT_H_
44
45 /*
46  * Basic types upon which most other types are built.
47  */
48 typedef __signed char   __int8_t;
49 typedef unsigned char   __uint8_t;
50 typedef short           __int16_t;
51 typedef unsigned short  __uint16_t;
52 typedef int             __int32_t;
53 typedef unsigned int    __uint32_t;
54
55 /*
56  * This mess is to override compiler options that might restrict long long
57  * and for lint which doesn't understand GNUC attributes.
58  */
59 #if defined(lint)
60 typedef long long               __int64_t;
61 typedef unsigned long long      __uint64_t;
62 #elif defined(__GNUC__)
63 typedef int __attribute__((__mode__(__DI__)))           __int64_t;
64 typedef unsigned int __attribute__((__mode__(__DI__)))  __uint64_t;
65 #else
66 typedef long long               __int64_t;
67 typedef unsigned long long      __uint64_t;
68 #endif
69
70 /*
71  * Standard type definitions.
72  */
73 typedef __int64_t       __intmax_t;
74 typedef __uint64_t      __uintmax_t;
75
76 typedef __int32_t       __intptr_t;
77 typedef __uint32_t      __uintptr_t;
78
79 typedef __int32_t       __ptrdiff_t;            /* ptr1 - ptr2 */
80
81 typedef __int32_t       __int_fast8_t;
82 typedef __int32_t       __int_fast16_t;
83 typedef __int32_t       __int_fast32_t;
84 typedef __int64_t       __int_fast64_t;
85 typedef __int8_t        __int_least8_t;
86 typedef __int16_t       __int_least16_t;
87 typedef __int32_t       __int_least32_t;
88 typedef __int64_t       __int_least64_t;
89 typedef __uint32_t      __uint_fast8_t;
90 typedef __uint32_t      __uint_fast16_t;
91 typedef __uint32_t      __uint_fast32_t;
92 typedef __uint64_t      __uint_fast64_t;
93 typedef __uint8_t       __uint_least8_t;
94 typedef __uint16_t      __uint_least16_t;
95 typedef __uint32_t      __uint_least32_t;
96 typedef __uint64_t      __uint_least64_t;
97
98 /*
99  * System types conveniently placed in this header file in order to put them
100  * in proximity with the limit macros below and for convenient access by
101  * other include files which need to pick and choose particular types but
102  * do not wish to overly pollute their namespaces.
103  */
104
105 typedef __uint32_t      __size_t;
106 typedef __int32_t       __ssize_t;
107 typedef long            __time_t;
108 typedef int             __timer_t;
109 typedef __int32_t       __register_t;
110 typedef __uint32_t      __u_register_t;
111 typedef __int32_t       __sig_atomic_t;
112 typedef unsigned long   __clock_t;
113 typedef unsigned long   __clockid_t;
114 typedef __uint32_t      __socklen_t;
115
116 /*
117  * Its convenient to put these here rather then create another header file.
118  */
119 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
120 #define __arysize(ary)          (sizeof(ary)/sizeof((ary)[0]))
121
122 #endif /* _MACHINE_STDINT_H_ */
123
124 /*
125  * OpenGroup stdint.h extensions.  Since these are protected by a define we
126  * do not have to generate __ versions of them.
127  */
128 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
129 #ifndef _MACHINE_STDINT_H_STDC_CONSTANT_MACROS_
130 #define _MACHINE_STDINT_H_STDC_CONSTANT_MACROS_
131
132 #define INT8_C(c)       (c)
133 #define INT16_C(c)      (c)
134 #define INT32_C(c)      (c)
135 #define INT64_C(c)      (c ## LL)
136
137 #define UINT8_C(c)      (c)
138 #define UINT16_C(c)     (c)
139 #define UINT32_C(c)     (c ## U)
140 #define UINT64_C(c)     (c ## ULL)
141
142 #define INTMAX_C(c)     (c ## LL)
143 #define UINTMAX_C(c)    (c ## ULL)
144
145 #endif
146 #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
147
148 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
149 #ifndef _MACHINE_STDINT_H_STDC_LIMIT_MAVROS_
150 #define _MACHINE_STDINT_H_STDC_LIMIT_MAVROS_
151
152 /*
153  * ISO/IEC 9899:1999
154  * 7.18.2.1 Limits of exact-width integer types
155  */
156 /* Minimum values of exact-width signed integer types. */
157 #define INT8_MIN        (-0x7f-1)
158 #define INT16_MIN       (-0x7fff-1)
159 #define INT32_MIN       (-0x7fffffff-1)
160 #define INT64_MIN       (-0x7fffffffffffffffLL-1)
161
162 /* Maximum values of exact-width signed integer types. */
163 #define INT8_MAX        0x7f
164 #define INT16_MAX       0x7fff
165 #define INT32_MAX       0x7fffffff
166 #define INT64_MAX       0x7fffffffffffffffLL
167
168 /* Maximum values of exact-width unsigned integer types. */
169 #define UINT8_MAX       0xff
170 #define UINT16_MAX      0xffff
171 #define UINT32_MAX      0xffffffffU
172 #define UINT64_MAX      0xffffffffffffffffULL
173
174 /*
175  * ISO/IEC 9899:1999
176  * 7.18.2.4  Limits of integer types capable of holding object pointers
177  */
178 #define INTPTR_MIN      INT32_MIN
179 #define INTPTR_MAX      INT32_MAX
180 #define UINTPTR_MAX     UINT32_MAX
181
182 /*
183  * ISO/IEC 9899:1999
184  * 7.18.2.5  Limits of greatest-width integer types
185  */
186 #define INTMAX_MIN      INT64_MIN
187 #define INTMAX_MAX      INT64_MAX
188 #define UINTMAX_MAX     UINT64_MAX
189
190 /*
191  * ISO/IEC 9899:1999
192  * 7.18.3  Limits of other integer types
193  */
194 /* Limits of ptrdiff_t. */
195 #define PTRDIFF_MIN     INT32_MIN       
196 #define PTRDIFF_MAX     INT32_MAX
197
198 /* Limits of sig_atomic_t. */
199 #define SIG_ATOMIC_MIN  INT32_MIN
200 #define SIG_ATOMIC_MAX  INT32_MAX
201
202 /* Limit of size_t. */
203 #define SIZE_MAX        UINT32_MAX
204
205 /* NOTE: wchar and wint macros in sys/stdint.h */
206
207 /*
208  * ISO/IEC 9899:1999
209  * 7.18.2.2  Limits of minimum-width integer types
210  */
211 /* Minimum values of minimum-width signed integer types. */
212 #define INT_LEAST8_MIN          INT8_MIN
213 #define INT_LEAST16_MIN         INT16_MIN
214 #define INT_LEAST32_MIN         INT32_MIN
215 #define INT_LEAST64_MIN         INT64_MIN
216
217 /* Maximum values of minimum-width signed integer types. */
218 #define INT_LEAST8_MAX          INT8_MAX
219 #define INT_LEAST16_MAX         INT16_MAX
220 #define INT_LEAST32_MAX         INT32_MAX
221 #define INT_LEAST64_MAX         INT64_MAX
222
223 /* Maximum values of minimum-width unsigned integer types. */
224 #define UINT_LEAST8_MAX         UINT8_MAX
225 #define UINT_LEAST16_MAX        UINT16_MAX
226 #define UINT_LEAST32_MAX        UINT32_MAX
227 #define UINT_LEAST64_MAX        UINT64_MAX
228
229 /*
230  * ISO/IEC 9899:1999
231  * 7.18.2.3  Limits of fastest minimum-width integer types
232  */
233 /* Minimum values of fastest minimum-width signed integer types. */
234 #define INT_FAST8_MIN           INT32_MIN
235 #define INT_FAST16_MIN          INT32_MIN
236 #define INT_FAST32_MIN          INT32_MIN
237 #define INT_FAST64_MIN          INT64_MIN
238
239 /* Maximum values of fastest minimum-width signed integer types. */
240 #define INT_FAST8_MAX           INT32_MAX
241 #define INT_FAST16_MAX          INT32_MAX
242 #define INT_FAST32_MAX          INT32_MAX
243 #define INT_FAST64_MAX          INT64_MAX
244
245 /* Maximum values of fastest minimum-width unsigned integer types. */
246 #define UINT_FAST8_MAX          UINT32_MAX
247 #define UINT_FAST16_MAX         UINT32_MAX
248 #define UINT_FAST32_MAX         UINT32_MAX
249 #define UINT_FAST64_MAX         UINT64_MAX
250
251 #endif
252 #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
253