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