xref: /dragonfly/sys/sys/stdint.h (revision 9014ed326271a05eb60ff7c12575b7a923127cb4)
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_PREREQ__(3, 0)
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 #ifndef _UINT8_T_DECLARED
70 typedef   __uint8_t uint8_t;
71 #define   _UINT8_T_DECLARED
72 #endif
73 #ifndef _UINT16_T_DECLARED
74 typedef   __uint16_t          uint16_t;
75 #define   _UINT16_T_DECLARED
76 #endif
77 #ifndef _UINT32_T_DECLARED
78 typedef   __uint32_t          uint32_t;
79 #define   _UINT32_T_DECLARED
80 #endif
81 #ifndef _UINT64_T_DECLARED
82 typedef   __uint64_t          uint64_t;
83 #define   _UINT64_T_DECLARED
84 #endif
85 
86 #ifndef _INTPTR_T_DECLARED
87 typedef   __intptr_t          intptr_t; /* VKERNEL uses <unistd.h> */
88 #define   _INTPTR_T_DECLARED
89 #endif
90 typedef   __uintptr_t         uintptr_t;
91 
92 typedef   __intmax_t          intmax_t;
93 typedef   __uintmax_t         uintmax_t;
94 #endif /* _KERNEL */
95 
96 #ifndef _KERNEL
97 #ifndef _STDINT_H_
98 #include <stdint.h>                     /* in case we still need it */
99 #endif
100 #endif /* !_KERNEL */
101 
102 #endif /* !_SYS_STDINT_H_ */
103