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