[BACK]Return to param.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/param.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: param.h,v 1.72 2007/07/25 20:07:28 deraadt Exp $      */
                      2: /*     $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $       */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1982, 1986, 1989, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  * (c) UNIX System Laboratories, Inc.
                      8:  * All or some portions of this file are derived from material licensed
                      9:  * to the University of California by American Telephone and Telegraph
                     10:  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
                     11:  * the permission of UNIX System Laboratories, Inc.
                     12:  *
                     13:  * Redistribution and use in source and binary forms, with or without
                     14:  * modification, are permitted provided that the following conditions
                     15:  * are met:
                     16:  * 1. Redistributions of source code must retain the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer.
                     18:  * 2. Redistributions in binary form must reproduce the above copyright
                     19:  *    notice, this list of conditions and the following disclaimer in the
                     20:  *    documentation and/or other materials provided with the distribution.
                     21:  * 3. Neither the name of the University nor the names of its contributors
                     22:  *    may be used to endorse or promote products derived from this software
                     23:  *    without specific prior written permission.
                     24:  *
                     25:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     26:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     27:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     28:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     29:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     30:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     31:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     32:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     33:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     34:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     35:  * SUCH DAMAGE.
                     36:  *
                     37:  *     @(#)param.h     8.2 (Berkeley) 1/21/94
                     38:  */
                     39:
                     40: #define        BSD     199306          /* System version (year & month). */
                     41: #define BSD4_3 1
                     42: #define BSD4_4 1
                     43:
                     44: #define OpenBSD        200711          /* OpenBSD version (year & month). */
                     45: #define OpenBSD4_2 1           /* OpenBSD 4.2 */
                     46:
                     47: #ifndef NULL
                     48: #ifdef         __GNUG__
                     49: #define        NULL    __null
                     50: #else
                     51: #define        NULL    0L
                     52: #endif
                     53: #endif
                     54:
                     55: #ifndef _LOCORE
                     56: #include <sys/types.h>
                     57: #include <sys/simplelock.h>
                     58: #endif
                     59:
                     60: /*
                     61:  * Machine-independent constants (some used in following include files).
                     62:  * Redefined constants are from POSIX 1003.1 limits file.
                     63:  *
                     64:  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
                     65:  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
                     66:  */
                     67: #include <sys/syslimits.h>
                     68:
                     69: #define        MAXCOMLEN       16              /* max command name remembered */
                     70: #define        MAXINTERP       64              /* max interpreter file name length */
                     71: #define        MAXLOGNAME      LOGIN_NAME_MAX  /* max login name length w/ NUL */
                     72: #define        MAXUPRC         CHILD_MAX       /* max simultaneous processes */
                     73: #define        NCARGS          ARG_MAX         /* max bytes for an exec function */
                     74: #define        NGROUPS         NGROUPS_MAX     /* max number groups */
                     75: #define        NOFILE          OPEN_MAX        /* max open files per process (soft) */
                     76: #define        NOFILE_MAX      1024            /* max open files per process (hard) */
                     77: #define        NOGROUP         65535           /* marker for empty group set member */
                     78: #define MAXHOSTNAMELEN 256             /* max hostname size */
                     79:
                     80: /* More types and definitions used throughout the kernel. */
                     81: #ifdef _KERNEL
                     82: #include <sys/cdefs.h>
                     83: #include <sys/errno.h>
                     84: #include <sys/time.h>
                     85: #include <sys/resource.h>
                     86: #include <sys/ucred.h>
                     87: #include <sys/uio.h>
                     88: #endif
                     89:
                     90: /* Signals. */
                     91: #include <sys/signal.h>
                     92:
                     93: /* Machine type dependent parameters. */
                     94: #include <sys/limits.h>
                     95: #include <machine/param.h>
                     96:
                     97: /*
                     98:  * Priorities.  Note that with 32 run queues, differences less than 4 are
                     99:  * insignificant.
                    100:  */
                    101: #define        PSWP    0
                    102: #define        PVM     4
                    103: #define        PINOD   8
                    104: #define        PRIBIO  16
                    105: #define        PVFS    20
                    106: #define        PZERO   22              /* No longer magic, shouldn't be here.  XXX */
                    107: #define        PSOCK   24
                    108: #define        PWAIT   32
                    109: #define        PLOCK   36
                    110: #define        PPAUSE  40
                    111: #define        PUSER   50
                    112: #define        MAXPRI  127             /* Priorities range from 0 through MAXPRI. */
                    113:
                    114: #define        PRIMASK         0x0ff
                    115: #define        PCATCH          0x100   /* OR'd with pri for tsleep to check signals */
                    116: #define PNORELOCK      0x200   /* OR'd with pri for ltsleep to not relock
                    117:                                   the interlock */
                    118:
                    119: #define        NBPW    sizeof(int)     /* number of bytes per word (integer) */
                    120:
                    121: #define        CMASK   022             /* default file mask: S_IWGRP|S_IWOTH */
                    122: #define        NODEV   (dev_t)(-1)     /* non-existent device */
                    123: #define NETDEV (dev_t)(-2)     /* network device (for nfs swap) */
                    124:
                    125: #define        CBLOCK  64              /* Clist block size, must be a power of 2. */
                    126: #define CBQSIZE        (CBLOCK/NBBY)   /* Quote bytes/cblock - can do better. */
                    127:                                /* Data chars/clist. */
                    128: #define        CBSIZE  (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
                    129: #define        CROUND  (CBLOCK - 1)    /* Clist rounding. */
                    130:
                    131: /*
                    132:  * Constants related to network buffer management.
                    133:  * MCLBYTES must be no larger than NBPG (the software page size), and,
                    134:  * on machines that exchange pages of input or output buffers with mbuf
                    135:  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
                    136:  * of the hardware page size.
                    137:  */
                    138: #define        MSIZE           256             /* size of an mbuf */
                    139: #define        MCLSHIFT        11              /* convert bytes to m_buf clusters */
                    140:                                        /* 2K cluster can hold Ether frame */
                    141: #define        MCLBYTES        (1 << MCLSHIFT) /* size of a m_buf cluster */
                    142: #define        MCLOFSET        (MCLBYTES - 1)
                    143:
                    144:
                    145: /*
                    146:  * File system parameters and macros.
                    147:  *
                    148:  * The file system is made out of blocks of at most MAXBSIZE units, with
                    149:  * smaller units (fragments) only in the last direct block.  MAXBSIZE
                    150:  * primarily determines the size of buffers in the buffer pool.  It may be
                    151:  * made larger without any effect on existing file systems; however making
                    152:  * it smaller makes some file systems unmountable.
                    153:  */
                    154: #ifndef MAXBSIZE       /* XXX temp until sun3 DMA chaining */
                    155: #define        MAXBSIZE        MAXPHYS
                    156: #endif
                    157: #define MAXFRAG        8
                    158:
                    159: /*
                    160:  * MAXPATHLEN defines the longest permissible path length after expanding
                    161:  * symbolic links. It is used to allocate a temporary buffer from the buffer
                    162:  * pool in which to do the name expansion, hence should be a power of two,
                    163:  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
                    164:  * maximum number of symbolic links that may be expanded in a path name.
                    165:  * It should be set high enough to allow all legitimate uses, but halt
                    166:  * infinite loops reasonably quickly.
                    167:  */
                    168: #define        MAXPATHLEN      PATH_MAX
                    169: #define MAXSYMLINKS    SYMLOOP_MAX
                    170:
                    171: /* Macros to set/clear/test flags. */
                    172: #ifdef _KERNEL
                    173: #define SET(t, f)      ((t) |= (f))
                    174: #define CLR(t, f)      ((t) &= ~(f))
                    175: #define ISSET(t, f)    ((t) & (f))
                    176: #endif
                    177:
                    178: /* Bit map related macros. */
                    179: #define        setbit(a,i)     ((a)[(i)>>3] |= 1<<((i)&(NBBY-1)))
                    180: #define        clrbit(a,i)     ((a)[(i)>>3] &= ~(1<<((i)&(NBBY-1))))
                    181: #define        isset(a,i)      ((a)[(i)>>3] & (1<<((i)&(NBBY-1))))
                    182: #define        isclr(a,i)      (((a)[(i)>>3] & (1<<((i)&(NBBY-1)))) == 0)
                    183:
                    184: /* Macros for counting and rounding. */
                    185: #ifndef howmany
                    186: #define        howmany(x, y)   (((x)+((y)-1))/(y))
                    187: #endif
                    188: #define        roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
                    189: #define powerof2(x)    ((((x)-1)&(x))==0)
                    190:
                    191: /* Macros for min/max. */
                    192: #define        MIN(a,b) (((a)<(b))?(a):(b))
                    193: #define        MAX(a,b) (((a)>(b))?(a):(b))
                    194:
                    195: /* Macros for calculating the offset of a field */
                    196: #if !defined(offsetof) && defined(_KERNEL)
                    197: #define offsetof(s, e) ((size_t)&((s *)0)->e)
                    198: #endif
                    199:
                    200: /*
                    201:  * Constants for setting the parameters of the kernel memory allocator.
                    202:  *
                    203:  * 2 ** MINBUCKET is the smallest unit of memory that will be
                    204:  * allocated. It must be at least large enough to hold a pointer.
                    205:  *
                    206:  * Units of memory less or equal to MAXALLOCSAVE will permanently
                    207:  * allocate physical memory; requests for these size pieces of
                    208:  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
                    209:  * always allocate and free physical memory; requests for these
                    210:  * size allocations should be done infrequently as they will be slow.
                    211:  *
                    212:  * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
                    213:  * MAXALLOCSIZE must be a power of two.
                    214:  */
                    215: #define MINBUCKET      4               /* 4 => min allocation of 16 bytes */
                    216: #define MAXALLOCSAVE   (2 * PAGE_SIZE)
                    217:
                    218: /*
                    219:  * Scale factor for scaled integers used to count %cpu time and load avgs.
                    220:  *
                    221:  * The number of CPU `tick's that map to a unique `%age' can be expressed
                    222:  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
                    223:  * can be calculated (assuming 32 bits) can be closely approximated using
                    224:  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
                    225:  *
                    226:  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
                    227:  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
                    228:  */
                    229: #define        FSHIFT  11              /* bits to right of fixed binary point */
                    230: #define FSCALE (1<<FSHIFT)
                    231:
                    232: /*
                    233:  * The time for a process to be blocked before being very swappable.
                    234:  * This is a number of seconds which the system takes as being a non-trivial
                    235:  * amount of real time.  You probably shouldn't change this;
                    236:  * it is used in subtle ways (fractions and multiples of it are, that is, like
                    237:  * half of a ``long time'', almost a long time, etc.)
                    238:  * It is related to human patience and other factors which don't really
                    239:  * change over time.
                    240:  */
                    241: #define        MAXSLP  20
                    242:
                    243: /*
                    244:  * rfork() options.
                    245:  *
                    246:  * XXX currently, operations without RFPROC set are not supported.
                    247:  */
                    248: #define RFNAMEG                (1<<0)  /* UNIMPL new plan9 `name space' */
                    249: #define RFENVG         (1<<1)  /* UNIMPL copy plan9 `env space' */
                    250: #define RFFDG          (1<<2)  /* copy fd table */
                    251: #define RFNOTEG                (1<<3)  /* UNIMPL create new plan9 `note group' */
                    252: #define RFPROC         (1<<4)  /* change child (else changes curproc) */
                    253: #define RFMEM          (1<<5)  /* share `address space' */
                    254: #define RFNOWAIT       (1<<6)  /* parent need not wait() on child */
                    255: #define RFCNAMEG       (1<<10) /* UNIMPL zero plan9 `name space' */
                    256: #define RFCENVG                (1<<11) /* UNIMPL zero plan9 `env space' */
                    257: #define RFCFDG         (1<<12) /* zero fd table */
                    258: #define RFTHREAD       (1<<13) /* create a thread, not a process */

CVSweb