os/ossrv/genericopenlibs/openenvcore/include/sys/param.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*-
sl@0
     2
 * Copyright (c) 1982, 1986, 1989, 1993
sl@0
     3
 *	The Regents of the University of California.  All rights reserved.
sl@0
     4
 * (c) UNIX System Laboratories, Inc.
sl@0
     5
 * All or some portions of this file are derived from material licensed
sl@0
     6
 * to the University of California by American Telephone and Telegraph
sl@0
     7
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
sl@0
     8
 * the permission of UNIX System Laboratories, Inc.
sl@0
     9
 *
sl@0
    10
 * Redistribution and use in source and binary forms, with or without
sl@0
    11
 * modification, are permitted provided that the following conditions
sl@0
    12
 * are met:
sl@0
    13
 * 1. Redistributions of source code must retain the above copyright
sl@0
    14
 *    notice, this list of conditions and the following disclaimer.
sl@0
    15
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    16
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    17
 *    documentation and/or other materials provided with the distribution.
sl@0
    18
 * 4. Neither the name of the University nor the names of its contributors
sl@0
    19
 *    may be used to endorse or promote products derived from this software
sl@0
    20
 *    without specific prior written permission.
sl@0
    21
 *
sl@0
    22
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0
    23
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    24
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    25
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0
    26
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    27
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    28
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    29
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    30
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    31
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    32
 * SUCH DAMAGE.
sl@0
    33
 *
