Clean up more #include files. Create an internal __boolean_t so two or
[dragonfly.git] / sys / cpu / i386 / include / stdint.h
... / ...
CommitLineData
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/cpu/i386/include/stdint.h,v 1.5 2006/05/21 03:43:44 dillon 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 */
48typedef __signed char __int8_t;
49typedef unsigned char __uint8_t;
50typedef short __int16_t;
51typedef unsigned short __uint16_t;
52typedef int __int32_t;
53typedef unsigned int __uint32_t;
54typedef int __boolean_t;
55
56/*
57 * This mess is to override compiler options that might restrict long long
58 * and for lint which doesn't understand GNUC attributes.
59 */
60#if defined(lint)
61typedef long long __int64_t;
62typedef unsigned long long __uint64_t;
63#elif defined(__GNUC__)
64typedef int __attribute__((__mode__(__DI__))) __int64_t;
65typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
66#else
67typedef long long __int64_t;
68typedef unsigned long long __uint64_t;
69#endif
70
71/*
72 * Standard type definitions.
73 */
74typedef __int64_t __intmax_t;
75typedef __uint64_t __uintmax_t;
76
77typedef __int32_t __intptr_t;
78typedef __uint32_t __uintptr_t;
79
80typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
81
82typedef __int32_t __int_fast8_t;
83typedef __int32_t __int_fast16_t;
84typedef __int32_t __int_fast32_t;
85typedef __int64_t __int_fast64_t;
86typedef __int8_t __int_least8_t;
87typedef __int16_t __int_least16_t;
88typedef __int32_t __int_least32_t;
89typedef __int64_t __int_least64_t;
90typedef __uint32_t __uint_fast8_t;
91typedef __uint32_t __uint_fast16_t;
92typedef __uint32_t __uint_fast32_t;
93typedef __uint64_t __uint_fast64_t;
94typedef __uint8_t __uint_least8_t;
95typedef __uint16_t __uint_least16_t;
96typedef __uint32_t __uint_least32_t;
97typedef __uint64_t __uint_least64_t;
98
99/*
100 * System types conveniently placed in this header file in order to put them
101 * in proximity with the limit macros below and for convenient access by
102 * other include files which need to pick and choose particular types but
103 * do not wish to overly pollute their namespaces.
104 */
105
106typedef __uint32_t __size_t;
107typedef __int32_t __ssize_t;
108typedef long __time_t;
109typedef int __timer_t;
110typedef __int32_t __register_t;
111typedef __uint32_t __u_register_t;
112typedef __int32_t __sig_atomic_t;
113typedef unsigned long __clock_t;
114typedef unsigned long __clockid_t;
115typedef __uint32_t __socklen_t;
116
117/*
118 * Its convenient to put these here rather then create another header file.
119 */
120#ifndef __cplusplus
121#define __offsetof(type, field) ((__size_t)(&((type *)0)->field))
122#elif (__GNUC__ >= 4)
123#define __offsetof(type, field) __builtin_offsetof(type, field)
124#else
125#define __offsetof(type, field) \
126 (__offsetof__ (reinterpret_cast <__size_t> \
127 (&reinterpret_cast <const volatile char &> \
128 (static_cast<type *> (0)->field))))
129#endif
130
131#define __arysize(ary) (sizeof(ary)/sizeof((ary)[0]))
132
133#endif /* _MACHINE_STDINT_H_ */
134
135/*
136 * OpenGroup stdint.h extensions. Since these are protected by a define we
137 * do not have to generate __ versions of them.
138 */
139#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
140#ifndef _MACHINE_STDINT_H_STDC_CONSTANT_MACROS_
141#define _MACHINE_STDINT_H_STDC_CONSTANT_MACROS_
142
143#define INT8_C(c) (c)
144#define INT16_C(c) (c)
145#define INT32_C(c) (c)
146#define INT64_C(c) (c ## LL)
147
148#define UINT8_C(c) (c)
149#define UINT16_C(c) (c)
150#define UINT32_C(c) (c ## U)
151#define UINT64_C(c) (c ## ULL)
152
153#define INTMAX_C(c) (c ## LL)
154#define UINTMAX_C(c) (c ## ULL)
155
156#endif
157#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
158
159#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
160#ifndef _MACHINE_STDINT_H_STDC_LIMIT_MAVROS_
161#define _MACHINE_STDINT_H_STDC_LIMIT_MAVROS_
162
163/*
164 * ISO/IEC 9899:1999
165 * 7.18.2.1 Limits of exact-width integer types
166 */
167/* Minimum values of exact-width signed integer types. */
168#define INT8_MIN (-0x7f-1)
169#define INT16_MIN (-0x7fff-1)
170#define INT32_MIN (-0x7fffffff-1)
171#define INT64_MIN (-0x7fffffffffffffffLL-1)
172
173/* Maximum values of exact-width signed integer types. */
174#define INT8_MAX 0x7f
175#define INT16_MAX 0x7fff
176#define INT32_MAX 0x7fffffff
177#define INT64_MAX 0x7fffffffffffffffLL
178
179/* Maximum values of exact-width unsigned integer types. */
180#define UINT8_MAX 0xff
181#define UINT16_MAX 0xffff
182#define UINT32_MAX 0xffffffffU
183#define UINT64_MAX 0xffffffffffffffffULL
184
185/*
186 * ISO/IEC 9899:1999
187 * 7.18.2.4 Limits of integer types capable of holding object pointers
188 */
189#define INTPTR_MIN INT32_MIN
190#define INTPTR_MAX INT32_MAX
191#define UINTPTR_MAX UINT32_MAX
192
193/*
194 * ISO/IEC 9899:1999
195 * 7.18.2.5 Limits of greatest-width integer types
196 */
197#define INTMAX_MIN INT64_MIN
198#define INTMAX_MAX INT64_MAX
199#define UINTMAX_MAX UINT64_MAX
200
201/*
202 * ISO/IEC 9899:1999
203 * 7.18.3 Limits of other integer types
204 */
205/* Limits of ptrdiff_t. */
206#define PTRDIFF_MIN INT32_MIN
207#define PTRDIFF_MAX INT32_MAX
208
209/* Limits of sig_atomic_t. */
210#define SIG_ATOMIC_MIN INT32_MIN
211#define SIG_ATOMIC_MAX INT32_MAX
212
213/* Limit of size_t. */
214#define SIZE_MAX UINT32_MAX
215
216/* NOTE: wchar and wint macros in sys/stdint.h */
217
218/*
219 * ISO/IEC 9899:1999
220 * 7.18.2.2 Limits of minimum-width integer types
221 */
222/* Minimum values of minimum-width signed integer types. */
223#define INT_LEAST8_MIN INT8_MIN
224#define INT_LEAST16_MIN INT16_MIN
225#define INT_LEAST32_MIN INT32_MIN
226#define INT_LEAST64_MIN INT64_MIN
227
228/* Maximum values of minimum-width signed integer types. */
229#define INT_LEAST8_MAX INT8_MAX
230#define INT_LEAST16_MAX INT16_MAX
231#define INT_LEAST32_MAX INT32_MAX
232#define INT_LEAST64_MAX INT64_MAX
233
234/* Maximum values of minimum-width unsigned integer types. */
235#define UINT_LEAST8_MAX UINT8_MAX
236#define UINT_LEAST16_MAX UINT16_MAX
237#define UINT_LEAST32_MAX UINT32_MAX
238#define UINT_LEAST64_MAX UINT64_MAX
239
240/*
241 * ISO/IEC 9899:1999
242 * 7.18.2.3 Limits of fastest minimum-width integer types
243 */
244/* Minimum values of fastest minimum-width signed integer types. */
245#define INT_FAST8_MIN INT32_MIN
246#define INT_FAST16_MIN INT32_MIN
247#define INT_FAST32_MIN INT32_MIN
248#define INT_FAST64_MIN INT64_MIN
249
250/* Maximum values of fastest minimum-width signed integer types. */
251#define INT_FAST8_MAX INT32_MAX
252#define INT_FAST16_MAX INT32_MAX
253#define INT_FAST32_MAX INT32_MAX
254#define INT_FAST64_MAX INT64_MAX
255
256/* Maximum values of fastest minimum-width unsigned integer types. */
257#define UINT_FAST8_MAX UINT32_MAX
258#define UINT_FAST16_MAX UINT32_MAX
259#define UINT_FAST32_MAX UINT32_MAX
260#define UINT_FAST64_MAX UINT64_MAX
261
262#endif
263#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
264