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 <newlib.h>
62 #include <sys/config.h>
63 #include <machine/_types.h>
64 
65 #ifndef __machine_blkcnt_t_defined
66 typedef long __blkcnt_t;
67 typedef __int64_t __blkcnt64_t;
68 #endif
69 
70 #ifndef __machine_blksize_t_defined
71 typedef long __blksize_t;
72 #endif
73 
74 #ifndef __machine_fsblkcnt_t_defined
75 typedef __uint64_t __fsblkcnt_t;
76 #endif
77 
78 #ifndef __machine_fsfilcnt_t_defined
79 typedef __uint32_t __fsfilcnt_t;
80 #endif
81 
82 #ifndef __machine_off_t_defined
83 typedef long _off_t;
84 #endif
85 
86 #if defined(__XMK__)
87 typedef signed char __pid_t;
88 #else
89 typedef int __pid_t;
90 #endif
91 
92 #ifndef __machine_dev_t_defined
93 #ifdef __linux
94 typedef __uint64_t __dev_t;
95 #else
96 typedef short __dev_t;
97 #endif
98 #endif
99 
100 #ifndef __machine_uid_t_defined
101 #ifdef __linux
102 typedef __uint32_t __uid_t;
103 #else
104 typedef unsigned short __uid_t;
105 #endif
106 #endif
107 #ifndef __machine_gid_t_defined
108 #ifdef __linux
109 typedef __uint32_t __gid_t;
110 #else
111 typedef unsigned short __gid_t;
112 #endif
113 #endif
114 
115 #ifndef __machine_id_t_defined
116 typedef __uint32_t __id_t;
117 #endif
118 
119 #ifndef __machine_ino_t_defined
120 #if (defined(__i386__) && (defined(GO32) || defined(__MSDOS__))) || \
121 	defined(__sparc__) || defined(__SPU__) || defined(__linux)
122 typedef unsigned long __ino_t;
123 #else
124 typedef unsigned short __ino_t;
125 #endif
126 typedef __uint64_t      __ino64_t;
127 #endif
128 
129 #ifndef __machine_mode_t_defined
130 #if defined(__i386__) && (defined(GO32) || defined(__MSDOS__))
131 typedef int __mode_t;
132 #else
133 #if defined(__sparc__) && !defined(__sparc_v9__)
134 #ifdef __svr4__
135 typedef unsigned long __mode_t;
136 #else
137 typedef unsigned short __mode_t;
138 #endif
139 #else
140 typedef __uint32_t __mode_t;
141 #endif
142 #endif
143 #endif
144 
145 #ifndef __machine_off64_t_defined
146 __extension__ typedef long long _off64_t;
147 #endif
148 
149 #if defined(__CYGWIN__) && !defined(__LP64__)
150 typedef _off64_t __off_t;
151 #else
152 typedef _off_t __off_t;
153 typedef __uint64_t __off64_t;
154 #endif
155 
156 typedef _off64_t __loff_t;
157 
158 #ifndef __machine_key_t_defined
159 typedef long __key_t;
160 #endif
161 
162 /*
163  * We need fpos_t for the following, but it doesn't have a leading "_",
164  * so we use _fpos_t instead.
165  */
166 #ifndef __machine_fpos_t_defined
167 typedef long _fpos_t;		/* XXX must match off_t in <sys/types.h> */
168 				/* (and must be `long' for now) */
169 #endif
170 
171 #ifdef __LARGE64_FILES
172 #ifndef __machine_fpos64_t_defined
173 typedef _off64_t _fpos64_t;
174 #endif
175 #endif
176 
177 /* Defined by GCC provided <stddef.h> */
178 #undef __size_t
179 
180 #ifndef __machine_size_t_defined
181 #ifdef __SIZE_TYPE__
182 typedef __SIZE_TYPE__ __size_t;
183 #else
184 #if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
185 typedef unsigned int __size_t;
186 #else
187 typedef unsigned long __size_t;
188 #endif
189 #endif
190 #endif
191 
192 #ifndef __machine_ssize_t_defined
193 #ifdef __SIZE_TYPE__
194 /* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.
195    We simply change "unsigned" to "signed" for this single definition
196    to make sure ssize_t and size_t only differ by their signedness. */
197 #define unsigned signed
198 typedef __SIZE_TYPE__ _ssize_t;
199 #undef unsigned
200 #else
201 #if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
202 typedef int _ssize_t;
203 #else
204 typedef long _ssize_t;
205 #endif
206 #endif
207 #endif
208 
209 typedef _ssize_t __ssize_t;
210 
211 #ifndef __machine_mbstate_t_defined
212 /* Conversion state information.  */
213 typedef struct
214 {
215   int __count;
216   union
217   {
218     wint_t __wch;
219     unsigned char __wchb[4];
220   } __value;		/* Value so far.  */
221 } _mbstate_t;
222 #endif
223 
224 #ifndef __machine_iconv_t_defined
225 /* Iconv descriptor type */
226 typedef void *_iconv_t;
227 #endif
228 
229 #ifndef __machine_clock_t_defined
230 #define	_CLOCK_T_	unsigned long	/* clock() */
231 #endif
232 
233 typedef	_CLOCK_T_	__clock_t;
234 
235 #if defined(_USE_LONG_TIME_T) || __LONG_MAX__ > 0x7fffffffL
236 #define	_TIME_T_ long
237 #else
238 #define	_TIME_T_ __int_least64_t
239 #endif
240 typedef	_TIME_T_	__time_t;
241 
242 #ifndef __machine_clockid_t_defined
243 #define	_CLOCKID_T_ 	unsigned long
244 #endif
245 
246 typedef	_CLOCKID_T_	__clockid_t;
247 
248 #ifndef __machine_daddr_t_defined
249 typedef	long		__daddr_t;
250 #endif
251 
252 #define	_TIMER_T_	unsigned long
253 typedef	_TIMER_T_	__timer_t;
254 
255 #ifndef __machine_sa_family_t_defined
256 typedef	__uint8_t	__sa_family_t;
257 #endif
258 
259 #ifndef __machine_socklen_t_defined
260 typedef	__uint32_t	__socklen_t;
261 #endif
262 
263 typedef	__int32_t	__nl_item;
264 typedef	unsigned short	__nlink_t;
265 typedef	long		__suseconds_t;	/* microseconds (signed) */
266 typedef	unsigned long	__useconds_t;	/* microseconds (unsigned) */
267 
268 #endif	/* _SYS__TYPES_H */
269