1 /* 2 * Copyright (c) 1982 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)types.h 7.10 (Berkeley) 05/17/90 7 */ 8 9 #ifndef _TYPES_ 10 #define _TYPES_ 11 12 typedef short dev_t; 13 /* major part of a device */ 14 #define major(x) ((int)(((unsigned)(x)>>8)&0377)) 15 /* minor part of a device */ 16 #define minor(x) ((int)((x)&0377)) 17 /* make a device number */ 18 #define makedev(x,y) ((dev_t)(((x)<<8) | (y))) 19 20 typedef unsigned char u_char; 21 typedef unsigned short u_short; 22 typedef unsigned int u_int; 23 typedef unsigned long u_long; 24 typedef unsigned short ushort; /* sys V compatibility */ 25 26 #ifdef KERNEL 27 #include "machine/machtypes.h" 28 #else 29 #include <machine/machtypes.h> 30 #endif 31 #ifdef _SIZE_T_ 32 typedef _SIZE_T_ size_t; 33 #undef _SIZE_T_ 34 #endif 35 36 typedef struct _uquad { unsigned long val[2]; } u_quad; 37 typedef struct _quad { long val[2]; } quad; 38 typedef long * qaddr_t; /* should be typedef quad * qaddr_t; */ 39 40 typedef long daddr_t; 41 typedef char * caddr_t; 42 typedef u_long ino_t; 43 typedef long swblk_t; 44 typedef long segsz_t; 45 typedef long time_t; 46 typedef u_long clock_t; 47 typedef long off_t; 48 typedef u_short uid_t; 49 typedef u_short gid_t; 50 typedef short pid_t; 51 typedef u_short nlink_t; 52 typedef u_short mode_t; 53 typedef u_long fixpt_t; 54 55 #define NBBY 8 /* number of bits in a byte */ 56 57 /* 58 * Select uses bit masks of file descriptors in longs. These macros 59 * manipulate such bit fields (the filesystem macros use chars). 60 * FD_SETSIZE may be defined by the user, but the default here should 61 * be >= NOFILE (param.h). 62 */ 63 #ifndef FD_SETSIZE 64 #define FD_SETSIZE 256 65 #endif 66 67 typedef long fd_mask; 68 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 69 70 #ifndef howmany 71 #define howmany(x, y) (((x)+((y)-1))/(y)) 72 #endif 73 74 typedef struct fd_set { 75 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 76 } fd_set; 77 78 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 79 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 80 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 81 #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 82 83 #endif /* _TYPES_ */ 84