authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-03-12 17:45:20+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-03-12 18:05:50+01:00
loga745e704f6ded6cf1ec02e9666cac554697f69ff
tree0c5de3467dd8084b663308dd813fb75d9cfcfbd5
parent89e522b935a8cca96b2e6d0cce0515a1eb8e6451

macos: add missing x86_64 libc headers


12 files changed, 2208 insertions(+), 0 deletions(-)

lib/libc/include/x86_64-macos-gnu/libproc.h created+187
......@@ -0,0 +1,187 @@
1/*
2 * Copyright (c) 2006, 2007, 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23#ifndef _LIBPROC_H_
24#define _LIBPROC_H_
25
26#include <sys/cdefs.h>
27#include <sys/param.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <sys/mount.h>
31#include <sys/resource.h>
32#include <stdint.h>
33#include <stdbool.h>
34#include <mach/message.h> /* for audit_token_t */
35
36#include <sys/proc_info.h>
37
38#include <Availability.h>
39#include <os/availability.h>
40
41/*
42 * This header file contains private interfaces to obtain process information.
43 * These interfaces are subject to change in future releases.
44 */
45
46/*!
47 * @define PROC_LISTPIDSPATH_PATH_IS_VOLUME
48 * @discussion This flag indicates that all processes that hold open
49 * file references on the volume associated with the specified
50 * path should be returned.
51 */
52#define PROC_LISTPIDSPATH_PATH_IS_VOLUME 1
53
54
55/*!
56 * @define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY
57 * @discussion This flag indicates that file references that were opened
58 * with the O_EVTONLY flag should be excluded from the matching
59 * criteria.
60 */
61#define PROC_LISTPIDSPATH_EXCLUDE_EVTONLY 2
62
63__BEGIN_DECLS
64
65
66/*!
67 * @function proc_listpidspath
68 * @discussion A function which will search through the current
69 * processes looking for open file references which match
70 * a specified path or volume.
71 * @param type types of processes to be searched (see proc_listpids)
72 * @param typeinfo adjunct information for type
73 * @param path file or volume path
74 * @param pathflags flags to control which files should be considered
75 * during the process search.
76 * @param buffer a C array of int-sized values to be filled with
77 * process identifiers that hold an open file reference
78 * matching the specified path or volume. Pass NULL to
79 * obtain the minimum buffer size needed to hold the
80 * currently active processes.
81 * @param buffersize the size (in bytes) of the provided buffer.
82 * @result the number of bytes of data returned in the provided buffer;
83 * -1 if an error was encountered;
84 */
85int proc_listpidspath(uint32_t type,
86 uint32_t typeinfo,
87 const char *path,
88 uint32_t pathflags,
89 void *buffer,
90 int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
91
92int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
93int proc_listallpids(void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
94int proc_listpgrppids(pid_t pgrpid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
95int proc_listchildpids(pid_t ppid, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_1);
96int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
97int proc_pidfdinfo(int pid, int fd, int flavor, void * buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
98int proc_pidfileportinfo(int pid, uint32_t fileport, int flavor, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
99int proc_name(int pid, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
100int proc_regionfilename(int pid, uint64_t address, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
101int proc_kmsgbuf(void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
102int proc_pidpath(int pid, void * buffer, uint32_t buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
103int proc_pidpath_audittoken(audit_token_t *audittoken, void * buffer, uint32_t buffersize) API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));
104int proc_libversion(int *major, int * minor) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
105
106/*
107 * Return resource usage information for the given pid, which can be a live process or a zombie.
108 *
109 * Returns 0 on success; or -1 on failure, with errno set to indicate the specific error.
110 */
111int proc_pid_rusage(int pid, int flavor, rusage_info_t *buffer) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
112
113/*
114 * A process can use the following api to set its own process control
115 * state on resoure starvation. The argument can have one of the PROC_SETPC_XX values
116 */
117#define PROC_SETPC_NONE 0
118#define PROC_SETPC_THROTTLEMEM 1
119#define PROC_SETPC_SUSPEND 2
120#define PROC_SETPC_TERMINATE 3
121
122int proc_setpcontrol(const int control) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
123int proc_setpcontrol(const int control);
124
125int proc_track_dirty(pid_t pid, uint32_t flags);
126int proc_set_dirty(pid_t pid, bool dirty);
127int proc_get_dirty(pid_t pid, uint32_t *flags);
128int proc_clear_dirty(pid_t pid, uint32_t flags);
129
130int proc_terminate(pid_t pid, int *sig);
131
132/*
133 * NO_SMT means that on an SMT CPU, this thread must be scheduled alone,
134 * with the paired CPU idle.
135 *
136 * Set NO_SMT on the current proc (all existing and future threads)
137 * This attribute is inherited on fork and exec
138 */
139int proc_set_no_smt(void) __API_AVAILABLE(macos(11.0));
140
141/* Set NO_SMT on the current thread */
142int proc_setthread_no_smt(void) __API_AVAILABLE(macos(11.0));
143
144/*
145 * CPU Security Mitigation APIs
146 *
147 * Set CPU security mitigation on the current proc (all existing and future threads)
148 * This attribute is inherited on fork and exec
149 */
150int proc_set_csm(uint32_t flags) __API_AVAILABLE(macos(11.0));
151
152/* Set CPU security mitigation on the current thread */
153int proc_setthread_csm(uint32_t flags) __API_AVAILABLE(macos(11.0));
154
155/*
156 * flags for CPU Security Mitigation APIs
157 * PROC_CSM_ALL should be used in most cases,
158 * the individual flags are provided only for performance evaluation etc
159 */
160#define PROC_CSM_ALL 0x0001 /* Set all available mitigations */
161#define PROC_CSM_NOSMT 0x0002 /* Set NO_SMT - see above */
162#define PROC_CSM_TECS 0x0004 /* Execute VERW on every return to user mode */
163
164#ifdef PRIVATE
165#include <sys/event.h>
166/*
167 * Enumerate potential userspace pointers embedded in kernel data structures.
168 * Currently inspects kqueues only.
169 *
170 * NOTE: returned "pointers" are opaque user-supplied values and thus not
171 * guaranteed to address valid objects or be pointers at all.
172 *
173 * Returns the number of pointers found (which may exceed buffersize), or -1 on
174 * failure and errno set appropriately.
175 */
176int proc_list_uptrs(pid_t pid, uint64_t *buffer, uint32_t buffersize);
177
178int proc_list_dynkqueueids(int pid, kqueue_id_t *buf, uint32_t bufsz);
179int proc_piddynkqueueinfo(int pid, int flavor, kqueue_id_t kq_id, void *buffer,
180 int buffersize);
181#endif /* PRIVATE */
182
183int proc_udata_info(int pid, int flavor, void *buffer, int buffersize);
184
185__END_DECLS
186
187#endif /*_LIBPROC_H_ */
lib/libc/include/x86_64-macos-gnu/net/route.h created+257
......@@ -0,0 +1,257 @@
1/*
2 * Copyright (c) 2000-2017 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) 1980, 1986, 1993
30 * The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)route.h 8.3 (Berkeley) 4/19/94
61 * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $
62 */
63
64#ifndef _NET_ROUTE_H_
65#define _NET_ROUTE_H_
66#include <sys/appleapiopts.h>
67#include <stdint.h>
68#include <sys/types.h>
69#include <sys/socket.h>
70
71/*
72 * These numbers are used by reliable protocols for determining
73 * retransmission behavior and are included in the routing structure.
74 */
75struct rt_metrics {
76 u_int32_t rmx_locks; /* Kernel leaves these values alone */
77 u_int32_t rmx_mtu; /* MTU for this path */
78 u_int32_t rmx_hopcount; /* max hops expected */
79 int32_t rmx_expire; /* lifetime for route, e.g. redirect */
80 u_int32_t rmx_recvpipe; /* inbound delay-bandwidth product */
81 u_int32_t rmx_sendpipe; /* outbound delay-bandwidth product */
82 u_int32_t rmx_ssthresh; /* outbound gateway buffer limit */
83 u_int32_t rmx_rtt; /* estimated round trip time */
84 u_int32_t rmx_rttvar; /* estimated rtt variance */
85 u_int32_t rmx_pksent; /* packets sent using this route */
86 u_int32_t rmx_state; /* route state */
87 u_int32_t rmx_filler[3]; /* will be used for TCP's peer-MSS cache */
88};
89
90/*
91 * rmx_rtt and rmx_rttvar are stored as microseconds;
92 */
93#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */
94
95
96
97#define RTF_UP 0x1 /* route usable */
98#define RTF_GATEWAY 0x2 /* destination is a gateway */
99#define RTF_HOST 0x4 /* host entry (net otherwise) */
100#define RTF_REJECT 0x8 /* host or net unreachable */
101#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
102#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
103#define RTF_DONE 0x40 /* message confirmed */
104#define RTF_DELCLONE 0x80 /* delete cloned route */
105#define RTF_CLONING 0x100 /* generate new routes on use */
106#define RTF_XRESOLVE 0x200 /* external daemon resolves name */
107#define RTF_LLINFO 0x400 /* DEPRECATED - exists ONLY for backward
108 * compatibility */
109#define RTF_LLDATA 0x400 /* used by apps to add/del L2 entries */
110#define RTF_STATIC 0x800 /* manually added */
111#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */
112#define RTF_NOIFREF 0x2000 /* not eligible for RTF_IFREF */
113#define RTF_PROTO2 0x4000 /* protocol specific routing flag */
114#define RTF_PROTO1 0x8000 /* protocol specific routing flag */
115
116#define RTF_PRCLONING 0x10000 /* protocol requires cloning */
117#define RTF_WASCLONED 0x20000 /* route generated through cloning */
118#define RTF_PROTO3 0x40000 /* protocol specific routing flag */
119 /* 0x80000 unused */
120#define RTF_PINNED 0x100000 /* future use */
121#define RTF_LOCAL 0x200000 /* route represents a local address */
122#define RTF_BROADCAST 0x400000 /* route represents a bcast address */
123#define RTF_MULTICAST 0x800000 /* route represents a mcast address */
124#define RTF_IFSCOPE 0x1000000 /* has valid interface scope */
125#define RTF_CONDEMNED 0x2000000 /* defunct; no longer modifiable */
126#define RTF_IFREF 0x4000000 /* route holds a ref to interface */
127#define RTF_PROXY 0x8000000 /* proxying, no interface scope */
128#define RTF_ROUTER 0x10000000 /* host is a router */
129#define RTF_DEAD 0x20000000 /* Route entry is being freed */
130 /* 0x40000000 and up unassigned */
131
132#define RTPRF_OURS RTF_PROTO3 /* set on routes we manage */
133#define RTF_BITS \
134 "\020\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" \
135 "\10DELCLONE\11CLONING\12XRESOLVE\13LLINFO\14STATIC\15BLACKHOLE" \
136 "\16NOIFREF\17PROTO2\20PROTO1\21PRCLONING\22WASCLONED\23PROTO3" \
137 "\25PINNED\26LOCAL\27BROADCAST\30MULTICAST\31IFSCOPE\32CONDEMNED" \
138 "\33IFREF\34PROXY\35ROUTER"
139
140#define IS_DIRECT_HOSTROUTE(rt) \
141 (((rt)->rt_flags & (RTF_HOST | RTF_GATEWAY)) == RTF_HOST)
142/*
143 * Routing statistics.
144 */
145struct rtstat {
146 short rts_badredirect; /* bogus redirect calls */
147 short rts_dynamic; /* routes created by redirects */
148 short rts_newgateway; /* routes modified by redirects */
149 short rts_unreach; /* lookups which failed */
150 short rts_wildcard; /* lookups satisfied by a wildcard */
151 short rts_badrtgwroute; /* route to gateway is not direct */
152};
153
154/*
155 * Structures for routing messages.
156 */
157struct rt_msghdr {
158 u_short rtm_msglen; /* to skip over non-understood messages */
159 u_char rtm_version; /* future binary compatibility */
160 u_char rtm_type; /* message type */
161 u_short rtm_index; /* index for associated ifp */
162 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
163 int rtm_addrs; /* bitmask identifying sockaddrs in msg */
164 pid_t rtm_pid; /* identify sender */
165 int rtm_seq; /* for sender to identify action */
166 int rtm_errno; /* why failed */
167 int rtm_use; /* from rtentry */
168 u_int32_t rtm_inits; /* which metrics we are initializing */
169 struct rt_metrics rtm_rmx; /* metrics themselves */
170};
171
172struct rt_msghdr2 {
173 u_short rtm_msglen; /* to skip over non-understood messages */
174 u_char rtm_version; /* future binary compatibility */
175 u_char rtm_type; /* message type */
176 u_short rtm_index; /* index for associated ifp */
177 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
178 int rtm_addrs; /* bitmask identifying sockaddrs in msg */
179 int32_t rtm_refcnt; /* reference count */
180 int rtm_parentflags; /* flags of the parent route */
181 int rtm_reserved; /* reserved field set to 0 */
182 int rtm_use; /* from rtentry */
183 u_int32_t rtm_inits; /* which metrics we are initializing */
184 struct rt_metrics rtm_rmx; /* metrics themselves */
185};
186
187
188#define RTM_VERSION 5 /* Up the ante and ignore older versions */
189
190/*
191 * Message types.
192 */
193#define RTM_ADD 0x1 /* Add Route */
194#define RTM_DELETE 0x2 /* Delete Route */
195#define RTM_CHANGE 0x3 /* Change Metrics or flags */
196#define RTM_GET 0x4 /* Report Metrics */
197#define RTM_LOSING 0x5 /* RTM_LOSING is no longer generated by xnu
198 * and is deprecated */
199#define RTM_REDIRECT 0x6 /* Told to use different route */
200#define RTM_MISS 0x7 /* Lookup failed on this address */
201#define RTM_LOCK 0x8 /* fix specified metrics */
202#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
203#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
204#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */
205#define RTM_NEWADDR 0xc /* address being added to iface */
206#define RTM_DELADDR 0xd /* address being removed from iface */
207#define RTM_IFINFO 0xe /* iface going up/down etc. */
208#define RTM_NEWMADDR 0xf /* mcast group membership being added to if */
209#define RTM_DELMADDR 0x10 /* mcast group membership being deleted */
210#define RTM_IFINFO2 0x12 /* */
211#define RTM_NEWMADDR2 0x13 /* */
212#define RTM_GET2 0x14 /* */
213
214/*
215 * Bitmask values for rtm_inits and rmx_locks.
216 */
217#define RTV_MTU 0x1 /* init or lock _mtu */
218#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
219#define RTV_EXPIRE 0x4 /* init or lock _expire */
220#define RTV_RPIPE 0x8 /* init or lock _recvpipe */
221#define RTV_SPIPE 0x10 /* init or lock _sendpipe */
222#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */
223#define RTV_RTT 0x40 /* init or lock _rtt */
224#define RTV_RTTVAR 0x80 /* init or lock _rttvar */
225
226/*
227 * Bitmask values for rtm_addrs.
228 */
229#define RTA_DST 0x1 /* destination sockaddr present */
230#define RTA_GATEWAY 0x2 /* gateway sockaddr present */
231#define RTA_NETMASK 0x4 /* netmask sockaddr present */
232#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */
233#define RTA_IFP 0x10 /* interface name sockaddr present */
234#define RTA_IFA 0x20 /* interface addr sockaddr present */
235#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */
236#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */
237
238/*
239 * Index offsets for sockaddr array for alternate internal encoding.
240 */
241#define RTAX_DST 0 /* destination sockaddr present */
242#define RTAX_GATEWAY 1 /* gateway sockaddr present */
243#define RTAX_NETMASK 2 /* netmask sockaddr present */
244#define RTAX_GENMASK 3 /* cloning mask sockaddr present */
245#define RTAX_IFP 4 /* interface name sockaddr present */
246#define RTAX_IFA 5 /* interface addr sockaddr present */
247#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */
248#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */
249#define RTAX_MAX 8 /* size of array to allocate */
250
251struct rt_addrinfo {
252 int rti_addrs;
253 struct sockaddr *rti_info[RTAX_MAX];
254};
255
256
257#endif /* _NET_ROUTE_H_ */
lib/libc/include/x86_64-macos-gnu/os/clock.h created+18
......@@ -0,0 +1,18 @@
1#ifndef __OS_CLOCK__
2#define __OS_CLOCK__
3
4#include <os/base.h>
5#include <stdint.h>
6
7/*
8 * @typedef os_clockid_t
9 *
10 * @abstract
11 * Describes the kind of clock that the workgroup timestamp parameters are
12 * specified in
13 */
14OS_ENUM(os_clockid, uint32_t,
15 OS_CLOCK_MACH_ABSOLUTE_TIME = 32,
16);
17
18#endif /* __OS_CLOCK__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup.h created+37
......@@ -0,0 +1,37 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP__
22#define __OS_WORKGROUP__
23
24#ifndef __DISPATCH_BUILDING_DISPATCH__
25#ifndef __OS_WORKGROUP_INDIRECT__
26#define __OS_WORKGROUP_INDIRECT__
27#endif /* __OS_WORKGROUP_INDIRECT__ */
28
29#include <os/workgroup_base.h>
30#include <os/workgroup_object.h>
31#include <os/workgroup_interval.h>
32#include <os/workgroup_parallel.h>
33
34#undef __OS_WORKGROUP_INDIRECT__
35#endif /* __DISPATCH_BUILDING_DISPATCH__ */
36
37#endif /* __OS_WORKGROUP__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_base.h created+78
......@@ -0,0 +1,78 @@
1#ifndef __OS_WORKGROUP_BASE__
2#define __OS_WORKGROUP_BASE__
3
4#ifndef __OS_WORKGROUP_INDIRECT__
5#error "Please #include <os/workgroup.h> instead of this file directly."
6#endif
7
8#include <sys/types.h>
9#include <stddef.h>
10#include <stdint.h>
11#include <stdbool.h>
12#include <string.h>
13#include <stdlib.h>
14
15#include <mach/port.h>
16
17#include <Availability.h>
18#include <os/base.h>
19#include <os/object.h>
20#include <os/clock.h>
21
22#if __has_feature(assume_nonnull)
23#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
24#define OS_WORKGROUP_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
25#else
26#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN
27#define OS_WORKGROUP_ASSUME_NONNULL_END
28#endif
29#define OS_WORKGROUP_WARN_RESULT __attribute__((__warn_unused_result__))
30#define OS_WORKGROUP_EXPORT OS_EXPORT
31#define OS_WORKGROUP_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
32
33#define OS_WORKGROUP_DECL(name, swift_name) \
34 OS_SWIFT_NAME(swift_name) \
35 OS_OBJECT_SHOW_CLASS(name, OS_OBJECT_CLASS(object))
36
37#if OS_OBJECT_USE_OBJC
38#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) \
39 OS_SWIFT_NAME(swift_name) \
40 OS_OBJECT_DECL_PROTOCOL(name ## __VA_ARGS__ )
41#else
42#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...)
43#endif
44
45#define OS_WORKGROUP_SUBCLASS_DECL(name, super, swift_name, ...) \
46 OS_SWIFT_NAME(swift_name) \
47 OS_OBJECT_SHOW_SUBCLASS(name, super, name, ## __VA_ARGS__)
48
49#if defined(__LP64__)
50#define __OS_WORKGROUP_ATTR_SIZE__ 60
51#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56
52#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 36
53#else
54#define __OS_WORKGROUP_ATTR_SIZE__ 60
55#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56
56#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 28
57#endif
58
59#define _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT 0x2FA863B4
60#define _OS_WORKGROUP_ATTR_SIG_EMPTY_INIT 0x2FA863C4
61
62struct OS_REFINED_FOR_SWIFT os_workgroup_attr_opaque_s {
63 uint32_t sig;
64 char opaque[__OS_WORKGROUP_ATTR_SIZE__];
65};
66
67#define _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT 0x52A74C4D
68struct OS_REFINED_FOR_SWIFT os_workgroup_interval_data_opaque_s {
69 uint32_t sig;
70 char opaque[__OS_WORKGROUP_INTERVAL_DATA_SIZE__];
71};
72
73struct OS_REFINED_FOR_SWIFT os_workgroup_join_token_opaque_s {
74 uint32_t sig;
75 char opaque[__OS_WORKGROUP_JOIN_TOKEN_SIZE__];
76};
77
78#endif /* __OS_WORKGROUP_BASE__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_interval.h created+155
......@@ -0,0 +1,155 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP_INTERVAL__
22#define __OS_WORKGROUP_INTERVAL__
23
24#ifndef __OS_WORKGROUP_INDIRECT__
25#error "Please #include <os/workgroup.h> instead of this file directly."
26#include <os/workgroup_base.h> // For header doc
27#endif
28
29__BEGIN_DECLS
30
31OS_WORKGROUP_ASSUME_NONNULL_BEGIN
32
33/*!
34 * @typedef os_workgroup_interval_t
35 *
36 * @abstract
37 * A subclass of an os_workgroup_t for tracking work performed as part of
38 * a repeating interval-driven workload.
39 */
40OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_interval, Repeatable);
41OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_interval, os_workgroup, WorkGroupInterval);
42
43/* During the first instance of this API, the only supported interval
44 * workgroups are for audio workloads. Please refer to the AudioToolbox
45 * framework for more information.
46 */
47
48/*
49 * @typedef os_workgroup_interval_data, os_workgroup_interval_data_t
50 *
51 * @abstract
52 * An opaque structure containing additional configuration for the workgroup
53 * interval.
54 */
55typedef struct os_workgroup_interval_data_opaque_s os_workgroup_interval_data_s;
56typedef struct os_workgroup_interval_data_opaque_s *os_workgroup_interval_data_t;
57#define OS_WORKGROUP_INTERVAL_DATA_INITIALIZER \
58 { .sig = _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT }
59
60/*!
61 * @function os_workgroup_interval_start
62 *
63 * @abstract
64 * Indicates to the system that the member threads of this
65 * os_workgroup_interval_t have begun working on an instance of the repeatable
66 * interval workload with the specified timestamps. This function is real time
67 * safe.
68 *
69 * This function will set and return an errno in the following cases:
70 *
71 * - The current thread is not a member of the os_workgroup_interval_t
72 * - The os_workgroup_interval_t has been cancelled
73 * - The timestamps passed in are malformed
74 * - os_workgroup_interval_start() was previously called on the
75 * os_workgroup_interval_t without an intervening os_workgroup_interval_finish()
76 * - A concurrent workgroup interval configuration operation is taking place.
77 *
78 * @param start
79 * Start timestamp specified in the os_clockid_t with which the
80 * os_workgroup_interval_t was created. This is generally a time in the past and
81 * indicates when the workgroup started working on an interval period
82 *
83 * @param deadline
84 * Deadline timestamp specified in the os_clockid_t with which the
85 * os_workgroup_interval_t was created. This specifies the deadline which the
86 * interval period would like to meet.
87 *
88 * @param data
89 * This field is currently unused and should be NULL
90 */
91API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
92OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
93int
94os_workgroup_interval_start(os_workgroup_interval_t wg, uint64_t start, uint64_t
95 deadline, os_workgroup_interval_data_t _Nullable data);
96
97/*!
98 * @function os_workgroup_interval_update
99 *
100 * @abstract
101 * Updates an already started interval workgroup to have the new
102 * deadline specified. This function is real time safe.
103 *
104 * This function will return an error in the following cases:
105 * - The current thread is not a member of the os_workgroup_interval_t
106 * - The os_workgroup_interval_t has been cancelled
107 * - The timestamp passed in is malformed
108 * - os_workgroup_interval_start() was not previously called on the
109 * os_workgroup_interval_t or was already matched with an
110 * os_workgroup_interval_finish()
111 * - A concurrent workgroup interval configuration operation is taking place
112 *
113 * @param deadline
114 * Timestamp specified in the os_clockid_t with
115 * which the os_workgroup_interval_t was created.
116 *
117 * @param data
118 * This field is currently unused and should be NULL
119 */
120API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
121OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
122int
123os_workgroup_interval_update(os_workgroup_interval_t wg, uint64_t deadline,
124 os_workgroup_interval_data_t _Nullable data);
125
126/*!
127 * @function os_workgroup_interval_finish
128 *
129 * @abstract
130 * Indicates to the system that the member threads of
131 * this os_workgroup_interval_t have finished working on the current instance
132 * of the interval workload. This function is real time safe.
133 *
134 * This function will return an error in the following cases:
135 * - The current thread is not a member of the os_workgroup_interval_t
136 * - os_workgroup_interval_start() was not previously called on the
137 * os_workgroup_interval_t or was already matched with an
138 * os_workgroup_interval_finish()
139 * - A concurrent workgroup interval configuration operation is taking place.
140 *
141 * @param data
142 * This field is currently unused and should be NULL
143 *
144 */
145API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
146OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
147int
148os_workgroup_interval_finish(os_workgroup_interval_t wg,
149 os_workgroup_interval_data_t _Nullable data);
150
151OS_WORKGROUP_ASSUME_NONNULL_END
152
153__END_DECLS
154
155#endif /* __OS_WORKGROUP_INTERVAL__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_object.h created+357
......@@ -0,0 +1,357 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP_OBJECT__
22#define __OS_WORKGROUP_OBJECT__
23
24#ifndef __OS_WORKGROUP_INDIRECT__
25#error "Please #include <os/workgroup.h> instead of this file directly."
26#include <os/workgroup_base.h> // For header doc
27#endif
28
29__BEGIN_DECLS
30
31OS_WORKGROUP_ASSUME_NONNULL_BEGIN
32
33/*!
34 * @typedef os_workgroup_t
35 *
36 * @abstract
37 * A reference counted os object representing a workload that needs to
38 * be distinctly recognized and tracked by the system. The workgroup
39 * tracks a collection of threads all working cooperatively. An os_workgroup
40 * object - when not an instance of a specific os_workgroup_t subclass -
41 * represents a generic workload and makes no assumptions about the kind of
42 * work done.
43 *
44 * @discussion
45 * Threads can explicitly join an os_workgroup_t to mark themselves as
46 * participants in the workload.
47 */
48OS_WORKGROUP_DECL(os_workgroup, WorkGroup);
49
50
51/* Attribute creation and specification */
52
53/*!
54 * @typedef os_workgroup_attr_t
55 *
56 * @abstract
57 * Pointer to an opaque structure for describing attributes that can be
58 * configured on a workgroup at creation.
59 */
60typedef struct os_workgroup_attr_opaque_s os_workgroup_attr_s;
61typedef struct os_workgroup_attr_opaque_s *os_workgroup_attr_t;
62
63/* os_workgroup_t attributes need to be initialized before use. This initializer
64 * allows you to create a workgroup with the system default attributes. */
65#define OS_WORKGROUP_ATTR_INITIALIZER_DEFAULT \
66 { .sig = _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT }
67
68
69
70/* The main use of the workgroup API is through instantiations of the concrete
71 * subclasses - please refer to os/workgroup_interval.h and
72 * os/workgroup_parallel.h for more information on creating workgroups.
73 *
74 * The functions below operate on all subclasses of os_workgroup_t.
75 */
76
77/*!
78 * @function os_workgroup_copy_port
79 *
80 * @abstract
81 * Returns a reference to a send right representing this workgroup that is to be
82 * sent to other processes. This port is to be passed to
83 * os_workgroup_create_with_port() to create a workgroup object.
84 *
85 * It is the client's responsibility to release the send right reference.
86 *
87 * If an error is encountered, errno is set and returned.
88 */
89API_AVAILABLE(macos(11.0))
90API_UNAVAILABLE(ios, tvos, watchos)
91OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
92int
93os_workgroup_copy_port(os_workgroup_t wg, mach_port_t *mach_port_out);
94
95/*!
96 * @function os_workgroup_create_with_port
97 *
98 * @abstract
99 * Create an os_workgroup_t object from a send right returned by a previous
100 * call to os_workgroup_copy_port, potentially in a different process.
101 *
102 * A newly created os_workgroup_t has no initial member threads - in particular
103 * the creating thread does not join the os_workgroup_t implicitly.
104 *
105 * @param name
106 * A client specified string for labelling the workgroup. This parameter is
107 * optional and can be NULL.
108 *
109 * @param mach_port
110 * The send right to create the workgroup from. No reference is consumed
111 * on the specified send right.
112 */
113API_AVAILABLE(macos(11.0))
114API_UNAVAILABLE(ios, tvos, watchos)
115OS_SWIFT_NAME(WorkGroup.init(__name:port:)) OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
116os_workgroup_t _Nullable
117os_workgroup_create_with_port(const char *_Nullable name, mach_port_t mach_port);
118
119/*!
120 * @function os_workgroup_create_with_workgroup
121 *
122 * @abstract
123 * Create a new os_workgroup object from an existing os_workgroup.
124 *
125 * The newly created os_workgroup has no initial member threads - in particular
126 * the creating threaad does not join the os_workgroup_t implicitly.
127 *
128 * @param name
129 * A client specified string for labelling the workgroup. This parameter is
130 * optional and can be NULL.
131 *
132 * @param wg
133 * The existing workgroup to create a new workgroup object from.
134 */
135API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
136OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
137os_workgroup_t _Nullable
138os_workgroup_create_with_workgroup(const char * _Nullable name, os_workgroup_t wg);
139
140/*!
141 * @typedef os_workgroup_join_token, os_workgroup_join_token_t
142 *
143 * @abstract
144 * An opaque join token which the client needs to pass to os_workgroup_join
145 * and os_workgroup_leave
146 */
147OS_REFINED_FOR_SWIFT
148typedef struct os_workgroup_join_token_opaque_s os_workgroup_join_token_s;
149OS_REFINED_FOR_SWIFT
150typedef struct os_workgroup_join_token_opaque_s *os_workgroup_join_token_t;
151
152
153/*!
154 * @function os_workgroup_join
155 *
156 * @abstract
157 * Joins the current thread to the specified workgroup and populates the join
158 * token that has been passed in. This API is real-time safe.
159 *
160 * @param wg
161 * The workgroup that the current thread would like to join
162 *
163 * @param token_out
164 * Pointer to a client allocated struct which the function will populate
165 * with the join token. This token must be passed in by the thread when it calls
166 * os_workgroup_leave().
167 *
168 * Errors will be returned in the following cases:
169 *
170 * EALREADY The thread is already part of a workgroup that the specified
171 * workgroup does not nest with
172 * EINVAL The workgroup has been cancelled
173 */
174API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
175OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
176int
177os_workgroup_join(os_workgroup_t wg, os_workgroup_join_token_t token_out);
178
179/*!
180 * @function os_workgroup_leave
181 *
182 * @abstract
183 * This removes the current thread from a workgroup it has previously
184 * joined. Threads must leave all workgroups in the reverse order that they
185 * have joined them. Failing to do so before exiting will result in undefined
186 * behavior.
187 *
188 * If the join token is malformed, the process will be aborted.
189 *
190 * This API is real time safe.
191 *
192 * @param wg
193 * The workgroup that the current thread would like to leave.
194 *
195 * @param token
196 * This is the join token populated by the most recent call to
197 * os_workgroup_join().
198 */
199API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
200OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
201void
202os_workgroup_leave(os_workgroup_t wg, os_workgroup_join_token_t token);
203
204/* Working Arena index of a thread in a workgroup */
205typedef uint32_t os_workgroup_index;
206/* Destructor for Working Arena */
207typedef void (*os_workgroup_working_arena_destructor_t)(void * _Nullable);
208
209/*!
210 * @function os_workgroup_set_working_arena
211 *
212 * @abstract
213 * Associates a client defined working arena with the workgroup. The arena
214 * is local to the workgroup object in the process. This is intended for
215 * distributing a manually managed memory allocation between member threads
216 * of the workgroup.
217 *
218 * This function can be called multiple times and the client specified
219 * destructor will be called on the previously assigned arena, if any. This
220 * function can only be called when no threads have currently joined the
221 * workgroup and all workloops associated with the workgroup are idle.
222 *
223 * @param wg
224 * The workgroup to associate the working arena with
225 *
226 * @param arena
227 * The client managed arena to associate with the workgroup. This value can
228 * be NULL.
229 *
230 * @param max_workers
231 * The maximum number of threads that will ever query the workgroup for the
232 * arena and request an index into it. If the arena is not used to partition
233 * work amongst member threads, then this field can be 0.
234 *
235 * @param destructor
236 * A destructor to call on the previously assigned working arena, if any
237 */
238API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
239OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
240int
241os_workgroup_set_working_arena(os_workgroup_t wg, void * _Nullable arena,
242 uint32_t max_workers, os_workgroup_working_arena_destructor_t destructor);
243
244/*!
245 * @function os_workgroup_get_working_arena
246 *
247 * @abstract
248 * Returns the working arena associated with the workgroup and the current
249 * thread's index in the workgroup. This function can only be called by a member
250 * of the workgroup. Multiple calls to this API by a member thread will return
251 * the same arena and index until the thread leaves the workgroup.
252 *
253 * For workloops with an associated workgroup, every work item on the workloop
254 * will receive the same index in the arena.
255 *
256 * This method returns NULL if no arena is set on the workgroup. The index
257 * returned by this function is zero-based and is namespaced per workgroup
258 * object in the process. The indices provided are strictly monotonic and never
259 * reused until a future call to os_workgroup_set_working_arena.
260 *
261 * @param wg
262 * The workgroup to get the working arena from.
263 *
264 * @param index_out
265 * A pointer to a os_workgroup_index which will be populated by the caller's
266 * index in the workgroup.
267 */
268API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
269OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
270void * _Nullable
271os_workgroup_get_working_arena(os_workgroup_t wg,
272 os_workgroup_index * _Nullable index_out);
273
274/*!
275 * @function os_workgroup_cancel
276 *
277 * @abstract
278 * This API invalidates a workgroup and indicates to the system that the
279 * workload is no longer relevant to the caller.
280 *
281 * No new work should be initiated for a cancelled workgroup and
282 * work that is already underway should periodically check for
283 * cancellation with os_workgroup_testcancel and initiate cleanup if needed.
284 *
285 * Threads currently in the workgroup continue to be tracked together but no
286 * new threads may join this workgroup - the only possible operation allowed is
287 * to leave the workgroup. Other actions may have undefined behavior or
288 * otherwise fail.
289 *
290 * This API is idempotent. Cancellation is local to the workgroup object
291 * it is called on and does not affect other workgroups.
292 *
293 * @param wg
294 * The workgroup that that the thread would like to cancel
295 */
296API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
297OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
298void
299os_workgroup_cancel(os_workgroup_t wg);
300
301/*!
302 * @function os_workgroup_testcancel
303 *
304 * @abstract
305 * Returns true if the workgroup object has been cancelled. See also
306 * os_workgroup_cancel
307 */
308API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
309OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
310bool
311os_workgroup_testcancel(os_workgroup_t wg);
312
313/*!
314 * @typedef os_workgroup_max_parallel_threads_attr_t
315 *
316 * @abstract
317 * A pointer to a structure describing the set of properties of a workgroup to
318 * override with the explicitly specified values in the structure.
319 *
320 * See also os_workgroup_max_parallel_threads.
321 */
322OS_REFINED_FOR_SWIFT
323typedef struct os_workgroup_max_parallel_threads_attr_s os_workgroup_mpt_attr_s;
324OS_REFINED_FOR_SWIFT
325typedef struct os_workgroup_max_parallel_threads_attr_s *os_workgroup_mpt_attr_t;
326
327/*!
328 * @function os_workgroup_max_parallel_threads
329 *
330 * @abstract
331 * Returns the system's recommendation for maximum number of threads the client
332 * should make for a multi-threaded workload in a given workgroup.
333 *
334 * This API takes into consideration the current hardware the code is running on
335 * and the attributes of the workgroup. It does not take into consideration the
336 * current load of the system and therefore always provides the most optimal
337 * recommendation for the workload.
338 *
339 * @param wg
340 * The workgroup in which the multi-threaded workload will be performed in. The
341 * threads performing the multi-threaded workload are expected to join this
342 * workgroup.
343 *
344 * @param attr
345 * This value is currently unused and should be NULL.
346 */
347API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
348OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
349int
350os_workgroup_max_parallel_threads(os_workgroup_t wg, os_workgroup_mpt_attr_t
351 _Nullable attr);
352
353OS_WORKGROUP_ASSUME_NONNULL_END
354
355__END_DECLS
356
357#endif /* __OS_WORKGROUP_OBJECT__ */
lib/libc/include/x86_64-macos-gnu/os/workgroup_parallel.h created+74
......@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __OS_WORKGROUP_PARALLEL__
22#define __OS_WORKGROUP_PARALLEL__
23
24#ifndef __OS_WORKGROUP_INDIRECT__
25#error "Please #include <os/workgroup.h> instead of this file directly."
26#include <os/workgroup_base.h> // For header doc
27#endif
28
29#include <os/workgroup_object.h>
30
31__BEGIN_DECLS
32
33OS_WORKGROUP_ASSUME_NONNULL_BEGIN
34
35/*!
36 * @typedef os_workgroup_parallel_t
37 *
38 * @abstract
39 * A subclass of an os_workgroup_t for tracking parallel work.
40 */
41OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_parallel, Parallelizable);
42OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_parallel, os_workgroup, WorkGroupParallel);
43
44/*!
45 * @function os_workgroup_parallel_create
46 *
47 * @abstract
48 * Creates an os_workgroup_t which tracks a parallel workload.
49 * A newly created os_workgroup_interval_t has no initial member threads -
50 * in particular the creating thread does not join the os_workgroup_parallel_t
51 * implicitly.
52 *
53 * See also os_workgroup_max_parallel_threads().
54 *
55 * @param name
56 * A client specified string for labelling the workgroup. This parameter is
57 * optional and can be NULL.
58 *
59 * @param attr
60 * The requested set of workgroup attributes. NULL is to be specified for the
61 * default set of attributes.
62 */
63API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
64OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
65OS_SWIFT_NAME(WorkGroupParallel.init(__name:attr:))
66os_workgroup_parallel_t _Nullable
67os_workgroup_parallel_create(const char * _Nullable name,
68 os_workgroup_attr_t _Nullable attr);
69
70OS_WORKGROUP_ASSUME_NONNULL_END
71
72__END_DECLS
73
74#endif /* __OS_WORKGROUP_PARALLEL__ */
lib/libc/include/x86_64-macos-gnu/sys/kern_control.h created+151
......@@ -0,0 +1,151 @@
1/*
2 * Copyright (c) 2000-2004, 2012-2016 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 * @header kern_control.h
30 * This header defines an API to communicate between a kernel
31 * extension and a process outside of the kernel.
32 */
33
34#ifndef KPI_KERN_CONTROL_H
35#define KPI_KERN_CONTROL_H
36
37
38#include <sys/appleapiopts.h>
39#include <sys/_types/_u_char.h>
40#include <sys/_types/_u_int16_t.h>
41#include <sys/_types/_u_int32_t.h>
42
43/*
44 * Define Controller event subclass, and associated events.
45 * Subclass of KEV_SYSTEM_CLASS
46 */
47
48/*!
49 * @defined KEV_CTL_SUBCLASS
50 * @discussion The kernel event subclass for kernel control events.
51 */
52#define KEV_CTL_SUBCLASS 2
53
54/*!
55 * @defined KEV_CTL_REGISTERED
56 * @discussion The event code indicating a new controller was
57 * registered. The data portion will contain a ctl_event_data.
58 */
59#define KEV_CTL_REGISTERED 1 /* a new controller appears */
60
61/*!
62 * @defined KEV_CTL_DEREGISTERED
63 * @discussion The event code indicating a controller was unregistered.
64 * The data portion will contain a ctl_event_data.
65 */
66#define KEV_CTL_DEREGISTERED 2 /* a controller disappears */
67
68/*!
69 * @struct ctl_event_data
70 * @discussion This structure is used for KEV_CTL_SUBCLASS kernel
71 * events.
72 * @field ctl_id The kernel control id.
73 * @field ctl_unit The kernel control unit.
74 */
75struct ctl_event_data {
76 u_int32_t ctl_id; /* Kernel Controller ID */
77 u_int32_t ctl_unit;
78};
79
80/*
81 * Controls destined to the Controller Manager.
82 */
83
84/*!
85 * @defined CTLIOCGCOUNT
86 * @discussion The CTLIOCGCOUNT ioctl can be used to determine the
87 * number of kernel controllers registered.
88 */
89#define CTLIOCGCOUNT _IOR('N', 2, int) /* get number of control structures registered */
90
91/*!
92 * @defined CTLIOCGINFO
93 * @discussion The CTLIOCGINFO ioctl can be used to convert a kernel
94 * control name to a kernel control id.
95 */
96#define CTLIOCGINFO _IOWR('N', 3, struct ctl_info) /* get id from name */
97
98
99/*!
100 * @defined MAX_KCTL_NAME
101 * @discussion Kernel control names must be no longer than
102 * MAX_KCTL_NAME.
103 */
104#define MAX_KCTL_NAME 96
105
106/*
107 * Controls destined to the Controller Manager.
108 */
109
110/*!
111 * @struct ctl_info
112 * @discussion This structure is used with the CTLIOCGINFO ioctl to
113 * translate from a kernel control name to a control id.
114 * @field ctl_id The kernel control id, filled out upon return.
115 * @field ctl_name The kernel control name to find.
116 */
117struct ctl_info {
118 u_int32_t ctl_id; /* Kernel Controller ID */
119 char ctl_name[MAX_KCTL_NAME]; /* Kernel Controller Name (a C string) */
120};
121
122
123/*!
124 * @struct sockaddr_ctl
125 * @discussion The controller address structure is used to establish
126 * contact between a user client and a kernel controller. The
127 * sc_id/sc_unit uniquely identify each controller. sc_id is a
128 * unique identifier assigned to the controller. The identifier can
129 * be assigned by the system at registration time or be a 32-bit
130 * creator code obtained from Apple Computer. sc_unit is a unit
131 * number for this sc_id, and is privately used by the kernel
132 * controller to identify several instances of the controller.
133 * @field sc_len The length of the structure.
134 * @field sc_family AF_SYSTEM.
135 * @field ss_sysaddr AF_SYS_KERNCONTROL.
136 * @field sc_id Controller unique identifier.
137 * @field sc_unit Kernel controller private unit number.
138 * @field sc_reserved Reserved, must be set to zero.
139 */
140struct sockaddr_ctl {
141 u_char sc_len; /* depends on size of bundle ID string */
142 u_char sc_family; /* AF_SYSTEM */
143 u_int16_t ss_sysaddr; /* AF_SYS_KERNCONTROL */
144 u_int32_t sc_id; /* Controller unique identifier */
145 u_int32_t sc_unit; /* Developer private unit number */
146 u_int32_t sc_reserved[5];
147};
148
149
150
151#endif /* KPI_KERN_CONTROL_H */
lib/libc/include/x86_64-macos-gnu/sys/proc_info.h created+799
......@@ -0,0 +1,799 @@
1/*
2 * Copyright (c) 2005-2020 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
29#ifndef _SYS_PROC_INFO_H
30#define _SYS_PROC_INFO_H
31
32#include <sys/cdefs.h>
33#include <sys/param.h>
34#include <sys/types.h>
35#include <sys/stat.h>
36#include <sys/mount.h>
37#include <sys/socket.h>
38#include <sys/un.h>
39#include <sys/kern_control.h>
40#include <sys/event.h>
41#include <net/if.h>
42#include <net/route.h>
43#include <netinet/in.h>
44#include <netinet/tcp.h>
45#include <mach/machine.h>
46#include <uuid/uuid.h>
47
48
49__BEGIN_DECLS
50
51
52#define PROC_ALL_PIDS 1
53#define PROC_PGRP_ONLY 2
54#define PROC_TTY_ONLY 3
55#define PROC_UID_ONLY 4
56#define PROC_RUID_ONLY 5
57#define PROC_PPID_ONLY 6
58#define PROC_KDBG_ONLY 7
59
60struct proc_bsdinfo {
61 uint32_t pbi_flags; /* 64bit; emulated etc */
62 uint32_t pbi_status;
63 uint32_t pbi_xstatus;
64 uint32_t pbi_pid;
65 uint32_t pbi_ppid;
66 uid_t pbi_uid;
67 gid_t pbi_gid;
68 uid_t pbi_ruid;
69 gid_t pbi_rgid;
70 uid_t pbi_svuid;
71 gid_t pbi_svgid;
72 uint32_t rfu_1; /* reserved */
73 char pbi_comm[MAXCOMLEN];
74 char pbi_name[2 * MAXCOMLEN]; /* empty if no name is registered */
75 uint32_t pbi_nfiles;
76 uint32_t pbi_pgid;
77 uint32_t pbi_pjobc;
78 uint32_t e_tdev; /* controlling tty dev */
79 uint32_t e_tpgid; /* tty process group id */
80 int32_t pbi_nice;
81 uint64_t pbi_start_tvsec;
82 uint64_t pbi_start_tvusec;
83};
84
85
86struct proc_bsdshortinfo {
87 uint32_t pbsi_pid; /* process id */
88 uint32_t pbsi_ppid; /* process parent id */
89 uint32_t pbsi_pgid; /* process perp id */
90 uint32_t pbsi_status; /* p_stat value, SZOMB, SRUN, etc */
91 char pbsi_comm[MAXCOMLEN]; /* upto 16 characters of process name */
92 uint32_t pbsi_flags; /* 64bit; emulated etc */
93 uid_t pbsi_uid; /* current uid on process */
94 gid_t pbsi_gid; /* current gid on process */
95 uid_t pbsi_ruid; /* current ruid on process */
96 gid_t pbsi_rgid; /* current tgid on process */
97 uid_t pbsi_svuid; /* current svuid on process */
98 gid_t pbsi_svgid; /* current svgid on process */
99 uint32_t pbsi_rfu; /* reserved for future use*/
100};
101
102
103
104
105/* pbi_flags values */
106#define PROC_FLAG_SYSTEM 1 /* System process */
107#define PROC_FLAG_TRACED 2 /* process currently being traced, possibly by gdb */
108#define PROC_FLAG_INEXIT 4 /* process is working its way in exit() */
109#define PROC_FLAG_PPWAIT 8
110#define PROC_FLAG_LP64 0x10 /* 64bit process */
111#define PROC_FLAG_SLEADER 0x20 /* The process is the session leader */
112#define PROC_FLAG_CTTY 0x40 /* process has a control tty */
113#define PROC_FLAG_CONTROLT 0x80 /* Has a controlling terminal */
114#define PROC_FLAG_THCWD 0x100 /* process has a thread with cwd */
115/* process control bits for resource starvation */
116#define PROC_FLAG_PC_THROTTLE 0x200 /* In resource starvation situations, this process is to be throttled */
117#define PROC_FLAG_PC_SUSP 0x400 /* In resource starvation situations, this process is to be suspended */
118#define PROC_FLAG_PC_KILL 0x600 /* In resource starvation situations, this process is to be terminated */
119#define PROC_FLAG_PC_MASK 0x600
120/* process action bits for resource starvation */
121#define PROC_FLAG_PA_THROTTLE 0x800 /* The process is currently throttled due to resource starvation */
122#define PROC_FLAG_PA_SUSP 0x1000 /* The process is currently suspended due to resource starvation */
123#define PROC_FLAG_PSUGID 0x2000 /* process has set privileges since last exec */
124#define PROC_FLAG_EXEC 0x4000 /* process has called exec */
125
126
127struct proc_taskinfo {
128 uint64_t pti_virtual_size; /* virtual memory size (bytes) */
129 uint64_t pti_resident_size; /* resident memory size (bytes) */
130 uint64_t pti_total_user; /* total time */
131 uint64_t pti_total_system;
132 uint64_t pti_threads_user; /* existing threads only */
133 uint64_t pti_threads_system;
134 int32_t pti_policy; /* default policy for new threads */
135 int32_t pti_faults; /* number of page faults */
136 int32_t pti_pageins; /* number of actual pageins */
137 int32_t pti_cow_faults; /* number of copy-on-write faults */
138 int32_t pti_messages_sent; /* number of messages sent */
139 int32_t pti_messages_received; /* number of messages received */
140 int32_t pti_syscalls_mach; /* number of mach system calls */
141 int32_t pti_syscalls_unix; /* number of unix system calls */
142 int32_t pti_csw; /* number of context switches */
143 int32_t pti_threadnum; /* number of threads in the task */
144 int32_t pti_numrunning; /* number of running threads */
145 int32_t pti_priority; /* task priority*/
146};
147
148struct proc_taskallinfo {
149 struct proc_bsdinfo pbsd;
150 struct proc_taskinfo ptinfo;
151};
152
153#define MAXTHREADNAMESIZE 64
154
155struct proc_threadinfo {
156 uint64_t pth_user_time; /* user run time */
157 uint64_t pth_system_time; /* system run time */
158 int32_t pth_cpu_usage; /* scaled cpu usage percentage */
159 int32_t pth_policy; /* scheduling policy in effect */
160 int32_t pth_run_state; /* run state (see below) */
161 int32_t pth_flags; /* various flags (see below) */
162 int32_t pth_sleep_time; /* number of seconds that thread */
163 int32_t pth_curpri; /* cur priority*/
164 int32_t pth_priority; /* priority*/
165 int32_t pth_maxpriority; /* max priority*/
166 char pth_name[MAXTHREADNAMESIZE]; /* thread name, if any */
167};
168
169struct proc_regioninfo {
170 uint32_t pri_protection;
171 uint32_t pri_max_protection;
172 uint32_t pri_inheritance;
173 uint32_t pri_flags; /* shared, external pager, is submap */
174 uint64_t pri_offset;
175 uint32_t pri_behavior;
176 uint32_t pri_user_wired_count;
177 uint32_t pri_user_tag;
178 uint32_t pri_pages_resident;
179 uint32_t pri_pages_shared_now_private;
180 uint32_t pri_pages_swapped_out;
181 uint32_t pri_pages_dirtied;
182 uint32_t pri_ref_count;
183 uint32_t pri_shadow_depth;
184 uint32_t pri_share_mode;
185 uint32_t pri_private_pages_resident;
186 uint32_t pri_shared_pages_resident;
187 uint32_t pri_obj_id;
188 uint32_t pri_depth;
189 uint64_t pri_address;
190 uint64_t pri_size;
191};
192
193#define PROC_REGION_SUBMAP 1
194#define PROC_REGION_SHARED 2
195
196#define SM_COW 1
197#define SM_PRIVATE 2
198#define SM_EMPTY 3
199#define SM_SHARED 4
200#define SM_TRUESHARED 5
201#define SM_PRIVATE_ALIASED 6
202#define SM_SHARED_ALIASED 7
203#define SM_LARGE_PAGE 8
204
205
206/*
207 * Thread run states (state field).
208 */
209
210#define TH_STATE_RUNNING 1 /* thread is running normally */
211#define TH_STATE_STOPPED 2 /* thread is stopped */
212#define TH_STATE_WAITING 3 /* thread is waiting normally */
213#define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
214 * wait */
215#define TH_STATE_HALTED 5 /* thread is halted at a
216 * clean point */
217
218/*
219 * Thread flags (flags field).
220 */
221#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
222#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
223
224
225struct proc_workqueueinfo {
226 uint32_t pwq_nthreads; /* total number of workqueue threads */
227 uint32_t pwq_runthreads; /* total number of running workqueue threads */
228 uint32_t pwq_blockedthreads; /* total number of blocked workqueue threads */
229 uint32_t pwq_state;
230};
231
232/*
233 * workqueue state (pwq_state field)
234 */
235#define WQ_EXCEEDED_CONSTRAINED_THREAD_LIMIT 0x1
236#define WQ_EXCEEDED_TOTAL_THREAD_LIMIT 0x2
237#define WQ_FLAGS_AVAILABLE 0x4
238
239struct proc_fileinfo {
240 uint32_t fi_openflags;
241 uint32_t fi_status;
242 off_t fi_offset;
243 int32_t fi_type;
244 uint32_t fi_guardflags;
245};
246
247/* stats flags in proc_fileinfo */
248#define PROC_FP_SHARED 1 /* shared by more than one fd */
249#define PROC_FP_CLEXEC 2 /* close on exec */
250#define PROC_FP_GUARDED 4 /* guarded fd */
251#define PROC_FP_CLFORK 8 /* close on fork */
252
253#define PROC_FI_GUARD_CLOSE (1u << 0)
254#define PROC_FI_GUARD_DUP (1u << 1)
255#define PROC_FI_GUARD_SOCKET_IPC (1u << 2)
256#define PROC_FI_GUARD_FILEPORT (1u << 3)
257
258struct proc_exitreasonbasicinfo {
259 uint32_t beri_namespace;
260 uint64_t beri_code;
261 uint64_t beri_flags;
262 uint32_t beri_reason_buf_size;
263} __attribute__((packed));
264
265struct proc_exitreasoninfo {
266 uint32_t eri_namespace;
267 uint64_t eri_code;
268 uint64_t eri_flags;
269 uint32_t eri_reason_buf_size;
270 uint64_t eri_kcd_buf;
271} __attribute__((packed));
272
273/*
274 * A copy of stat64 with static sized fields.
275 */
276struct vinfo_stat {
277 uint32_t vst_dev; /* [XSI] ID of device containing file */
278 uint16_t vst_mode; /* [XSI] Mode of file (see below) */
279 uint16_t vst_nlink; /* [XSI] Number of hard links */
280 uint64_t vst_ino; /* [XSI] File serial number */
281 uid_t vst_uid; /* [XSI] User ID of the file */
282 gid_t vst_gid; /* [XSI] Group ID of the file */
283 int64_t vst_atime; /* [XSI] Time of last access */
284 int64_t vst_atimensec; /* nsec of last access */
285 int64_t vst_mtime; /* [XSI] Last data modification time */
286 int64_t vst_mtimensec; /* last data modification nsec */
287 int64_t vst_ctime; /* [XSI] Time of last status change */
288 int64_t vst_ctimensec; /* nsec of last status change */
289 int64_t vst_birthtime; /* File creation time(birth) */
290 int64_t vst_birthtimensec; /* nsec of File creation time */
291 off_t vst_size; /* [XSI] file size, in bytes */
292 int64_t vst_blocks; /* [XSI] blocks allocated for file */
293 int32_t vst_blksize; /* [XSI] optimal blocksize for I/O */
294 uint32_t vst_flags; /* user defined flags for file */
295 uint32_t vst_gen; /* file generation number */
296 uint32_t vst_rdev; /* [XSI] Device ID */
297 int64_t vst_qspare[2]; /* RESERVED: DO NOT USE! */
298};
299
300struct vnode_info {
301 struct vinfo_stat vi_stat;
302 int vi_type;
303 int vi_pad;
304 fsid_t vi_fsid;
305};
306
307struct vnode_info_path {
308 struct vnode_info vip_vi;
309 char vip_path[MAXPATHLEN]; /* tail end of it */
310};
311
312struct vnode_fdinfo {
313 struct proc_fileinfo pfi;
314 struct vnode_info pvi;
315};
316
317struct vnode_fdinfowithpath {
318 struct proc_fileinfo pfi;
319 struct vnode_info_path pvip;
320};
321
322struct proc_regionwithpathinfo {
323 struct proc_regioninfo prp_prinfo;
324 struct vnode_info_path prp_vip;
325};
326
327struct proc_regionpath {
328 uint64_t prpo_addr;
329 uint64_t prpo_regionlength;
330 char prpo_path[MAXPATHLEN];
331};
332
333struct proc_vnodepathinfo {
334 struct vnode_info_path pvi_cdir;
335 struct vnode_info_path pvi_rdir;
336};
337
338struct proc_threadwithpathinfo {
339 struct proc_threadinfo pt;
340 struct vnode_info_path pvip;
341};
342
343/*
344 * Socket
345 */
346
347
348/*
349 * IPv4 and IPv6 Sockets
350 */
351
352#define INI_IPV4 0x1
353#define INI_IPV6 0x2
354
355struct in4in6_addr {
356 u_int32_t i46a_pad32[3];
357 struct in_addr i46a_addr4;
358};
359
360struct in_sockinfo {
361 int insi_fport; /* foreign port */
362 int insi_lport; /* local port */
363 uint64_t insi_gencnt; /* generation count of this instance */
364 uint32_t insi_flags; /* generic IP/datagram flags */
365 uint32_t insi_flow;
366
367 uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */
368 uint8_t insi_ip_ttl; /* time to live proto */
369 uint32_t rfu_1; /* reserved */
370 /* protocol dependent part */
371 union {
372 struct in4in6_addr ina_46;
373 struct in6_addr ina_6;
374 } insi_faddr; /* foreign host table entry */
375 union {
376 struct in4in6_addr ina_46;
377 struct in6_addr ina_6;
378 } insi_laddr; /* local host table entry */
379 struct {
380 u_char in4_tos; /* type of service */
381 } insi_v4;
382 struct {
383 uint8_t in6_hlim;
384 int in6_cksum;
385 u_short in6_ifindex;
386 short in6_hops;
387 } insi_v6;
388};
389
390/*
391 * TCP Sockets
392 */
393
394#define TSI_T_REXMT 0 /* retransmit */
395#define TSI_T_PERSIST 1 /* retransmit persistence */
396#define TSI_T_KEEP 2 /* keep alive */
397#define TSI_T_2MSL 3 /* 2*msl quiet time timer */
398#define TSI_T_NTIMERS 4
399
400#define TSI_S_CLOSED 0 /* closed */
401#define TSI_S_LISTEN 1 /* listening for connection */
402#define TSI_S_SYN_SENT 2 /* active, have sent syn */
403#define TSI_S_SYN_RECEIVED 3 /* have send and received syn */
404#define TSI_S_ESTABLISHED 4 /* established */
405#define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */
406#define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */
407#define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */
408#define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */
409#define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */
410#define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */
411#define TSI_S_RESERVED 11 /* pseudo state: reserved */
412
413struct tcp_sockinfo {
414 struct in_sockinfo tcpsi_ini;
415 int tcpsi_state;
416 int tcpsi_timer[TSI_T_NTIMERS];
417 int tcpsi_mss;
418 uint32_t tcpsi_flags;
419 uint32_t rfu_1; /* reserved */
420 uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */
421};
422
423/*
424 * Unix Domain Sockets
425 */
426
427
428struct un_sockinfo {
429 uint64_t unsi_conn_so; /* opaque handle of connected socket */
430 uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */
431 union {
432 struct sockaddr_un ua_sun;
433 char ua_dummy[SOCK_MAXADDRLEN];
434 } unsi_addr; /* bound address */
435 union {
436 struct sockaddr_un ua_sun;
437 char ua_dummy[SOCK_MAXADDRLEN];
438 } unsi_caddr; /* address of socket connected to */
439};
440
441/*
442 * PF_NDRV Sockets
443 */
444
445struct ndrv_info {
446 uint32_t ndrvsi_if_family;
447 uint32_t ndrvsi_if_unit;
448 char ndrvsi_if_name[IF_NAMESIZE];
449};
450
451/*
452 * Kernel Event Sockets
453 */
454
455struct kern_event_info {
456 uint32_t kesi_vendor_code_filter;
457 uint32_t kesi_class_filter;
458 uint32_t kesi_subclass_filter;
459};
460
461/*
462 * Kernel Control Sockets
463 */
464
465struct kern_ctl_info {
466 uint32_t kcsi_id;
467 uint32_t kcsi_reg_unit;
468 uint32_t kcsi_flags; /* support flags */
469 uint32_t kcsi_recvbufsize; /* request more than the default buffer size */
470 uint32_t kcsi_sendbufsize; /* request more than the default buffer size */
471 uint32_t kcsi_unit;
472 char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */
473};
474
475/*
476 * VSock Sockets
477 */
478
479struct vsock_sockinfo {
480 uint32_t local_cid;
481 uint32_t local_port;
482 uint32_t remote_cid;
483 uint32_t remote_port;
484};
485
486/* soi_state */
487
488#define SOI_S_NOFDREF 0x0001 /* no file table ref any more */
489#define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */
490#define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */
491#define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */
492#define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */
493#define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */
494#define SOI_S_RCVATMARK 0x0040 /* at mark on input */
495#define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */
496#define SOI_S_NBIO 0x0100 /* non-blocking ops */
497#define SOI_S_ASYNC 0x0200 /* async i/o notify */
498#define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */
499#define SOI_S_COMP 0x1000 /* unaccepted, complete connection */
500#define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
501#define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */
502
503struct sockbuf_info {
504 uint32_t sbi_cc;
505 uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */
506 uint32_t sbi_mbcnt;
507 uint32_t sbi_mbmax;
508 uint32_t sbi_lowat;
509 short sbi_flags;
510 short sbi_timeo;
511};
512
513enum {
514 SOCKINFO_GENERIC = 0,
515 SOCKINFO_IN = 1,
516 SOCKINFO_TCP = 2,
517 SOCKINFO_UN = 3,
518 SOCKINFO_NDRV = 4,
519 SOCKINFO_KERN_EVENT = 5,
520 SOCKINFO_KERN_CTL = 6,
521 SOCKINFO_VSOCK = 7,
522};
523
524struct socket_info {
525 struct vinfo_stat soi_stat;
526 uint64_t soi_so; /* opaque handle of socket */
527 uint64_t soi_pcb; /* opaque handle of protocol control block */
528 int soi_type;
529 int soi_protocol;
530 int soi_family;
531 short soi_options;
532 short soi_linger;
533 short soi_state;
534 short soi_qlen;
535 short soi_incqlen;
536 short soi_qlimit;
537 short soi_timeo;
538 u_short soi_error;
539 uint32_t soi_oobmark;
540 struct sockbuf_info soi_rcv;
541 struct sockbuf_info soi_snd;
542 int soi_kind;
543 uint32_t rfu_1; /* reserved */
544 union {
545 struct in_sockinfo pri_in; /* SOCKINFO_IN */
546 struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */
547 struct un_sockinfo pri_un; /* SOCKINFO_UN */
548 struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */
549 struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */
550 struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */
551 struct vsock_sockinfo pri_vsock; /* SOCKINFO_VSOCK */
552 } soi_proto;
553};
554
555struct socket_fdinfo {
556 struct proc_fileinfo pfi;
557 struct socket_info psi;
558};
559
560
561
562struct psem_info {
563 struct vinfo_stat psem_stat;
564 char psem_name[MAXPATHLEN];
565};
566
567struct psem_fdinfo {
568 struct proc_fileinfo pfi;
569 struct psem_info pseminfo;
570};
571
572
573
574struct pshm_info {
575 struct vinfo_stat pshm_stat;
576 uint64_t pshm_mappaddr;
577 char pshm_name[MAXPATHLEN];
578};
579
580struct pshm_fdinfo {
581 struct proc_fileinfo pfi;
582 struct pshm_info pshminfo;
583};
584
585
586struct pipe_info {
587 struct vinfo_stat pipe_stat;
588 uint64_t pipe_handle;
589 uint64_t pipe_peerhandle;
590 int pipe_status;
591 int rfu_1; /* reserved */
592};
593
594struct pipe_fdinfo {
595 struct proc_fileinfo pfi;
596 struct pipe_info pipeinfo;
597};
598
599
600struct kqueue_info {
601 struct vinfo_stat kq_stat;
602 uint32_t kq_state;
603 uint32_t rfu_1; /* reserved */
604};
605
606struct kqueue_dyninfo {
607 struct kqueue_info kqdi_info;
608 uint64_t kqdi_servicer;
609 uint64_t kqdi_owner;
610 uint32_t kqdi_sync_waiters;
611 uint8_t kqdi_sync_waiter_qos;
612 uint8_t kqdi_async_qos;
613 uint16_t kqdi_request_state;
614 uint8_t kqdi_events_qos;
615 uint8_t kqdi_pri;
616 uint8_t kqdi_pol;
617 uint8_t kqdi_cpupercent;
618 uint8_t _kqdi_reserved0[4];
619 uint64_t _kqdi_reserved1[4];
620};
621
622/* keep in sync with KQ_* in sys/eventvar.h */
623#define PROC_KQUEUE_SELECT 0x01
624#define PROC_KQUEUE_SLEEP 0x02
625#define PROC_KQUEUE_32 0x08
626#define PROC_KQUEUE_64 0x10
627#define PROC_KQUEUE_QOS 0x20
628
629
630struct kqueue_fdinfo {
631 struct proc_fileinfo pfi;
632 struct kqueue_info kqueueinfo;
633};
634
635struct appletalk_info {
636 struct vinfo_stat atalk_stat;
637};
638
639struct appletalk_fdinfo {
640 struct proc_fileinfo pfi;
641 struct appletalk_info appletalkinfo;
642};
643
644typedef uint64_t proc_info_udata_t;
645
646/* defns of process file desc type */
647#define PROX_FDTYPE_ATALK 0
648#define PROX_FDTYPE_VNODE 1
649#define PROX_FDTYPE_SOCKET 2
650#define PROX_FDTYPE_PSHM 3
651#define PROX_FDTYPE_PSEM 4
652#define PROX_FDTYPE_KQUEUE 5
653#define PROX_FDTYPE_PIPE 6
654#define PROX_FDTYPE_FSEVENTS 7
655#define PROX_FDTYPE_NETPOLICY 9
656
657struct proc_fdinfo {
658 int32_t proc_fd;
659 uint32_t proc_fdtype;
660};
661
662struct proc_fileportinfo {
663 uint32_t proc_fileport;
664 uint32_t proc_fdtype;
665};
666
667
668/* Flavors for proc_pidinfo() */
669#define PROC_PIDLISTFDS 1
670#define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo))
671
672#define PROC_PIDTASKALLINFO 2
673#define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo))
674
675#define PROC_PIDTBSDINFO 3
676#define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo))
677
678#define PROC_PIDTASKINFO 4
679#define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo))
680
681#define PROC_PIDTHREADINFO 5
682#define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo))
683
684#define PROC_PIDLISTTHREADS 6
685#define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t))
686
687#define PROC_PIDREGIONINFO 7
688#define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo))
689
690#define PROC_PIDREGIONPATHINFO 8
691#define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo))
692
693#define PROC_PIDVNODEPATHINFO 9
694#define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo))
695
696#define PROC_PIDTHREADPATHINFO 10
697#define PROC_PIDTHREADPATHINFO_SIZE (sizeof(struct proc_threadwithpathinfo))
698
699#define PROC_PIDPATHINFO 11
700#define PROC_PIDPATHINFO_SIZE (MAXPATHLEN)
701#define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN)
702
703#define PROC_PIDWORKQUEUEINFO 12
704#define PROC_PIDWORKQUEUEINFO_SIZE (sizeof(struct proc_workqueueinfo))
705
706#define PROC_PIDT_SHORTBSDINFO 13
707#define PROC_PIDT_SHORTBSDINFO_SIZE (sizeof(struct proc_bsdshortinfo))
708
709#define PROC_PIDLISTFILEPORTS 14
710#define PROC_PIDLISTFILEPORTS_SIZE (sizeof(struct proc_fileportinfo))
711
712#define PROC_PIDTHREADID64INFO 15
713#define PROC_PIDTHREADID64INFO_SIZE (sizeof(struct proc_threadinfo))
714
715#define PROC_PID_RUSAGE 16
716#define PROC_PID_RUSAGE_SIZE 0
717
718/* Flavors for proc_pidfdinfo */
719
720#define PROC_PIDFDVNODEINFO 1
721#define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo))
722
723#define PROC_PIDFDVNODEPATHINFO 2
724#define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath))
725
726#define PROC_PIDFDSOCKETINFO 3
727#define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo))
728
729#define PROC_PIDFDPSEMINFO 4
730#define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo))
731
732#define PROC_PIDFDPSHMINFO 5
733#define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo))
734
735#define PROC_PIDFDPIPEINFO 6
736#define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo))
737
738#define PROC_PIDFDKQUEUEINFO 7
739#define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo))
740
741#define PROC_PIDFDATALKINFO 8
742#define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo))
743
744
745
746/* Flavors for proc_pidfileportinfo */
747
748#define PROC_PIDFILEPORTVNODEPATHINFO 2 /* out: vnode_fdinfowithpath */
749#define PROC_PIDFILEPORTVNODEPATHINFO_SIZE \
750 PROC_PIDFDVNODEPATHINFO_SIZE
751
752#define PROC_PIDFILEPORTSOCKETINFO 3 /* out: socket_fdinfo */
753#define PROC_PIDFILEPORTSOCKETINFO_SIZE PROC_PIDFDSOCKETINFO_SIZE
754
755#define PROC_PIDFILEPORTPSHMINFO 5 /* out: pshm_fdinfo */
756#define PROC_PIDFILEPORTPSHMINFO_SIZE PROC_PIDFDPSHMINFO_SIZE
757
758#define PROC_PIDFILEPORTPIPEINFO 6 /* out: pipe_fdinfo */
759#define PROC_PIDFILEPORTPIPEINFO_SIZE PROC_PIDFDPIPEINFO_SIZE
760
761/* used for proc_setcontrol */
762#define PROC_SELFSET_PCONTROL 1
763
764#define PROC_SELFSET_THREADNAME 2
765#define PROC_SELFSET_THREADNAME_SIZE (MAXTHREADNAMESIZE -1)
766
767#define PROC_SELFSET_VMRSRCOWNER 3
768
769#define PROC_SELFSET_DELAYIDLESLEEP 4
770
771/* used for proc_dirtycontrol */
772#define PROC_DIRTYCONTROL_TRACK 1
773#define PROC_DIRTYCONTROL_SET 2
774#define PROC_DIRTYCONTROL_GET 3
775#define PROC_DIRTYCONTROL_CLEAR 4
776
777/* proc_track_dirty() flags */
778#define PROC_DIRTY_TRACK 0x1
779#define PROC_DIRTY_ALLOW_IDLE_EXIT 0x2
780#define PROC_DIRTY_DEFER 0x4
781#define PROC_DIRTY_LAUNCH_IN_PROGRESS 0x8
782#define PROC_DIRTY_DEFER_ALWAYS 0x10
783
784/* proc_get_dirty() flags */
785#define PROC_DIRTY_TRACKED 0x1
786#define PROC_DIRTY_ALLOWS_IDLE_EXIT 0x2
787#define PROC_DIRTY_IS_DIRTY 0x4
788#define PROC_DIRTY_LAUNCH_IS_IN_PROGRESS 0x8
789
790/* Flavors for proc_udata_info */
791#define PROC_UDATA_INFO_GET 1
792#define PROC_UDATA_INFO_SET 2
793
794
795
796
797__END_DECLS
798
799#endif /*_SYS_PROC_INFO_H */
lib/libc/include/x86_64-macos-gnu/sys/ucontext.h created+41
......@@ -0,0 +1,41 @@
1/*
2 * Copyright (c) 2002-2006 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
29#ifndef _SYS_UCONTEXT_H_
30#define _SYS_UCONTEXT_H_
31
32#include <sys/cdefs.h>
33#include <sys/_types.h>
34
35#include <machine/_mcontext.h>
36#include <sys/_types/_ucontext.h>
37
38#include <sys/_types/_sigset_t.h>
39
40
41#endif /* _SYS_UCONTEXT_H_ */
lib/libc/include/x86_64-macos-gnu/ucontext.h created+54
......@@ -0,0 +1,54 @@
1/*
2 * Copyright (c) 2002, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 * These routines are DEPRECATED and should not be used.
26 */
27#ifndef _UCONTEXT_H_
28#define _UCONTEXT_H_
29
30#include <sys/cdefs.h>
31
32#ifdef _XOPEN_SOURCE
33#include <sys/ucontext.h>
34#include <Availability.h>
35
36__BEGIN_DECLS
37__API_DEPRECATED("No longer supported", macos(10.5, 10.6))
38int getcontext(ucontext_t *);
39
40__API_DEPRECATED("No longer supported", macos(10.5, 10.6))
41void makecontext(ucontext_t *, void (*)(), int, ...);
42
43__API_DEPRECATED("No longer supported", macos(10.5, 10.6))
44int setcontext(const ucontext_t *);
45
46__API_DEPRECATED("No longer supported", macos(10.5, 10.6))
47int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict);
48
49__END_DECLS
50#else /* !_XOPEN_SOURCE */
51#error The deprecated ucontext routines require _XOPEN_SOURCE to be defined
52#endif /* _XOPEN_SOURCE */
53
54#endif /* _UCONTEXT_H_ */