gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/include/sys/param.hbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*      $OpenBSD: param.h,v 1.94 2012/01/11 22:11:34 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 201205          /* OpenBSD version (year & month). */
   45: #define OpenBSD5_1 1            /* OpenBSD 5.1 */
   46: 
   47: #ifndef NULL
   48: #ifdef  __GNUG__
   49: #define NULL    __null
   50: #else
   51: #define NULL    ((void *)0)
   52: #endif
   53: #endif
   54: 
   55: #ifndef _LOCORE
   56: #include <sys/types.h>
   57: #endif
   58: 
   59: /*
   60:  * Machine-independent constants (some used in following include files).
   61:  * Redefined constants are from POSIX 1003.1 limits file.
   62:  *
   63:  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
   64:  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
   65:  */
   66: #include <sys/syslimits.h>
   67: 
   68: #define MAXCOMLEN       16            /* max command name remembered */
   69: #define MAXINTERP       128           /* max interpreter file name length */
   70: #define MAXLOGNAME      LOGIN_NAME_MAX       /* max login name length w/ NUL */
   71: #define MAXUPRC         CHILD_MAX      /* max simultaneous processes */
   72: #define NCARGS          ARG_MAX         /* max bytes for an exec function */
   73: #define NGROUPS         NGROUPS_MAX    /* max number groups */
   74: #define NOFILE          OPEN_MAX        /* max open files per process (soft) */
   75: #define NOFILE_MAX      1024         /* max open files per process (hard) */
   76: #define NOGROUP         65535          /* marker for empty group set member */
   77: #define MAXHOSTNAMELEN  256              /* max hostname size */
   78: 
   79: /* More types and definitions used throughout the kernel. */
   80: #ifdef _KERNEL
   81: #include <sys/cdefs.h>
   82: #include <sys/errno.h>
   83: #include <sys/time.h>
   84: #include <sys/resource.h>
   85: #include <sys/ucred.h>
   86: #include <sys/uio.h>
   87: #endif
   88: 
   89: /* Signals. */
   90: #include <sys/signal.h>
   91: 
   92: /* Machine type dependent parameters. */
   93: #include <sys/limits.h>
   94: #include <machine/param.h>
   95: 
   96: /*
   97:  * Priorities.  Note that with 32 run queues, differences less than 4 are
   98:  * insignificant.
   99:  */
  100: #define PSWP    0
  101: #define PVM     4
  102: #define PINOD   8
  103: #define PRIBIO  16
  104: #define PVFS    20
  105: #define PZERO   22                /* No longer magic, shouldn't be here.  XXX */
  106: #define PSOCK   24
  107: #define PWAIT   32
  108: #define PLOCK   36
  109: #define PPAUSE  40
  110: #define PUSER   50
  111: #define MAXPRI  127              /* Priorities range from 0 through MAXPRI. */
  112: 
  113: #define PRIMASK         0x0ff
  114: #define PCATCH          0x100   /* OR'd with pri for tsleep to check signals */
  115: #define PNORELOCK       0x200 /* OR'd with pri for msleep to not reaquire
  116:                                    the mutex */
  117: 
  118: #define CMASK   022               /* default file mask: S_IWGRP|S_IWOTH */
  119: #define NODEV   (dev_t)(-1)       /* non-existent device */
  120: #define NETDEV  (dev_t)(-2)      /* network device (for nfs swap) */
  121:         
  122: #define CBLOCK  64               /* Clist block size, must be a power of 2. */
  123: #define CBQSIZE (CBLOCK/NBBY)   /* Quote bytes/cblock - can do better. */
  124:                                 /* Data chars/clist. */
  125: #define CBSIZE  (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
  126: #define CROUND  (CBLOCK - 1)     /* Clist rounding. */
  127: 
  128: /*
  129:  * Constants related to network buffer management.
  130:  * MCLBYTES must be no larger than NBPG (the software page size), and,
  131:  * on machines that exchange pages of input or output buffers with mbuf
  132:  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
  133:  * of the hardware page size.
  134:  */
  135: #define MSIZE           256              /* size of an mbuf */
  136: #define MCLSHIFT        11             /* convert bytes to m_buf clusters */
  137:                                         /* 2K cluster can hold Ether frame */
  138: #define MCLBYTES        (1 << MCLSHIFT)        /* size of a m_buf cluster */
  139: #define MCLOFSET        (MCLBYTES - 1)
  140: 
  141: #define MAXMCLBYTES     (64 * 1024) /* largest cluster from the stack */
  142: 
  143: /*
  144:  * File system parameters and macros.
  145:  *
  146:  * The file system is made out of blocks of at most MAXBSIZE units, with
  147:  * smaller units (fragments) only in the last direct block.  MAXBSIZE
  148:  * primarily determines the size of buffers in the buffer pool.  It may be
  149:  * made larger without any effect on existing file systems; however making
  150:  * it smaller makes some file systems unmountable.
  151:  */
  152: #ifndef MAXBSIZE        /* XXX temp until sun3 DMA chaining */
  153: #define MAXBSIZE        MAXPHYS
  154: #endif
  155: #define MAXFRAG         8
  156: 
  157: /*
  158:  * MAXPATHLEN defines the longest permissible path length after expanding
  159:  * symbolic links. It is used to allocate a temporary buffer from the buffer
  160:  * pool in which to do the name expansion, hence should be a power of two,
  161:  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
  162:  * maximum number of symbolic links that may be expanded in a path name.
  163:  * It should be set high enough to allow all legitimate uses, but halt
  164:  * infinite loops reasonably quickly.
  165:  */
  166: #define MAXPATHLEN      PATH_MAX
  167: #define MAXSYMLINKS     SYMLOOP_MAX
  168: 
  169: /* Macros to set/clear/test flags. */
  170: #ifdef _KERNEL
  171: #define SET(t, f)       ((t) |= (f))
  172: #define CLR(t, f)       ((t) &= ~(f))
  173: #define ISSET(t, f)     ((t) & (f))
  174: #endif
  175: 
  176: /* Bit map related macros. */
  177: #define setbit(a,i)     ((a)[(i)>>3] |= 1<<((i)&(NBBY-1)))
  178: #define clrbit(a,i)     ((a)[(i)>>3] &= ~(1<<((i)&(NBBY-1))))
  179: #define isset(a,i)      ((a)[(i)>>3] & (1<<((i)&(NBBY-1))))
  180: #define isclr(a,i)      (((a)[(i)>>3] & (1<<((i)&(NBBY-1)))) == 0)
  181: 
  182: /* Macros for counting and rounding. */
  183: #ifndef howmany
  184: #define howmany(x, y)   (((x)+((y)-1))/(y))
  185: #endif
  186: #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
  187: #define powerof2(x)     ((((x)-1)&(x))==0)
  188: 
  189: /* Macros for min/max. */
  190: #define MIN(a,b) (((a)<(b))?(a):(b))
  191: #define MAX(a,b) (((a)>(b))?(a):(b))
  192: 
  193: /* Macros for calculating the offset of a field */
  194: #if !defined(offsetof) && defined(_KERNEL)
  195: #define offsetof(s, e) ((size_t)&((s *)0)->e)
  196: #endif
  197: 
  198: #define nitems(_a)      (sizeof((_a)) / sizeof((_a)[0]))
  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 */