1: /* 2: * Copyright (c) 1982, 1986 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.1 (Berkeley) 6/4/86 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: #ifdef vax 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 u_long ino_t; 40: typedef long swblk_t; 41: typedef long size_t; 42: typedef long time_t; 43: typedef short dev_t; 44: typedef long off_t; 45: typedef u_short uid_t; 46: typedef u_short gid_t; 47: 48: #define NBBY 8 /* number of bits in a byte */ 49: /* 50: * Select uses bit masks of file descriptors in longs. 51: * These macros manipulate such bit fields (the filesystem macros use chars). 52: * FD_SETSIZE may be defined by the user, but the default here 53: * should be >= NOFILE (param.h). 54: */ 55: #ifndef FD_SETSIZE 56: #define FD_SETSIZE 256 57: #endif 58: 59: typedef long fd_mask; 60: #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 61: #ifndef howmany 62: #define howmany(x, y) (((x)+((y)-1))/(y)) 63: #endif 64: 65: typedef struct fd_set { 66: fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 67: } fd_set; 68: 69: #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 70: #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 71: #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 72: #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 73: 74: #endif