Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Gunar Schorcht
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
21
22/* unified sys/types.h:
23 start with sef's sysvi386 version.
24 merge go32 version -- a few ifdefs.
25 h8300hms, h8300xray, and sysvnecv70 disagree on the following types:
26
27 typedef int gid_t;
28 typedef int uid_t;
29 typedef int dev_t;
30 typedef int ino_t;
31 typedef int mode_t;
32 typedef int caddr_t;
33
34 however, these aren't "reasonable" values, the sysvi386 ones make far
35 more sense, and should work sufficiently well (in particular, h8300
36 doesn't have a stat, and the necv70 doesn't matter.) -- eichin
37 */
38
39#ifndef DOXYGEN
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#ifndef _FSBLKCNT_T_DECLARED
46#include <stdint.h>
47typedef uint32_t fsblkcnt_t;
48typedef uint32_t fsfilcnt_t;
49#define _FSBLKCNT_T_DECLARED
50#endif
51
52#ifndef _SYS_TYPES_H
53
54#include <_ansi.h>
55
56#ifndef __INTTYPES_DEFINED__
57#define __INTTYPES_DEFINED__
58
59#include <machine/_types.h>
60
61#if defined(__rtems__) || defined(__XMK__)
62/*
63 * The following section is RTEMS specific and is needed to more
64 * closely match the types defined in the BSD sys/types.h.
65 * This is needed to let the RTEMS/BSD TCP/IP stack compile.
66 */
67
68/* deprecated */
69#if ___int8_t_defined
70typedef __uint8_t u_int8_t;
71#endif
72#if ___int16_t_defined
73typedef __uint16_t u_int16_t;
74#endif
75#if ___int32_t_defined
76typedef __uint32_t u_int32_t;
77#endif
78
79#if ___int64_t_defined
80typedef __uint64_t u_int64_t;
81
82/* deprecated */
83typedef __uint64_t u_quad_t;
84typedef __int64_t quad_t;
85typedef quad_t * qaddr_t;
86#endif
87
88#endif
89
90#endif /* ! __INTTYPES_DEFINED */
91
92#ifndef __need_inttypes
93
94#define _SYS_TYPES_H
95#include <sys/_types.h>
96
97#ifdef __i386__
98#if defined (GO32) || defined (__MSDOS__)
99#define __MS_types__
100#endif
101#endif
102
103# include <stddef.h>
104# include <machine/types.h>
105
106/* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
107 changes, we assume sizeof short and long never change and have all types
108 used to define struct stat use them and not int where possible.
109 Where not possible, _ST_INTxx are used. It would be preferable to not have
110 such assumptions, but until the extra fluff is necessary, it's avoided.
111 No 64 bit targets use stat yet. What to do about them is postponed
112 until necessary. */
113#ifdef __GNUC__
114#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
115#else
116#define _ST_INT32
117#endif
118
119# ifndef _POSIX_SOURCE
120
121# define physadr physadr_t
122# define quad quad_t
123
124#ifndef _BSDTYPES_DEFINED
125/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
126#ifndef __u_char_defined
127typedef unsigned char u_char;
128#define __u_char_defined
129#endif
130#ifndef __u_short_defined
131typedef unsigned short u_short;
132#define __u_short_defined
133#endif
134#ifndef __u_int_defined
135typedef unsigned int u_int;
136#define __u_int_defined
137#endif
138#ifndef __u_long_defined
139typedef unsigned long u_long;
140#define __u_long_defined
141#endif
142#define _BSDTYPES_DEFINED
143#endif
144
145typedef unsigned short ushort; /* System V compatibility */
146typedef unsigned int uint; /* System V compatibility */
147typedef unsigned long ulong; /* System V compatibility */
148# endif
149
150#ifndef __clock_t_defined
151typedef _CLOCK_T_ clock_t;
152#define __clock_t_defined
153#endif
154
155#ifndef __time_t_defined
156typedef _TIME_T_ time_t;
157#define __time_t_defined
158#endif
159
160#ifndef __timespec_defined
161#define __timespec_defined
162/* Time Value Specification Structures, P1003.1b-1993, p. 261 */
163
164struct timespec {
165 time_t tv_sec; /* Seconds */
166 long tv_nsec; /* Nanoseconds */
167};
168#endif
169
170struct itimerspec {
171 struct timespec it_interval; /* Timer period */
172 struct timespec it_value; /* Timer expiration */
173};
174
175#ifndef __daddr_t_defined
176typedef long daddr_t;
177#define __daddr_t_defined
178#endif
179#ifndef __caddr_t_defined
180typedef char * caddr_t;
181#define __caddr_t_defined
182#endif
183
184#ifndef __CYGWIN__
185#if defined(__MS_types__) || defined(__rtems__) || \
186 defined(__sparc__) || defined(__SPU__)
187typedef unsigned long ino_t;
188#else
189typedef unsigned short ino_t;
190#endif
191#endif /*__CYGWIN__*/
192
193#ifdef __MS_types__
194typedef unsigned long vm_offset_t;
195typedef unsigned long vm_size_t;
196
197#define __BIT_TYPES_DEFINED__
198
199typedef signed char int8_t;
200typedef unsigned char u_int8_t;
201typedef short int16_t;
202typedef unsigned short u_int16_t;
203typedef int int32_t;
204typedef unsigned int u_int32_t;
205typedef long long int64_t;
206typedef unsigned long long u_int64_t;
207typedef int32_t register_t;
208#endif /* __MS_types__ */
209
210/*
211 * All these should be machine specific - right now they are all broken.
212 * However, for all of Cygnus' embedded targets, we want them to all be
213 * the same. Otherwise things like sizeof (struct stat) might depend on
214 * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
215 */
216
217#ifndef __CYGWIN__ /* which defines these types in it's own types.h. */
218typedef _off_t off_t;
219typedef __dev_t dev_t;
220typedef __uid_t uid_t;
221typedef __gid_t gid_t;
222#endif
223
224#if defined(__XMK__)
225typedef signed char pid_t;
226#else
227typedef int pid_t;
228#endif
229
230#if defined(__rtems__)
231typedef _mode_t mode_t;
232#endif
233
234#ifndef __CYGWIN__
235typedef long key_t;
236#endif
237typedef _ssize_t ssize_t;
238
239#if !defined(__CYGWIN__) && !defined(__rtems__)
240#ifdef __MS_types__
241typedef char * addr_t;
242typedef int mode_t;
243#else
244#if defined (__sparc__) && !defined (__sparc_v9__)
245#ifdef __svr4__
246typedef unsigned long mode_t;
247#else
248typedef unsigned short mode_t;
249#endif
250#else
251typedef unsigned int mode_t _ST_INT32;
252#endif
253#endif /* ! __MS_types__ */
254#endif /*__CYGWIN__*/
255
256typedef unsigned short nlink_t;
257
258/* We don't define fd_set and friends if we are compiling POSIX
259 source, or if we have included (or may include as indicated
260 by __USE_W32_SOCKETS) the W32api winsock[2].h header which
261 defines Windows versions of them. Note that a program which
262 includes the W32api winsock[2].h header must know what it is doing;
263 it must not call the cygwin32 select function.
264*/
265# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
266# define _SYS_TYPES_FD_SET
267# define NBBY 8 /* number of bits in a byte */
268/*
269 * Select uses bit masks of file descriptors in longs.
270 * These macros manipulate such bit fields (the filesystem macros use chars).
271 * FD_SETSIZE may be defined by the user, but the default here
272 * should be >= NOFILE (param.h).
273 */
274# ifndef FD_SETSIZE
275# define FD_SETSIZE 64
276# endif
277
278typedef long fd_mask;
279# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
280# ifndef howmany
281# define howmany(x,y) (((x)+((y)-1))/(y))
282# endif
283
284/* We use a macro for fd_set so that including Sockets.h afterwards
285 can work. */
286typedef struct _types_fd_set {
287 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
288} _types_fd_set;
289
290#define fd_set _types_fd_set
291
292# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
293# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
294# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
295# define FD_ZERO(p) (__extension__ (void)({ \
296 size_t __i; \
297 char *__tmp = (char *)p; \
298 for (__i = 0; __i < sizeof (*(p)); ++__i) \
299 *__tmp++ = 0; \
300}))
301
302# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) */
303
304#undef __MS_types__
305#undef _ST_INT32
306
307#ifndef __clockid_t_defined
308typedef _CLOCKID_T_ clockid_t;
309#define __clockid_t_defined
310#endif
311
312#ifndef __timer_t_defined
313typedef _TIMER_T_ timer_t;
314#define __timer_t_defined
315#endif
316
317typedef unsigned long useconds_t;
318typedef long suseconds_t;
319
320#endif /* !__need_inttypes */
321
322#undef __need_inttypes
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif /* DOXYGEN */
329#endif /* SYS_TYPES_H */
#define FD_SETSIZE
Maximum number of file descriptors in an fd_set structure.
Definition select.h:82