···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>) && 0
3131-# include_next <stdatomic.h>
3030+#ifdef __STDC_NO_ATOMICS__
3131+3232#else
33333434#include <stddef.h>
+64
kernel-include/bank/bank_types.h
···11+/*
22+ * Copyright (c) 2012-2013 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 _BANK_BANK_TYPES_H_
3030+#define _BANK_BANK_TYPES_H_
3131+3232+#include <stdint.h>
3333+#include <mach/mach_types.h>
3434+3535+#define MACH_VOUCHER_ATTR_BANK_NULL ((mach_voucher_attr_recipe_command_t)601)
3636+#define MACH_VOUCHER_ATTR_BANK_CREATE ((mach_voucher_attr_recipe_command_t)610)
3737+3838+#define MACH_VOUCHER_BANK_CONTENT_SIZE (500)
3939+4040+typedef uint32_t bank_action_t;
4141+#define BANK_ORIGINATOR_PID 0x1
4242+#define BANK_PERSONA_TOKEN 0x2
4343+4444+struct proc_persona_info {
4545+ uint64_t unique_pid;
4646+ int32_t pid;
4747+ uint32_t flags;
4848+ uint32_t pidversion;
4949+ uint32_t persona_id;
5050+ uint32_t uid;
5151+ uint32_t gid;
5252+ uint8_t macho_uuid[16];
5353+};
5454+5555+struct persona_token {
5656+ struct proc_persona_info originator;
5757+ struct proc_persona_info proximate;
5858+};
5959+6060+#ifdef PRIVATE
6161+#define ENTITLEMENT_PERSONA_PROPAGATE "com.apple.private.personas.propagate"
6262+#endif /* PRIVATE */
6363+6464+#endif /* _BANK_BANK_TYPES_H_ */
+226-31
platform-include/mach-o/dyld_priv.h
···4040//
4141extern int _dyld_func_lookup(const char* dyld_func_name, void **address);
42424343-4444-//
4545-// _dyld_moninit() is a private interface between libSystem.dylib and dyld
4646-//
4747-extern void _dyld_moninit(void (*monaddition)(char *lowpc, char *highpc));
4848-4943//
5044// private interface between libSystem.dylib and dyld
5145//
5246extern void _dyld_fork_child();
534754485555-//
5656-// Possible state changes for which you can register to be notified
5757-//
4949+// DEPRECATED
5850enum dyld_image_states
5951{
6052 dyld_image_state_mapped = 10, // No batch notification for this
···6658 dyld_image_state_terminated = 60 // Only single notification for this
6759};
68606969-//
7070-// Callback that provides a bottom-up array of images
7171-// For dyld_image_state_[dependents_]mapped state only, returning non-NULL will cause dyld to abort loading all those images
7272-// and append the returned string to its load failure error message. dyld does not free the string, so
7373-// it should be a literal string or a static buffer
7474-//
6161+// DEPRECATED
7562typedef const char* (*dyld_image_state_change_handler)(enum dyld_image_states state, uint32_t infoCount, const struct dyld_image_info info[]);
76636464+6565+6666+typedef void (*_dyld_objc_notify_mapped)(unsigned count, const char* const paths[], const struct mach_header* const mh[]);
6767+typedef void (*_dyld_objc_notify_init)(const char* path, const struct mach_header* mh);
6868+typedef void (*_dyld_objc_notify_unmapped)(const char* path, const struct mach_header* mh);
6969+7070+7771//
7878-// Register a handler to be called when any image changes to the requested state.
7979-// If 'batch' is true, the callback is called with an array of all images that are in the requested state sorted by dependency.
8080-// If 'batch' is false, the callback is called with one image at a time as each image transitions to the the requested state.
8181-// During the call to this function, the handler may be called back with existing images and the handler should
8282-// not return a string, since there is no load to abort. In batch mode, existing images at or past the request
8383-// state supplied in the callback. In non-batch mode, the callback is called for each image exactly in the
8484-// requested state.
7272+// Note: only for use by objc runtime
7373+// Register handlers to be called when objc images are mapped, unmapped, and initialized.
7474+// Dyld will call back the "mapped" function with an array of images that contain an objc-image-info section.
7575+// Those images that are dylibs will have the ref-counts automatically bumped, so objc will no longer need to
7676+// call dlopen() on them to keep them from being unloaded. During the call to _dyld_objc_notify_register(),
7777+// dyld will call the "mapped" function with already loaded objc images. During any later dlopen() call,
7878+// dyld will also call the "mapped" function. Dyld will call the "init" function when dyld would be called
7979+// initializers in that image. This is when objc calls any +load methods in that image.
8580//
8686-extern void
8787-dyld_register_image_state_change_handler(enum dyld_image_states state, bool batch, dyld_image_state_change_handler handler);
8181+void _dyld_objc_notify_register(_dyld_objc_notify_mapped mapped,
8282+ _dyld_objc_notify_init init,
8383+ _dyld_objc_notify_unmapped unmapped);
8484+888589869087//
···144141// Exists in Mac OS X 10.4 and later through _dyld_func_lookup()
145142// Exists in Mac OS X 10.6 and later through libSystem.dylib
146143//
147147-const struct dyld_all_image_infos* _dyld_get_all_image_infos();
144144+const struct dyld_all_image_infos* _dyld_get_all_image_infos() __attribute__((deprecated));
148145149146150147···177174extern const char* dyld_image_path_containing_address(const void* addr);
178175179176177177+//
178178+// This is an optimized form of dladdr() that only returns the dli_fbase field.
179179+// Return NULL, if address is not in any image tracked by dyld.
180180+//
181181+// Exists in Mac OS X 10.11 and later
182182+extern const struct mach_header* dyld_image_header_containing_address(const void* addr);
183183+184184+185185+186186+// Convienence constants for return values from dyld_get_sdk_version() and friends.
187187+#define DYLD_MACOSX_VERSION_10_4 0x000A0400
188188+#define DYLD_MACOSX_VERSION_10_5 0x000A0500
189189+#define DYLD_MACOSX_VERSION_10_6 0x000A0600
190190+#define DYLD_MACOSX_VERSION_10_7 0x000A0700
191191+#define DYLD_MACOSX_VERSION_10_8 0x000A0800
192192+#define DYLD_MACOSX_VERSION_10_9 0x000A0900
193193+#define DYLD_MACOSX_VERSION_10_10 0x000A0A00
194194+#define DYLD_MACOSX_VERSION_10_11 0x000A0B00
195195+#define DYLD_MACOSX_VERSION_10_12 0x000A0C00
196196+197197+#define DYLD_IOS_VERSION_2_0 0x00020000
198198+#define DYLD_IOS_VERSION_2_1 0x00020100
199199+#define DYLD_IOS_VERSION_2_2 0x00020200
200200+#define DYLD_IOS_VERSION_3_0 0x00030000
201201+#define DYLD_IOS_VERSION_3_1 0x00030100
202202+#define DYLD_IOS_VERSION_3_2 0x00030200
203203+#define DYLD_IOS_VERSION_4_0 0x00040000
204204+#define DYLD_IOS_VERSION_4_1 0x00040100
205205+#define DYLD_IOS_VERSION_4_2 0x00040200
206206+#define DYLD_IOS_VERSION_4_3 0x00040300
207207+#define DYLD_IOS_VERSION_5_0 0x00050000
208208+#define DYLD_IOS_VERSION_5_1 0x00050100
209209+#define DYLD_IOS_VERSION_6_0 0x00060000
210210+#define DYLD_IOS_VERSION_6_1 0x00060100
211211+#define DYLD_IOS_VERSION_7_0 0x00070000
212212+#define DYLD_IOS_VERSION_7_1 0x00070100
213213+#define DYLD_IOS_VERSION_8_0 0x00080000
214214+#define DYLD_IOS_VERSION_8_1 0x00080100
215215+#define DYLD_IOS_VERSION_8_2 0x00080200
216216+#define DYLD_IOS_VERSION_8_3 0x00080300
217217+#define DYLD_IOS_VERSION_8_4 0x00080400
218218+#define DYLD_IOS_VERSION_9_0 0x00090000
219219+#define DYLD_IOS_VERSION_9_1 0x00090100
220220+#define DYLD_IOS_VERSION_9_2 0x00090200
221221+#define DYLD_IOS_VERSION_9_3 0x00090300
222222+#define DYLD_IOS_VERSION_10_0 0x000A0000
223223+224224+225225+#define DYLD_WATCHOS_VERSION_1_0 0x00010000
226226+#define DYLD_WATCHOS_VERSION_2_0 0x00020000
227227+#define DYLD_WATCHOS_VERSION_2_1 0x00020100
228228+#define DYLD_WATCHOS_VERSION_2_2 0x00020200
229229+#define DYLD_WATCHOS_VERSION_3_0 0x00030000
230230+180231181232182233//
183183-// This is finds the SDK version a binary was built against.
234234+// This finds the SDK version a binary was built against.
184235// Returns zero on error, or if SDK version could not be determined.
185236//
186237// Exists in Mac OS X 10.8 and later
238238+// Exists in iOS 6.0 and later
187239extern uint32_t dyld_get_sdk_version(const struct mach_header* mh);
188240189241190242//
191191-// This is finds the SDK version the main executable was built against.
243243+// This finds the SDK version that the main executable was built against.
192244// Returns zero on error, or if SDK version could not be determined.
193245//
246246+// Note on WatchOS, this returns the equivalent iOS SDK version number
247247+// (i.e an app built against WatchOS 2.0 SDK returne 9.0). To see the
248248+// platform specific sdk version use dyld_get_program_sdk_watch_os_version().
249249+//
194250// Exists in Mac OS X 10.8 and later
251251+// Exists in iOS 6.0 and later
195252extern uint32_t dyld_get_program_sdk_version();
196253197254255255+// Watch OS only.
256256+// This finds the Watch OS SDK version that the main executable was built against.
257257+// Exists in Watch OS 2.0 and later
258258+extern uint32_t dyld_get_program_sdk_watch_os_version(); // __WATCHOS_AVAILABLE(2.0);
259259+260260+261261+// Watch OS only.
262262+// This finds the Watch min OS version that the main executable was built to run on.
263263+// Note: dyld_get_program_min_os_version() returns the iOS equivalent (e.g. 9.0)
264264+// whereas this returns the raw watchOS version (e.g. 2.0).
265265+// Exists in Watch OS 3.0 and later
266266+extern uint32_t dyld_get_program_min_watch_os_version(); // __WATCHOS_AVAILABLE(3.0);
267267+268268+198269//
199199-// This is finds the min OS version a binary was built to run on.
270270+// This finds the min OS version a binary was built to run on.
200271// Returns zero on error, or if no min OS recorded in binary.
201272//
202273// Exists in Mac OS X 10.8 and later
274274+// Exists in iOS 6.0 and later
203275extern uint32_t dyld_get_min_os_version(const struct mach_header* mh);
204276205277206278//
207207-// This is finds the min OS version the main executable was built to run on.
279279+// This finds the min OS version the main executable was built to run on.
208280// Returns zero on error, or if no min OS recorded in binary.
209281//
210282// Exists in Mac OS X 10.8 and later
283283+// Exists in iOS 6.0 and later
211284extern uint32_t dyld_get_program_min_os_version();
212285213286214287215288216216-#if __IPHONE_OS_VERSION_MIN_REQUIRED
217289//
218290// Returns if any OS dylib has overridden its copy in the shared cache
219291//
220292// Exists in iPhoneOS 3.1 and later
293293+// Exists in Mac OS X 10.10 and later
221294extern bool dyld_shared_cache_some_image_overridden();
222222-#endif
223295224296297297+298298+//
299299+// Returns if the process is setuid or is code signed with entitlements.
300300+//
301301+// Exists in Mac OS X 10.9 and later
302302+extern bool dyld_process_is_restricted();
303303+304304+305305+306306+//
307307+// Returns path used by dyld for standard dyld shared cache file for the current arch.
308308+//
309309+// Exists in Mac OS X 10.11 and later
310310+extern const char* dyld_shared_cache_file_path();
311311+312312+313313+314314+//
315315+// <rdar://problem/13820686> for OpenGL to tell dyld it is ok to deallocate a memory based image when done.
316316+//
317317+// Exists in Mac OS X 10.9 and later
318318+#define NSLINKMODULE_OPTION_CAN_UNLOAD 0x20
319319+320320+321321+//
322322+// Update all bindings on specified image.
323323+// Looks for uses of 'replacement' and changes it to 'replacee'.
324324+// NOTE: this is less safe than using static interposing via DYLD_INSERT_LIBRARIES
325325+// because the running program may have already copy the pointer values to other
326326+// locations that dyld does not know about.
327327+//
328328+struct dyld_interpose_tuple {
329329+ const void* replacement;
330330+ const void* replacee;
331331+};
332332+extern void dyld_dynamic_interpose(const struct mach_header* mh, const struct dyld_interpose_tuple array[], size_t count);
333333+334334+335335+struct dyld_shared_cache_dylib_text_info {
336336+ uint64_t version; // current version 1
337337+ // following fields all exist in version 1
338338+ uint64_t loadAddressUnslid;
339339+ uint64_t textSegmentSize;
340340+ uuid_t dylibUuid;
341341+ const char* path; // pointer invalid at end of iterations
342342+};
343343+typedef struct dyld_shared_cache_dylib_text_info dyld_shared_cache_dylib_text_info;
344344+345345+//
346346+// Given the UUID of a dyld shared cache file, this function will attempt to locate the cache
347347+// file and if found iterate all images, returning info about each one. Returns 0 on success.
348348+//
349349+// Exists in Mac OS X 10.11 and later
350350+// iOS 9.0 and later
351351+extern int dyld_shared_cache_iterate_text(const uuid_t cacheUuid, void (^callback)(const dyld_shared_cache_dylib_text_info* info));
352352+353353+354354+//
355355+// Given the UUID of a dyld shared cache file, and a NULL terminated array of extra directory paths to search,
356356+// this function will scan the standard and extra directories looking for a cache file that matches the UUID
357357+// and if found iterate all images, returning info about each one. Returns 0 on success.
358358+//
359359+// Exists in Mac OS X 10.12 and later
360360+// iOS 10.0 and later
361361+extern int dyld_shared_cache_find_iterate_text(const uuid_t cacheUuid, const char* extraSearchDirs[], void (^callback)(const dyld_shared_cache_dylib_text_info* info));
362362+363363+364364+//
365365+// Returns if the specified address range is in a dyld owned memory
366366+// that is mapped read-only and will never be unloaded.
367367+//
368368+// Exists in Mac OS X 10.12 and later
369369+// iOS 10.0 and later
370370+extern bool _dyld_is_memory_immutable(const void* addr, size_t length);
371371+372372+373373+//
374374+// Finds the UUID (from LC_UUID load command) of given image.
375375+// Returns false if LC_UUID is missing or mach_header is malformed.
376376+//
377377+// Exists in Mac OS X 10.12 and later
378378+// Exists in iOS 10.0 and later
379379+extern bool _dyld_get_image_uuid(const struct mach_header* mh, uuid_t uuid);
380380+381381+382382+//
383383+// Gets the UUID of the dyld shared cache in the current process.
384384+// Returns false if there is no dyld shared cache in use by the processes.
385385+//
386386+// Exists in Mac OS X 10.12 and later
387387+// Exists in iOS 10.0 and later
388388+extern bool _dyld_get_shared_cache_uuid(uuid_t uuid);
389389+390390+391391+392392+//
393393+// When dyld must terminate a process because of a required dependent dylib
394394+// could not be loaded or a symbol is missing, dyld calls abort_with_reason()
395395+// using one of the following error codes.
396396+//
397397+#define DYLD_EXIT_REASON_DYLIB_MISSING 1
398398+#define DYLD_EXIT_REASON_DYLIB_WRONG_ARCH 2
399399+#define DYLD_EXIT_REASON_DYLIB_WRONG_VERSION 3
400400+#define DYLD_EXIT_REASON_SYMBOL_MISSING 4
401401+#define DYLD_EXIT_REASON_CODE_SIGNATURE 5
402402+#define DYLD_EXIT_REASON_FILE_SYSTEM_SANDBOX 6
403403+#define DYLD_EXIT_REASON_MALFORMED_MACHO 7
404404+#define DYLD_EXIT_REASON_OTHER 9
405405+406406+//
407407+// When it has more information about the termination, dyld will use abort_with_payload().
408408+// The payload is a dyld_abort_payload structure. The fixed fields are offsets into the
409409+// payload for the corresponding string. If the offset is zero, that string is not available.
410410+//
411411+struct dyld_abort_payload {
412412+ uint32_t version; // first version is 1
413413+ uint32_t flags; // 0x00000001 means dyld terminated at launch, backtrace not useful
414414+ uint32_t targetDylibPathOffset; // offset in payload of path string to dylib that could not be loaded
415415+ uint32_t clientPathOffset; // offset in payload of path string to image requesting dylib
416416+ uint32_t symbolOffset; // offset in payload of symbol string that could not be found
417417+ // string data
418418+};
419419+typedef struct dyld_abort_payload dyld_abort_payload;
225420226421#if __cplusplus
227422}
+14
platform-include/mach/mach_time.h
···515152525353uint64_t mach_absolute_time(void);
5454+5555+__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_8_0)
5456uint64_t mach_approximate_time(void);
5757+5858+/*
5959+ * like mach_absolute_time, but advances during sleep
6060+ */
6161+__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
6262+uint64_t mach_continuous_time(void);
6363+6464+/*
6565+ * like mach_approximate_time, but advances during sleep
6666+ */
6767+__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
6868+uint64_t mach_continuous_approximate_time(void);
5569__END_DECLS
56705771#endif /* _MACH_MACH_TIME_H_ */