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