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