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