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