williamr@2: /*- williamr@2: * Copyright (c) 1982, 1986, 1989, 1993 williamr@2: * The Regents of the University of California. All rights reserved. williamr@2: * (c) UNIX System Laboratories, Inc. williamr@2: * All or some portions of this file are derived from material licensed williamr@2: * to the University of California by American Telephone and Telegraph williamr@2: * Co. or Unix System Laboratories, Inc. and are reproduced herein with williamr@2: * the permission of UNIX System Laboratories, Inc. williamr@2: * williamr@2: * Redistribution and use in source and binary forms, with or without williamr@2: * modification, are permitted provided that the following conditions williamr@2: * are met: williamr@2: * 1. Redistributions of source code must retain the above copyright williamr@2: * notice, this list of conditions and the following disclaimer. williamr@2: * 2. Redistributions in binary form must reproduce the above copyright williamr@2: * notice, this list of conditions and the following disclaimer in the williamr@2: * documentation and/or other materials provided with the distribution. williamr@2: * 4. Neither the name of the University nor the names of its contributors williamr@2: * may be used to endorse or promote products derived from this software williamr@2: * without specific prior written permission. williamr@2: * williamr@2: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND williamr@2: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE williamr@2: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE williamr@2: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE williamr@2: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL williamr@2: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS williamr@2: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) williamr@2: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT williamr@2: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY williamr@2: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF williamr@2: * SUCH DAMAGE. williamr@2: * williamr@2: * @(#)param.h 8.3 (Berkeley) 4/4/95 williamr@2: * $FreeBSD: src/sys/sys/param.h,v 1.244.2.2 2005/08/13 21:27:58 rwatson Exp $ williamr@2: */ williamr@2: williamr@2: #ifndef _SYS_PARAM_H_ williamr@2: #define _SYS_PARAM_H_ williamr@2: williamr@2: #include williamr@2: williamr@2: #define BSD 199506 /* System version (year & month). */ williamr@2: #define BSD4_3 1 williamr@2: #define BSD4_4 1 williamr@2: williamr@2: /* williamr@2: * __FreeBSD_version numbers are documented in the Porter's Handbook. williamr@2: * If you bump the version for any reason, you should update the documentation williamr@2: * there. williamr@2: * Currently this lives here: williamr@2: * williamr@2: * doc/en_US.ISO8859-1/books/porters-handbook/book.sgml williamr@2: * williamr@2: * scheme is: Rxx williamr@2: * 'R' is 0 if release branch or x.0-CURRENT before RELENG_*_0 williamr@2: * is created, otherwise 1. williamr@2: */ williamr@2: #undef __FreeBSD_version williamr@2: #define __FreeBSD_version 600034 /* Master, propagated to newvers */ williamr@2: williamr@2: #ifndef LOCORE williamr@2: #include williamr@2: #endif williamr@2: williamr@2: /* williamr@2: * Machine-independent constants (some used in following include files). williamr@2: * Redefined constants are from POSIX 1003.1 limits file. williamr@2: * williamr@2: * MAXCOMLEN should be >= sizeof(ac_comm) (see ) williamr@2: * MAXLOGNAME should be == UT_NAMESIZE+1 (see ) williamr@2: */ williamr@2: #include williamr@2: williamr@2: #define MAXCOMLEN 19 /* max command name remembered */ williamr@2: #define MAXINTERP 32 /* max interpreter file name length */ williamr@2: #define MAXLOGNAME 17 /* max login name length (incl. NUL) */ williamr@2: #define MAXUPRC CHILD_MAX /* max simultaneous processes */ williamr@2: #define NCARGS ARG_MAX /* max bytes for an exec function */ williamr@2: #define NGROUPS NGROUPS_MAX /* max number groups */ williamr@2: #define NOFILE OPEN_MAX /* max open files per process */ williamr@2: #define NOGROUP 65535 /* marker for empty group set member */ williamr@2: #define MAXHOSTNAMELEN 256 /* max hostname size */ williamr@2: #define SPECNAMELEN 63 /* max length of devicename */ williamr@2: williamr@2: /* More types and definitions used throughout the kernel. */ williamr@2: #ifdef _KERNEL williamr@2: #if 0 williamr@2: #if (defined(BURN_BRIDGES) || __FreeBSD_version >= 600000) \ williamr@2: && defined(OBSOLETE_IN_6) williamr@2: #error "This file contains obsolete code to be removed in 6.0-current" williamr@2: #endif williamr@2: #endif williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: #ifndef __SYMBIAN32__ williamr@2: #include williamr@2: #endif //__SYMBIAN32__ williamr@2: williamr@2: #define FALSE 0 williamr@2: #define TRUE 1 williamr@2: #endif williamr@2: williamr@2: #ifndef _KERNEL williamr@2: /* Signals. */ williamr@2: #ifndef __SYMBIAN32__ williamr@2: #include williamr@2: #endif //__SYMBIAN32__ williamr@2: #endif williamr@2: williamr@2: /* Machine type dependent parameters. */ williamr@2: #include williamr@2: #ifndef _KERNEL williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #ifndef _NO_NAMESPACE_POLLUTION williamr@2: williamr@2: #ifndef DEV_BSHIFT williamr@2: #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ williamr@2: #endif williamr@2: #define DEV_BSIZE (1<>PAGE_SHIFT) williamr@2: #endif williamr@2: williamr@2: /* williamr@2: * btodb() is messy and perhaps slow because `bytes' may be an off_t. We williamr@2: * want to shift an unsigned type to avoid sign extension and we don't williamr@2: * want to widen `bytes' unnecessarily. Assume that the result fits in williamr@2: * a daddr_t. williamr@2: */ williamr@2: #ifndef btodb williamr@2: #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ williamr@2: (sizeof (bytes) > sizeof(long) \ williamr@2: ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ williamr@2: : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) williamr@2: #endif williamr@2: williamr@2: #ifndef dbtob williamr@2: #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ williamr@2: ((off_t)(db) << DEV_BSHIFT) williamr@2: #endif williamr@2: williamr@2: #endif /* _NO_NAMESPACE_POLLUTION */ williamr@2: williamr@2: #define PRIMASK 0x0ff williamr@2: #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ williamr@2: #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ williamr@2: williamr@2: #define NZERO 0 /* default "nice" */ williamr@2: williamr@2: #define NBBY 8 /* number of bits in a byte */ williamr@2: #define NBPW sizeof(int) /* number of bytes per word (integer) */ williamr@2: williamr@2: #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ williamr@2: williamr@2: #define NODEV (dev_t)(-1) /* non-existent device */ williamr@2: williamr@2: #define CBLOCK 128 /* Clist block size, must be a power of 2. */ williamr@2: #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ williamr@2: /* Data chars/clist. */ williamr@2: #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) williamr@2: #define CROUND (CBLOCK - 1) /* Clist rounding. */ williamr@2: williamr@2: /* williamr@2: * File system parameters and macros. williamr@2: * williamr@2: * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes williamr@2: * per block. MAXBSIZE may be made larger without effecting williamr@2: * any existing filesystems as long as it does not exceed MAXPHYS, williamr@2: * and may be made smaller at the risk of not being able to use williamr@2: * filesystems which require a block size exceeding MAXBSIZE. williamr@2: * williamr@2: * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the williamr@2: * minimum KVM memory reservation the kernel is willing to make. williamr@2: * Filesystems can of course request smaller chunks. Actual williamr@2: * backing memory uses a chunk size of a page (PAGE_SIZE). williamr@2: * williamr@2: * If you make BKVASIZE too small you risk seriously fragmenting williamr@2: * the buffer KVM map which may slow things down a bit. If you williamr@2: * make it too big the kernel will not be able to optimally use williamr@2: * the KVM memory reserved for the buffer cache and will wind williamr@2: * up with too-few buffers. williamr@2: * williamr@2: * The default is 16384, roughly 2x the block size used by a williamr@2: * normal UFS filesystem. williamr@2: */ williamr@2: #define MAXBSIZE 65536 /* must be power of 2 */ williamr@2: #define BKVASIZE 16384 /* must be power of 2 */ williamr@2: #define BKVAMASK (BKVASIZE-1) williamr@2: williamr@2: /* williamr@2: * MAXPATHLEN defines the longest permissible path length after expanding williamr@2: * symbolic links. It is used to allocate a temporary buffer from the buffer williamr@2: * pool in which to do the name expansion, hence should be a power of two, williamr@2: * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the williamr@2: * maximum number of symbolic links that may be expanded in a path name. williamr@2: * It should be set high enough to allow all legitimate uses, but halt williamr@2: * infinite loops reasonably quickly. williamr@2: */ williamr@2: #define MAXPATHLEN PATH_MAX williamr@2: #define MAXSYMLINKS 32 williamr@2: williamr@2: /* Bit map related macros. */ williamr@2: #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) williamr@2: #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) williamr@2: #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) williamr@2: #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) williamr@2: williamr@2: /* Macros for counting and rounding. */ williamr@2: #ifndef howmany williamr@2: #define howmany(x, y) (((x)+((y)-1))/(y)) williamr@2: #endif williamr@2: #define rounddown(x, y) (((x)/(y))*(y)) williamr@2: #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ williamr@2: #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ williamr@2: #define powerof2(x) ((((x)-1)&(x))==0) williamr@2: williamr@2: /* Macros for min/max. */ williamr@2: #define MIN(a,b) (((a)<(b))?(a):(b)) williamr@2: #define MAX(a,b) (((a)>(b))?(a):(b)) williamr@2: williamr@2: #ifdef _KERNEL williamr@2: /* williamr@2: * Basic byte order function prototypes for non-inline functions. williamr@2: */ williamr@2: #ifndef _BYTEORDER_PROTOTYPED williamr@2: #define _BYTEORDER_PROTOTYPED williamr@2: __BEGIN_DECLS williamr@2: __uint32_t htonl(__uint32_t); williamr@2: __uint16_t htons(__uint16_t); williamr@2: __uint32_t ntohl(__uint32_t); williamr@2: __uint16_t ntohs(__uint16_t); williamr@2: __END_DECLS williamr@2: #endif williamr@2: williamr@2: #ifndef lint williamr@2: #ifndef _BYTEORDER_FUNC_DEFINED williamr@2: #define _BYTEORDER_FUNC_DEFINED williamr@2: #define htonl(x) __htonl(x) williamr@2: #define htons(x) __htons(x) williamr@2: #define ntohl(x) __ntohl(x) williamr@2: #define ntohs(x) __ntohs(x) williamr@2: #endif /* !_BYTEORDER_FUNC_DEFINED */ williamr@2: #endif /* lint */ williamr@2: #endif /* _KERNEL */ williamr@2: williamr@2: /* williamr@2: * Constants for setting the parameters of the kernel memory allocator. williamr@2: * williamr@2: * 2 ** MINBUCKET is the smallest unit of memory that will be williamr@2: * allocated. It must be at least large enough to hold a pointer. williamr@2: * williamr@2: * Units of memory less or equal to MAXALLOCSAVE will permanently williamr@2: * allocate physical memory; requests for these size pieces of williamr@2: * memory are quite fast. Allocations greater than MAXALLOCSAVE must williamr@2: * always allocate and free physical memory; requests for these williamr@2: * size allocations should be done infrequently as they will be slow. williamr@2: * williamr@2: * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and williamr@2: * MAXALLOCSIZE must be a power of two. williamr@2: */ williamr@2: #if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) williamr@2: #define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ williamr@2: #else williamr@2: #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ williamr@2: #endif williamr@2: #define MAXALLOCSAVE (2 * PAGE_SIZE) williamr@2: williamr@2: /* williamr@2: * Scale factor for scaled integers used to count %cpu time and load avgs. williamr@2: * williamr@2: * The number of CPU `tick's that map to a unique `%age' can be expressed williamr@2: * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that williamr@2: * can be calculated (assuming 32 bits) can be closely approximated using williamr@2: * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). williamr@2: * williamr@2: * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', williamr@2: * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. williamr@2: */ williamr@2: #define FSHIFT 11 /* bits to right of fixed binary point */ williamr@2: #define FSCALE (1<> (PAGE_SHIFT - DEV_BSHIFT)) williamr@2: williamr@2: #define ctodb(db) /* calculates pages to devblks */ \ williamr@2: ((db) << (PAGE_SHIFT - DEV_BSHIFT)) williamr@2: williamr@2: #endif /* _SYS_PARAM_H_ */