source: rtems-libbsd/rtemsbsd/include/rtems/bsd/sys/param.h @ efc782b

55-freebsd-126-freebsd-12
Last change on this file since efc782b was efc782b, checked in by Christian Mauderer <Christian.Mauderer@…>, on 12/12/16 at 11:31:33

Port IEEE 802.11.

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