The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/param.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: param.h,v 1.211.2.16 2007/06/28 11:43:13 ghen Exp $    */
    2 
    3 /*-
    4  * Copyright (c) 1982, 1986, 1989, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  * (c) UNIX System Laboratories, Inc.
    7  * All or some portions of this file are derived from material licensed
    8  * to the University of California by American Telephone and Telegraph
    9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   10  * the permission of UNIX System Laboratories, Inc.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)param.h     8.3 (Berkeley) 4/4/95
   37  */
   38 
   39 #ifndef _SYS_PARAM_H_
   40 #define _SYS_PARAM_H_
   41 
   42 /*
   43  * Historic BSD #defines -- probably will remain untouched for all time.
   44  */
   45 #define BSD     199506          /* System version (year & month). */
   46 #define BSD4_3  1
   47 #define BSD4_4  1
   48 
   49 /*
   50  *      #define __NetBSD_Version__ MMmmrrpp00
   51  *
   52  *      M = major version
   53  *      m = minor version; a minor number of 99 indicates current.
   54  *      r = 0 (*)
   55  *      p = patchlevel
   56  *
   57  * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local
   58  * needs to be updated and the changes sent back to the groff maintainers.
   59  *
   60  * (*)  Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric
   61  *              e.g. NetBSD-1.2D  = 102040000 ('D' == 4)
   62  *      NetBSD-2.0H     (200080000) was changed on 20041001 to:
   63  *      2.99.9          (299000900)
   64  */
   65 
   66 #define __NetBSD_Version__      301000001       /* NetBSD 3.1_STABLE */
   67 
   68 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
   69     (m) * 1000000) + (p) * 100) >= __NetBSD_Version__)
   70 
   71 /*
   72  * Historical NetBSD #define
   73  *
   74  * NetBSD 1.4 was the last release for which this value was incremented.
   75  * The value is now permanently fixed at 199905. It will never be
   76  * changed again.
   77  *
   78  * New code must use __NetBSD_Version__ instead, and should not even
   79  * count on NetBSD being defined.
   80  *
   81  */
   82 
   83 #define NetBSD  199905          /* NetBSD version (year & month). */
   84 
   85 #include <sys/null.h>
   86 
   87 #ifndef _LOCORE
   88 #include <sys/inttypes.h>
   89 #include <sys/types.h>
   90 #endif
   91 
   92 /*
   93  * Machine-independent constants (some used in following include files).
   94  * Redefined constants are from POSIX 1003.1 limits file.
   95  *
   96  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
   97  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
   98  */
   99 #include <sys/syslimits.h>
  100 
  101 #define MAXCOMLEN       16              /* max command name remembered */
  102 #define MAXINTERP       PATH_MAX        /* max interpreter file name length */
  103 /* DEPRECATED: use LOGIN_NAME_MAX instead. */
  104 #define MAXLOGNAME      (LOGIN_NAME_MAX - 1) /* max login name length */
  105 #define NCARGS          ARG_MAX         /* max bytes for an exec function */
  106 #define NGROUPS         NGROUPS_MAX     /* max number groups */
  107 #define NOGROUP         65535           /* marker for empty group set member */
  108 #define MAXHOSTNAMELEN  256             /* max hostname size */
  109 
  110 #ifndef NOFILE
  111 #define NOFILE          OPEN_MAX        /* max open files per process */
  112 #endif
  113 #ifndef MAXUPRC                         /* max simultaneous processes */
  114 #define MAXUPRC         CHILD_MAX       /* POSIX 1003.1-compliant default */
  115 #else
  116 #if (MAXUPRC - 0) < CHILD_MAX
  117 #error MAXUPRC less than CHILD_MAX.  See options(4) for details.
  118 #endif /* (MAXUPRC - 0) < CHILD_MAX */
  119 #endif /* !defined(MAXUPRC) */
  120 
  121 /* More types and definitions used throughout the kernel. */
  122 #ifdef _KERNEL
  123 #include <sys/cdefs.h>
  124 #include <sys/errno.h>
  125 #include <sys/time.h>
  126 #include <sys/resource.h>
  127 #include <sys/ucred.h>
  128 #include <sys/uio.h>
  129 #ifndef NPROC
  130 #define NPROC   (20 + 16 * MAXUSERS)
  131 #endif
  132 #ifndef NTEXT
  133 #define NTEXT   (80 + NPROC / 8)                /* actually the object cache */
  134 #endif
  135 #ifndef NVNODE
  136 #define NVNODE  (NPROC + NTEXT + 100)
  137 #define NVNODE_IMPLICIT
  138 #endif
  139 #endif /* _KERNEL */
  140 
  141 /* Signals. */
  142 #include <sys/signal.h>
  143 
  144 /* Machine type dependent parameters. */
  145 #include <machine/param.h>
  146 #include <machine/limits.h>
  147 
  148 /*
  149  * Stack macros.  On most architectures, the stack grows down,
  150  * towards lower addresses; it is the rare architecture where
  151  * it grows up, towards higher addresses.
  152  *
  153  * STACK_GROW and STACK_SHRINK adjust a stack pointer by some
  154  * size, no questions asked.  STACK_ALIGN aligns a stack pointer.
  155  *
  156  * STACK_ALLOC returns a pointer to allocated stack space of
  157  * some size; given such a pointer and a size, STACK_MAX gives
  158  * the maximum (in the "maxsaddr" sense) stack address of the
  159  * allocated memory.
  160  */
  161 #if defined(_KERNEL) || defined(__EXPOSE_STACK)
  162 #ifdef __MACHINE_STACK_GROWS_UP
  163 #define STACK_GROW(sp, _size)           (((caddr_t)(sp)) + (_size))
  164 #define STACK_SHRINK(sp, _size)         (((caddr_t)(sp)) - (_size))
  165 #define STACK_ALIGN(sp, bytes)  \
  166         ((caddr_t)((((unsigned long)(sp)) + (bytes)) & ~(bytes)))
  167 #define STACK_ALLOC(sp, _size)          ((caddr_t)(sp))
  168 #define STACK_MAX(p, _size)             (((caddr_t)(p)) + (_size))
  169 #else
  170 #define STACK_GROW(sp, _size)           (((caddr_t)(sp)) - (_size))
  171 #define STACK_SHRINK(sp, _size)         (((caddr_t)(sp)) + (_size))
  172 #define STACK_ALIGN(sp, bytes)  \
  173         ((caddr_t)(((unsigned long)(sp)) & ~(bytes)))
  174 #define STACK_ALLOC(sp, _size)          (((caddr_t)(sp)) - (_size))
  175 #define STACK_MAX(p, _size)             ((caddr_t)(p))
  176 #endif
  177 #endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */
  178 
  179 /*
  180  * Priorities.  Note that with 32 run queues, differences less than 4 are
  181  * insignificant.
  182  */
  183 #define PSWP    0
  184 #define PVM     4
  185 #define PINOD   8
  186 #define PRIBIO  16
  187 #define PVFS    20
  188 #define PZERO   22              /* No longer magic, shouldn't be here.  XXX */
  189 #define PSOCK   24
  190 #define PWAIT   32
  191 #define PLOCK   36
  192 #define PPAUSE  40
  193 #define PUSER   50
  194 #define MAXPRI  127             /* Priorities range from 0 through MAXPRI. */
  195 
  196 #define PRIMASK         0x0ff
  197 #define PCATCH          0x100   /* OR'd with pri for tsleep to check signals */
  198 #define PNORELOCK       0x200   /* OR'd with pri for cond_wait() to not relock
  199                                    the interlock */
  200 #define PNOEXITERR      0x400   /* OR'd with pri for tsleep to not exit
  201                                    with an error code when LWPs are exiting */
  202 #define NBPW    sizeof(int)     /* number of bytes per word (integer) */
  203 
  204 #define CMASK   022             /* default file mask: S_IWGRP|S_IWOTH */
  205 #define NODEV   (dev_t)(-1)     /* non-existent device */
  206 
  207 #define CBLOCK  64              /* Clist block size, must be a power of 2. */
  208 #define CBQSIZE (CBLOCK/NBBY)   /* Quote bytes/cblock - can do better. */
  209                                 /* Data chars/clist. */
  210 #define CBSIZE  (CBLOCK - (int)sizeof(struct cblock *) - CBQSIZE)
  211 #define CROUND  (CBLOCK - 1)    /* Clist rounding. */
  212 
  213 /*
  214  * File system parameters and macros.
  215  *
  216  * The file system is made out of blocks of at most MAXBSIZE units, with
  217  * smaller units (fragments) only in the last direct block.  MAXBSIZE
  218  * primarily determines the size of buffers in the buffer pool.  It may be
  219  * made larger without any effect on existing file systems; however making
  220  * it smaller may make some file systems unmountable.
  221  */
  222 #ifndef MAXBSIZE                                /* XXX */
  223 #define MAXBSIZE        MAXPHYS
  224 #endif
  225 #define MAXFRAG         8
  226 
  227 /*
  228  * MAXPATHLEN defines the longest permissible path length after expanding
  229  * symbolic links. It is used to allocate a temporary buffer from the buffer
  230  * pool in which to do the name expansion, hence should be a power of two,
  231  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
  232  * maximum number of symbolic links that may be expanded in a path name.
  233  * It should be set high enough to allow all legitimate uses, but halt
  234  * infinite loops reasonably quickly.
  235  */
  236 #define MAXPATHLEN      PATH_MAX
  237 #define MAXSYMLINKS     32
  238 
  239 /* Bit map related macros. */
  240 #define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
  241 #define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
  242 #define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
  243 #define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
  244 
  245 /* Macros for counting and rounding. */
  246 #ifndef howmany
  247 #define howmany(x, y)   (((x)+((y)-1))/(y))
  248 #endif
  249 #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
  250 #define powerof2(x)     ((((x)-1)&(x))==0)
  251 
  252 /* Macros for min/max. */
  253 #define MIN(a,b)        (((a)<(b))?(a):(b))
  254 #define MAX(a,b)        (((a)>(b))?(a):(b))
  255 
  256 /*
  257  * Constants for setting the parameters of the kernel memory allocator.
  258  *
  259  * 2 ** MINBUCKET is the smallest unit of memory that will be
  260  * allocated. It must be at least large enough to hold a pointer.
  261  *
  262  * Units of memory less or equal to MAXALLOCSAVE will permanently
  263  * allocate physical memory; requests for these size pieces of
  264  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
  265  * always allocate and free physical memory; requests for these
  266  * size allocations should be done infrequently as they will be slow.
  267  *
  268  * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
  269  * MAXALLOCSAVE must be a power of two.
  270  */
  271 #ifdef _LP64
  272 #define MINBUCKET       5               /* 5 => min allocation of 32 bytes */
  273 #else
  274 #define MINBUCKET       4               /* 4 => min allocation of 16 bytes */
  275 #endif
  276 #define MAXALLOCSAVE    (2 * NBPG)
  277 
  278 /*
  279  * Scale factor for scaled integers used to count %cpu time and load avgs.
  280  *
  281  * The number of CPU `tick's that map to a unique `%age' can be expressed
  282  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
  283  * can be calculated (assuming 32 bits) can be closely approximated using
  284  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
  285  *
  286  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
  287  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
  288  */
  289 #define FSHIFT  11              /* bits to right of fixed binary point */
  290 #define FSCALE  (1<<FSHIFT)
  291 
  292 /*
  293  * The time for a process to be blocked before being very swappable.
  294  * This is a number of seconds which the system takes as being a non-trivial
  295  * amount of real time.  You probably shouldn't change this;
  296  * it is used in subtle ways (fractions and multiples of it are, that is, like
  297  * half of a ``long time'', almost a long time, etc.)
  298  * It is related to human patience and other factors which don't really
  299  * change over time.
  300  */
  301 #define        MAXSLP          20
  302 
  303 /*
  304  * Defaults for Unified Buffer Cache parameters.
  305  * These may be overridden in <machine/param.h>.
  306  */
  307 
  308 #ifndef UBC_WINSHIFT
  309 #define UBC_WINSHIFT    13
  310 #endif
  311 #ifndef UBC_NWINS
  312 #define UBC_NWINS       1024
  313 #endif
  314 
  315 #ifdef _KERNEL
  316 /*
  317  * macro to convert from milliseconds to hz without integer overflow
  318  * Default version using only 32bits arithmetics.
  319  * 64bit port can define 64bit version in their <machine/param.h>
  320  * 0x20000 is safe for hz < 20000
  321  */
  322 #ifndef mstohz
  323 #define mstohz(ms) \
  324         (__predict_false((ms) >= 0x20000) ? \
  325             ((ms +0u) / 1000u) * hz : \
  326             ((ms +0u) * hz) / 1000u)
  327 #endif
  328 #endif /* _KERNEL */
  329 
  330 #endif /* !_SYS_PARAM_H_ */

Cache object: 9977954477f2e7099570725d6cfa1867


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.