···2727/* If we're hosted, fall back to the system's stdatomic.h. FreeBSD, for
2828 * example, already has a Clang-compatible stdatomic.h header.
2929 */
3030-#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
3030+#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>) && 0
3131# include_next <stdatomic.h>
3232#else
3333
+66
platform-include/i386/atomic.h
···11+/*
22+ * Copyright (c) 2015 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _I386_ATOMIC_H_
3030+#define _I386_ATOMIC_H_
3131+3232+#include <i386/smp.h>
3333+3434+#if __SMP__
3535+3636+#define memory_order_consume_smp memory_order_consume
3737+#define memory_order_acquire_smp memory_order_acquire
3838+#define memory_order_release_smp memory_order_release
3939+#define memory_order_acq_rel_smp memory_order_acq_rel
4040+#define memory_order_seq_cst_smp memory_order_seq_cst
4141+4242+#else
4343+4444+#define memory_order_consume_smp memory_order_relaxed
4545+#define memory_order_acquire_smp memory_order_relaxed
4646+#define memory_order_release_smp memory_order_relaxed
4747+#define memory_order_acq_rel_smp memory_order_relaxed
4848+#define memory_order_seq_cst_smp memory_order_relaxed
4949+5050+#endif
5151+5252+#ifdef ATOMIC_PRIVATE
5353+5454+static boolean_t
5555+atomic_compare_exchange(uintptr_t *target, uintptr_t oldval, uintptr_t newval,
5656+ enum memory_order ord, boolean_t wait)
5757+{
5858+ (void)wait;
5959+ return __c11_atomic_compare_exchange_strong((_Atomic uintptr_t *)target, &oldval, newval, ord, memory_order_relaxed);
6060+}
6161+6262+#endif // ATOMIC_PRIVATE
6363+6464+6565+#endif // _I386_ATOMIC_H_
6666+
+35
platform-include/i386/smp.h
···11+/*
22+ * Copyright (c) 2014 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _I386_SMP_H_
3030+#define _I386_SMP_H_
3131+3232+/* x86_64 kernels are always built SMP, even if only 1 CPU is active */
3333+#define __SMP__ 1
3434+3535+#endif /* _I386_SMP_H_ */
+51
platform-include/machine/atomic.h
···11+/*
22+ * Copyright (c) 2015 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _MACHINE_ATOMIC_H
3030+#define _MACHINE_ATOMIC_H
3131+#include <stdatomic.h>
3232+3333+#if 0
3434+/* This should be in stdatomic.h once supported by compiler */
3535+enum memory_order {
3636+ memory_order_relaxed,
3737+ memory_order_consume,
3838+ memory_order_acquire,
3939+ memory_order_release,
4040+ memory_order_acq_rel,
4141+ memory_order_seq_cst
4242+};
4343+#endif
4444+4545+#if defined (__x86_64__) || defined (__i386__)
4646+#include "i386/atomic.h"
4747+#else
4848+#error architecture not supported
4949+#endif
5050+5151+#endif /* _MACHINE_ATOMIC_H */
+419
platform-include/sys/spawn_internal.h
···11+/*
22+ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+3030+/*
3131+ * [SPN] Support for _POSIX_SPAWN
3232+ *
3333+ * This file contains internal data structures which are externally represented
3434+ * as opaque void pointers to prevent introspection. This permits us to
3535+ * change the underlying implementation of the code to maintain it or to
3636+ * support new features, as needed, without the consumer needing to recompile
3737+ * their code because of structure size changes or data reorganization.
3838+ */
3939+4040+#ifndef _SYS_SPAWN_INTERNAL_H_
4141+#define _SYS_SPAWN_INTERNAL_H_
4242+4343+#include <sys/_types.h> /* __offsetof(), __darwin_size_t */
4444+#include <sys/param.h>
4545+#include <sys/syslimits.h> /* PATH_MAX */
4646+#include <sys/spawn.h>
4747+#include <mach/machine.h>
4848+#include <mach/port.h>
4949+#include <mach/exception_types.h>
5050+#include <mach/coalition.h> /* COALITION_NUM_TYPES */
5151+5252+/*
5353+ * Allowable posix_spawn() port action types
5454+ */
5555+typedef enum {
5656+ PSPA_SPECIAL = 0,
5757+ PSPA_EXCEPTION = 1,
5858+ PSPA_AU_SESSION = 2,
5959+ PSPA_IMP_WATCHPORTS = 3,
6060+} pspa_t;
6161+6262+/*
6363+ * Internal representation of one port to be set on posix_spawn().
6464+ * Currently this is limited to setting special and exception ports,
6565+ * but could be extended to other inheritable port types.
6666+ */
6767+typedef struct _ps_port_action {
6868+ pspa_t port_type;
6969+ exception_mask_t mask;
7070+ mach_port_name_t new_port;
7171+ exception_behavior_t behavior;
7272+ thread_state_flavor_t flavor;
7373+ int which;
7474+} _ps_port_action_t;
7575+7676+/*
7777+ * A collection of port actions to take on the newly spawned process.
7878+ */
7979+typedef struct _posix_spawn_port_actions {
8080+ int pspa_alloc;
8181+ int pspa_count;
8282+ _ps_port_action_t pspa_actions[];
8383+} *_posix_spawn_port_actions_t;
8484+8585+/*
8686+ * Returns size in bytes of a _posix_spawn_port_actions holding x elements.
8787+ */
8888+#define PS_PORT_ACTIONS_SIZE(x) \
8989+ __offsetof(struct _posix_spawn_port_actions, pspa_actions[(x)])
9090+9191+#define NBINPREFS 4
9292+9393+/*
9494+ * Mapping of opaque data pointer to a MAC policy (specified by name).
9595+ */
9696+typedef struct _ps_mac_policy_extension {
9797+ char policyname[128];
9898+ union {
9999+ uint64_t data;
100100+ void *datap; /* pointer in kernel memory */
101101+ };
102102+ uint64_t datalen;
103103+} _ps_mac_policy_extension_t;
104104+105105+/*
106106+ * A collection of extra data passed to MAC policies for the newly spawned process.
107107+ */
108108+typedef struct _posix_spawn_mac_policy_extensions {
109109+ int psmx_alloc;
110110+ int psmx_count;
111111+ _ps_mac_policy_extension_t psmx_extensions[];
112112+} *_posix_spawn_mac_policy_extensions_t;
113113+114114+/*
115115+ * Returns size in bytes of a _posix_spawn_mac_policy_extensions holding x elements.
116116+ */
117117+#define PS_MAC_EXTENSIONS_SIZE(x) \
118118+ __offsetof(struct _posix_spawn_mac_policy_extensions, psmx_extensions[(x)])
119119+120120+#define PS_MAC_EXTENSIONS_INIT_COUNT 2
121121+122122+/*
123123+ * Coalition posix spawn attributes
124124+ */
125125+struct _posix_spawn_coalition_info {
126126+ struct {
127127+ uint64_t psci_id;
128128+ uint32_t psci_role;
129129+ uint32_t psci_reserved1;
130130+ uint64_t psci_reserved2;
131131+ } psci_info[COALITION_NUM_TYPES];
132132+};
133133+134134+/*
135135+ * Persona attributes
136136+ */
137137+struct _posix_spawn_persona_info {
138138+ uid_t pspi_id; /* persona ID (unix UID) */
139139+ uint32_t pspi_flags; /* spawn persona flags */
140140+ uid_t pspi_uid; /* alternate posix/unix UID */
141141+ gid_t pspi_gid; /* alternate posix/unix GID */
142142+ uint32_t pspi_ngroups; /* alternate advisory groups */
143143+ gid_t pspi_groups[NGROUPS];
144144+ uid_t pspi_gmuid; /* group membership UID */
145145+};
146146+147147+#define POSIX_SPAWN_PERSONA_FLAGS_NONE 0x0
148148+#define POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE 0x1
149149+#define POSIX_SPAWN_PERSONA_FLAGS_VERIFY 0x2
150150+151151+#define POSIX_SPAWN_PERSONA_ALL_FLAGS \
152152+ (POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE \
153153+ | POSIX_SPAWN_PERSONA_FLAGS_VERIFY \
154154+ )
155155+156156+#define POSIX_SPAWN_PERSONA_UID 0x00010000
157157+#define POSIX_SPAWN_PERSONA_GID 0x00020000
158158+#define POSIX_SPAWN_PERSONA_GROUPS 0x00040000
159159+160160+161161+/*
162162+ * A posix_spawnattr structure contains all of the attribute elements that
163163+ * can be set, as well as any metadata whose validity is signalled by the
164164+ * presence of a bit in the flags field. All fields are initialized to the
165165+ * appropriate default values by posix_spawnattr_init().
166166+ */
167167+168168+typedef struct _posix_spawnattr {
169169+ short psa_flags; /* spawn attribute flags */
170170+ short flags_padding; /* get the flags to be int aligned */
171171+ sigset_t psa_sigdefault; /* signal set to default */
172172+ sigset_t psa_sigmask; /* signal set to mask */
173173+ pid_t psa_pgroup; /* pgroup to spawn into */
174174+ cpu_type_t psa_binprefs[NBINPREFS]; /* cpu affinity prefs*/
175175+ int psa_pcontrol; /* process control bits on resource starvation */
176176+ int psa_apptype; /* app type and process spec behav */
177177+ uint64_t psa_cpumonitor_percent; /* CPU usage monitor percentage */
178178+ uint64_t psa_cpumonitor_interval; /* CPU usage monitor interval, in seconds */
179179+ uint64_t psa_reserved;
180180+181181+ short psa_jetsam_flags; /* jetsam flags */
182182+ short short_padding; /* Padding for alignment issues */
183183+ int psa_priority; /* jetsam relative importance */
184184+ int psa_memlimit_active; /* jetsam memory limit (in MB) when process is active */
185185+ int psa_memlimit_inactive; /* jetsam memory limit (in MB) when process is inactive */
186186+187187+ uint64_t psa_qos_clamp; /* QoS Clamp to set on the new process */
188188+ uint64_t psa_darwin_role; /* PRIO_DARWIN_ROLE to set on the new process */
189189+190190+ /*
191191+ * NOTE: Extensions array pointers must stay at the end so that
192192+ * everything above this point stays the same size on different bitnesses
193193+ * see <rdar://problem/12858307>
194194+ */
195195+ _posix_spawn_port_actions_t psa_ports; /* special/exception ports */
196196+ _posix_spawn_mac_policy_extensions_t psa_mac_extensions; /* MAC policy-specific extensions. */
197197+ struct _posix_spawn_coalition_info *psa_coalition_info; /* coalition info */
198198+ struct _posix_spawn_persona_info *psa_persona_info; /* spawn new process into given persona */
199199+} *_posix_spawnattr_t;
200200+201201+/*
202202+ * Jetsam flags eg: psa_jetsam_flags
203203+ */
204204+#define POSIX_SPAWN_JETSAM_SET 0x8000
205205+206206+#define POSIX_SPAWN_JETSAM_USE_EFFECTIVE_PRIORITY 0x01
207207+#define POSIX_SPAWN_JETSAM_HIWATER_BACKGROUND 0x02 /* to be deprecated */
208208+#define POSIX_SPAWN_JETSAM_MEMLIMIT_FATAL 0x04 /* to be deprecated */
209209+210210+/*
211211+ * Additional flags available for use with
212212+ * the posix_spawnattr_setjetsam_ext() call
213213+ */
214214+#define POSIX_SPAWN_JETSAM_MEMLIMIT_ACTIVE_FATAL 0x04 /* if set, limit is fatal when the process is active */
215215+#define POSIX_SPAWN_JETSAM_MEMLIMIT_INACTIVE_FATAL 0x08 /* if set, limit is fatal when the process is inactive */
216216+217217+/*
218218+ * Deprecated posix_spawn psa_flags values
219219+ *
220220+ * POSIX_SPAWN_OSX_TALAPP_START 0x0400
221221+ * POSIX_SPAWN_IOS_RESV1_APP_START 0x0400
222222+ * POSIX_SPAWN_IOS_APPLE_DAEMON_START 0x0800
223223+ * POSIX_SPAWN_IOS_APP_START 0x1000
224224+ * POSIX_SPAWN_OSX_WIDGET_START 0x0800
225225+ * POSIX_SPAWN_OSX_DBCLIENT_START 0x0800
226226+ * POSIX_SPAWN_OSX_RESVAPP_START 0x1000
227227+ */
228228+229229+/*
230230+ * Deprecated posix_spawn psa_apptype values
231231+ *
232232+ * POSIX_SPAWN_PROCESS_TYPE_APPLEDAEMON 0x00000001
233233+ * POSIX_SPAWN_PROCESS_TYPE_UIAPP 0x00000002
234234+ * POSIX_SPAWN_PROCESS_TYPE_ADAPTIVE 0x00000004
235235+ * POSIX_SPAWN_PROCESS_TYPE_TAL 0x00000001
236236+ * POSIX_SPAWN_PROCESS_TYPE_WIDGET 0x00000002
237237+ * POSIX_SPAWN_PROCESS_TYPE_DELAYIDLESLEEP 0x10000000
238238+ *
239239+ * POSIX_SPAWN_PROCESS_FLAG_IMPORTANCE_DONOR 0x00000010
240240+ * POSIX_SPAWN_PROCESS_FLAG_ADAPTIVE 0x00000020
241241+ * POSIX_SPAWN_PROCESS_FLAG_START_BACKGROUND 0x00000040
242242+ * POSIX_SPAWN_PROCESS_FLAG_START_LIGHT_THROTTLE 0x00000080
243243+ */
244244+245245+/*
246246+ * posix_spawn psa_apptype process type settings.
247247+ * when POSIX_SPAWN_PROC_TYPE is set, old psa_apptype bits are ignored
248248+ */
249249+250250+#define POSIX_SPAWN_PROCESS_TYPE_NORMAL 0x00000000
251251+#define POSIX_SPAWN_PROCESS_TYPE_DEFAULT POSIX_SPAWN_PROCESS_TYPE_NORMAL
252252+253253+#define POSIX_SPAWN_PROC_TYPE_MASK 0x00000F00
254254+255255+#define POSIX_SPAWN_PROC_TYPE_APP_DEFAULT 0x00000100
256256+#define POSIX_SPAWN_PROC_TYPE_APP_TAL 0x00000200
257257+258258+#define POSIX_SPAWN_PROC_TYPE_DAEMON_STANDARD 0x00000300
259259+#define POSIX_SPAWN_PROC_TYPE_DAEMON_INTERACTIVE 0x00000400
260260+#define POSIX_SPAWN_PROC_TYPE_DAEMON_BACKGROUND 0x00000500
261261+#define POSIX_SPAWN_PROC_TYPE_DAEMON_ADAPTIVE 0x00000600
262262+263263+#define POSIX_SPAWN_PROC_CLAMP_NONE 0x00000000
264264+#define POSIX_SPAWN_PROC_CLAMP_UTILITY 0x00000001
265265+#define POSIX_SPAWN_PROC_CLAMP_BACKGROUND 0x00000002
266266+#define POSIX_SPAWN_PROC_CLAMP_MAINTENANCE 0x00000003
267267+#define POSIX_SPAWN_PROC_CLAMP_LAST 0x00000004
268268+269269+/* Setting to indicate no change to darwin role */
270270+#define POSIX_SPAWN_DARWIN_ROLE_NONE 0x00000000
271271+/* Other possible values are specified by PRIO_DARWIN_ROLE in sys/resource.h */
272272+273273+/*
274274+ * Allowable posix_spawn() file actions
275275+ */
276276+typedef enum {
277277+ PSFA_OPEN = 0,
278278+ PSFA_CLOSE = 1,
279279+ PSFA_DUP2 = 2,
280280+ PSFA_INHERIT = 3
281281+} psfa_t;
282282+283283+284284+/*
285285+ * A posix_spawn() file action record for a single action
286286+ *
287287+ * Notes: We carry around the full open arguments for both the open
288288+ * and the close to permit the use of a single array of action
289289+ * elements to be associated with a file actions object.
290290+ *
291291+ * A possible future optimization would be to break this into
292292+ * a variable sized vector list to save space (i.e. a separate
293293+ * string area, allocation of least amount of path buffer per
294294+ * open action, etc.).
295295+ *
296296+ * XXX: Currently overloading psfao_oflag for PSFA_DUP2
297297+ */
298298+typedef struct _psfa_action {
299299+ psfa_t psfaa_type; /* file action type */
300300+ int psfaa_filedes; /* fd to operate on */
301301+ struct _psfaa_open {
302302+ int psfao_oflag; /* open flags to use */
303303+ mode_t psfao_mode; /* mode for open */
304304+ char psfao_path[PATH_MAX]; /* path to open */
305305+ } psfaa_openargs;
306306+} _psfa_action_t;
307307+308308+309309+/*
310310+ * Internal representation of posix_spawn() file actions structure
311311+ *
312312+ * Notes: This is implemented as a structure followed by an array of
313313+ * file action records. The psfa_act_alloc value is the number
314314+ * of elements allocated in this array, and the psfa_act_count is
315315+ * the number of elements currently in use (to permit some form
316316+ * of preallocation, e.g. a power of 2 growth for reallocation,
317317+ * etc.).
318318+ *
319319+ * A possible future optimization would keep a size value and
320320+ * a structure base reference pointer to permit copyin to the
321321+ * kernel directly as a single blob, without damaging relative
322322+ * internal pointer math. It's probably better that this be a
323323+ * long long rather than a true pointer, to make it invariant
324324+ * for 32 vs. 64 bt programming SPIs.
325325+ */
326326+typedef struct _posix_spawn_file_actions {
327327+ int psfa_act_alloc; /* available actions space */
328328+ int psfa_act_count; /* count of defined actions */
329329+ _psfa_action_t psfa_act_acts[]; /* actions array (uses c99) */
330330+} *_posix_spawn_file_actions_t;
331331+332332+/*
333333+ * Calculate the size of a structure, given the number of elements that it is
334334+ * capable of containing.
335335+ */
336336+#define PSF_ACTIONS_SIZE(x) \
337337+ __offsetof(struct _posix_spawn_file_actions, psfa_act_acts[(x)])
338338+339339+/*
340340+ * Initial count of actions in a struct _posix_spawn_file_actions after it is
341341+ * first allocated; this should be non-zero, since we expect that one would not
342342+ * have been allocated unless there was an intent to use it.
343343+ */
344344+#define PSF_ACTIONS_INIT_COUNT 2
345345+346346+/*
347347+ * Structure defining the true third argument to the posix_spawn() system call
348348+ * entry point; we wrap it and pass a descriptor so that we can know the
349349+ * copyin size ahead of time, and deal with copying in variant lists of things
350350+ * as single monolithic units, instead of many individual elements. This is a
351351+ * performance optimization.
352352+ */
353353+struct _posix_spawn_args_desc {
354354+ __darwin_size_t attr_size; /* size of attributes block */
355355+ _posix_spawnattr_t attrp; /* pointer to block */
356356+ __darwin_size_t file_actions_size; /* size of file actions block */
357357+ _posix_spawn_file_actions_t
358358+ file_actions; /* pointer to block */
359359+ __darwin_size_t port_actions_size; /* size of port actions block */
360360+ _posix_spawn_port_actions_t
361361+ port_actions; /* pointer to port block */
362362+ __darwin_size_t mac_extensions_size;
363363+ _posix_spawn_mac_policy_extensions_t
364364+ mac_extensions; /* pointer to policy-specific
365365+ * attributes */
366366+ __darwin_size_t coal_info_size;
367367+ struct _posix_spawn_coalition_info *coal_info; /* pointer to coalition info */
368368+369369+ __darwin_size_t persona_info_size;
370370+ struct _posix_spawn_persona_info *persona_info;
371371+};
372372+373373+#ifdef KERNEL
374374+#include <sys/appleapiopts.h>
375375+#ifdef __APPLE_API_PRIVATE
376376+377377+#if __DARWIN_ALIGN_NATURAL
378378+#pragma options align=natural
379379+#endif
380380+381381+struct user32__posix_spawn_args_desc {
382382+ uint32_t attr_size; /* size of attributes block */
383383+ uint32_t attrp; /* pointer to block */
384384+ uint32_t file_actions_size; /* size of file actions block */
385385+ uint32_t file_actions; /* pointer to block */
386386+ uint32_t port_actions_size; /* size of port actions block */
387387+ uint32_t port_actions; /* pointer to block */
388388+ uint32_t mac_extensions_size;
389389+ uint32_t mac_extensions;
390390+ uint32_t coal_info_size;
391391+ uint32_t coal_info;
392392+ uint32_t persona_info_size;
393393+ uint32_t persona_info;
394394+};
395395+396396+struct user__posix_spawn_args_desc {
397397+ user_size_t attr_size; /* size of attributes block */
398398+ user_addr_t attrp; /* pointer to block */
399399+ user_size_t file_actions_size; /* size of file actions block */
400400+ user_addr_t file_actions; /* pointer to block */
401401+ user_size_t port_actions_size; /* size of port actions block */
402402+ user_addr_t port_actions; /* pointer to block */
403403+ user_size_t mac_extensions_size; /* size of MAC-specific attrs. */
404404+ user_addr_t mac_extensions; /* pointer to block */
405405+ user_size_t coal_info_size;
406406+ user_addr_t coal_info;
407407+ user_size_t persona_info_size;
408408+ user_addr_t persona_info;
409409+};
410410+411411+412412+#if __DARWIN_ALIGN_NATURAL
413413+#pragma options align=reset
414414+#endif
415415+416416+#endif /* __APPLE_API_PRIVATE */
417417+#endif /* KERNEL */
418418+419419+#endif /* _SYS_SPAWN_INTERNAL_H_ */