1 .\" $NetBSD: types.5,v 1.11 2005/12/26 20:00:04 perry Exp $
3 .\" Copyright (c) 1980, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)types.5 8.1 (Berkeley) 6/5/93
43 contains the defined data types used in the kernel (most are
44 used throughout the system).
48 code, when an integer of a specific width is needed, the C99
50 .Vt int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t
55 .Vt u_int8_t, u_int16_t, u_int32_t, u_int64_t
61 /* Machine type dependent parameters. */
62 #include \*[Lt]machine/types.h\*[Gt]
64 #include \*[Lt]machine/ansi.h\*[Gt]
65 #include \*[Lt]machine/endian.h\*[Gt]
67 #if !defined(_POSIX_SOURCE) \*[Am]\*[Am] !defined(_XOPEN_SOURCE)
68 typedef unsigned char u_char;
69 typedef unsigned short u_short;
70 typedef unsigned int u_int;
71 typedef unsigned long u_long;
73 typedef unsigned char unchar; /* Sys V compatibility */
74 typedef unsigned short ushort; /* Sys V compatibility */
75 typedef unsigned int uint; /* Sys V compatibility */
76 typedef unsigned long ulong; /* Sys V compatibility */
79 typedef uint64_t u_quad_t; /* quads */
80 typedef int64_t quad_t;
81 typedef quad_t * qaddr_t;
83 typedef char * caddr_t; /* core address */
84 typedef int32_t daddr_t; /* disk address */
85 typedef int32_t dev_t; /* device number */
86 typedef uint32_t fixpt_t; /* fixed point number */
87 typedef uint32_t gid_t; /* group id */
88 typedef uint32_t ino_t; /* inode number */
89 typedef long key_t; /* IPC key (for Sys V IPC) */
90 typedef uint16_t mode_t; /* permissions */
91 typedef uint16_t nlink_t; /* link count */
92 typedef quad_t off_t; /* file offset */
93 typedef int32_t pid_t; /* process id */
94 typedef quad_t rlim_t; /* resource limit */
95 typedef int32_t segsz_t; /* segment size */
96 typedef int32_t swblk_t; /* swap offset */
97 typedef uint32_t uid_t; /* user id */
99 #if !defined(_POSIX_SOURCE) \*[Am]\*[Am] !defined(_XOPEN_SOURCE)
100 /* Major, minor numbers, dev_t's. */
101 #define major(x) ((int32_t)(((uint32_t)(x) \*[Gt]\*[Gt] 8) \*[Am] 0xff))
102 #define minor(x) ((int32_t)((x) \*[Am] 0xff))
103 #define makedev(x,y) ((dev_t)(((x) \*[Lt]\*[Lt] 8) | (y)))
107 typedef _BSD_CLOCK_T_ clock_t;
112 typedef _BSD_SIZE_T_ size_t;
117 typedef _BSD_SSIZE_T_ ssize_t;
122 typedef _BSD_TIME_T_ time_t;
126 #ifdef _BSD_CLOCKID_T_
127 typedef _BSD_CLOCKID_T_ clockid_t;
128 #undef _BSD_CLOCKID_T_
132 typedef _BSD_TIMER_T_ timer_t;
136 #if !defined(_POSIX_SOURCE) \*[Am]\*[Am] !defined(_XOPEN_SOURCE)
137 #define NBBY 8 /* number of bits in a byte */
140 * Select uses bit masks of file descriptors in longs. These macros
141 * manipulate such bit fields (the filesystem macros use chars).
142 * FD_SETSIZE may be defined by the user, but the default here should
143 * be enough for most uses.
146 #define FD_SETSIZE 256
149 typedef int32_t fd_mask;
150 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
153 #define howmany(x, y) (((x) + ((y) - 1)) / (y))
156 typedef struct fd_set {
157 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
160 #define FD_SET(n, p) ((p)-\*[Gt]fds_bits[(n)/NFDBITS] |= (1 \*[Lt]\*[Lt] ((n) % NFDBITS)))
161 #define FD_CLR(n, p) ((p)-\*[Gt]fds_bits[(n)/NFDBITS] \*[Am]= ~(1 \*[Lt]\*[Lt] ((n) % NFDBITS)))
162 #define FD_ISSET(n, p) ((p)-\*[Gt]fds_bits[(n)/NFDBITS] \*[Am] (1 \*[Lt]\*[Lt] ((n) % NFDBITS)))
163 #define FD_COPY(f, t) memcpy(t, f, sizeof(*(f)))
164 #define FD_ZERO(p) memset(p, 0, sizeof(*(p)))
166 #endif /* !defined(_POSIX_SOURCE) ... */
167 #endif /* !_SYS_TYPES_H_ */