build - Unbreak world
[dragonfly.git] / sys / cpu / x86_64 / include / stdint.h
CommitLineData
fc3f9779
SS
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 $
fc3f9779
SS
39 */
40
41#ifndef _CPU_STDINT_H_
42#define _CPU_STDINT_H_
43
44/*
45 * Basic types upon which most other types are built.
46 */
47typedef __signed char __int8_t;
48typedef unsigned char __uint8_t;
49typedef short __int16_t;
50typedef unsigned short __uint16_t;
51typedef int __int32_t;
52typedef unsigned int __uint32_t;
53typedef int __boolean_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)
60typedef long __int64_t;
61typedef unsigned long __uint64_t;
62#elif defined(__GNUC__)
63typedef int __attribute__((__mode__(__DI__))) __int64_t;
64typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
b2b3ffcd 65#elif defined(__x86_64__)
fc3f9779
SS
66typedef long __int64_t;
67typedef unsigned long __uint64_t;
e9c7aa03
MD
68#elif defined(__i386__)
69typedef long long __int64_t;
70typedef unsigned long long __uint64_t;
fc3f9779
SS
71#endif
72
73/*
74 * Standard type definitions.
75 */
76typedef __int64_t __intmax_t;
77typedef __uint64_t __uintmax_t;
78
b2b3ffcd 79#if defined(__x86_64__)
fc3f9779
SS
80typedef __int64_t __intptr_t;
81typedef __uint64_t __uintptr_t;
fc3f9779 82typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */
e9c7aa03
MD
83#elif defined(__i386__)
84typedef __int32_t __intptr_t;
85typedef __uint32_t __uintptr_t;
86typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
87#endif
fc3f9779
SS
88
89typedef __int32_t __int_fast8_t;
90typedef __int32_t __int_fast16_t;
91typedef __int32_t __int_fast32_t;
92typedef __int64_t __int_fast64_t;
93typedef __int8_t __int_least8_t;
94typedef __int16_t __int_least16_t;
95typedef __int32_t __int_least32_t;
96typedef __int64_t __int_least64_t;
97typedef __uint32_t __uint_fast8_t;
98typedef __uint32_t __uint_fast16_t;
99typedef __uint32_t __uint_fast32_t;
100typedef __uint64_t __uint_fast64_t;
101typedef __uint8_t __uint_least8_t;
102typedef __uint16_t __uint_least16_t;
103typedef __uint32_t __uint_least32_t;
104typedef __uint64_t __uint_least64_t;
105
106/*
107 * System types conveniently placed in this header file in order to put them
108 * in proximity with the limit macros below and for convenient access by
109 * other include files which need to pick and choose particular types but
110 * do not wish to overly pollute their namespaces.
111 */
112
b2b3ffcd 113#if defined(__x86_64__)
98d036ab
SS
114typedef __uint64_t __size_t;
115typedef __int64_t __ssize_t;
fc3f9779
SS
116typedef __int64_t __register_t;
117typedef __uint64_t __u_register_t;
e9c7aa03 118#elif defined(__i386__)
fe681df1
MD
119typedef __uint32_t __size_t;
120typedef __int32_t __ssize_t;
e9c7aa03
MD
121typedef __int32_t __register_t;
122typedef __uint32_t __u_register_t;
123#endif
124typedef long __time_t;
125typedef int __timer_t;
fc3f9779
SS
126typedef __int32_t __sig_atomic_t; /* XXX */
127typedef unsigned long __clock_t;
128typedef unsigned long __clockid_t;
129typedef __uint32_t __socklen_t;
130typedef volatile int __atomic_intr_t;
131
132/*
133 * Its convenient to put these here rather then create another header file.
134 */
7f32c88b 135#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
262e0d74
JM
136#define __offsetof(type, field) __builtin_offsetof(type, field)
137#else
3cbeca21
SS
138#ifndef __cplusplus
139#define __offsetof(type, field) ((__size_t)(&((type *)0)->field))
3cbeca21
SS
140#else
141#define __offsetof(type, field) \
142 (__offsetof__ (reinterpret_cast <__size_t> \
143 (&reinterpret_cast <const volatile char &> \
144 (static_cast<type *> (0)->field))))
145#endif
262e0d74 146#endif
3cbeca21 147
84c0772c
VS
148#define __arysize(ary) (sizeof(ary)/sizeof((ary)[0]))
149
fc3f9779 150#endif /* _CPU_STDINT_H_ */