authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-08 20:07:14-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-08 20:21:29-08:00
log16b7be34a1cc78ea3c2b6c89236eae3a7529c8a7
tree3deeed19c09ad2ec051e35bf6339814cba6a55b6
parent1213e26ba8b88bd18e9653b571d60a030dbe2a93

macOS libc headers: add sys/param.h

libcxx depends on it

3 files changed, 464 insertions(+), 0 deletions(-)

lib/libc/include/x86_64-macos-gnu/i386/param.h created+171
......@@ -0,0 +1,171 @@
1/*
2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*-
29 * Copyright (c) 1990, 1993
30 * The Regents of the University of California. All rights reserved.
31 * (c) UNIX System Laboratories, Inc.
32 * All or some portions of this file are derived from material licensed
33 * to the University of California by American Telephone and Telegraph
34 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
35 * the permission of UNIX System Laboratories, Inc.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE.
64 *
65 * @(#)param.h 8.1 (Berkeley) 4/4/95
66 */
67
68/*
69 * Machine dependent constants for Intel 386.
70 */
71
72#ifndef _I386_PARAM_H_
73#define _I386_PARAM_H_
74
75#include <i386/_param.h>
76
77/*
78 * Round p (pointer or byte index) up to a correctly-aligned value for all
79 * data types (int, long, ...). The result is unsigned int and must be
80 * cast to any desired pointer type.
81 */
82#define ALIGNBYTES __DARWIN_ALIGNBYTES
83#define ALIGN(p) __DARWIN_ALIGN(p)
84
85#define NBPG 4096 /* bytes/page */
86#define PGOFSET (NBPG-1) /* byte offset into page */
87#define PGSHIFT 12 /* LOG2(NBPG) */
88
89#define DEV_BSIZE 512
90#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
91#define BLKDEV_IOSIZE 2048
92#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
93
94#define CLSIZE 1
95#define CLSIZELOG2 0
96
97/*
98 * Constants related to network buffer management.
99 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
100 * on machines that exchange pages of input or output buffers with mbuf
101 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
102 * of the hardware page size.
103 */
104#define MSIZESHIFT 8 /* 256 */
105#define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */
106#define MCLSHIFT 11 /* 2048 */
107#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */
108#define MBIGCLSHIFT 12 /* 4096 */
109#define MBIGCLBYTES (1 << MBIGCLSHIFT) /* size of a big cluster */
110#define M16KCLSHIFT 14 /* 16384 */
111#define M16KCLBYTES (1 << M16KCLSHIFT) /* size of a jumbo cluster */
112
113#define MCLOFSET (MCLBYTES - 1)
114#ifndef NMBCLUSTERS
115#define NMBCLUSTERS ((1024 * 1024) / MCLBYTES) /* cl map size: 1MB */
116#endif
117
118/*
119 * Some macros for units conversion
120 */
121/* Core clicks (NeXT_page_size bytes) to segments and vice versa */
122#define ctos(x) (x)
123#define stoc(x) (x)
124
125/* Core clicks (4096 bytes) to disk blocks */
126#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
127#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
128#define dtob(x) ((x)<<DEV_BSHIFT)
129
130/* clicks to bytes */
131#define ctob(x) ((x)<<PGSHIFT)
132
133/* bytes to clicks */
134#define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
135
136#ifdef __APPLE__
137#define btodb(bytes, devBlockSize) \
138 ((unsigned)(bytes) / devBlockSize)
139#define dbtob(db, devBlockSize) \
140 ((unsigned)(db) * devBlockSize)
141#else
142#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
143 ((unsigned)(bytes) >> DEV_BSHIFT)
144#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
145 ((unsigned)(db) << DEV_BSHIFT)
146#endif
147
148/*
149 * Map a ``block device block'' to a file system block.
150 * This should be device dependent, and will be if we
151 * add an entry to cdevsw/bdevsw for that purpose.
152 * For now though just use DEV_BSIZE.
153 */
154#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
155
156/*
157 * Macros to decode (and encode) processor status word.
158 */
159#define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl))
160#define USERMODE(x) (((x) & 3) == 3)
161#define BASEPRI(x) (((x) & (255 << 8)) == 0)
162
163
164#if defined(KERNEL) || defined(STANDALONE)
165#define DELAY(n) delay(n)
166
167#else /* defined(KERNEL) || defined(STANDALONE) */
168#define DELAY(n) { int N = (n); while (--N > 0); }
169#endif /* defined(KERNEL) || defined(STANDALONE) */
170
171#endif /* _I386_PARAM_H_ */
lib/libc/include/x86_64-macos-gnu/machine/param.h created+40
......@@ -0,0 +1,40 @@
1/*
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * Copyright 1995 NeXT Computer, Inc. All rights reserved.
30 */
31#ifndef _BSD_MACHINE_PARAM_H_
32#define _BSD_MACHINE_PARAM_H_
33
34#if defined (__i386__) || defined(__x86_64__)
35#include "i386/param.h"
36#else
37#error architecture not supported
38#endif
39
40#endif /* _BSD_MACHINE_PARAM_H_ */
lib/libc/include/x86_64-macos-gnu/sys/param.h created+253
......@@ -0,0 +1,253 @@
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/* Copyright (c) 1995, 1997 Apple Computer, Inc. All Rights Reserved */
29/*-
30 * Copyright (c) 1982, 1986, 1989, 1993
31 * The Regents of the University of California. All rights reserved.
32 * (c) UNIX System Laboratories, Inc.
33 * All or some portions of this file are derived from material licensed
34 * to the University of California by American Telephone and Telegraph
35 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36 * the permission of UNIX System Laboratories, Inc.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)param.h 8.3 (Berkeley) 4/4/95
67 */
68
69#ifndef _SYS_PARAM_H_
70#define _SYS_PARAM_H_
71
72#define BSD 199506 /* System version (year & month). */
73#define BSD4_3 1
74#define BSD4_4 1
75
76#define NeXTBSD 1995064 /* NeXTBSD version (year, month, release) */
77#define NeXTBSD4_0 0 /* NeXTBSD 4.0 */
78
79#include <sys/_types.h>
80#include <sys/_types/_null.h>
81
82#ifndef LOCORE
83#include <sys/types.h>
84#endif
85
86/*
87 * Machine-independent constants (some used in following include files).
88 * Redefined constants are from POSIX 1003.1 limits file.
89 *
90 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
91 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
92 */
93#include <sys/syslimits.h>
94
95#define MAXCOMLEN 16 /* max command name remembered */
96#define MAXINTERP 64 /* max interpreter file name length */
97#define MAXLOGNAME 255 /* max login name length */
98#define MAXUPRC CHILD_MAX /* max simultaneous processes */
99#define NCARGS ARG_MAX /* max bytes for an exec function */
100#define NGROUPS NGROUPS_MAX /* max number groups */
101#define NOFILE 256 /* default max open files per process */
102#define NOGROUP 65535 /* marker for empty group set member */
103#define MAXHOSTNAMELEN 256 /* max hostname size */
104#define MAXDOMNAMELEN 256 /* maximum domain name length */
105
106/* Machine type dependent parameters. */
107#include <machine/param.h>
108
109/* More types and definitions used throughout the kernel. */
110#include <limits.h>
111
112/* Signals. */
113#include <sys/signal.h>
114
115/*
116 * Priorities. Note that with 32 run queues, differences less than 4 are
117 * insignificant.
118 */
119#define PSWP 0
120#define PVM 4
121#define PINOD 8
122#define PRIBIO 16
123#define PVFS 20
124#define PZERO 22 /* No longer magic, shouldn't be here. XXX */
125#define PSOCK 24
126#define PWAIT 32
127#define PLOCK 36
128#define PPAUSE 40
129#define PUSER 50
130#define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
131
132#define PRIMASK 0x0ff
133#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
134#define PTTYBLOCK 0x200 /* for tty SIGTTOU and SIGTTIN blocking */
135#define PDROP 0x400 /* OR'd with pri to stop re-aquistion of mutex upon wakeup */
136#define PSPIN 0x800 /* OR'd with pri to require mutex in spin mode upon wakeup */
137
138#define NBPW sizeof(int) /* number of bytes per word (integer) */
139
140#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
141#define NODEV (dev_t)(-1) /* non-existent device */
142
143/*
144 * Clustering of hardware pages on machines with ridiculously small
145 * page sizes is done here. The paging subsystem deals with units of
146 * CLSIZE pte's describing NBPG (from machine/param.h) pages each.
147 */
148#define CLBYTES (CLSIZE*NBPG)
149#define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
150#define claligned(x) ((((int)(x))&CLOFSET)==0)
151#define CLOFF CLOFSET
152#define CLSHIFT (PGSHIFT+CLSIZELOG2)
153
154#if CLSIZE == 1
155#define clbase(i) (i)
156#define clrnd(i) (i)
157#else
158/* Give the base virtual address (first of CLSIZE). */
159#define clbase(i) ((i) &~ (CLSIZE-1))
160/* Round a number of clicks up to a whole cluster. */
161#define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
162#endif
163
164#define CBLOCK 64 /* Clist block size, must be a power of 2. */
165#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
166 /* Data chars/clist. */
167#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
168#define CROUND (CBLOCK - 1) /* Clist rounding. */
169
170/*
171 * File system parameters and macros.
172 *
173 * The file system is made out of blocks of at most MAXPHYS units, with
174 * smaller units (fragments) only in the last direct block. MAXBSIZE
175 * primarily determines the size of buffers in the buffer pool. It may be
176 * made larger than MAXPHYS without any effect on existing file systems;
177 * however making it smaller may make some file systems unmountable.
178 * We set this to track the value of MAX_UPL_TRANSFER_BYTES from
179 * osfmk/mach/memory_object_types.h to bound it at the maximum UPL size.
180 */
181#define MAXBSIZE (256 * 4096)
182#define MAXPHYSIO MAXPHYS
183#define MAXFRAG 8
184
185#define MAXPHYSIO_WIRED (16 * 1024 * 1024)
186
187/*
188 * MAXPATHLEN defines the longest permissable path length after expanding
189 * symbolic links. It is used to allocate a temporary buffer from the buffer
190 * pool in which to do the name expansion, hence should be a power of two,
191 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
192 * maximum number of symbolic links that may be expanded in a path name.
193 * It should be set high enough to allow all legitimate uses, but halt
194 * infinite loops reasonably quickly.
195 */
196#define MAXPATHLEN PATH_MAX
197#define MAXSYMLINKS 32
198
199/* Bit map related macros. */
200#define setbit(a, i) (((char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
201#define clrbit(a, i) (((char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
202#define isset(a, i) (((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
203#define isclr(a, i) ((((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
204
205/* Macros for counting and rounding. */
206#ifndef howmany
207#define howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1))
208#endif
209#define roundup(x, y) ((((x) % (y)) == 0) ? \
210 (x) : ((x) + ((y) - ((x) % (y)))))
211#define powerof2(x) ((((x)-1)&(x))==0)
212
213/* Macros for min/max. */
214#ifndef MIN
215#define MIN(a, b) (((a)<(b))?(a):(b))
216#endif /* MIN */
217#ifndef MAX
218#define MAX(a, b) (((a)>(b))?(a):(b))
219#endif /* MAX */
220
221/*
222 * Constants for setting the parameters of the kernel memory allocator.
223 *
224 * 2 ** MINBUCKET is the smallest unit of memory that will be
225 * allocated. It must be at least large enough to hold a pointer.
226 *
227 * Units of memory less or equal to MAXALLOCSAVE will permanently
228 * allocate physical memory; requests for these size pieces of
229 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
230 * always allocate and free physical memory; requests for these
231 * size allocations should be done infrequently as they will be slow.
232 *
233 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
234 * MAXALLOCSIZE must be a power of two.
235 */
236#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
237#define MAXALLOCSAVE (2 * CLBYTES)
238
239/*
240 * Scale factor for scaled integers used to count %cpu time and load avgs.
241 *
242 * The number of CPU `tick's that map to a unique `%age' can be expressed
243 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
244 * can be calculated (assuming 32 bits) can be closely approximated using
245 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
246 *
247 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
248 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
249 */
250#define FSHIFT 11 /* bits to right of fixed binary point */
251#define FSCALE (1<<FSHIFT)
252
253#endif /* _SYS_PARAM_H_ */