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