Annotation of src/sys/sys/types.h, Revision 1.29
1.29 ! jtc 1: /* $NetBSD: types.h,v 1.28 1996/07/18 20:01:43 explorer Exp $ */
1.16 cgd 2:
1.12 cgd 3: /*-
1.14 cgd 4: * Copyright (c) 1982, 1986, 1991, 1993
5: * The Regents of the University of California. All rights reserved.
1.12 cgd 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. All advertising materials mentioning features or use of this software
21: * must display the following acknowledgement:
22: * This product includes software developed by the University of
23: * California, Berkeley and its contributors.
24: * 4. Neither the name of the University nor the names of its contributors
25: * may be used to endorse or promote products derived from this software
26: * without specific prior written permission.
27: *
28: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38: * SUCH DAMAGE.
39: *
1.15 cgd 40: * @(#)types.h 8.4 (Berkeley) 1/21/94
1.12 cgd 41: */
42:
43: #ifndef _SYS_TYPES_H_
1.14 cgd 44: #define _SYS_TYPES_H_
1.12 cgd 45:
46: /* Machine type dependent parameters. */
1.18 cgd 47: #include <machine/types.h>
48:
49: #include <machine/ansi.h>
1.12 cgd 50: #include <machine/endian.h>
51:
1.25 jtc 52: #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
1.12 cgd 53: typedef unsigned char u_char;
54: typedef unsigned short u_short;
55: typedef unsigned int u_int;
56: typedef unsigned long u_long;
1.25 jtc 57:
58: typedef unsigned char unchar; /* Sys V compatibility */
1.12 cgd 59: typedef unsigned short ushort; /* Sys V compatibility */
1.14 cgd 60: typedef unsigned int uint; /* Sys V compatibility */
1.25 jtc 61: typedef unsigned long ulong; /* Sys V compatibility */
1.14 cgd 62: #endif
1.12 cgd 63:
1.18 cgd 64: typedef u_int64_t u_quad_t; /* quads */
65: typedef int64_t quad_t;
1.12 cgd 66: typedef quad_t * qaddr_t;
67:
1.14 cgd 68: typedef char * caddr_t; /* core address */
1.18 cgd 69: typedef int32_t daddr_t; /* disk address */
70: typedef int32_t dev_t; /* device number */
71: typedef u_int32_t fixpt_t; /* fixed point number */
72: typedef u_int32_t gid_t; /* group id */
73: typedef u_int32_t ino_t; /* inode number */
74: typedef long key_t; /* IPC key (for Sys V IPC) */
75: typedef u_int16_t mode_t; /* permissions */
76: typedef u_int16_t nlink_t; /* link count */
1.14 cgd 77: typedef quad_t off_t; /* file offset */
1.18 cgd 78: typedef int32_t pid_t; /* process id */
1.20 jtc 79: typedef quad_t rlim_t; /* resource limit */
1.18 cgd 80: typedef int32_t segsz_t; /* segment size */
81: typedef int32_t swblk_t; /* swap offset */
82: typedef u_int32_t uid_t; /* user id */
1.12 cgd 83:
84: /*
1.22 jtc 85: * These belong in unistd.h, but are placed here too to ensure that
1.26 cgd 86: * long arguments will be promoted to off_t if the program fails to
1.22 jtc 87: * include that header or explicitly cast them to off_t.
1.12 cgd 88: */
1.25 jtc 89: #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
1.21 jtc 90: #ifndef _KERNEL
1.12 cgd 91: #include <sys/cdefs.h>
92: __BEGIN_DECLS
93: off_t lseek __P((int, off_t, int));
1.22 jtc 94: int ftruncate __P((int, off_t));
95: int truncate __P((const char *, off_t));
1.12 cgd 96: __END_DECLS
1.23 jtc 97: #endif /* !_KERNEL */
1.25 jtc 98: #endif /* !defined(_POSIX_SOURCE) ... */
1.12 cgd 99:
1.25 jtc 100: #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
1.18 cgd 101: /* Major, minor numbers, dev_t's. */
102: #define major(x) ((int32_t)(((u_int32_t)(x) >> 8) & 0xff))
103: #define minor(x) ((int32_t)((x) & 0xff))
104: #define makedev(x,y) ((dev_t)(((x) << 8) | (y)))
1.12 cgd 105: #endif
106:
1.14 cgd 107: #ifdef _BSD_CLOCK_T_
108: typedef _BSD_CLOCK_T_ clock_t;
109: #undef _BSD_CLOCK_T_
1.12 cgd 110: #endif
111:
1.14 cgd 112: #ifdef _BSD_SIZE_T_
113: typedef _BSD_SIZE_T_ size_t;
114: #undef _BSD_SIZE_T_
1.12 cgd 115: #endif
116:
1.14 cgd 117: #ifdef _BSD_SSIZE_T_
118: typedef _BSD_SSIZE_T_ ssize_t;
119: #undef _BSD_SSIZE_T_
1.12 cgd 120: #endif
121:
1.14 cgd 122: #ifdef _BSD_TIME_T_
123: typedef _BSD_TIME_T_ time_t;
124: #undef _BSD_TIME_T_
1.29 ! jtc 125: #endif
! 126:
! 127: #ifdef _BSD_CLOCKID_T_
! 128: typedef _BSD_CLOCKID_T_ clockid_t;
! 129: #undef _BSD_CLOCKID_T_
! 130: #endif
! 131:
! 132: #ifdef _BSD_TIMER_T_
! 133: typedef _BSD_TIMER_T_ timer_t;
! 134: #undef _BSD_TIMER_T_
1.12 cgd 135: #endif
136:
1.25 jtc 137: #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
1.12 cgd 138: #define NBBY 8 /* number of bits in a byte */
139:
140: /*
141: * Select uses bit masks of file descriptors in longs. These macros
142: * manipulate such bit fields (the filesystem macros use chars).
143: * FD_SETSIZE may be defined by the user, but the default here should
144: * be enough for most uses.
145: */
146: #ifndef FD_SETSIZE
1.28 explorer 147: #define FD_SETSIZE 256
1.12 cgd 148: #endif
149:
1.18 cgd 150: typedef int32_t fd_mask;
1.12 cgd 151: #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
152:
153: #ifndef howmany
1.18 cgd 154: #define howmany(x, y) (((x) + ((y) - 1)) / (y))
1.12 cgd 155: #endif
156:
157: typedef struct fd_set {
158: fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
159: } fd_set;
160:
161: #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
162: #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
163: #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
1.24 jtc 164: #ifdef _KERNEL
1.13 cgd 165: #define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
1.14 cgd 166: #define FD_ZERO(p) bzero(p, sizeof(*(p)))
1.24 jtc 167: #else
168: #define FD_COPY(f, t) memcpy(t, f, sizeof(*(f)))
169: #define FD_ZERO(p) memset(p, 0, sizeof(*(p)))
170: #endif
1.12 cgd 171:
1.21 jtc 172: #if defined(__STDC__) && defined(_KERNEL)
1.12 cgd 173: /*
1.14 cgd 174: * Forward structure declarations for function prototypes. We include the
175: * common structures that cross subsystem boundaries here; others are mostly
176: * used in the same place that the structure is defined.
1.12 cgd 177: */
178: struct proc;
179: struct pgrp;
180: struct ucred;
181: struct rusage;
182: struct file;
183: struct buf;
184: struct tty;
185: struct uio;
186: #endif
187:
1.25 jtc 188: #endif /* !defined(_POSIX_SOURCE) ... */
1.12 cgd 189: #endif /* !_SYS_TYPES_H_ */
CVSweb <webmaster@jp.NetBSD.org>