1 /*- 2 * Copyright (c) 1982, 1986, 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)types.h 7.23 (Berkeley) 06/23/92 8 */ 9 10 #ifndef _TYPES_H_ 11 #define _TYPES_H_ 12 13 /* Machine type dependent parameters. */ 14 #include <machine/endian.h> 15 16 typedef unsigned char u_char; 17 typedef unsigned short u_short; 18 typedef unsigned int u_int; 19 typedef unsigned long u_long; 20 typedef unsigned short ushort; /* Sys V compatibility */ 21 22 typedef unsigned long long u_quad_t; 23 typedef long long quad_t; 24 typedef quad_t * qaddr_t; 25 typedef char * caddr_t; /* core address */ 26 typedef long daddr_t; /* disk address */ 27 typedef u_long dev_t; /* device number */ 28 typedef u_long ino_t; /* inode number */ 29 typedef quad_t off_t; /* file offset */ 30 typedef u_short nlink_t; /* link count */ 31 typedef long swblk_t; /* swap offset */ 32 typedef long segsz_t; /* segment size */ 33 typedef u_long uid_t; /* user id */ 34 typedef u_long gid_t; /* group id */ 35 typedef short pid_t; /* process id */ 36 typedef u_short mode_t; /* permissions */ 37 typedef u_long fixpt_t; /* fixed point number */ 38 39 #ifndef _POSIX_SOURCE 40 #define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ 41 #define minor(x) ((int)((x)&0xff)) /* minor number */ 42 #define makedev(x,y) ((dev_t)(((x)<<8) | (y))) /* create dev_t */ 43 #endif 44 45 #include <machine/ansi.h> 46 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 47 #include <machine/types.h> 48 #endif 49 50 #ifdef _BSD_CLOCK_T_ 51 typedef _BSD_CLOCK_T_ clock_t; 52 #undef _BSD_CLOCK_T_ 53 #endif 54 55 #ifdef _BSD_SIZE_T_ 56 typedef _BSD_SIZE_T_ size_t; 57 #undef _BSD_SIZE_T_ 58 #endif 59 60 #ifdef _BSD_SSIZE_T_ 61 typedef _BSD_SSIZE_T_ ssize_t; 62 #undef _BSD_SSIZE_T_ 63 #endif 64 65 #ifdef _BSD_TIME_T_ 66 typedef _BSD_TIME_T_ time_t; 67 #undef _BSD_TIME_T_ 68 #endif 69 70 #ifndef _POSIX_SOURCE 71 #define NBBY 8 /* number of bits in a byte */ 72 73 /* 74 * Select uses bit masks of file descriptors in longs. These macros 75 * manipulate such bit fields (the filesystem macros use chars). 76 * FD_SETSIZE may be defined by the user, but the default here should 77 * be enough for most uses. 78 */ 79 #ifndef FD_SETSIZE 80 #define FD_SETSIZE 256 81 #endif 82 83 typedef long fd_mask; 84 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 85 86 #ifndef howmany 87 #define howmany(x, y) (((x)+((y)-1))/(y)) 88 #endif 89 90 typedef struct fd_set { 91 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 92 } fd_set; 93 94 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 95 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 96 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 97 #define FD_ZERO(p) bzero(p, sizeof(*(p))) 98 99 #if defined(__STDC__) && defined(KERNEL) 100 /* 101 * Forward structure declarations for function prototypes. 102 * We include the common structures that cross subsystem boundaries here; 103 * others are mostly used in the same place that the structure is defined. 104 */ 105 struct proc; 106 struct pgrp; 107 struct ucred; 108 struct rusage; 109 struct file; 110 struct buf; 111 struct tty; 112 struct uio; 113 #endif 114 115 #endif /* !_POSIX_SOURCE */ 116 #endif /* !_TYPES_H_ */ 117