home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Headers / bsd / sys / param.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-27  |  8.5 KB  |  304 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7.  /*
  8.  * HISTORY
  9.  * $Log:    param.h,v $
  10.  * 07-Jan-93  Mac Gillon (mgillon) at NeXT
  11.  *    Integrated POSIX support
  12.  *
  13.  * 02-Apr-90  Avadis Tevanian, Jr. (avie) at NeXT
  14.  *    Increased MAXUPRC to 100 for NeXT.
  15.  *
  16.  * 28-Feb-90  Gregg kellogg (gk) at NeXT
  17.  *    Fixed CHECK_SIGNALS macro to take 3 arguments instead of 2.
  18.  *
  19.  * Revision 2.12  89/10/11  14:53:22  dlb
  20.  *     Minor macro changes to pass thread to thread_should_halt.
  21.  *     [88/10/18            dlb]
  22.  * 
  23.  */
  24. /*
  25.  * Copyright (c) 1982, 1986 Regents of the University of California.
  26.  * All rights reserved.  The Berkeley software License Agreement
  27.  * specifies the terms and conditions for redistribution.
  28.  *
  29.  *    @(#)param.h    7.1 (Berkeley) 6/4/86
  30.  */
  31.  
  32. /* SUN_VFS */
  33. /*    @(#)param.h    2.2 88/06/09 4.0NFSSRC SMI;    */
  34. /* SUN_VFS */
  35.  
  36. #ifndef    _SYS_PARAM_H_
  37. #define _SYS_PARAM_H_
  38.  
  39. #ifndef BSD
  40. #define    BSD    43        /* 4.3 * 10, as cpp doesn't do floats */
  41. #endif
  42.  
  43. #define BSD4_3    1
  44.  
  45. /*
  46.  * Machine type dependent parameters.
  47.  */
  48. #include <machine/machparam.h>
  49.  
  50. #define    NPTEPG        (NBPG/(sizeof (struct pte)))
  51.  
  52. /*
  53.  * Machine-independent constants
  54.  */
  55. #define    NMOUNT    40        /* est. of # mountable fs for quota calc */
  56. /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
  57. #define    MSWAPX    15        /* pseudo mount table index for swapdev */
  58. #if    NeXT
  59. #define    MAXUPRC    100
  60. #define    NOFILE    256        /* max open files per process */
  61. #else    NeXT
  62. #if    defined(multimax) || defined(balance)
  63. #define    MAXUPRC 100        /* max processes per user */
  64. #else    defined(multimax) || defined(balance)
  65. #define    MAXUPRC    40        /* max processes per user */
  66. #endif    defined(multimax) || defined(balance)
  67. #define    NOFILE    64        /* max open files per process */
  68. #endif    NeXT
  69. /* SUN_VFS */
  70. #define MAXLINK 32767        /* max links */
  71. /* SUN_VFS */
  72. #define    CANBSIZ    256        /* max size of typewriter line */
  73. #if    NeXT
  74. #define NCARGS    40960        /* # characters in exec arglist */
  75. #else    NeXT
  76. #define    NCARGS    20480        /* # characters in exec arglist */
  77. #endif    NeXT
  78. #define    NGROUPS    16        /* max number groups */
  79.  
  80. #define    NOGROUP    (gid_t)65535    /* marker for empty group set member */
  81.  
  82. /*
  83.  * Priorities
  84.  */
  85. #define    PSWP    0
  86. #define    PINOD    10
  87. #define    PRIBIO    20
  88. #define    PRIUBA    24
  89. #define    PZERO    25
  90. #define    PPIPE    26
  91. /* SUN_VFS */
  92. #define    PVFS    27
  93. /* SUN_VFS */
  94. #define    PWAIT    30
  95. #define    PLOCK    35
  96. #define    PSLEP    40
  97. #define    PUSER    50
  98. #define PMASK    0177
  99. #define PCATCH    0400    /* return if sleep interrupted, don't longjmp */
  100.  
  101. #define    NZERO    0
  102.  
  103. /*
  104.  * Signals
  105.  */
  106. #import <sys/signal.h> 
  107.  
  108. /*
  109.  * Return values from tsleep().
  110.  */
  111. #define    TS_OK    0    /* normal wakeup */
  112. #define    TS_TIME    1    /* timed-out wakeup */
  113. #define    TS_SIG    2    /* asynchronous signal wakeup */
  114.  
  115. /*
  116.  *    Check for per-process and per thread signals.
  117.  */
  118. #define SHOULDissig(p,uthreadp) \
  119.     (((p)->p_sig | (uthreadp)->uu_sig) && ((p)->p_flag&STRC || \
  120.      (((p)->p_sig | (uthreadp)->uu_sig) &~ \
  121.        ((p)->p_sigignore | (p)->p_sigmask))))
  122.  
  123. /*
  124.  *    Check for signals, handling possible stop signals.
  125.  *    Ignores signals already 'taken' and per-thread signals.
  126.  *    Use before and after thread_block() in sleep().
  127.  *    (p) is always current process.
  128.  */
  129. #if NeXT
  130. #define    ISSIG(p) (thread_should_halt(current_thread()) || \
  131.      (SHOULDissig(p,current_thread()->_uthread) && issig(0)))
  132.  
  133. #define    ISSIG_CATCH(p) (thread_should_halt(current_thread()) || \
  134.      (SHOULDissig(p,current_thread()->_uthread) && issig(1)))
  135. #else
  136. #define    ISSIG(p) (thread_should_halt(current_thread()) || \
  137.      (SHOULDissig(p,current_thread()->_uthread) && issig()))
  138. #endif
  139.  
  140. /*
  141.  *    Check for signals, including signals already taken and
  142.  *    per-thread signals.  Use in trap() and syscall() before
  143.  *    exiting kernel.
  144.  */
  145. #define    CHECK_SIGNALS(p, thread, uthreadp)    \
  146.     (!thread_should_halt(thread)    \
  147.      && ((p)->p_cursig        \
  148.          || SHOULDissig(p,uthreadp)))
  149.  
  150. #define    NBPW    sizeof(int)    /* number of bytes in an integer */
  151.  
  152. #ifndef NULL
  153. #if    defined(__STRICT_BSD__) || defined(KERNEL)
  154. #define    NULL    0
  155. #else /* __STRICT_BSD__  || KERNEL */
  156. #import <stddef.h>
  157. #endif /* __STRICT_BSD__ || KERNEL */
  158. #endif /* NULL */
  159. #define    CMASK    022        /* default mask for file creation */
  160. #define    NODEV    (dev_t)(-1)
  161.  
  162. /*
  163.  * Clustering of hardware pages on machines with ridiculously small
  164.  * page sizes is done here.  The paging subsystem deals with units of
  165.  * CLSIZE pte's describing NBPG (from vm.h) pages each.
  166.  *
  167.  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
  168.  */
  169. #define    CLBYTES        (CLSIZE*NBPG)
  170. #define    CLOFSET        (CLSIZE*NBPG-1)    /* for clusters, like PGOFSET */
  171. #define    claligned(x)    ((((int)(x))&CLOFSET)==0)
  172. #define    CLOFF        CLOFSET
  173. #define    CLSHIFT        (PGSHIFT+CLSIZELOG2)
  174.  
  175. #if CLSIZE==1
  176. #define    clbase(i)    (i)
  177. #define    clrnd(i)    (i)
  178. #else
  179. /* give the base virtual address (first of CLSIZE) */
  180. #define    clbase(i)    ((i) &~ (CLSIZE-1))
  181. /* round a number of clicks up to a whole cluster */
  182. #define    clrnd(i)    (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
  183. #endif
  184.  
  185. /* CBLOCK is the size of a clist block, must be power of 2 */
  186. #define    CBLOCK    64
  187. #define CBQSIZE    (CBLOCK/NBBY)    /* Quote bytes/cblock - can do better. */
  188.                 /* Data chars/clist. */
  189. #define    CBSIZE    (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
  190. #define    CROUND    (CBLOCK - 1)                /* clist rounding */
  191.  
  192. #ifndef __ASSEMBLER__
  193. #import <sys/types.h>
  194. #endif
  195.  
  196. /*
  197.  * File system parameters and macros.
  198.  *
  199.  * The file system is made out of blocks of at most MAXBSIZE units,
  200.  * with smaller units (fragments) only in the last direct block.
  201.  * MAXBSIZE primarily determines the size of buffers in the buffer
  202.  * pool. It may be made larger without any effect on existing
  203.  * file systems; however making it smaller make make some file
  204.  * systems unmountable.
  205.  *
  206.  * Note that the blocked devices are assumed to have DEV_BSIZE
  207.  * "sectors" and that fragments must be some multiple of this size.
  208.  * Block devices are read in BLKDEV_IOSIZE units. This number must
  209.  * be a power of two and in the range of
  210.  *    DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
  211.  * This size has no effect upon the file system, but is usually set
  212.  * to the block size of the root file system, so as to maximize the
  213.  * speed of ``fsck''.
  214.  */
  215. #define    MAXBSIZE    8192
  216. #define BLKDEV_IOSIZE    2048
  217. #define MAXFRAG     8
  218.  
  219. #if    NeXT
  220. #define    btodb(bytes, blocksize)    ((unsigned int) ((bytes) / (blocksize)))
  221. #define    dbtob(block, blocksize)    ((unsigned int) ((block) * (blocksize)))
  222. #else    NeXT
  223. #define    DEV_BSIZE    512
  224. #define    DEV_BSHIFT    9        /* log2(DEV_BSIZE) */
  225.  
  226. #define    btodb(bytes)             /* calculates (bytes / DEV_BSIZE) */ \
  227.     ((unsigned)(bytes) >> DEV_BSHIFT)
  228. #define    dbtob(db)            /* calculates (db * DEV_BSIZE) */ \
  229.     ((unsigned)(db) << DEV_BSHIFT)
  230.  
  231. /*
  232.  * Map a ``block device block'' to a file system block.
  233.  * This should be device dependent, and will be after we
  234.  * add an entry to cdevsw for that purpose.  For now though
  235.  * just use DEV_BSIZE.
  236.  */
  237. #define    bdbtofsb(bn)    ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
  238. #endif    !NeXT
  239.  
  240. /*
  241.  * MAXPATHLEN defines the longest permissable path length
  242.  * after expanding symbolic links. It is used to allocate
  243.  * a temporary buffer from the buffer pool in which to do the
  244.  * name expansion, hence should be a power of two, and must
  245.  * be less than or equal to MAXBSIZE.
  246.  * MAXSYMLINKS defines the maximum number of symbolic links
  247.  * that may be expanded in a path name. It should be set high
  248.  * enough to allow all legitimate uses, but halt infinite loops
  249.  * reasonably quickly.
  250.  */
  251. #define MAXPATHLEN    1024
  252. #define MAXSYMLINKS    20
  253.  
  254. /*
  255.  * bit map related macros
  256.  */
  257. #define    setbit(a,i)    (*(((char *)(a)) + ((i)/NBBY)) |= 1<<((i)%NBBY))
  258. #define    clrbit(a,i)    (*(((char *)(a)) + ((i)/NBBY)) &= ~(1<<((i)%NBBY)))
  259. #define    isset(a,i)    (*(((char *)(a)) + ((i)/NBBY)) & (1<<((i)%NBBY)))
  260. #define    isclr(a,i)      ((*(((char *)(a)) + ((i)/NBBY)) & (1<<((i)%NBBY))) == 0)
  261.  
  262. #if    !defined(vax) && !defined(i386)
  263. #define _bit_set(i,a)   setbit(a,i)
  264. #define _bit_clear(i,a)    clrbit(a,i)
  265. #define _bit_tst(i,a)    isset(a,i)
  266. #endif    !defined(vax) && !defined(i386)
  267.  
  268. /*
  269.  * Macros for fast min/max.
  270.  */
  271. #ifndef    MIN
  272. #define    MIN(a,b) (((a)<(b))?(a):(b))
  273. #endif    MIN
  274. #ifndef    MAX
  275. #define    MAX(a,b) (((a)>(b))?(a):(b))
  276. #endif    MAX
  277.  
  278. /*
  279.  * Macros for counting and rounding.
  280.  */
  281. #ifndef howmany
  282. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  283. #endif
  284. #define    roundup(x, y)    ((((x)+((y)-1))/(y))*(y))
  285.  
  286. /* SUN_VFS */
  287. /*
  288.  * Scale factor for scaled integers used to count
  289.  * %cpu time and load averages.
  290.  */
  291. #define FSHIFT    8    /* bits to right of fixed binary point */
  292. #define FSCALE    (1<<FSHIFT)
  293. /* SUN_VFS */
  294.  
  295. /*
  296.  * Maximum size of hostname recognized and stored in the kernel.
  297.  */
  298. #define MAXHOSTNAMELEN    256
  299. #define MAXDOMNAMELEN    256        /* maximum domain name length */
  300.  
  301. #define    DEFAULTHOSTNAME    "localhost"
  302.  
  303. #endif    _SYS_PARAM_H_
  304.