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