xref: /dragonfly/sys/sys/stdint.h (revision 4d18c287)
1 /*
2  * Copyright (c) 2019 The DragonFly Project.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
16  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
17  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
23  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 #ifndef _SYS_STDINT_H_
28 #define	_SYS_STDINT_H_
29 
30 #ifndef _SYS_CDEFS_H_
31 #include <sys/cdefs.h>
32 #endif
33 #include <machine/stdint.h>
34 
35 /*
36  * Proxy header for kernel compilation.  Do not include outside kernel
37  * headers. Userland should use <stdint.h> instead.
38  *
39  * This header is not a convenient placeholder for non integer types.
40  */
41 
42 #ifdef _KERNEL
43 #include <machine/int_limits.h>
44 
45 typedef	__boolean_t	boolean_t;		/* kernel only */
46 
47 #if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
48 #define	__bool_true_false_are_defined	1
49 #define	false	0
50 #define	true	1
51 #if __STDC_VERSION__ < 199901L && __GNUC__ < 3
52 typedef	int	_Bool;
53 #endif
54 typedef	_Bool	bool;
55 #endif /* !__bool_true_false_are_defined && !__cplusplus */
56 
57 #define	offsetof(type, field)	__offsetof(type, field)
58 
59 #ifndef _PTRDIFF_T_DECLARED
60 typedef	__ptrdiff_t	ptrdiff_t;	/* ptr1 - ptr2 for kernel */
61 #define	_PTRDIFF_T_DECLARED
62 #endif
63 
64 typedef	__int8_t	int8_t;
65 typedef	__int16_t	int16_t;
66 typedef	__int32_t	int32_t;
67 typedef	__int64_t	int64_t;
68 
69 typedef	__uint8_t	uint8_t;
70 typedef	__uint16_t	uint16_t;
71 typedef	__uint32_t	uint32_t;
72 typedef	__uint64_t	uint64_t;
73 
74 #ifndef _INTPTR_T_DECLARED
75 typedef	__intptr_t	intptr_t;	/* VKERNEL uses <unistd.h> */
76 #define	_INTPTR_T_DECLARED
77 #endif
78 typedef	__uintptr_t	uintptr_t;
79 
80 typedef	__intmax_t	intmax_t;
81 typedef	__uintmax_t	uintmax_t;
82 #endif /* _KERNEL */
83 
84 #ifndef _KERNEL
85 #ifndef _STDINT_H_
86 #include <stdint.h>			/* in case we still need it */
87 #endif
88 #endif /* !_KERNEL */
89 
90 #endif /* !_SYS_STDINT_H_ */
91