FreeBSD/Linux Kernel Cross Reference
sys/sys/types.h
1 /* $NetBSD: types.h,v 1.71.12.1 2007/09/27 13:40:47 xtraeme Exp $ */
2
3 /*-
4 * Copyright (c) 1982, 1986, 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)types.h 8.4 (Berkeley) 1/21/94
37 */
38
39 #ifndef _SYS_TYPES_H_
40 #define _SYS_TYPES_H_
41
42 #include <sys/featuretest.h>
43
44 /* Machine type dependent parameters. */
45 #include <machine/types.h>
46
47 #include <machine/ansi.h>
48 #include <machine/int_types.h>
49
50
51 #include <sys/ansi.h>
52
53 #ifndef int8_t
54 typedef __int8_t int8_t;
55 #define int8_t __int8_t
56 #endif
57
58 #ifndef uint8_t
59 typedef __uint8_t uint8_t;
60 #define uint8_t __uint8_t
61 #endif
62
63 #ifndef int16_t
64 typedef __int16_t int16_t;
65 #define int16_t __int16_t
66 #endif
67
68 #ifndef uint16_t
69 typedef __uint16_t uint16_t;
70 #define uint16_t __uint16_t
71 #endif
72
73 #ifndef int32_t
74 typedef __int32_t int32_t;
75 #define int32_t __int32_t
76 #endif
77
78 #ifndef uint32_t
79 typedef __uint32_t uint32_t;
80 #define uint32_t __uint32_t
81 #endif
82
83 #ifndef int64_t
84 typedef __int64_t int64_t;
85 #define int64_t __int64_t
86 #endif
87
88 #ifndef uint64_t
89 typedef __uint64_t uint64_t;
90 #define uint64_t __uint64_t
91 #endif
92
93 typedef uint8_t u_int8_t;
94 typedef uint16_t u_int16_t;
95 typedef uint32_t u_int32_t;
96 typedef uint64_t u_int64_t;
97
98 #include <machine/endian.h>
99
100 #if defined(_NETBSD_SOURCE)
101 typedef unsigned char u_char;
102 typedef unsigned short u_short;
103 typedef unsigned int u_int;
104 typedef unsigned long u_long;
105
106 typedef unsigned char unchar; /* Sys V compatibility */
107 typedef unsigned short ushort; /* Sys V compatibility */
108 typedef unsigned int uint; /* Sys V compatibility */
109 typedef unsigned long ulong; /* Sys V compatibility */
110
111 typedef u_long cpuid_t;
112 #endif
113
114 typedef uint64_t u_quad_t; /* quads */
115 typedef int64_t quad_t;
116 typedef quad_t * qaddr_t;
117
118 /*
119 * The types longlong_t and u_longlong_t exist for use with the
120 * Sun-derived XDR routines involving these types, and their usage
121 * in other contexts is discouraged. Further note that these types
122 * may not be equivalent to "long long" and "unsigned long long",
123 * they are only guaranteed to be signed and unsigned 64-bit types
124 * respectively. Portable programs that need 64-bit types should use
125 * the C99 types int64_t and uint64_t instead.
126 */
127
128 typedef int64_t longlong_t; /* for XDR */
129 typedef uint64_t u_longlong_t; /* for XDR */
130
131 typedef int64_t blkcnt_t; /* fs block count */
132 typedef uint32_t blksize_t; /* fs optimal block size */
133
134 #ifndef fsblkcnt_t
135 typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */
136 #define fsblkcnt_t __fsblkcnt_t
137 #endif
138
139 #ifndef fsfilcnt_t
140 typedef __fsfilcnt_t fsfilcnt_t; /* fs file count */
141 #define fsfilcnt_t __fsfilcnt_t
142 #endif
143
144 #ifndef caddr_t
145 typedef __caddr_t caddr_t; /* core address */
146 #define caddr_t __caddr_t
147 #endif
148
149 #ifdef __daddr_t
150 typedef __daddr_t daddr_t; /* disk address */
151 #undef __daddr_t
152 #else
153 typedef int64_t daddr_t; /* disk address */
154 #endif
155
156 typedef uint32_t dev_t; /* device number */
157 typedef uint32_t fixpt_t; /* fixed point number */
158
159 #ifndef gid_t
160 typedef __gid_t gid_t; /* group id */
161 #define gid_t __gid_t
162 #endif
163
164 typedef uint32_t id_t; /* group id, process id or user id */
165 typedef uint64_t ino_t; /* inode number */
166 typedef long key_t; /* IPC key (for Sys V IPC) */
167
168 #ifndef mode_t
169 typedef __mode_t mode_t; /* permissions */
170 #define mode_t __mode_t
171 #endif
172
173 typedef uint32_t nlink_t; /* link count */
174
175 #ifndef off_t
176 typedef __off_t off_t; /* file offset */
177 #define off_t __off_t
178 #endif
179
180 #ifndef pid_t
181 typedef __pid_t pid_t; /* process id */
182 #define pid_t __pid_t
183 #endif
184 typedef int32_t lwpid_t; /* LWP id */
185 typedef quad_t rlim_t; /* resource limit */
186 typedef int32_t segsz_t; /* segment size */
187 typedef int32_t swblk_t; /* swap offset */
188
189 #ifndef uid_t
190 typedef __uid_t uid_t; /* user id */
191 #define uid_t __uid_t
192 #endif
193
194 typedef int32_t dtime_t; /* on-disk time_t */
195
196 #if defined(_KERNEL) || defined(_STANDALONE)
197 /*
198 * Boolean type definitions for the kernel environment. User-space
199 * boolean definitions are found in <stdbool.h>.
200 */
201 #define bool _Bool
202 #define true 1
203 #define false 0
204 /*
205 * Deprecated Mach-style boolean_t type. Should not be used by new code.
206 */
207 typedef int boolean_t;
208 #ifndef TRUE
209 #define TRUE 1
210 #endif
211 #ifndef FALSE
212 #define FALSE 0
213 #endif
214 #endif
215
216 #if defined(_KERNEL) || defined(_LIBC)
217 /*
218 * semctl(2)'s argument structure. This is here for the benefit of
219 * <sys/syscallargs.h>. It is not in the user's namespace in SUSv2.
220 * The SUSv2 semctl(2) takes variable arguments.
221 */
222 union __semun {
223 int val; /* value for SETVAL */
224 struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
225 unsigned short *array; /* array for GETALL & SETALL */
226 };
227 /* For the same reason as above */
228 #include <sys/stdint.h>
229 typedef intptr_t semid_t;
230 #endif /* _KERNEL || _LIBC */
231
232 /*
233 * These belong in unistd.h, but are placed here too to ensure that
234 * long arguments will be promoted to off_t if the program fails to
235 * include that header or explicitly cast them to off_t.
236 */
237 #if defined(_NETBSD_SOURCE)
238 #ifndef __OFF_T_SYSCALLS_DECLARED
239 #define __OFF_T_SYSCALLS_DECLARED
240 #ifndef _KERNEL
241 #include <sys/cdefs.h>
242 __BEGIN_DECLS
243 off_t lseek(int, off_t, int);
244 int ftruncate(int, off_t);
245 int truncate(const char *, off_t);
246 __END_DECLS
247 #endif /* !_KERNEL */
248 #endif /* __OFF_T_SYSCALLS_DECLARED */
249 #endif /* defined(_NETBSD_SOURCE) */
250
251 #if defined(_NETBSD_SOURCE)
252 /* Major, minor numbers, dev_t's. */
253 #define major(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
254 #define minor(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
255 (((x) & 0x000000ff) >> 0)))
256 #define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
257 (((y) << 12) & 0xfff00000) | \
258 (((y) << 0) & 0x000000ff)))
259 #endif
260
261 #ifdef _BSD_CLOCK_T_
262 typedef _BSD_CLOCK_T_ clock_t;
263 #undef _BSD_CLOCK_T_
264 #endif
265
266 #ifdef _BSD_SIZE_T_
267 typedef _BSD_SIZE_T_ size_t;
268 #define _SIZE_T
269 #undef _BSD_SIZE_T_
270 #endif
271
272 #ifdef _BSD_SSIZE_T_
273 typedef _BSD_SSIZE_T_ ssize_t;
274 #undef _BSD_SSIZE_T_
275 #endif
276
277 #ifdef _BSD_TIME_T_
278 typedef _BSD_TIME_T_ time_t;
279 #undef _BSD_TIME_T_
280 #endif
281
282 #ifdef _BSD_CLOCKID_T_
283 typedef _BSD_CLOCKID_T_ clockid_t;
284 #undef _BSD_CLOCKID_T_
285 #endif
286
287 #ifdef _BSD_TIMER_T_
288 typedef _BSD_TIMER_T_ timer_t;
289 #undef _BSD_TIMER_T_
290 #endif
291
292 #ifdef _BSD_SUSECONDS_T_
293 typedef _BSD_SUSECONDS_T_ suseconds_t;
294 #undef _BSD_SUSECONDS_T_
295 #endif
296
297 #ifdef _BSD_USECONDS_T_
298 typedef _BSD_USECONDS_T_ useconds_t;
299 #undef _BSD_USECONDS_T_
300 #endif
301
302 #ifdef _NETBSD_SOURCE
303 #include <sys/fd_set.h>
304 #define NBBY __NBBY
305
306 typedef struct kauth_cred *kauth_cred_t;
307
308 #endif
309
310 #if defined(__STDC__) && defined(_KERNEL)
311 /*
312 * Forward structure declarations for function prototypes. We include the
313 * common structures that cross subsystem boundaries here; others are mostly
314 * used in the same place that the structure is defined.
315 */
316 struct lwp;
317 struct user;
318 struct __ucontext;
319 struct proc;
320 struct pgrp;
321 struct rusage;
322 struct file;
323 struct buf;
324 struct tty;
325 struct uio;
326 #endif
327
328 #ifdef _KERNEL
329 #define SET(t, f) ((t) |= (f))
330 #define ISSET(t, f) ((t) & (f))
331 #define CLR(t, f) ((t) &= ~(f))
332 #endif
333
334 #if !defined(_KERNEL) && !defined(_STANDALONE)
335 #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
336 defined(_NETBSD_SOURCE)
337 #include <pthread_types.h>
338 #endif
339 #endif
340
341 #endif /* !_SYS_TYPES_H_ */
Cache object: 7baf6d5c40f2591438d1a236ecad1761
|