sl@0
    34
 *	@(#)param.h	8.3 (Berkeley) 4/4/95
sl@0
    35
 * $FreeBSD: src/sys/sys/param.h,v 1.244.2.2 2005/08/13 21:27:58 rwatson Exp $
sl@0
    36
 */
sl@0
    37
sl@0
    38
#ifndef _SYS_PARAM_H_
sl@0
    39
#define _SYS_PARAM_H_
sl@0
    40
sl@0
    41
#include <sys/_null.h>
sl@0
    42
sl@0
    43
#define	BSD	199506		/* System version (year & month). */
sl@0
    44
#define BSD4_3	1
sl@0
    45
#define BSD4_4	1
sl@0
    46
sl@0
    47
/* 
sl@0
    48
 * __FreeBSD_version numbers are documented in the Porter's Handbook.
sl@0
    49
 * If you bump the version for any reason, you should update the documentation
sl@0
    50
 * there.
sl@0
    51
 * Currently this lives here:
sl@0
    52
 *
sl@0
    53
 *	doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
sl@0
    54
 *
sl@0
    55
 * scheme is:  <major><two digit minor>Rxx
sl@0
    56
 *		'R' is 0 if release branch or x.0-CURRENT before RELENG_*_0
sl@0
    57
 *		is created, otherwise 1.
sl@0
    58
 */
sl@0
    59
#undef __FreeBSD_version
sl@0
    60
#define __FreeBSD_version 600034	/* Master, propagated to newvers */
sl@0
    61
sl@0
    62
#ifndef LOCORE
sl@0
    63
#include <sys/types.h>
sl@0
    64
#endif
sl@0
    65
sl@0
    66
/*
sl@0
    67
 * Machine-independent constants (some used in following include files).
sl@0
    68
 * Redefined constants are from POSIX 1003.1 limits file.
sl@0
    69
 *
sl@0
    70
 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
sl@0
    71
 * MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>)
sl@0
    72
 */
sl@0
    73
#include <sys/syslimits.h>
sl@0
    74
sl@0
    75
#define	MAXCOMLEN	19		/* max command name remembered */
sl@0
    76
#define	MAXINTERP	32		/* max interpreter file name length */
sl@0
    77
#define	MAXLOGNAME	17		/* max login name length (incl. NUL) */
sl@0
    78
#define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
sl@0
    79
#define	NCARGS		ARG_MAX		/* max bytes for an exec function */
sl@0
    80
#define	NGROUPS		NGROUPS_MAX	/* max number groups */
sl@0
    81
#define	NOFILE		OPEN_MAX	/* max open files per process */
sl@0
    82
#define	NOGROUP		65535		/* marker for empty group set member */
sl@0
    83
#define MAXHOSTNAMELEN	256		/* max hostname size */
sl@0
    84
#define SPECNAMELEN	63		/* max length of devicename */
sl@0
    85
sl@0
    86
/* More types and definitions used throughout the kernel. */
sl@0
    87
#ifdef _KERNEL
sl@0
    88
#if 0
sl@0
    89
#if (defined(BURN_BRIDGES) || __FreeBSD_version >= 600000) \
sl@0
    90
	&& defined(OBSOLETE_IN_6)
sl@0
    91
#error "This file contains obsolete code to be removed in 6.0-current"
sl@0
    92
#endif
sl@0
    93
#endif
sl@0
    94
#include <sys/cdefs.h>
sl@0
    95
#include <sys/errno.h>
sl@0
    96
#include <sys/time.h>
sl@0
    97
sl@0
    98
#ifndef __SYMBIAN32__
sl@0
    99
#include <sys/priority.h>
sl@0
   100
#endif //__SYMBIAN32__
sl@0
   101
sl@0
   102
#define	FALSE	0
sl@0
   103
#define	TRUE	1
sl@0
   104
#endif
sl@0
   105
sl@0
   106
#ifndef _KERNEL
sl@0
   107
/* Signals. */
sl@0
   108
#ifndef __SYMBIAN32__
sl@0
   109
#include <sys/signal.h>
sl@0
   110
#endif //__SYMBIAN32__
sl@0
   111
#endif
sl@0
   112
sl@0
   113
/* Machine type dependent parameters. */
sl@0
   114
#include <stdapis/machine/param.h>
sl@0
   115
#ifndef _KERNEL
sl@0
   116
#include <sys/limits.h>
sl@0
   117
#endif
sl@0
   118
sl@0
   119
#ifndef _NO_NAMESPACE_POLLUTION
sl@0
   120
sl@0
   121
#ifndef DEV_BSHIFT
sl@0
   122
#define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
sl@0
   123
#endif
sl@0
   124
#define	DEV_BSIZE	(1<<DEV_BSHIFT)
sl@0
   125
sl@0
   126
#ifndef BLKDEV_IOSIZE
sl@0
   127
#define BLKDEV_IOSIZE  PAGE_SIZE	/* default block device I/O size */
sl@0
   128
#endif
sl@0
   129
#ifndef DFLTPHYS
sl@0
   130
#define DFLTPHYS	(64 * 1024)	/* default max raw I/O transfer size */
sl@0
   131
#endif
sl@0
   132
#ifndef MAXPHYS
sl@0
   133
#define MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
sl@0
   134
#endif
sl@0
   135
#ifndef MAXDUMPPGS
sl@0
   136
#define MAXDUMPPGS	(DFLTPHYS/PAGE_SIZE)
sl@0
   137
#endif
sl@0
   138
sl@0
   139
/*
sl@0
   140
 * Constants related to network buffer management.
sl@0
   141
 * MCLBYTES must be no larger than PAGE_SIZE.
sl@0
   142
 */
sl@0
   143
#ifndef	MSIZE
sl@0
   144
#define MSIZE		256		/* size of an mbuf */
sl@0
   145
#endif	/* MSIZE */
sl@0
   146
sl@0
   147
#ifndef	MCLSHIFT
sl@0
   148
#define MCLSHIFT	11		/* convert bytes to mbuf clusters */
sl@0
   149
#endif	/* MCLSHIFT */
sl@0
   150
sl@0
   151
#define MCLBYTES	(1 << MCLSHIFT)	/* size of an mbuf cluster */
sl@0
   152
sl@0
   153
/*
sl@0
   154
 * Some macros for units conversion
sl@0
   155
 */
sl@0
   156
sl@0
   157
/* clicks to bytes */
sl@0
   158
#ifndef ctob
sl@0
   159
#define ctob(x)	((x)<<PAGE_SHIFT)
sl@0
   160
#endif
sl@0
   161
sl@0
   162
/* bytes to clicks */
sl@0
   163
#ifndef btoc
sl@0
   164
#define btoc(x)	(((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
sl@0
   165
#endif
sl@0
   166
sl@0
   167
/*
sl@0
   168
 * btodb() is messy and perhaps slow because `bytes' may be an off_t.  We
sl@0
   169
 * want to shift an unsigned type to avoid sign extension and we don't
sl@0
   170
 * want to widen `bytes' unnecessarily.  Assume that the result fits in
sl@0
   171
 * a daddr_t.
sl@0
   172
 */
sl@0
   173
#ifndef btodb
sl@0
   174
#define btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
sl@0
   175
	(sizeof (bytes) > sizeof(long) \
sl@0
   176
	 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
sl@0
   177
	 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
sl@0
   178
#endif
sl@0
   179
sl@0
   180
#ifndef dbtob
sl@0
   181
#define dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
sl@0
   182
	((off_t)(db) << DEV_BSHIFT)
sl@0
   183
#endif
sl@0
   184
sl@0
   185
#endif /* _NO_NAMESPACE_POLLUTION */
sl@0
   186
sl@0
   187
#define	PRIMASK	0x0ff
sl@0
   188
#define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
sl@0
   189
#define	PDROP	0x200	/* OR'd with pri to stop re-entry of interlock mutex */
sl@0
   190
sl@0
   191
#define	NZERO	0		/* default "nice" */
sl@0
   192
sl@0
   193
#define	NBBY	8		/* number of bits in a byte */
sl@0
   194
#define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
sl@0
   195
sl@0
   196
#define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
sl@0
   197
sl@0
   198
#define	NODEV	(dev_t)(-1)	/* non-existent device */
sl@0
   199
sl@0
   200
#define	CBLOCK	128		/* Clist block size, must be a power of 2. */
sl@0
   201
#define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
sl@0
   202
				/* Data chars/clist. */
sl@0
   203
#define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
sl@0
   204
#define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
sl@0
   205
sl@0
   206
/*
sl@0
   207
 * File system parameters and macros.
sl@0
   208
 *
sl@0
   209
 * MAXBSIZE -	Filesystems are made out of blocks of at most MAXBSIZE bytes
sl@0
   210
 *		per block.  MAXBSIZE may be made larger without effecting
sl@0
   211
 *		any existing filesystems as long as it does not exceed MAXPHYS,
sl@0
   212
 *		and may be made smaller at the risk of not being able to use
sl@0
   213
 *		filesystems which require a block size exceeding MAXBSIZE.
sl@0
   214
 *
sl@0
   215
 * BKVASIZE -	Nominal buffer space per buffer, in bytes.  BKVASIZE is the
sl@0
   216
 *		minimum KVM memory reservation the kernel is willing to make.
sl@0
   217
 *		Filesystems can of course request smaller chunks.  Actual 
sl@0
   218
 *		backing memory uses a chunk size of a page (PAGE_SIZE).
sl@0
   219
 *
sl@0
   220
 *		If you make BKVASIZE too small you risk seriously fragmenting
sl@0
   221
 *		the buffer KVM map which may slow things down a bit.  If you
sl@0
   222
 *		make it too big the kernel will not be able to optimally use 
sl@0
   223
 *		the KVM memory reserved for the buffer cache and will wind 
sl@0
   224
 *		up with too-few buffers.
sl@0
   225
 *
sl@0
   226
 *		The default is 16384, roughly 2x the block size used by a
sl@0
   227
 *		normal UFS filesystem.
sl@0
   228
 */
sl@0
   229
#define MAXBSIZE	65536	/* must be power of 2 */
sl@0
   230
#define BKVASIZE	16384	/* must be power of 2 */
sl@0
   231
#define BKVAMASK	(BKVASIZE-1)
sl@0
   232
sl@0
   233
/*
sl@0
   234
 * MAXPATHLEN defines the longest permissible path length after expanding
sl@0
   235
 * symbolic links. It is used to allocate a temporary buffer from the buffer
sl@0
   236
 * pool in which to do the name expansion, hence should be a power of two,
sl@0
   237
 * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
sl@0
   238
 * maximum number of symbolic links that may be expanded in a path name.
sl@0
   239
 * It should be set high enough to allow all legitimate uses, but halt
sl@0
   240
 * infinite loops reasonably quickly.
sl@0
   241
 */
sl@0
   242
#define	MAXPATHLEN	PATH_MAX
sl@0
   243
#define MAXSYMLINKS	32
sl@0
   244
sl@0
   245
/* Bit map related macros. */
sl@0
   246
#define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
sl@0
   247
#define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
sl@0
   248
#define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
sl@0
   249
#define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
sl@0
   250
sl@0
   251
/* Macros for counting and rounding. */
sl@0
   252
#ifndef howmany
sl@0
   253
#define	howmany(x, y)	(((x)+((y)-1))/(y))
sl@0
   254
#endif
sl@0
   255
#define	rounddown(x, y)	(((x)/(y))*(y))
sl@0
   256
#define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
sl@0
   257
#define	roundup2(x, y)	(((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
sl@0
   258
#define powerof2(x)	((((x)-1)&(x))==0)
sl@0
   259
sl@0
   260
/* Macros for min/max. */
sl@0
   261
#define	MIN(a,b) (((a)<(b))?(a):(b))
sl@0
   262
#define	MAX(a,b) (((a)>(b))?(a):(b))
sl@0
   263
sl@0
   264
#ifdef _KERNEL
sl@0
   265
/*
sl@0
   266
 * Basic byte order function prototypes for non-inline functions.
sl@0
   267
 */
sl@0
   268
#ifndef _BYTEORDER_PROTOTYPED
sl@0
   269
#define	_BYTEORDER_PROTOTYPED
sl@0
   270
__BEGIN_DECLS
sl@0
   271
__uint32_t	 htonl(__uint32_t);
sl@0
   272
__uint16_t	 htons(__uint16_t);
sl@0
   273
__uint32_t	 ntohl(__uint32_t);
sl@0
   274
__uint16_t	 ntohs(__uint16_t);
sl@0
   275
__END_DECLS
sl@0
   276
#endif
sl@0
   277
sl@0
   278
#ifndef lint
sl@0
   279
#ifndef _BYTEORDER_FUNC_DEFINED
sl@0
   280
#define	_BYTEORDER_FUNC_DEFINED
sl@0
   281
#define	htonl(x)	__htonl(x)
sl@0
   282
#define	htons(x)	__htons(x)
sl@0
   283
#define	ntohl(x)	__ntohl(x)
sl@0
   284
#define	ntohs(x)	__ntohs(x)
sl@0
   285
#endif /* !_BYTEORDER_FUNC_DEFINED */
sl@0
   286
#endif /* lint */
sl@0
   287
#endif /* _KERNEL */
sl@0
   288
sl@0
   289
/*
sl@0
   290
 * Constants for setting the parameters of the kernel memory allocator.
sl@0
   291
 *
sl@0
   292
 * 2 ** MINBUCKET is the smallest unit of memory that will be
sl@0
   293
 * allocated. It must be at least large enough to hold a pointer.
sl@0
   294
 *
sl@0
   295
 * Units of memory less or equal to MAXALLOCSAVE will permanently
sl@0
   296
 * allocate physical memory; requests for these size pieces of
sl@0
   297
 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
sl@0
   298
 * always allocate and free physical memory; requests for these
sl@0
   299
 * size allocations should be done infrequently as they will be slow.
sl@0
   300
 *
sl@0
   301
 * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
sl@0
   302
 * MAXALLOCSIZE must be a power of two.
sl@0
   303
 */
sl@0
   304
#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__)
sl@0
   305
#define MINBUCKET	5		/* 5 => min allocation of 32 bytes */
sl@0
   306
#else
sl@0
   307
#define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
sl@0
   308
#endif
sl@0
   309
#define MAXALLOCSAVE	(2 * PAGE_SIZE)
sl@0
   310
sl@0
   311
/*
sl@0
   312
 * Scale factor for scaled integers used to count %cpu time and load avgs.
sl@0
   313
 *
sl@0
   314
 * The number of CPU `tick's that map to a unique `%age' can be expressed
sl@0
   315
 * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
sl@0
   316
 * can be calculated (assuming 32 bits) can be closely approximated using
sl@0
   317
 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
sl@0
   318
 *
sl@0
   319
 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
sl@0
   320
 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
sl@0
   321
 */
sl@0
   322
#define	FSHIFT	11		/* bits to right of fixed binary point */
sl@0
   323
#define FSCALE	(1<<FSHIFT)
sl@0
   324
sl@0
   325
#define dbtoc(db)			/* calculates devblks to pages */ \
sl@0
   326
	((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
sl@0
   327
 
sl@0
   328
#define ctodb(db)			/* calculates pages to devblks */ \
sl@0
   329
	((db) << (PAGE_SHIFT - DEV_BSHIFT))
sl@0
   330
sl@0
   331
#endif	/* _SYS_PARAM_H_ */