1 /* $NetBSD: types.h,v 1.86 2009/03/07 21:59:25 ad Exp $ */
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.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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.
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
36 * @(#)types.h 8.4 (Berkeley) 1/21/94
42 #include <sys/featuretest.h>
44 /* Machine type dependent parameters. */
45 #include <machine/types.h>
47 #include <machine/ansi.h>
48 #include <machine/int_types.h>
53 typedef __int8_t
int8_t;
54 #define int8_t __int8_t
58 typedef __uint8_t
uint8_t;
59 #define uint8_t __uint8_t
63 typedef __int16_t
int16_t;
64 #define int16_t __int16_t
68 typedef __uint16_t
uint16_t;
69 #define uint16_t __uint16_t
73 typedef __int32_t
int32_t;
74 #define int32_t __int32_t
78 typedef __uint32_t
uint32_t;
79 #define uint32_t __uint32_t
83 typedef __int64_t
int64_t;
84 #define int64_t __int64_t
88 typedef __uint64_t
uint64_t;
89 #define uint64_t __uint64_t
92 typedef uint8_t u_int8_t
;
93 typedef uint16_t u_int16_t
;
94 typedef uint32_t u_int32_t
;
95 typedef uint64_t u_int64_t
;
99 typedef uint16_t u16_t
;
100 typedef uint32_t u32_t
;
101 typedef uint64_t u64_t
;
104 typedef int16_t i16_t
;
105 typedef int32_t i32_t
;
106 typedef int64_t i64_t
;
108 typedef uint64_t big_ino_t
;
109 typedef int64_t big_off_t
;
110 typedef u32_t big_dev_t
;
111 typedef u32_t big_gid_t
;
112 typedef u32_t big_mode_t
;
113 typedef u32_t big_nlink_t
;
114 typedef u32_t big_uid_t
;
118 /* some Minix specific types that do not conflict with posix */
119 typedef u32_t zone_t
; /* zone number */
120 typedef u32_t block_t
; /* block number */
121 typedef u32_t bit_t
; /* bit number in a bit map */
122 typedef u16_t zone1_t
; /* zone number for V1 file systems */
123 typedef u32_t bitchunk_t
; /* collection of bits in a bitmap */
126 /* ANSI C makes writing down the promotion of unsigned types very messy. When
127 * sizeof(short) == sizeof(int), there is no promotion, so the type stays
128 * unsigned. When the compiler is not ANSI, there is usually no loss of
129 * unsignedness, and there are usually no prototypes so the promoted type
130 * doesn't matter. The use of types like Ino_t is an attempt to use ints
131 * (which are not promoted) while providing information to the reader.
134 typedef unsigned long Ino_t
;
138 #include <machine/endian.h>
140 #if defined(_NETBSD_SOURCE)
141 typedef unsigned char u_char
;
142 typedef unsigned short u_short
;
143 typedef unsigned int u_int
;
144 typedef unsigned long u_long
;
146 typedef unsigned char unchar
; /* Sys V compatibility */
147 typedef unsigned short ushort
; /* Sys V compatibility */
148 typedef unsigned int uint
; /* Sys V compatibility */
149 typedef unsigned long ulong
; /* Sys V compatibility */
152 typedef uint64_t u_quad_t
; /* quads */
153 typedef int64_t quad_t
;
154 typedef quad_t
* qaddr_t
;
157 * The types longlong_t and u_longlong_t exist for use with the
158 * Sun-derived XDR routines involving these types, and their usage
159 * in other contexts is discouraged. Further note that these types
160 * may not be equivalent to "long long" and "unsigned long long",
161 * they are only guaranteed to be signed and unsigned 64-bit types
162 * respectively. Portable programs that need 64-bit types should use
163 * the C99 types int64_t and uint64_t instead.
166 typedef int64_t longlong_t
; /* for XDR */
167 typedef uint64_t u_longlong_t
; /* for XDR */
169 typedef int64_t blkcnt_t
; /* fs block count */
170 typedef uint32_t blksize_t
; /* fs optimal block size */
173 typedef __fsblkcnt_t fsblkcnt_t
; /* fs block count (statvfs) */
174 #define fsblkcnt_t __fsblkcnt_t
178 typedef __fsfilcnt_t fsfilcnt_t
; /* fs file count */
179 #define fsfilcnt_t __fsfilcnt_t
182 #if !defined(_KERNEL) && !defined(_STANDALONE)
183 /* We don't and shouldn't use caddr_t in the kernel anymore */
185 typedef __caddr_t caddr_t
; /* core address */
186 #define caddr_t __caddr_t
191 typedef __daddr_t daddr_t
; /* disk address */
194 typedef int64_t daddr_t
; /* disk address */
198 typedef uint32_t dev_t
; /* device number */
199 typedef uint32_t fixpt_t
; /* fixed point number */
202 typedef __gid_t gid_t
; /* group id */
203 #define gid_t __gid_t
206 typedef int idtype_t
; /* type of the id */
207 typedef uint32_t id_t
; /* group id, process id or user id */
208 typedef unsigned long ino_t
; /* inode number */
209 typedef long key_t
; /* IPC key (for Sys V IPC) */
212 typedef __mode_t mode_t
; /* permissions */
213 #define mode_t __mode_t
216 typedef short nlink_t
; /* link count */
219 typedef __off_t off_t
; /* file offset */
220 #define off_t __off_t
224 typedef __pid_t pid_t
; /* process id */
225 #define pid_t __pid_t
228 typedef int32_t lwpid_t
; /* LWP id */
229 typedef unsigned long rlim_t
; /* resource limit */
230 typedef int32_t segsz_t
; /* segment size */
231 typedef int32_t swblk_t
; /* swap offset */
234 typedef __uid_t uid_t
; /* user id */
235 #define uid_t __uid_t
241 typedef unsigned long cpuid_t
;
243 typedef int psetid_t
;
245 #if defined(_KERNEL) || defined(_STANDALONE)
247 * Boolean type definitions for the kernel environment. User-space
248 * boolean definitions are found in <stdbool.h>.
255 * Deprecated Mach-style boolean_t type. Should not be used by new code.
257 typedef int boolean_t
;
265 #endif /* _KERNEL || _STANDALONE */
267 #if defined(_KERNEL) || defined(_LIBC)
269 * semctl(2)'s argument structure. This is here for the benefit of
270 * <sys/syscallargs.h>. It is not in the user's namespace in SUSv2.
271 * The SUSv2 semctl(2) takes variable arguments.
274 int val
; /* value for SETVAL */
275 struct semid_ds
*buf
; /* buffer for IPC_STAT & IPC_SET */
276 unsigned short *array
; /* array for GETALL & SETALL */
278 #include <sys/stdint.h>
279 #endif /* _KERNEL || _LIBC */
282 * These belong in unistd.h, but are placed here too to ensure that
283 * long arguments will be promoted to off_t if the program fails to
284 * include that header or explicitly cast them to off_t.
286 #if defined(_NETBSD_SOURCE)
287 #ifndef __OFF_T_SYSCALLS_DECLARED
288 #define __OFF_T_SYSCALLS_DECLARED
290 #include <sys/cdefs.h>
292 off_t
lseek(int, off_t
, int);
293 int ftruncate(int, off_t
);
294 int truncate(const char *, off_t
);
296 #endif /* !_KERNEL */
297 #endif /* __OFF_T_SYSCALLS_DECLARED */
298 #endif /* defined(_NETBSD_SOURCE) */
300 #if defined(_NETBSD_SOURCE)
301 typedef int32_t __devmajor_t
, __devminor_t
;
302 #define devmajor_t __devmajor_t
303 #define devminor_t __devminor_t
304 #define NODEVMAJOR (-1)
306 /* Major, minor numbers, dev_t's. */
307 #define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */
308 #define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */
309 #define minor(dev) ((devminor_t)(((dev) >> MINOR) & 0xff))
310 #define major(dev) ((devmajor_t)(((dev) >> MAJOR) & 0xff))
311 #define makedev(major, minor) \
312 ((dev_t) (((major) << MAJOR) | ((minor) << MINOR)))
317 typedef _BSD_CLOCK_T_
clock_t;
322 typedef _BSD_SIZE_T_
size_t;
328 typedef _BSD_SSIZE_T_ ssize_t
;
333 typedef _BSD_TIME_T_
time_t;
337 #ifdef _BSD_CLOCKID_T_
338 typedef _BSD_CLOCKID_T_ clockid_t
;
339 #undef _BSD_CLOCKID_T_
344 typedef _BSD_TIMER_T_ timer_t
;
349 #ifdef _BSD_SUSECONDS_T_
350 typedef _BSD_SUSECONDS_T_ suseconds_t
;
351 #undef _BSD_SUSECONDS_T_
354 #ifdef _BSD_USECONDS_T_
355 typedef _BSD_USECONDS_T_ useconds_t
;
356 #undef _BSD_USECONDS_T_
359 #ifdef _NETBSD_SOURCE
360 #include <sys/fd_set.h>
363 typedef struct kauth_cred
*kauth_cred_t
;
369 #if defined(__STDC__) && (defined(_KERNEL) || defined(_KMEMUSER))
371 * Forward structure declarations for function prototypes. We include the
372 * common structures that cross subsystem boundaries here; others are mostly
373 * used in the same place that the structure is defined.
376 typedef struct lwp lwp_t
;
380 typedef struct proc proc_t
;
384 typedef struct file file_t
;
386 typedef struct buf buf_t
;
392 #define SET(t, f) ((t) |= (f))
393 #define ISSET(t, f) ((t) & (f))
394 #define CLR(t, f) ((t) &= ~(f))
398 #if !defined(_KERNEL) && !defined(_STANDALONE)
399 #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
400 defined(_NETBSD_SOURCE)
401 #include <pthread_types.h>
404 #endif /* !__minix */
406 #endif /* !_SYS_TYPES_H_ */