1 /*
2 Copyright (c) 1982, 1986, 1993
3 The Regents of the University of California.  All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. Neither the name of the University nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 SUCH DAMAGE.
28  */
29 /* ANSI C namespace clean utility typedefs */
30 
31 /* This file defines various typedefs needed by the system calls that support
32    the C library.  Basically, they're just the POSIX versions with an '_'
33    prepended.  Targets shall use <machine/_types.h> to define their own
34    internal types if desired.
35 
36    There are three define patterns used for type definitions.  Lets assume
37    xyz_t is a user type.
38 
39    The internal type definition uses __machine_xyz_t_defined.  It is defined by
40    <machine/_types.h> to disable a default definition in <sys/_types.h>. It
41    must not be used in other files.
42 
43    User type definitions are guarded by __xyz_t_defined in glibc and
44    _XYZ_T_DECLARED in BSD compatible systems.
45 */
46 
47 #ifndef	_SYS__TYPES_H
48 #define _SYS__TYPES_H
49 
50 #define __need_size_t
51 #define __need_wint_t
52 #include <stddef.h>
53 
54 /* The Arm Compiler doesn't define wint_t as part of stddef.h so
55  * define it here.
56  */
57 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
58 typedef __WINT_TYPE__ wint_t;
59 #endif
60 
61 #include <machine/_types.h>
62 
63 #ifndef __machine_blkcnt_t_defined
64 typedef long __blkcnt_t;
65 typedef __int64_t __blkcnt64_t;
66 #endif
67 
68 #ifndef __machine_blksize_t_defined
69 typedef long __blksize_t;
70 #endif
71 
72 #ifndef __machine_fsblkcnt_t_defined
73 typedef __uint64_t __fsblkcnt_t;
74 #endif
75 
76 #ifndef __machine_fsfilcnt_t_defined
77 typedef __uint32_t __fsfilcnt_t;
78 #endif
79 
80 #ifndef __machine_off_t_defined
81 typedef long _off_t;
82 #endif
83 
84 #if defined(__XMK__)
85 typedef signed char __pid_t;
86 #else
87 typedef int __pid_t;
88 #endif
89 
90 #ifndef __machine_dev_t_defined
91 #ifdef __linux
92 typedef __uint64_t __dev_t;
93 #else
94 typedef short __dev_t;
95 #endif
96 #endif
97 
98 #ifndef __machine_uid_t_defined
99 #ifdef __linux
100 typedef __uint32_t __uid_t;
101 #else
102 typedef unsigned short __uid_t;
103 #endif
104 #endif
105 #ifndef __machine_gid_t_defined
106 #ifdef __linux
107 typedef __uint32_t __gid_t;
108 #else
109 typedef unsigned short __gid_t;
110 #endif
111 #endif
112 
113 #ifndef __machine_id_t_defined
114 typedef __uint32_t __id_t;
115 #endif
116 
117 #ifndef __machine_ino_t_defined
118 #if (defined(__i386__) && (defined(GO32) || defined(__MSDOS__))) || \
119 	defined(__sparc__) || defined(__SPU__) || defined(__linux)
120 typedef unsigned long __ino_t;
121 #else
122 typedef unsigned short __ino_t;
123 #endif
124 typedef __uint64_t      __ino64_t;
125 #endif
126 
127 #ifndef __machine_mode_t_defined
128 #if defined(__i386__) && (defined(GO32) || defined(__MSDOS__))
129 typedef int __mode_t;
130 #else
131 #if defined(__sparc__) && !defined(__sparc_v9__)
132 #ifdef __svr4__
133 typedef unsigned long __mode_t;
134 #else
135 typedef unsigned short __mode_t;
136 #endif
137 #else
138 typedef __uint32_t __mode_t;
139 #endif
140 #endif
141 #endif
142 
143 #ifndef __machine_off64_t_defined
144 __extension__ typedef long long _off64_t;
145 #endif
146 
147 typedef _off_t __off_t;
148 typedef __uint64_t __off64_t;
149 
150 typedef _off64_t __loff_t;
151 
152 #ifndef __machine_key_t_defined
153 typedef long __key_t;
154 #endif
155 
156 /*
157  * We need fpos_t for the following, but it doesn't have a leading "_",
158  * so we use _fpos_t instead.
159  */
160 #ifndef __machine_fpos_t_defined
161 typedef long _fpos_t;		/* XXX must match off_t in <sys/types.h> */
162 				/* (and must be `long' for now) */
163 #endif
164 
165 #ifndef __machine_fpos64_t_defined
166 typedef _off64_t _fpos64_t;
167 #endif
168 
169 /* Defined by GCC provided <stddef.h> */
170 #undef __size_t
171 
172 #ifndef __machine_size_t_defined
173 #ifdef __SIZE_TYPE__
174 typedef __SIZE_TYPE__ __size_t;
175 #else
176 #if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
177 typedef unsigned int __size_t;
178 #else
179 typedef unsigned long __size_t;
180 #endif
181 #endif
182 #endif
183 
184 #ifndef __machine_ssize_t_defined
185 #ifdef __SIZE_TYPE__
186 /* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.
187    We simply change "unsigned" to "signed" for this single definition
188    to make sure ssize_t and size_t only differ by their signedness. */
189 #define unsigned signed
190 typedef __SIZE_TYPE__ _ssize_t;
191 #undef unsigned
192 #else
193 #if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
194 typedef int _ssize_t;
195 #else
196 typedef long _ssize_t;
197 #endif
198 #endif
199 #endif
200 
201 typedef _ssize_t __ssize_t;
202 
203 #ifndef __machine_mbstate_t_defined
204 /* Conversion state information.  */
205 typedef struct
206 {
207   int __count;
208   union
209   {
210     wint_t __wch;
211     unsigned char __wchb[4];
212   } __value;		/* Value so far.  */
213 } _mbstate_t;
214 #endif
215 
216 #ifndef __machine_iconv_t_defined
217 /* Iconv descriptor type */
218 typedef void *_iconv_t;
219 #endif
220 
221 #ifndef __machine_clock_t_defined
222 #define	_CLOCK_T_	unsigned long	/* clock() */
223 #endif
224 
225 typedef	_CLOCK_T_	__clock_t;
226 
227 #if defined(_USE_LONG_TIME_T) || __LONG_MAX__ > 0x7fffffffL
228 #define	_TIME_T_ long
229 #else
230 #define	_TIME_T_ __int_least64_t
231 #endif
232 typedef	_TIME_T_	__time_t;
233 
234 #ifndef __machine_clockid_t_defined
235 #define	_CLOCKID_T_ 	unsigned long
236 #endif
237 
238 typedef	_CLOCKID_T_	__clockid_t;
239 
240 #ifndef __machine_daddr_t_defined
241 typedef	long		__daddr_t;
242 #endif
243 
244 #define	_TIMER_T_	unsigned long
245 typedef	_TIMER_T_	__timer_t;
246 
247 #ifndef __machine_sa_family_t_defined
248 typedef	__uint8_t	__sa_family_t;
249 #endif
250 
251 #ifndef __machine_socklen_t_defined
252 typedef	__uint32_t	__socklen_t;
253 #endif
254 
255 typedef	__int32_t	__nl_item;
256 typedef	unsigned short	__nlink_t;
257 typedef	long		__suseconds_t;	/* microseconds (signed) */
258 typedef	unsigned long	__useconds_t;	/* microseconds (unsigned) */
259 
260 #ifdef __STDC_WANT_LIB_EXT1__
261 #if (__STDC_WANT_LIB_EXT1__ != 0) && (__STDC_WANT_LIB_EXT1__ != 1)
262 #error Please define __STDC_WANT_LIB_EXT__ as 0 or 1
263 #endif
264 
265 #if __STDC_WANT_LIB_EXT1__ == 1
266 typedef size_t __rsize_t;
267 typedef int __errno_t;
268 #endif
269 #endif
270 
271 #endif	/* _SYS__TYPES_H */
272