199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1982, 1986, 1989, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (c) UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All or some portions of this file are derived from material licensed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to the University of California by American Telephone and Telegraph
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Co. or Unix System Laboratories, Inc. and are reproduced herein with
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the permission of UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)param.h 8.3 (Berkeley) 4/4/95
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_PARAM_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SYS_PARAM_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_null.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BSD 199506 /* System version (year & month). */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BSD4_3 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BSD4_4 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * __FreeBSD_version numbers are documented in the Porter's Handbook.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If you bump the version for any reason, you should update the documentation
199767f8919635c4928607450d9e0abb932109ceToomas Soome * there.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Currently this lives here in the doc/ repository:
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * head/en_US.ISO8859-1/books/porters-handbook/versions/chapter.xml
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * scheme is: <major><two digit minor>Rxx
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 'R' is in the range 0 to 4 if this is a release branch or
199767f8919635c4928607450d9e0abb932109ceToomas Soome * x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in the range 5 to 9.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#undef __FreeBSD_version
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __FreeBSD_version 1100100 /* Master, propagated to newvers */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * which by definition is always true on FreeBSD. This macro is also defined
199767f8919635c4928607450d9e0abb932109ceToomas Soome * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * It is tempting to use this macro in userland code when we want to enable
199767f8919635c4928607450d9e0abb932109ceToomas Soome * kernel-specific routines, and in fact it's fine to do this in code that
199767f8919635c4928607450d9e0abb932109ceToomas Soome * is part of FreeBSD itself. However, be aware that as presence of this
199767f8919635c4928607450d9e0abb932109ceToomas Soome * macro is still not widespread (e.g. older FreeBSD versions, 3rd party
199767f8919635c4928607450d9e0abb932109ceToomas Soome * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in
199767f8919635c4928607450d9e0abb932109ceToomas Soome * external applications without also checking for __FreeBSD__ as an
199767f8919635c4928607450d9e0abb932109ceToomas Soome * alternative.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#undef __FreeBSD_kernel__
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __FreeBSD_kernel__
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define P_OSREL_SIGWAIT 700000
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define P_OSREL_SIGSEGV 700004
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define P_OSREL_MAP_ANON 800104
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define P_OSREL_MAP_FSTRICT 1100036
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define P_OSREL_SHUTDOWN_ENOTCONN 1100077
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define P_OSREL_MAJOR(x) ((x) / 100000)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef LOCORE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/types.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Machine-independent constants (some used in following include files).
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redefined constants are from POSIX 1003.1 limits file.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/syslimits.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXCOMLEN 19 /* max command name remembered */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXINTERP PATH_MAX /* max interpreter file name length */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXLOGNAME 33 /* max login name length (incl. NUL) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXUPRC CHILD_MAX /* max simultaneous processes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NCARGS ARG_MAX /* max bytes for an exec function */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NGROUPS (NGROUPS_MAX+1) /* max number groups */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NOFILE OPEN_MAX /* max open files per process */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NOGROUP 65535 /* marker for empty group set member */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXHOSTNAMELEN 256 /* max hostname size */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SPECNAMELEN 63 /* max length of devicename */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* More types and definitions used throughout the kernel. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/cdefs.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/errno.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef LOCORE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/time.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/priority.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef FALSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FALSE 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef TRUE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define TRUE 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Signals. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/signal.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Machine type dependent parameters. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <machine/param.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/limits.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef DEV_BSHIFT
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DEV_BSIZE (1<<DEV_BSHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef BLKDEV_IOSIZE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef DFLTPHYS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef MAXPHYS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef MAXDUMPPGS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Constants related to network buffer management.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * MCLBYTES must be no larger than PAGE_SIZE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef MSIZE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MSIZE 256 /* size of an mbuf */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef MCLSHIFT
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCLSHIFT 11 /* convert bytes to mbuf clusters */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* MCLSHIFT */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if PAGE_SIZE < 2048
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MJUMPAGESIZE MCLBYTES
199767f8919635c4928607450d9e0abb932109ceToomas Soome#elif PAGE_SIZE <= 8192
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MJUMPAGESIZE PAGE_SIZE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MJUMPAGESIZE (8 * 1024)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Some macros for units conversion
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* clicks to bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef ctob
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ctob(x) ((x)<<PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* bytes to clicks */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef btoc
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * btodb() is messy and perhaps slow because `bytes' may be an off_t. We
199767f8919635c4928607450d9e0abb932109ceToomas Soome * want to shift an unsigned type to avoid sign extension and we don't
199767f8919635c4928607450d9e0abb932109ceToomas Soome * want to widen `bytes' unnecessarily. Assume that the result fits in
199767f8919635c4928607450d9e0abb932109ceToomas Soome * a daddr_t.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef btodb
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
199767f8919635c4928607450d9e0abb932109ceToomas Soome (sizeof (bytes) > sizeof(long) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef dbtob
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ((off_t)(db) << DEV_BSHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRIMASK 0x0ff
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NZERO 0 /* default "nice" */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NBBY 8 /* number of bits in a byte */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NBPW sizeof(int) /* number of bytes per word (integer) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NODEV (dev_t)(-1) /* non-existent device */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * File system parameters and macros.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes
199767f8919635c4928607450d9e0abb932109ceToomas Soome * per block. MAXBSIZE may be made larger without effecting
199767f8919635c4928607450d9e0abb932109ceToomas Soome * any existing filesystems as long as it does not exceed MAXPHYS,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and may be made smaller at the risk of not being able to use
199767f8919635c4928607450d9e0abb932109ceToomas Soome * filesystems which require a block size exceeding MAXBSIZE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * MAXBCACHEBUF - Maximum size of a buffer in the buffer cache. This must
199767f8919635c4928607450d9e0abb932109ceToomas Soome * be >= MAXBSIZE and can be set differently for different
199767f8919635c4928607450d9e0abb932109ceToomas Soome * architectures by defining it in <machine/param.h>.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Making this larger allows NFS to do larger reads/writes.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * minimum KVM memory reservation the kernel is willing to make.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Filesystems can of course request smaller chunks. Actual
199767f8919635c4928607450d9e0abb932109ceToomas Soome * backing memory uses a chunk size of a page (PAGE_SIZE).
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The default value here can be overridden on a per-architecture
199767f8919635c4928607450d9e0abb932109ceToomas Soome * basis by defining it in <machine/param.h>. This should
199767f8919635c4928607450d9e0abb932109ceToomas Soome * probably be done to increase its value, when MAXBCACHEBUF is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * defined as a larger value in <machine/param.h>.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If you make BKVASIZE too small you risk seriously fragmenting
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the buffer KVM map which may slow things down a bit. If you
199767f8919635c4928607450d9e0abb932109ceToomas Soome * make it too big the kernel will not be able to optimally use
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the KVM memory reserved for the buffer cache and will wind
199767f8919635c4928607450d9e0abb932109ceToomas Soome * up with too-few buffers.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The default is 16384, roughly 2x the block size used by a
199767f8919635c4928607450d9e0abb932109ceToomas Soome * normal UFS filesystem.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXBSIZE 65536 /* must be power of 2 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef MAXBCACHEBUF
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXBCACHEBUF MAXBSIZE /* must be a power of 2 >= MAXBSIZE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef BKVASIZE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BKVASIZE 16384 /* must be power of 2 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BKVAMASK (BKVASIZE-1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * MAXPATHLEN defines the longest permissible path length after expanding
199767f8919635c4928607450d9e0abb932109ceToomas Soome * symbolic links. It is used to allocate a temporary buffer from the buffer
199767f8919635c4928607450d9e0abb932109ceToomas Soome * pool in which to do the name expansion, hence should be a power of two,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * maximum number of symbolic links that may be expanded in a path name.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * It should be set high enough to allow all legitimate uses, but halt
199767f8919635c4928607450d9e0abb932109ceToomas Soome * infinite loops reasonably quickly.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXPATHLEN PATH_MAX
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXSYMLINKS 32
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Bit map related macros. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define isset(a,i) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define isclr(a,i) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Macros for counting and rounding. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef howmany
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define howmany(x, y) (((x)+((y)-1))/(y))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define nitems(x) (sizeof((x)) / sizeof((x)[0]))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define rounddown(x, y) (((x)/(y))*(y))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define rounddown2(x, y) ((x)&(~((y)-1))) /* if y is power of two */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define powerof2(x) ((((x)-1)&(x))==0)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Macros for min/max. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MIN(a,b) (((a)<(b))?(a):(b))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAX(a,b) (((a)>(b))?(a):(b))
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef _KERNEL
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Basic byte order function prototypes for non-inline functions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef LOCORE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _BYTEORDER_PROTOTYPED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _BYTEORDER_PROTOTYPED
199767f8919635c4928607450d9e0abb932109ceToomas Soome__BEGIN_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint32_t htonl(__uint32_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint16_t htons(__uint16_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint32_t ntohl(__uint32_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__uint16_t ntohs(__uint16_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome__END_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef lint
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _BYTEORDER_FUNC_DEFINED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _BYTEORDER_FUNC_DEFINED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define htonl(x) __htonl(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define htons(x) __htons(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ntohl(x) __ntohl(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ntohs(x) __ntohs(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_BYTEORDER_FUNC_DEFINED */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* lint */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _KERNEL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Scale factor for scaled integers used to count %cpu time and load avgs.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The number of CPU `tick's that map to a unique `%age' can be expressed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
199767f8919635c4928607450d9e0abb932109ceToomas Soome * can be calculated (assuming 32 bits) can be closely approximated using
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FSHIFT 11 /* bits to right of fixed binary point */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FSCALE (1<<FSHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define dbtoc(db) /* calculates devblks to pages */ \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ctodb(db) /* calculates pages to devblks */ \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ((db) << (PAGE_SHIFT - DEV_BSHIFT))
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Old spelling of __containerof().
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define member2struct(s, m, x) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome ((struct s *)(void *)((char *)(x) - offsetof(struct s, m)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Access a variable length array that has been declared as a fixed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * length array.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _SYS_PARAM_H_ */