1 /*- 2 * Copyright (c) 1982, 1986, 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * %sccs.include.redist.c% 11 * 12 * @(#)types.h 8.6 (Berkeley) 02/19/95 13 */ 14 15 #ifndef _SYS_TYPES_H_ 16 #define _SYS_TYPES_H_ 17 18 /* Machine type dependent parameters. */ 19 #include <machine/ansi.h> 20 #include <machine/types.h> 21 22 #ifndef _POSIX_SOURCE 23 typedef unsigned char u_char; 24 typedef unsigned short u_short; 25 typedef unsigned int u_int; 26 typedef unsigned long u_long; 27 typedef unsigned short ushort; /* Sys V compatibility */ 28 typedef unsigned int uint; /* Sys V compatibility */ 29 #endif 30 31 typedef u_int64_t u_quad_t; /* quads */ 32 typedef int64_t quad_t; 33 typedef quad_t * qaddr_t; 34 35 typedef char * caddr_t; /* core address */ 36 typedef int32_t daddr_t; /* disk address */ 37 typedef u_int32_t dev_t; /* device number */ 38 typedef u_int32_t fixpt_t; /* fixed point number */ 39 typedef u_int32_t gid_t; /* group id */ 40 typedef u_int32_t ino_t; /* inode number */ 41 typedef long key_t; /* IPC key (for Sys V IPC) */ 42 typedef u_int16_t mode_t; /* permissions */ 43 typedef u_int16_t nlink_t; /* link count */ 44 typedef quad_t off_t; /* file offset */ 45 typedef int32_t pid_t; /* process id */ 46 typedef int32_t segsz_t; /* segment size */ 47 typedef int32_t swblk_t; /* swap offset */ 48 typedef u_int32_t uid_t; /* user id */ 49 50 /* 51 * This belongs in unistd.h, but is placed here to ensure that programs 52 * casting the second parameter of lseek to off_t will get the correct 53 * version of lseek. 54 */ 55 #ifndef KERNEL 56 #include <sys/cdefs.h> 57 __BEGIN_DECLS 58 off_t lseek __P((int, off_t, int)); 59 __END_DECLS 60 #endif 61 62 #ifndef _POSIX_SOURCE 63 /* major number */ 64 #define major(x) ((int32_t)(((u_int32_t)(x) >> 8) & 0xff)) 65 #define minor(x) ((int32_t)((x) & 0xff)) /* minor number */ 66 #define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ 67 #endif 68 69 #include <machine/endian.h> 70 71 #ifdef _BSD_CLOCK_T_ 72 typedef _BSD_CLOCK_T_ clock_t; 73 #undef _BSD_CLOCK_T_ 74 #endif 75 76 #ifdef _BSD_SIZE_T_ 77 typedef _BSD_SIZE_T_ size_t; 78 #undef _BSD_SIZE_T_ 79 #endif 80 81 #ifdef _BSD_SSIZE_T_ 82 typedef _BSD_SSIZE_T_ ssize_t; 83 #undef _BSD_SSIZE_T_ 84 #endif 85 86 #ifdef _BSD_TIME_T_ 87 typedef _BSD_TIME_T_ time_t; 88 #undef _BSD_TIME_T_ 89 #endif 90 91 #ifndef _POSIX_SOURCE 92 #define NBBY 8 /* number of bits in a byte */ 93 94 /* 95 * Select uses bit masks of file descriptors in longs. These macros 96 * manipulate such bit fields (the filesystem macros use chars). 97 * FD_SETSIZE may be defined by the user, but the default here should 98 * be enough for most uses. 99 */ 100 #ifndef FD_SETSIZE 101 #define FD_SETSIZE 256 102 #endif 103 104 typedef int32_t fd_mask; 105 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 106 107 #ifndef howmany 108 #define howmany(x, y) (((x) + ((y) - 1)) / (y)) 109 #endif 110 111 typedef struct fd_set { 112 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 113 } fd_set; 114 115 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 116 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 117 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 118 #define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) 119 #define FD_ZERO(p) bzero(p, sizeof(*(p))) 120 121 #if defined(__STDC__) && defined(KERNEL) 122 /* 123 * Forward structure declarations for function prototypes. We include the 124 * common structures that cross subsystem boundaries here; others are mostly 125 * used in the same place that the structure is defined. 126 */ 127 struct proc; 128 struct pgrp; 129 struct ucred; 130 struct rusage; 131 struct file; 132 struct buf; 133 struct tty; 134 struct uio; 135 #endif 136 137 #endif /* !_POSIX_SOURCE */ 138 #endif /* !_SYS_TYPES_H_ */ 139