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 * @(#)param.h 7.9 (Berkeley) 05/09/89 7 */ 8 9 #define BSD 198810 /* system version (year & month) */ 10 #define BSD4_3 1 11 12 #include <sys/syslimits.h> 13 14 /* 15 * Machine-independent constants 16 */ 17 #define NMOUNT 20 /* number of mountable file systems */ 18 /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */ 19 #define MSWAPX NMOUNT /* pseudo mount table index for swapdev */ 20 #define MAXUPRC CHILD_MAX /* max processes per user */ 21 #define NOFILE OPEN_MAX /* max open files per process */ 22 #define CANBSIZ 256 /* max size of typewriter line */ 23 #define NCARGS ARG_MAX /* # characters in exec arglist */ 24 #define MAXINTERP 32 /* maximum interpreter file name length */ 25 #define NGROUPS NGROUPS_MAX /* max number groups */ 26 #define MAXHOSTNAMELEN 64 /* maximum hostname size */ 27 28 #define NOGROUP 65535 /* marker for empty group set member */ 29 30 /* 31 * Priorities 32 */ 33 #define PSWP 0 34 #define PINOD 10 35 #define PRIBIO 20 36 #define PVFS 22 37 #define PRIUBA 24 38 #define PZERO 25 39 #define PPIPE 26 40 #define PWAIT 30 41 #define PLOCK 35 42 #define PSLEP 40 43 #define PUSER 50 44 45 #define NZERO 0 46 47 #ifndef KERNEL 48 #include <sys/types.h> 49 #else 50 #ifndef LOCORE 51 #include "types.h" 52 #endif 53 #endif 54 55 /* 56 * Signals 57 */ 58 #ifdef KERNEL 59 #include "signal.h" 60 #else 61 #include <signal.h> 62 #endif 63 64 #define ISSIG(p) \ 65 ((p)->p_sig && ((p)->p_flag&STRC || \ 66 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig()) 67 68 /* 69 * Machine type dependent parameters. 70 */ 71 #ifdef KERNEL 72 #include "machine/machparam.h" 73 #else 74 #include <machine/machparam.h> 75 #endif 76 77 #define NBPW sizeof(int) /* number of bytes in an integer */ 78 79 #define NULL 0 80 #define CMASK 022 /* default mask for file creation */ 81 #define NODEV (dev_t)(-1) 82 83 /* 84 * Clustering of hardware pages on machines with ridiculously small 85 * page sizes is done here. The paging subsystem deals with units of 86 * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each. 87 * 88 * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE 89 */ 90 #define CLBYTES (CLSIZE*NBPG) 91 #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ 92 #define claligned(x) ((((int)(x))&CLOFSET)==0) 93 #define CLOFF CLOFSET 94 #define CLSHIFT (PGSHIFT+CLSIZELOG2) 95 96 #if CLSIZE==1 97 #define clbase(i) (i) 98 #define clrnd(i) (i) 99 #else 100 /* give the base virtual address (first of CLSIZE) */ 101 #define clbase(i) ((i) &~ (CLSIZE-1)) 102 /* round a number of clicks up to a whole cluster */ 103 #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) 104 #endif 105 106 /* CBLOCK is the size of a clist block, must be power of 2 */ 107 #define CBLOCK 64 108 #define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */ 109 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */ 110 #define CROUND (CBLOCK - 1) /* clist rounding */ 111 112 /* 113 * File system parameters and macros. 114 * 115 * The file system is made out of blocks of at most MAXBSIZE units, 116 * with smaller units (fragments) only in the last direct block. 117 * MAXBSIZE primarily determines the size of buffers in the buffer 118 * pool. It may be made larger without any effect on existing 119 * file systems; however making it smaller make make some file 120 * systems unmountable. 121 * 122 * Note that the blocked devices are assumed to have DEV_BSIZE 123 * "sectors" and that fragments must be some multiple of this size. 124 * Block devices are read in BLKDEV_IOSIZE units. This number must 125 * be a power of two and in the range of 126 * DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE 127 * This size has no effect upon the file system, but is usually set 128 * to the block size of the root file system, so as to maximize the 129 * speed of ``fsck''. 130 */ 131 #define MAXBSIZE 8192 132 #define MAXFRAG 8 133 134 /* 135 * MAXPATHLEN defines the longest permissable path length 136 * after expanding symbolic links. It is used to allocate 137 * a temporary buffer from the buffer pool in which to do the 138 * name expansion, hence should be a power of two, and must 139 * be less than or equal to MAXBSIZE. 140 * MAXSYMLINKS defines the maximum number of symbolic links 141 * that may be expanded in a path name. It should be set high 142 * enough to allow all legitimate uses, but halt infinite loops 143 * reasonably quickly. 144 */ 145 #define MAXPATHLEN PATH_MAX 146 #define MAXSYMLINKS 8 147 148 /* 149 * Constants for setting the parameters of the kernel memory allocator. 150 * 151 * 2 ** MINBUCKET is the smallest unit of memory that will be 152 * allocated. It must be at least large enough to hold a pointer. 153 * 154 * Units of memory less or equal to MAXALLOCSAVE will permanently 155 * allocate physical memory; requests for these size pieces of 156 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 157 * always allocate and free physical memory; requests for these 158 * size allocations should be done infrequently as they will be slow. 159 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14) 160 * and MAXALLOCSIZE must be a power of two. 161 */ 162 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 163 #define MAXALLOCSAVE (2 * CLBYTES) 164 165 /* 166 * bit map related macros 167 */ 168 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 169 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 170 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 171 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 172 173 /* 174 * Macros for fast min/max. 175 */ 176 #define MIN(a,b) (((a)<(b))?(a):(b)) 177 #define MAX(a,b) (((a)>(b))?(a):(b)) 178 179 /* 180 * Macros for counting and rounding. 181 */ 182 #ifndef howmany 183 #define howmany(x, y) (((x)+((y)-1))/(y)) 184 #endif 185 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 186 #define powerof2(x) ((((x)-1)&(x))==0) 187