epoc32/include/stdapis/sys/param.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/stdapis/sys/param.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/sys/param.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,331 @@
     1.4 -param.h
     1.5 +/*-
     1.6 + * Copyright (c) 1982, 1986, 1989, 1993
     1.7 + *	The Regents of the University of California.  All rights reserved.
     1.8 + * (c) UNIX System Laboratories, Inc.
     1.9 + * All or some portions of this file are derived from material licensed
    1.10 + * to the University of California by American Telephone and Telegraph
    1.11 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
    1.12 + * the permission of UNIX System Laboratories, Inc.
    1.13 + *
    1.14 + * Redistribution and use in source and binary forms, with or without
    1.15 + * modification, are permitted provided that the following conditions
    1.16 + * are met:
    1.17 + * 1. Redistributions of source code must retain the above copyright
    1.18 + *    notice, this list of conditions and the following disclaimer.
    1.19 + * 2. Redistributions in binary form must reproduce the above copyright
    1.20 + *    notice, this list of conditions and the following disclaimer in the
    1.21 + *    documentation and/or other materials provided with the distribution.
    1.22 + * 4. Neither the name of the University nor the names of its contributors
    1.23 + *    may be used to endorse or promote products derived from this software
    1.24 + *    without specific prior written permission.
    1.25 + *
    1.26 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    1.27 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.28 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.29 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    1.30 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.31 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.32 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.33 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.34 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.35 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.36 + * SUCH DAMAGE.
    1.37 + *
    1.38 + *	@(#)param.h	8.3 (Berkeley) 4/4/95
    1.39 + * $FreeBSD: src/sys/sys/param.h,v 1.244.2.2 2005/08/13 21:27:58 rwatson Exp $
    1.40 + */
    1.41 +
    1.42 +#ifndef _SYS_PARAM_H_
    1.43 +#define _SYS_PARAM_H_
    1.44 +
    1.45 +#include <sys/_null.h>
    1.46 +
    1.47 +#define	BSD	199506		/* System version (year & month). */
    1.48 +#define BSD4_3	1
    1.49 +#define BSD4_4	1
    1.50 +
    1.51 +/* 
    1.52 + * __FreeBSD_version numbers are documented in the Porter's Handbook.
    1.53 + * If you bump the version for any reason, you should update the documentation
    1.54 + * there.
    1.55 + * Currently this lives here:
    1.56 + *
    1.57 + *	doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
    1.58 + *
    1.59 + * scheme is:  <major><two digit minor>Rxx
    1.60 + *		'R' is 0 if release branch or x.0-CURRENT before RELENG_*_0
    1.61 + *		is created, otherwise 1.
    1.62 + */
    1.63 +#undef __FreeBSD_version
    1.64 +#define __FreeBSD_version 600034	/* Master, propagated to newvers */
    1.65 +
    1.66 +#ifndef LOCORE
    1.67 +#include <sys/types.h>
    1.68 +#endif
    1.69 +
    1.70 +/*
    1.71 + * Machine-independent constants (some used in following include files).
    1.72 + * Redefined constants are from POSIX 1003.1 limits file.
    1.73 + *
    1.74 + * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
    1.75 + * MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>)
    1.76 + */
    1.77 +#include <sys/syslimits.h>
    1.78 +
    1.79 +#define	MAXCOMLEN	19		/* max command name remembered */
    1.80 +#define	MAXINTERP	32		/* max interpreter file name length */
    1.81 +#define	MAXLOGNAME	17		/* max login name length (incl. NUL) */
    1.82 +#define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
    1.83 +#define	NCARGS		ARG_MAX		/* max bytes for an exec function */
    1.84 +#define	NGROUPS		NGROUPS_MAX	/* max number groups */
    1.85 +#define	NOFILE		OPEN_MAX	/* max open files per process */
    1.86 +#define	NOGROUP		65535		/* marker for empty group set member */
    1.87 +#define MAXHOSTNAMELEN	256		/* max hostname size */
    1.88 +#define SPECNAMELEN	63		/* max length of devicename */
    1.89 +
    1.90 +/* More types and definitions used throughout the kernel. */
    1.91 +#ifdef _KERNEL
    1.92 +#if 0
    1.93 +#if (defined(BURN_BRIDGES) || __FreeBSD_version >= 600000) \
    1.94 +	&& defined(OBSOLETE_IN_6)
    1.95 +#error "This file contains obsolete code to be removed in 6.0-current"
    1.96 +#endif
    1.97 +#endif
    1.98 +#include <sys/cdefs.h>
    1.99 +#include <sys/errno.h>
   1.100 +#include <sys/time.h>
   1.101 +
   1.102 +#ifndef __SYMBIAN32__
   1.103 +#include <sys/priority.h>
   1.104 +#endif //__SYMBIAN32__
   1.105 +
   1.106 +#define	FALSE	0
   1.107 +#define	TRUE	1
   1.108 +#endif
   1.109 +
   1.110 +#ifndef _KERNEL
   1.111 +/* Signals. */
   1.112 +#ifndef __SYMBIAN32__
   1.113 +#include <sys/signal.h>
   1.114 +#endif //__SYMBIAN32__
   1.115 +#endif
   1.116 +
   1.117 +/* Machine type dependent parameters. */
   1.118 +#include <machine/param.h>
   1.119 +#ifndef _KERNEL
   1.120 +#include <sys/limits.h>
   1.121 +#endif
   1.122 +
   1.123 +#ifndef _NO_NAMESPACE_POLLUTION
   1.124 +
   1.125 +#ifndef DEV_BSHIFT
   1.126 +#define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
   1.127 +#endif
   1.128 +#define	DEV_BSIZE	(1<<DEV_BSHIFT)
   1.129 +
   1.130 +#ifndef BLKDEV_IOSIZE
   1.131 +#define BLKDEV_IOSIZE  PAGE_SIZE	/* default block device I/O size */
   1.132 +#endif
   1.133 +#ifndef DFLTPHYS
   1.134 +#define DFLTPHYS	(64 * 1024)	/* default max raw I/O transfer size */
   1.135 +#endif
   1.136 +#ifndef MAXPHYS
   1.137 +#define MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
   1.138 +#endif
   1.139 +#ifndef MAXDUMPPGS
   1.140 +#define MAXDUMPPGS	(DFLTPHYS/PAGE_SIZE)
   1.141 +#endif
   1.142 +
   1.143 +/*
   1.144 + * Constants related to network buffer management.
   1.145 + * MCLBYTES must be no larger than PAGE_SIZE.
   1.146 + */
   1.147 +#ifndef	MSIZE
   1.148 +#define MSIZE		256		/* size of an mbuf */
   1.149 +#endif	/* MSIZE */
   1.150 +
   1.151 +#ifndef	MCLSHIFT
   1.152 +#define MCLSHIFT	11		/* convert bytes to mbuf clusters */
   1.153 +#endif	/* MCLSHIFT */
   1.154 +
   1.155 +#define MCLBYTES	(1 << MCLSHIFT)	/* size of an mbuf cluster */
   1.156 +
   1.157 +/*
   1.158 + * Some macros for units conversion
   1.159 + */
   1.160 +
   1.161 +/* clicks to bytes */
   1.162 +#ifndef ctob
   1.163 +#define ctob(x)	((x)<<PAGE_SHIFT)
   1.164 +#endif
   1.165 +
   1.166 +/* bytes to clicks */
   1.167 +#ifndef btoc
   1.168 +#define btoc(x)	(((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
   1.169 +#endif
   1.170 +
   1.171 +/*
   1.172 + * btodb() is messy and perhaps slow because `bytes' may be an off_t.  We
   1.173 + * want to shift an unsigned type to avoid sign extension and we don't
   1.174 + * want to widen `bytes' unnecessarily.  Assume that the result fits in
   1.175 + * a daddr_t.
   1.176 + */
   1.177 +#ifndef btodb
   1.178 +#define btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
   1.179 +	(sizeof (bytes) > sizeof(long) \
   1.180 +	 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
   1.181 +	 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
   1.182 +#endif
   1.183 +
   1.184 +#ifndef dbtob
   1.185 +#define dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
   1.186 +	((off_t)(db) << DEV_BSHIFT)
   1.187 +#endif
   1.188 +
   1.189 +#endif /* _NO_NAMESPACE_POLLUTION */
   1.190 +
   1.191 +#define	PRIMASK	0x0ff
   1.192 +#define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
   1.193 +#define	PDROP	0x200	/* OR'd with pri to stop re-entry of interlock mutex */
   1.194 +
   1.195 +#define	NZERO	0		/* default "nice" */
   1.196 +
   1.197 +#define	NBBY	8		/* number of bits in a byte */
   1.198 +#define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
   1.199 +
   1.200 +#define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
   1.201 +
   1.202 +#define	NODEV	(dev_t)(-1)	/* non-existent device */
   1.203 +
   1.204 +#define	CBLOCK	128		/* Clist block size, must be a power of 2. */
   1.205 +#define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
   1.206 +				/* Data chars/clist. */
   1.207 +#define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
   1.208 +#define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
   1.209 +
   1.210 +/*
   1.211 + * File system parameters and macros.
   1.212 + *
   1.213 + * MAXBSIZE -	Filesystems are made out of blocks of at most MAXBSIZE bytes
   1.214 + *		per block.  MAXBSIZE may be made larger without effecting
   1.215 + *		any existing filesystems as long as it does not exceed MAXPHYS,
   1.216 + *		and may be made smaller at the risk of not being able to use
   1.217 + *		filesystems which require a block size exceeding MAXBSIZE.
   1.218 + *
   1.219 + * BKVASIZE -	Nominal buffer space per buffer, in bytes.  BKVASIZE is the
   1.220 + *		minimum KVM memory reservation the kernel is willing to make.
   1.221 + *		Filesystems can of course request smaller chunks.  Actual 
   1.222 + *		backing memory uses a chunk size of a page (PAGE_SIZE).
   1.223 + *
   1.224 + *		If you make BKVASIZE too small you risk seriously fragmenting
   1.225 + *		the buffer KVM map which may slow things down a bit.  If you
   1.226 + *		make it too big the kernel will not be able to optimally use 
   1.227 + *		the KVM memory reserved for the buffer cache and will wind 
   1.228 + *		up with too-few buffers.
   1.229 + *
   1.230 + *		The default is 16384, roughly 2x the block size used by a
   1.231 + *		normal UFS filesystem.
   1.232 + */
   1.233 +#define MAXBSIZE	65536	/* must be power of 2 */
   1.234 +#define BKVASIZE	16384	/* must be power of 2 */
   1.235 +#define BKVAMASK	(BKVASIZE-1)
   1.236 +
   1.237 +/*
   1.238 + * MAXPATHLEN defines the longest permissible path length after expanding
   1.239 + * symbolic links. It is used to allocate a temporary buffer from the buffer
   1.240 + * pool in which to do the name expansion, hence should be a power of two,
   1.241 + * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
   1.242 + * maximum number of symbolic links that may be expanded in a path name.
   1.243 + * It should be set high enough to allow all legitimate uses, but halt
   1.244 + * infinite loops reasonably quickly.
   1.245 + */
   1.246 +#define	MAXPATHLEN	PATH_MAX
   1.247 +#define MAXSYMLINKS	32
   1.248 +
   1.249 +/* Bit map related macros. */
   1.250 +#define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
   1.251 +#define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
   1.252 +#define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
   1.253 +#define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
   1.254 +
   1.255 +/* Macros for counting and rounding. */
   1.256 +#ifndef howmany
   1.257 +#define	howmany(x, y)	(((x)+((y)-1))/(y))
   1.258 +#endif
   1.259 +#define	rounddown(x, y)	(((x)/(y))*(y))
   1.260 +#define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
   1.261 +#define	roundup2(x, y)	(((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
   1.262 +#define powerof2(x)	((((x)-1)&(x))==0)
   1.263 +
   1.264 +/* Macros for min/max. */
   1.265 +#define	MIN(a,b) (((a)<(b))?(a):(b))
   1.266 +#define	MAX(a,b) (((a)>(b))?(a):(b))
   1.267 +
   1.268 +#ifdef _KERNEL
   1.269 +/*
   1.270 + * Basic byte order function prototypes for non-inline functions.
   1.271 + */
   1.272 +#ifndef _BYTEORDER_PROTOTYPED
   1.273 +#define	_BYTEORDER_PROTOTYPED
   1.274 +__BEGIN_DECLS
   1.275 +__uint32_t	 htonl(__uint32_t);
   1.276 +__uint16_t	 htons(__uint16_t);
   1.277 +__uint32_t	 ntohl(__uint32_t);
   1.278 +__uint16_t	 ntohs(__uint16_t);
   1.279 +__END_DECLS
   1.280 +#endif
   1.281 +
   1.282 +#ifndef lint
   1.283 +#ifndef _BYTEORDER_FUNC_DEFINED
   1.284 +#define	_BYTEORDER_FUNC_DEFINED
   1.285 +#define	htonl(x)	__htonl(x)
   1.286 +#define	htons(x)	__htons(x)
   1.287 +#define	ntohl(x)	__ntohl(x)
   1.288 +#define	ntohs(x)	__ntohs(x)
   1.289 +#endif /* !_BYTEORDER_FUNC_DEFINED */
   1.290 +#endif /* lint */
   1.291 +#endif /* _KERNEL */
   1.292 +
   1.293 +/*
   1.294 + * Constants for setting the parameters of the kernel memory allocator.
   1.295 + *
   1.296 + * 2 ** MINBUCKET is the smallest unit of memory that will be
   1.297 + * allocated. It must be at least large enough to hold a pointer.
   1.298 + *
   1.299 + * Units of memory less or equal to MAXALLOCSAVE will permanently
   1.300 + * allocate physical memory; requests for these size pieces of
   1.301 + * memory are quite fast. Allocations greater than MAXALLOCSAVE must
   1.302 + * always allocate and free physical memory; requests for these
   1.303 + * size allocations should be done infrequently as they will be slow.
   1.304 + *
   1.305 + * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
   1.306 + * MAXALLOCSIZE must be a power of two.
   1.307 + */
   1.308 +#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__)
   1.309 +#define MINBUCKET	5		/* 5 => min allocation of 32 bytes */
   1.310 +#else
   1.311 +#define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
   1.312 +#endif
   1.313 +#define MAXALLOCSAVE	(2 * PAGE_SIZE)
   1.314 +
   1.315 +/*
   1.316 + * Scale factor for scaled integers used to count %cpu time and load avgs.
   1.317 + *
   1.318 + * The number of CPU `tick's that map to a unique `%age' can be expressed
   1.319 + * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
   1.320 + * can be calculated (assuming 32 bits) can be closely approximated using
   1.321 + * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
   1.322 + *
   1.323 + * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
   1.324 + * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
   1.325 + */
   1.326 +#define	FSHIFT	11		/* bits to right of fixed binary point */
   1.327 +#define FSCALE	(1<<FSHIFT)
   1.328 +
   1.329 +#define dbtoc(db)			/* calculates devblks to pages */ \
   1.330 +	((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
   1.331 + 
   1.332 +#define ctodb(db)			/* calculates pages to devblks */ \
   1.333 +	((db) << (PAGE_SHIFT - DEV_BSHIFT))
   1.334 +
   1.335 +#endif	/* _SYS_PARAM_H_ */