Add more missing libc headers used by frameworks

See
76f22c3905.
This commit is contained in:
Jakub Konka
2020-11-09 18:44:34 +01:00
parent 267116d626
commit 09cc61bfe4
168 changed files with 50774 additions and 611 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -132,130 +132,7 @@
#define __API_TO_BE_DEPRECATED 100000
#endif
#ifndef __MAC_10_0
#define __MAC_10_0 1000
#define __MAC_10_1 1010
#define __MAC_10_2 1020
#define __MAC_10_3 1030
#define __MAC_10_4 1040
#define __MAC_10_5 1050
#define __MAC_10_6 1060
#define __MAC_10_7 1070
#define __MAC_10_8 1080
#define __MAC_10_9 1090
#define __MAC_10_10 101000
#define __MAC_10_10_2 101002
#define __MAC_10_10_3 101003
#define __MAC_10_11 101100
#define __MAC_10_11_2 101102
#define __MAC_10_11_3 101103
#define __MAC_10_11_4 101104
#define __MAC_10_12 101200
#define __MAC_10_12_1 101201
#define __MAC_10_12_2 101202
#define __MAC_10_12_4 101204
#define __MAC_10_13 101300
#define __MAC_10_13_1 101301
#define __MAC_10_13_2 101302
#define __MAC_10_13_4 101304
#define __MAC_10_14 101400
#define __MAC_10_14_1 101401
#define __MAC_10_14_4 101404
#define __MAC_10_15 101500
#define __MAC_10_15_1 101501
#define __MAC_10_15_4 101504
/* __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
#define __IPHONE_2_0 20000
#define __IPHONE_2_1 20100
#define __IPHONE_2_2 20200
#define __IPHONE_3_0 30000
#define __IPHONE_3_1 30100
#define __IPHONE_3_2 30200
#define __IPHONE_4_0 40000
#define __IPHONE_4_1 40100
#define __IPHONE_4_2 40200
#define __IPHONE_4_3 40300
#define __IPHONE_5_0 50000
#define __IPHONE_5_1 50100
#define __IPHONE_6_0 60000
#define __IPHONE_6_1 60100
#define __IPHONE_7_0 70000
#define __IPHONE_7_1 70100
#define __IPHONE_8_0 80000
#define __IPHONE_8_1 80100
#define __IPHONE_8_2 80200
#define __IPHONE_8_3 80300
#define __IPHONE_8_4 80400
#define __IPHONE_9_0 90000
#define __IPHONE_9_1 90100
#define __IPHONE_9_2 90200
#define __IPHONE_9_3 90300
#define __IPHONE_10_0 100000
#define __IPHONE_10_1 100100
#define __IPHONE_10_2 100200
#define __IPHONE_10_3 100300
#define __IPHONE_11_0 110000
#define __IPHONE_11_1 110100
#define __IPHONE_11_2 110200
#define __IPHONE_11_3 110300
#define __IPHONE_11_4 110400
#define __IPHONE_12_0 120000
#define __IPHONE_12_1 120100
#define __IPHONE_12_2 120200
#define __IPHONE_12_3 120300
#define __IPHONE_13_0 130000
#define __IPHONE_13_1 130100
#define __IPHONE_13_2 130200
#define __IPHONE_13_3 130300
#define __IPHONE_13_4 130400
#define __IPHONE_13_5 130500
#define __IPHONE_13_6 130600
/* __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
#define __TVOS_9_0 90000
#define __TVOS_9_1 90100
#define __TVOS_9_2 90200
#define __TVOS_10_0 100000
#define __TVOS_10_0_1 100001
#define __TVOS_10_1 100100
#define __TVOS_10_2 100200
#define __TVOS_11_0 110000
#define __TVOS_11_1 110100
#define __TVOS_11_2 110200
#define __TVOS_11_3 110300
#define __TVOS_11_4 110400
#define __TVOS_12_0 120000
#define __TVOS_12_1 120100
#define __TVOS_12_2 120200
#define __TVOS_12_3 120300
#define __TVOS_13_0 130000
#define __TVOS_13_2 130200
#define __TVOS_13_3 130300
#define __TVOS_13_4 130400
#define __WATCHOS_1_0 10000
#define __WATCHOS_2_0 20000
#define __WATCHOS_2_1 20100
#define __WATCHOS_2_2 20200
#define __WATCHOS_3_0 30000
#define __WATCHOS_3_1 30100
#define __WATCHOS_3_1_1 30101
#define __WATCHOS_3_2 30200
#define __WATCHOS_4_0 40000
#define __WATCHOS_4_1 40100
#define __WATCHOS_4_2 40200
#define __WATCHOS_4_3 40300
#define __WATCHOS_5_0 50000
#define __WATCHOS_5_1 50100
#define __WATCHOS_5_2 50200
#define __WATCHOS_6_0 60000
#define __WATCHOS_6_1 60100
#define __WATCHOS_6_2 60200
#define __DRIVERKIT_19_0 190000
#endif /* __MAC_10_0 */
#include <AvailabilityVersions.h>
#include <AvailabilityInternal.h>
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED

View File

@@ -45,6 +45,9 @@
#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
/* compiler sets __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ when -miphoneos-version-min is used */
#define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
/* set to 1 when RC_FALLBACK_PLATFORM=iphoneos */
#elif 0
#define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_14_0
#endif
#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED */
@@ -52,7 +55,7 @@
#ifdef __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
/* compiler sets __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ when -mtvos-version-min is used */
#define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__
#define __TV_OS_VERSION_MAX_ALLOWED __TVOS_13_0
#define __TV_OS_VERSION_MAX_ALLOWED __TVOS_14_2
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED 90000
#endif
@@ -62,7 +65,7 @@
#ifdef __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
/* compiler sets __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ when -mwatchos-version-min is used */
#define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__
#define __WATCH_OS_VERSION_MAX_ALLOWED 60000
#define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_7_1
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED 90000
#endif
@@ -72,7 +75,7 @@
#ifdef __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__
#define __BRIDGE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__
#define __BRIDGE_OS_VERSION_MAX_ALLOWED 20000
#define __BRIDGE_OS_VERSION_MAX_ALLOWED 50000
/* for compatibility with existing code. New code should use platform specific checks */
#define __IPHONE_OS_VERSION_MIN_REQUIRED 110000
#endif
@@ -87,14 +90,14 @@
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
/* make sure a default max version is set */
#ifndef __MAC_OS_X_VERSION_MAX_ALLOWED
#define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_10_15
#define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_11_0
#endif
#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
/* make sure a default max version is set */
#ifndef __IPHONE_OS_VERSION_MAX_ALLOWED
#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_13_0
#define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_14_2
#endif
/* make sure a valid min is set */
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_2_0
@@ -2887,7 +2890,7 @@
#if __has_builtin(__is_target_environment)
#if __has_builtin(__is_target_variant_os)
#if __has_builtin(__is_target_variant_environment)
#if (__is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi))
#if ((__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi))
#define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION __attribute__((availability(ios,introduced=4.0)))
#define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION __attribute__((availability(ios,unavailable)))
#define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,unavailable)))

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,208 @@
/*
* Copyright (c) 2019 by Apple Inc.. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __AVAILABILITY_VERSIONS__
#define __AVAILABILITY_VERSIONS__
#define __MAC_10_0 1000
#define __MAC_10_1 1010
#define __MAC_10_2 1020
#define __MAC_10_3 1030
#define __MAC_10_4 1040
#define __MAC_10_5 1050
#define __MAC_10_6 1060
#define __MAC_10_7 1070
#define __MAC_10_8 1080
#define __MAC_10_9 1090
#define __MAC_10_10 101000
#define __MAC_10_10_2 101002
#define __MAC_10_10_3 101003
#define __MAC_10_11 101100
#define __MAC_10_11_2 101102
#define __MAC_10_11_3 101103
#define __MAC_10_11_4 101104
#define __MAC_10_12 101200
#define __MAC_10_12_1 101201
#define __MAC_10_12_2 101202
#define __MAC_10_12_4 101204
#define __MAC_10_13 101300
#define __MAC_10_13_1 101301
#define __MAC_10_13_2 101302
#define __MAC_10_13_4 101304
#define __MAC_10_14 101400
#define __MAC_10_14_1 101401
#define __MAC_10_14_4 101404
#define __MAC_10_14_6 101406
#define __MAC_10_15 101500
#define __MAC_10_15_1 101501
#define __MAC_10_15_4 101504
#define __MAC_10_16 101600
#define __MAC_11_0 110000
/* __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __IPHONE_2_0 20000
#define __IPHONE_2_1 20100
#define __IPHONE_2_2 20200
#define __IPHONE_3_0 30000
#define __IPHONE_3_1 30100
#define __IPHONE_3_2 30200
#define __IPHONE_4_0 40000
#define __IPHONE_4_1 40100
#define __IPHONE_4_2 40200
#define __IPHONE_4_3 40300
#define __IPHONE_5_0 50000
#define __IPHONE_5_1 50100
#define __IPHONE_6_0 60000
#define __IPHONE_6_1 60100
#define __IPHONE_7_0 70000
#define __IPHONE_7_1 70100
#define __IPHONE_8_0 80000
#define __IPHONE_8_1 80100
#define __IPHONE_8_2 80200
#define __IPHONE_8_3 80300
#define __IPHONE_8_4 80400
#define __IPHONE_9_0 90000
#define __IPHONE_9_1 90100
#define __IPHONE_9_2 90200
#define __IPHONE_9_3 90300
#define __IPHONE_10_0 100000
#define __IPHONE_10_1 100100
#define __IPHONE_10_2 100200
#define __IPHONE_10_3 100300
#define __IPHONE_11_0 110000
#define __IPHONE_11_1 110100
#define __IPHONE_11_2 110200
#define __IPHONE_11_3 110300
#define __IPHONE_11_4 110400
#define __IPHONE_12_0 120000
#define __IPHONE_12_1 120100
#define __IPHONE_12_2 120200
#define __IPHONE_12_3 120300
#define __IPHONE_12_4 120400
#define __IPHONE_13_0 130000
#define __IPHONE_13_1 130100
#define __IPHONE_13_2 130200
#define __IPHONE_13_3 130300
#define __IPHONE_13_4 130400
#define __IPHONE_13_5 130500
#define __IPHONE_13_6 130600
#define __IPHONE_13_7 130700
#define __IPHONE_14_0 140000
#define __IPHONE_14_1 140100
#define __IPHONE_14_2 140200
/* __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */
#define __TVOS_9_0 90000
#define __TVOS_9_1 90100
#define __TVOS_9_2 90200
#define __TVOS_10_0 100000
#define __TVOS_10_0_1 100001
#define __TVOS_10_1 100100
#define __TVOS_10_2 100200
#define __TVOS_11_0 110000
#define __TVOS_11_1 110100
#define __TVOS_11_2 110200
#define __TVOS_11_3 110300
#define __TVOS_11_4 110400
#define __TVOS_12_0 120000
#define __TVOS_12_1 120100
#define __TVOS_12_2 120200
#define __TVOS_12_3 120300
#define __TVOS_12_4 120400
#define __TVOS_13_0 130000
#define __TVOS_13_2 130200
#define __TVOS_13_3 130300
#define __TVOS_13_4 130400
#define __TVOS_14_0 140000
#define __TVOS_14_1 140100
#define __TVOS_14_2 140200
#define __WATCHOS_1_0 10000
#define __WATCHOS_2_0 20000
#define __WATCHOS_2_1 20100
#define __WATCHOS_2_2 20200
#define __WATCHOS_3_0 30000
#define __WATCHOS_3_1 30100
#define __WATCHOS_3_1_1 30101
#define __WATCHOS_3_2 30200
#define __WATCHOS_4_0 40000
#define __WATCHOS_4_1 40100
#define __WATCHOS_4_2 40200
#define __WATCHOS_4_3 40300
#define __WATCHOS_5_0 50000
#define __WATCHOS_5_1 50100
#define __WATCHOS_5_2 50200
#define __WATCHOS_5_3 50300
#define __WATCHOS_6_0 60000
#define __WATCHOS_6_1 60100
#define __WATCHOS_6_2 60200
#define __WATCHOS_7_0 70000
#define __WATCHOS_7_1 70100
/*
* Set up standard Mac OS X versions
*/
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
#define MAC_OS_X_VERSION_10_0 1000
#define MAC_OS_X_VERSION_10_1 1010
#define MAC_OS_X_VERSION_10_2 1020
#define MAC_OS_X_VERSION_10_3 1030
#define MAC_OS_X_VERSION_10_4 1040
#define MAC_OS_X_VERSION_10_5 1050
#define MAC_OS_X_VERSION_10_6 1060
#define MAC_OS_X_VERSION_10_7 1070
#define MAC_OS_X_VERSION_10_8 1080
#define MAC_OS_X_VERSION_10_9 1090
#define MAC_OS_X_VERSION_10_10 101000
#define MAC_OS_X_VERSION_10_10_2 101002
#define MAC_OS_X_VERSION_10_10_3 101003
#define MAC_OS_X_VERSION_10_11 101100
#define MAC_OS_X_VERSION_10_11_2 101102
#define MAC_OS_X_VERSION_10_11_3 101103
#define MAC_OS_X_VERSION_10_11_4 101104
#define MAC_OS_X_VERSION_10_12 101200
#define MAC_OS_X_VERSION_10_12_1 101201
#define MAC_OS_X_VERSION_10_12_2 101202
#define MAC_OS_X_VERSION_10_12_4 101204
#define MAC_OS_X_VERSION_10_13 101300
#define MAC_OS_X_VERSION_10_13_1 101301
#define MAC_OS_X_VERSION_10_13_2 101302
#define MAC_OS_X_VERSION_10_13_4 101304
#define MAC_OS_X_VERSION_10_14 101400
#define MAC_OS_X_VERSION_10_14_1 101401
#define MAC_OS_X_VERSION_10_14_4 101404
#define MAC_OS_X_VERSION_10_14_6 101406
#define MAC_OS_X_VERSION_10_15 101500
#define MAC_OS_X_VERSION_10_15_1 101501
#define MAC_OS_X_VERSION_10_16 101600
#define MAC_OS_VERSION_11_0 110000
#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */
#define __DRIVERKIT_19_0 190000
#define __DRIVERKIT_20_0 200000
#endif /* __AVAILABILITY_VERSIONS__ */

View File

@@ -0,0 +1,619 @@
/*
* Copyright (c) 1993-2011 by Apple Inc.. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
File: ConditionalMacros.h
Contains: Set up for compiler independent conditionals
Version: CarbonCore-769~1
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __CONDITIONALMACROS__
#define __CONDITIONALMACROS__
#include <Availability.h>
/****************************************************************************************************
UNIVERSAL_INTERFACES_VERSION
0x0400 --> version 4.0 (Mac OS X only)
0x0335 --> version 3.4
0x0331 --> version 3.3.1
0x0330 --> version 3.3
0x0320 --> version 3.2
0x0310 --> version 3.1
0x0301 --> version 3.0.1
0x0300 --> version 3.0
0x0210 --> version 2.1
This conditional did not exist prior to version 2.1
****************************************************************************************************/
#define UNIVERSAL_INTERFACES_VERSION 0x0400
/****************************************************************************************************
All TARGET_* condtionals are set up by TargetConditionals.h
****************************************************************************************************/
#include <TargetConditionals.h>
/****************************************************************************************************
PRAGMA_*
These conditionals specify whether the compiler supports particular #pragma's
PRAGMA_IMPORT - Compiler supports: #pragma import on/off/reset
PRAGMA_ONCE - Compiler supports: #pragma once
PRAGMA_STRUCT_ALIGN - Compiler supports: #pragma options align=mac68k/power/reset
PRAGMA_STRUCT_PACK - Compiler supports: #pragma pack(n)
PRAGMA_STRUCT_PACKPUSH - Compiler supports: #pragma pack(push, n)/pack(pop)
PRAGMA_ENUM_PACK - Compiler supports: #pragma options(!pack_enums)
PRAGMA_ENUM_ALWAYSINT - Compiler supports: #pragma enumsalwaysint on/off/reset
PRAGMA_ENUM_OPTIONS - Compiler supports: #pragma options enum=int/small/reset
FOUR_CHAR_CODE
This conditional is deprecated. It was used to work around a bug in one obscure compiler that did not pack multiple characters in single quotes rationally.
It was never intended for endian swapping.
FOUR_CHAR_CODE('abcd') - Convert a four-char-code to the correct 32-bit value
TYPE_*
These conditionals specify whether the compiler supports particular types.
TYPE_LONGLONG - Compiler supports "long long" 64-bit integers
TYPE_EXTENDED - Compiler supports "extended" 80/96 bit floating point
TYPE_LONGDOUBLE_IS_DOUBLE - Compiler implements "long double" same as "double"
FUNCTION_*
These conditionals specify whether the compiler supports particular language extensions
to function prototypes and definitions.
FUNCTION_PASCAL - Compiler supports "pascal void Foo()"
FUNCTION_DECLSPEC - Compiler supports "__declspec(xxx) void Foo()"
FUNCTION_WIN32CC - Compiler supports "void __cdecl Foo()" and "void __stdcall Foo()"
****************************************************************************************************/
#if defined(__GNUC__) && (defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__NEXT_CPP__) || defined(__MACOS_CLASSIC__))
/*
gcc based compilers used on Mac OS X
*/
#define PRAGMA_IMPORT 0
#define PRAGMA_ONCE 0
#if __GNUC__ >= 4
#define PRAGMA_STRUCT_PACK 1
#define PRAGMA_STRUCT_PACKPUSH 1
#else
#define PRAGMA_STRUCT_PACK 0
#define PRAGMA_STRUCT_PACKPUSH 0
#endif
#if __LP64__ || __arm64__ || __ARM_ARCH_7K
#define PRAGMA_STRUCT_ALIGN 0
#else
#define PRAGMA_STRUCT_ALIGN 1
#endif
#define PRAGMA_ENUM_PACK 0
#define PRAGMA_ENUM_ALWAYSINT 0
#define PRAGMA_ENUM_OPTIONS 0
#define FOUR_CHAR_CODE(x) (x)
#define TYPE_EXTENDED 0
#ifdef __ppc__
#ifdef __LONG_DOUBLE_128__
#define TYPE_LONGDOUBLE_IS_DOUBLE 0
#else
#define TYPE_LONGDOUBLE_IS_DOUBLE 1
#endif
#else
#define TYPE_LONGDOUBLE_IS_DOUBLE 0
#endif
#define TYPE_LONGLONG 1
#define FUNCTION_PASCAL 0
#define FUNCTION_DECLSPEC 0
#define FUNCTION_WIN32CC 0
#ifdef __MACOS_CLASSIC__
#ifndef TARGET_API_MAC_CARBON /* gcc cfm cross compiler assumes you're building Carbon code */
#define TARGET_API_MAC_CARBON 1
#endif
#endif
#elif defined(__MWERKS__)
/*
CodeWarrior compiler from Metrowerks/Motorola
*/
#define PRAGMA_ONCE 1
#define PRAGMA_IMPORT 0
#define PRAGMA_STRUCT_ALIGN 1
#define PRAGMA_STRUCT_PACK 1
#define PRAGMA_STRUCT_PACKPUSH 0
#define PRAGMA_ENUM_PACK 0
#define PRAGMA_ENUM_ALWAYSINT 1
#define PRAGMA_ENUM_OPTIONS 0
#if __option(enumsalwaysint) && __option(ANSI_strict)
#define FOUR_CHAR_CODE(x) ((long)(x)) /* otherwise compiler will complain about values with high bit set */
#else
#define FOUR_CHAR_CODE(x) (x)
#endif
#define FUNCTION_PASCAL 1
#define FUNCTION_DECLSPEC 1
#define FUNCTION_WIN32CC 0
#if __option(longlong)
#define TYPE_LONGLONG 1
#else
#define TYPE_LONGLONG 0
#endif
#define TYPE_EXTENDED 0
#define TYPE_LONGDOUBLE_IS_DOUBLE 1
#else
/*
Unknown compiler, perhaps set up from the command line
*/
#error unknown compiler
#ifndef PRAGMA_IMPORT
#define PRAGMA_IMPORT 0
#endif
#ifndef PRAGMA_STRUCT_ALIGN
#define PRAGMA_STRUCT_ALIGN 0
#endif
#ifndef PRAGMA_ONCE
#define PRAGMA_ONCE 0
#endif
#ifndef PRAGMA_STRUCT_PACK
#define PRAGMA_STRUCT_PACK 0
#endif
#ifndef PRAGMA_STRUCT_PACKPUSH
#define PRAGMA_STRUCT_PACKPUSH 0
#endif
#ifndef PRAGMA_ENUM_PACK
#define PRAGMA_ENUM_PACK 0
#endif
#ifndef PRAGMA_ENUM_ALWAYSINT
#define PRAGMA_ENUM_ALWAYSINT 0
#endif
#ifndef PRAGMA_ENUM_OPTIONS
#define PRAGMA_ENUM_OPTIONS 0
#endif
#ifndef FOUR_CHAR_CODE
#define FOUR_CHAR_CODE(x) (x)
#endif
#ifndef TYPE_LONGDOUBLE_IS_DOUBLE
#define TYPE_LONGDOUBLE_IS_DOUBLE 1
#endif
#ifndef TYPE_EXTENDED
#define TYPE_EXTENDED 0
#endif
#ifndef TYPE_LONGLONG
#define TYPE_LONGLONG 0
#endif
#ifndef FUNCTION_PASCAL
#define FUNCTION_PASCAL 0
#endif
#ifndef FUNCTION_DECLSPEC
#define FUNCTION_DECLSPEC 0
#endif
#ifndef FUNCTION_WIN32CC
#define FUNCTION_WIN32CC 0
#endif
#endif
/****************************************************************************************************
Under MacOS, the classic 68k runtime has two calling conventions: pascal or C
Under Win32, there are two calling conventions: __cdecl or __stdcall
Headers and implementation files can use the following macros to make their
source more portable by hiding the calling convention details:
EXTERN_API*
These macros are used to specify the calling convention on a function prototype.
EXTERN_API - Classic 68k: pascal, Win32: __cdecl
EXTERN_API_C - Classic 68k: C, Win32: __cdecl
EXTERN_API_STDCALL - Classic 68k: pascal, Win32: __stdcall
EXTERN_API_C_STDCALL - Classic 68k: C, Win32: __stdcall
DEFINE_API*
These macros are used to specify the calling convention on a function definition.
DEFINE_API - Classic 68k: pascal, Win32: __cdecl
DEFINE_API_C - Classic 68k: C, Win32: __cdecl
DEFINE_API_STDCALL - Classic 68k: pascal, Win32: __stdcall
DEFINE_API_C_STDCALL - Classic 68k: C, Win32: __stdcall
CALLBACK_API*
These macros are used to specify the calling convention of a function pointer.
CALLBACK_API - Classic 68k: pascal, Win32: __stdcall
CALLBACK_API_C - Classic 68k: C, Win32: __stdcall
CALLBACK_API_STDCALL - Classic 68k: pascal, Win32: __cdecl
CALLBACK_API_C_STDCALL - Classic 68k: C, Win32: __cdecl
****************************************************************************************************/
#if FUNCTION_PASCAL && !FUNCTION_DECLSPEC && !FUNCTION_WIN32CC
/* compiler supports pascal keyword only */
#define EXTERN_API(_type) extern pascal _type
#define EXTERN_API_C(_type) extern _type
#define EXTERN_API_STDCALL(_type) extern pascal _type
#define EXTERN_API_C_STDCALL(_type) extern _type
#define DEFINE_API(_type) pascal _type
#define DEFINE_API_C(_type) _type
#define DEFINE_API_STDCALL(_type) pascal _type
#define DEFINE_API_C_STDCALL(_type) _type
#define CALLBACK_API(_type, _name) pascal _type (*_name)
#define CALLBACK_API_C(_type, _name) _type (*_name)
#define CALLBACK_API_STDCALL(_type, _name) pascal _type (*_name)
#define CALLBACK_API_C_STDCALL(_type, _name) _type (*_name)
#elif FUNCTION_PASCAL && FUNCTION_DECLSPEC && !FUNCTION_WIN32CC
/* compiler supports pascal and __declspec() */
#define EXTERN_API(_type) extern pascal __declspec(dllimport) _type
#define EXTERN_API_C(_type) extern __declspec(dllimport) _type
#define EXTERN_API_STDCALL(_type) extern pascal __declspec(dllimport) _type
#define EXTERN_API_C_STDCALL(_type) extern __declspec(dllimport) _type
#define DEFINE_API(_type) pascal __declspec(dllexport) _type
#define DEFINE_API_C(_type) __declspec(dllexport) _type
#define DEFINE_API_STDCALL(_type) pascal __declspec(dllexport) _type
#define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type
#define CALLBACK_API(_type, _name) pascal _type (*_name)
#define CALLBACK_API_C(_type, _name) _type (*_name)
#define CALLBACK_API_STDCALL(_type, _name) pascal _type (*_name)
#define CALLBACK_API_C_STDCALL(_type, _name) _type (*_name)
#elif !FUNCTION_PASCAL && FUNCTION_DECLSPEC && !FUNCTION_WIN32CC
/* compiler supports __declspec() */
#define EXTERN_API(_type) extern __declspec(dllimport) _type
#define EXTERN_API_C(_type) extern __declspec(dllimport) _type
#define EXTERN_API_STDCALL(_type) extern __declspec(dllimport) _type
#define EXTERN_API_C_STDCALL(_type) extern __declspec(dllimport) _type
#define DEFINE_API(_type) __declspec(dllexport) _type
#define DEFINE_API_C(_type) __declspec(dllexport) _type
#define DEFINE_API_STDCALL(_type) __declspec(dllexport) _type
#define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type
#define CALLBACK_API(_type, _name) _type ( * _name)
#define CALLBACK_API_C(_type, _name) _type ( * _name)
#define CALLBACK_API_STDCALL(_type, _name) _type ( * _name)
#define CALLBACK_API_C_STDCALL(_type, _name) _type ( * _name)
#elif !FUNCTION_PASCAL && FUNCTION_DECLSPEC && FUNCTION_WIN32CC
/* compiler supports __declspec() and __cdecl */
#define EXTERN_API(_type) __declspec(dllimport) _type __cdecl
#define EXTERN_API_C(_type) __declspec(dllimport) _type __cdecl
#define EXTERN_API_STDCALL(_type) __declspec(dllimport) _type __stdcall
#define EXTERN_API_C_STDCALL(_type) __declspec(dllimport) _type __stdcall
#define DEFINE_API(_type) __declspec(dllexport) _type __cdecl
#define DEFINE_API_C(_type) __declspec(dllexport) _type __cdecl
#define DEFINE_API_STDCALL(_type) __declspec(dllexport) _type __stdcall
#define DEFINE_API_C_STDCALL(_type) __declspec(dllexport) _type __stdcall
#define CALLBACK_API(_type, _name) _type (__cdecl * _name)
#define CALLBACK_API_C(_type, _name) _type (__cdecl * _name)
#define CALLBACK_API_STDCALL(_type, _name) _type (__stdcall * _name)
#define CALLBACK_API_C_STDCALL(_type, _name) _type (__stdcall * _name)
#elif !FUNCTION_PASCAL && !FUNCTION_DECLSPEC && FUNCTION_WIN32CC
/* compiler supports __cdecl */
#define EXTERN_API(_type) _type __cdecl
#define EXTERN_API_C(_type) _type __cdecl
#define EXTERN_API_STDCALL(_type) _type __stdcall
#define EXTERN_API_C_STDCALL(_type) _type __stdcall
#define DEFINE_API(_type) _type __cdecl
#define DEFINE_API_C(_type) _type __cdecl
#define DEFINE_API_STDCALL(_type) _type __stdcall
#define DEFINE_API_C_STDCALL(_type) _type __stdcall
#define CALLBACK_API(_type, _name) _type (__cdecl * _name)
#define CALLBACK_API_C(_type, _name) _type (__cdecl * _name)
#define CALLBACK_API_STDCALL(_type, _name) _type (__stdcall * _name)
#define CALLBACK_API_C_STDCALL(_type, _name) _type (__stdcall * _name)
#else
/* compiler supports no extensions */
#define EXTERN_API(_type) extern _type
#define EXTERN_API_C(_type) extern _type
#define EXTERN_API_STDCALL(_type) extern _type
#define EXTERN_API_C_STDCALL(_type) extern _type
#define DEFINE_API(_type) _type
#define DEFINE_API_C(_type) _type
#define DEFINE_API_STDCALL(_type) _type
#define DEFINE_API_C_STDCALL(_type) _type
#define CALLBACK_API(_type, _name) _type ( * _name)
#define CALLBACK_API_C(_type, _name) _type ( * _name)
#define CALLBACK_API_STDCALL(_type, _name) _type ( * _name)
#define CALLBACK_API_C_STDCALL(_type, _name) _type ( * _name)
#undef pascal
#define pascal
#endif
/****************************************************************************************************
Set up TARGET_API_*_* values
****************************************************************************************************/
#if !defined(TARGET_API_MAC_OS8) && !defined(TARGET_API_MAC_OSX) && !defined(TARGET_API_MAC_CARBON)
/* No TARGET_API_MAC_* predefined on command line */
#if TARGET_RT_MAC_MACHO
/* Looks like MachO style compiler */
#define TARGET_API_MAC_OS8 0
#define TARGET_API_MAC_CARBON 1
#define TARGET_API_MAC_OSX 1
#elif defined(TARGET_CARBON) && TARGET_CARBON
/* grandfather in use of TARGET_CARBON */
#define TARGET_API_MAC_OS8 0
#define TARGET_API_MAC_CARBON 1
#define TARGET_API_MAC_OSX 0
#elif TARGET_CPU_PPC && TARGET_RT_MAC_CFM
/* Looks like CFM style PPC compiler */
#define TARGET_API_MAC_OS8 1
#define TARGET_API_MAC_CARBON 0
#define TARGET_API_MAC_OSX 0
#else
/* 68k or some other compiler */
#define TARGET_API_MAC_OS8 1
#define TARGET_API_MAC_CARBON 0
#define TARGET_API_MAC_OSX 0
#endif /* */
#else
#ifndef TARGET_API_MAC_OS8
#define TARGET_API_MAC_OS8 0
#endif /* !defined(TARGET_API_MAC_OS8) */
#ifndef TARGET_API_MAC_OSX
#define TARGET_API_MAC_OSX TARGET_RT_MAC_MACHO
#endif /* !defined(TARGET_API_MAC_OSX) */
#ifndef TARGET_API_MAC_CARBON
#define TARGET_API_MAC_CARBON TARGET_API_MAC_OSX
#endif /* !defined(TARGET_API_MAC_CARBON) */
#endif /* !defined(TARGET_API_MAC_OS8) && !defined(TARGET_API_MAC_OSX) && !defined(TARGET_API_MAC_CARBON) */
#if TARGET_API_MAC_OS8 && TARGET_API_MAC_OSX
#error TARGET_API_MAC_OS8 and TARGET_API_MAC_OSX are mutually exclusive
#endif /* TARGET_API_MAC_OS8 && TARGET_API_MAC_OSX */
#if !TARGET_API_MAC_OS8 && !TARGET_API_MAC_CARBON && !TARGET_API_MAC_OSX
#error At least one of TARGET_API_MAC_* must be true
#endif /* !TARGET_API_MAC_OS8 && !TARGET_API_MAC_CARBON && !TARGET_API_MAC_OSX */
/* Support source code still using TARGET_CARBON */
#ifndef TARGET_CARBON
#if TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8
#define TARGET_CARBON 1
#else
#define TARGET_CARBON 0
#endif /* TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 */
#endif /* !defined(TARGET_CARBON) */
/****************************************************************************************************
Backward compatibility for clients expecting 2.x version on ConditionalMacros.h
GENERATINGPOWERPC - Compiler is generating PowerPC instructions
GENERATING68K - Compiler is generating 68k family instructions
GENERATING68881 - Compiler is generating mc68881 floating point instructions
GENERATINGCFM - Code being generated assumes CFM calling conventions
CFMSYSTEMCALLS - No A-traps. Systems calls are made using CFM and UPP's
PRAGMA_ALIGN_SUPPORTED - Compiler supports: #pragma options align=mac68k/power/reset
PRAGMA_IMPORT_SUPPORTED - Compiler supports: #pragma import on/off/reset
CGLUESUPPORTED - Clients can use all lowercase toolbox functions that take C strings instead of pascal strings
****************************************************************************************************/
#if !TARGET_API_MAC_CARBON
#define GENERATINGPOWERPC TARGET_CPU_PPC
#define GENERATING68K 0
#define GENERATING68881 TARGET_RT_MAC_68881
#define GENERATINGCFM TARGET_RT_MAC_CFM
#define CFMSYSTEMCALLS TARGET_RT_MAC_CFM
#ifndef CGLUESUPPORTED
#define CGLUESUPPORTED 0
#endif /* !defined(CGLUESUPPORTED) */
#ifndef OLDROUTINELOCATIONS
#define OLDROUTINELOCATIONS 0
#endif /* !defined(OLDROUTINELOCATIONS) */
#define PRAGMA_ALIGN_SUPPORTED PRAGMA_STRUCT_ALIGN
#define PRAGMA_IMPORT_SUPPORTED PRAGMA_IMPORT
#else
/* Carbon code should not use old conditionals */
#define PRAGMA_ALIGN_SUPPORTED ..PRAGMA_ALIGN_SUPPORTED_is_obsolete..
#define GENERATINGPOWERPC ..GENERATINGPOWERPC_is_obsolete..
#define GENERATING68K ..GENERATING68K_is_obsolete..
#define GENERATING68881 ..GENERATING68881_is_obsolete..
#define GENERATINGCFM ..GENERATINGCFM_is_obsolete..
#define CFMSYSTEMCALLS ..CFMSYSTEMCALLS_is_obsolete..
#endif /* !TARGET_API_MAC_CARBON */
/****************************************************************************************************
OLDROUTINENAMES - "Old" names for Macintosh system calls are allowed in source code.
(e.g. DisposPtr instead of DisposePtr). The names of system routine
are now more sensitive to change because CFM binds by name. In the
past, system routine names were compiled out to just an A-Trap.
Macros have been added that each map an old name to its new name.
This allows old routine names to be used in existing source files,
but the macros only work if OLDROUTINENAMES is true. This support
will be removed in the near future. Thus, all source code should
be changed to use the new names! You can set OLDROUTINENAMES to false
to see if your code has any old names left in it.
****************************************************************************************************/
#ifndef OLDROUTINENAMES
#define OLDROUTINENAMES 0
#endif /* !defined(OLDROUTINENAMES) */
/****************************************************************************************************
The following macros isolate the use of 68K inlines in function prototypes.
On the Mac OS under the Classic 68K runtime, function prototypes were followed
by a list of 68K opcodes which the compiler inserted in the generated code instead
of a JSR. Under Classic 68K on the Mac OS, this macro will put the opcodes
in the right syntax. For all other OS's and runtimes the macro suppress the opcodes.
Example:
EXTERN_P void DrawPicture(PicHandle myPicture, const Rect *dstRect)
ONEWORDINLINE(0xA8F6);
****************************************************************************************************/
#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
#define ONEWORDINLINE(w1) = w1
#define TWOWORDINLINE(w1,w2) = {w1,w2}
#define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
#define FOURWORDINLINE(w1,w2,w3,w4) = {w1,w2,w3,w4}
#define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
#define SIXWORDINLINE(w1,w2,w3,w4,w5,w6) = {w1,w2,w3,w4,w5,w6}
#define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7) = {w1,w2,w3,w4,w5,w6,w7}
#define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8) = {w1,w2,w3,w4,w5,w6,w7,w8}
#define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9) = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
#define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
#define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
#define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12) = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
#else
#define ONEWORDINLINE(w1)
#define TWOWORDINLINE(w1,w2)
#define THREEWORDINLINE(w1,w2,w3)
#define FOURWORDINLINE(w1,w2,w3,w4)
#define FIVEWORDINLINE(w1,w2,w3,w4,w5)
#define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
#define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
#define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
#define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
#define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
#define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
#define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
#endif
/****************************************************************************************************
TARGET_CARBON - default: false. Switches all of the above as described. Overrides all others
- NOTE: If you set TARGET_CARBON to 1, then the other switches will be setup by
ConditionalMacros, and should not be set manually.
If you wish to do development for pre-Carbon Systems, you can set the following:
OPAQUE_TOOLBOX_STRUCTS - default: false. True for Carbon builds, hides struct fields.
OPAQUE_UPP_TYPES - default: false. True for Carbon builds, UPP types are unique and opaque.
ACCESSOR_CALLS_ARE_FUNCTIONS - default: false. True for Carbon builds, enables accessor functions.
CALL_NOT_IN_CARBON - default: true. False for Carbon builds, hides calls not supported in Carbon.
Specifically, if you are building a non-Carbon application (one that links against InterfaceLib)
but you wish to use some of the accessor functions, you can set ACCESSOR_CALLS_ARE_FUNCTIONS to 1
and link with CarbonAccessors.o, which implements just the accessor functions. This will help you
preserve source compatibility between your Carbon and non-Carbon application targets.
MIXEDMODE_CALLS_ARE_FUNCTIONS - deprecated.
****************************************************************************************************/
#if TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8
#ifndef OPAQUE_TOOLBOX_STRUCTS
#define OPAQUE_TOOLBOX_STRUCTS 1
#endif /* !defined(OPAQUE_TOOLBOX_STRUCTS) */
#ifndef OPAQUE_UPP_TYPES
#define OPAQUE_UPP_TYPES 1
#endif /* !defined(OPAQUE_UPP_TYPES) */
#ifndef ACCESSOR_CALLS_ARE_FUNCTIONS
#define ACCESSOR_CALLS_ARE_FUNCTIONS 1
#endif /* !defined(ACCESSOR_CALLS_ARE_FUNCTIONS) */
#ifndef CALL_NOT_IN_CARBON
#define CALL_NOT_IN_CARBON 0
#endif /* !defined(CALL_NOT_IN_CARBON) */
#ifndef MIXEDMODE_CALLS_ARE_FUNCTIONS
#define MIXEDMODE_CALLS_ARE_FUNCTIONS 1
#endif /* !defined(MIXEDMODE_CALLS_ARE_FUNCTIONS) */
#else
#ifndef OPAQUE_TOOLBOX_STRUCTS
#define OPAQUE_TOOLBOX_STRUCTS 0
#endif /* !defined(OPAQUE_TOOLBOX_STRUCTS) */
#ifndef ACCESSOR_CALLS_ARE_FUNCTIONS
#define ACCESSOR_CALLS_ARE_FUNCTIONS 0
#endif /* !defined(ACCESSOR_CALLS_ARE_FUNCTIONS) */
/*
* It's possible to have ACCESSOR_CALLS_ARE_FUNCTIONS set to true and OPAQUE_TOOLBOX_STRUCTS
* set to false, but not the other way around, so make sure the defines are not set this way.
*/
#ifndef CALL_NOT_IN_CARBON
#define CALL_NOT_IN_CARBON 1
#endif /* !defined(CALL_NOT_IN_CARBON) */
#ifndef MIXEDMODE_CALLS_ARE_FUNCTIONS
#define MIXEDMODE_CALLS_ARE_FUNCTIONS 0
#endif /* !defined(MIXEDMODE_CALLS_ARE_FUNCTIONS) */
#endif /* TARGET_API_MAC_CARBON && !TARGET_API_MAC_OS8 */
#endif /* __CONDITIONALMACROS__ */

View File

@@ -0,0 +1,808 @@
/*
* Copyright (c) 1985-2011 by Apple Inc.. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
File: MacTypes.h
Contains: Basic Macintosh data types.
Version: CarbonCore-769~1
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __MACTYPES__
#define __MACTYPES__
#ifndef __CONDITIONALMACROS__
#include <ConditionalMacros.h>
#endif
#include <stdbool.h>
#include <sys/types.h>
#include <Availability.h>
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(push, 2)
/*
CarbonCore Deprecation flags.
Certain Carbon API functions are deprecated in 10.3 and later
systems. These will produce a warning when compiling on 10.3.
Other functions and constants do not produce meaningful
results when building Carbon for Mac OS X. For these
functions, no-op macros are provided, but only when the
ALLOW_OBSOLETE_CARBON flag is defined to be 0: eg
-DALLOW_OBSOLETE_CARBON=0.
*/
#if ! defined(ALLOW_OBSOLETE_CARBON) || ! ALLOW_OBSOLETE_CARBON
#define ALLOW_OBSOLETE_CARBON_MACMEMORY 0
#define ALLOW_OBSOLETE_CARBON_OSUTILS 0
#else
#define ALLOW_OBSOLETE_CARBON_MACMEMORY 1 /* Removes obsolete constants; turns HLock/HUnlock into no-op macros */
#define ALLOW_OBSOLETE_CARBON_OSUTILS 1 /* Removes obsolete structures */
#endif
#ifndef NULL
#define NULL __DARWIN_NULL
#endif /* ! NULL */
#ifndef nil
#if defined(__has_feature)
#if __has_feature(cxx_nullptr)
#define nil nullptr
#else
#define nil __DARWIN_NULL
#endif
#else
#define nil __DARWIN_NULL
#endif
#endif
/********************************************************************************
Base integer types for all target OS's and CPU's
UInt8 8-bit unsigned integer
SInt8 8-bit signed integer
UInt16 16-bit unsigned integer
SInt16 16-bit signed integer
UInt32 32-bit unsigned integer
SInt32 32-bit signed integer
UInt64 64-bit unsigned integer
SInt64 64-bit signed integer
*********************************************************************************/
typedef unsigned char UInt8;
typedef signed char SInt8;
typedef unsigned short UInt16;
typedef signed short SInt16;
#if __LP64__
typedef unsigned int UInt32;
typedef signed int SInt32;
#else
typedef unsigned long UInt32;
typedef signed long SInt32;
#endif
/* avoid redeclaration if libkern/OSTypes.h */
#ifndef _OS_OSTYPES_H
#if TARGET_RT_BIG_ENDIAN
struct wide {
SInt32 hi;
UInt32 lo;
};
typedef struct wide wide;
struct UnsignedWide {
UInt32 hi;
UInt32 lo;
};
typedef struct UnsignedWide UnsignedWide;
#else
struct wide {
UInt32 lo;
SInt32 hi;
};
typedef struct wide wide;
struct UnsignedWide {
UInt32 lo;
UInt32 hi;
};
typedef struct UnsignedWide UnsignedWide;
#endif /* TARGET_RT_BIG_ENDIAN */
#endif
#if TYPE_LONGLONG
/*
Note: wide and UnsignedWide must always be structs for source code
compatibility. On the other hand UInt64 and SInt64 can be
either a struct or a long long, depending on the compiler.
If you use UInt64 and SInt64 you should do all operations on
those data types through the functions/macros in Math64.h.
This will assure that your code compiles with compilers that
support long long and those that don't.
The MS Visual C/C++ compiler uses __int64 instead of long long.
*/
#if defined(_MSC_VER) && !defined(__MWERKS__) && defined(_M_IX86)
typedef signed __int64 SInt64;
typedef unsigned __int64 UInt64;
#else
typedef signed long long SInt64;
typedef unsigned long long UInt64;
#endif
#else
typedef wide SInt64;
typedef UnsignedWide UInt64;
#endif /* TYPE_LONGLONG */
/********************************************************************************
Base fixed point types
Fixed 16-bit signed integer plus 16-bit fraction
UnsignedFixed 16-bit unsigned integer plus 16-bit fraction
Fract 2-bit signed integer plus 30-bit fraction
ShortFixed 8-bit signed integer plus 8-bit fraction
*********************************************************************************/
typedef SInt32 Fixed;
typedef Fixed * FixedPtr;
typedef SInt32 Fract;
typedef Fract * FractPtr;
typedef UInt32 UnsignedFixed;
typedef UnsignedFixed * UnsignedFixedPtr;
typedef short ShortFixed;
typedef ShortFixed * ShortFixedPtr;
/********************************************************************************
Base floating point types
Float32 32 bit IEEE float: 1 sign bit, 8 exponent bits, 23 fraction bits
Float64 64 bit IEEE float: 1 sign bit, 11 exponent bits, 52 fraction bits
Float80 80 bit MacOS float: 1 sign bit, 15 exponent bits, 1 integer bit, 63 fraction bits
Float96 96 bit 68881 float: 1 sign bit, 15 exponent bits, 16 pad bits, 1 integer bit, 63 fraction bits
Note: These are fixed size floating point types, useful when writing a floating
point value to disk. If your compiler does not support a particular size
float, a struct is used instead.
Use one of the NCEG types (e.g. double_t) or an ANSI C type (e.g. double) if
you want a floating point representation that is natural for any given
compiler, but might be a different size on different compilers.
*********************************************************************************/
typedef float Float32;
typedef double Float64;
struct Float80 {
SInt16 exp;
UInt16 man[4];
};
typedef struct Float80 Float80;
struct Float96 {
SInt16 exp[2]; /* the second 16-bits are undefined */
UInt16 man[4];
};
typedef struct Float96 Float96;
struct Float32Point {
Float32 x;
Float32 y;
};
typedef struct Float32Point Float32Point;
/********************************************************************************
MacOS Memory Manager types
Ptr Pointer to a non-relocatable block
Handle Pointer to a master pointer to a relocatable block
Size The number of bytes in a block (signed for historical reasons)
*********************************************************************************/
typedef char * Ptr;
typedef Ptr * Handle;
typedef long Size;
/********************************************************************************
Higher level basic types
OSErr 16-bit result error code
OSStatus 32-bit result error code
LogicalAddress Address in the clients virtual address space
ConstLogicalAddress Address in the clients virtual address space that will only be read
PhysicalAddress Real address as used on the hardware bus
BytePtr Pointer to an array of bytes
ByteCount The size of an array of bytes
ByteOffset An offset into an array of bytes
ItemCount 32-bit iteration count
OptionBits Standard 32-bit set of bit flags
PBVersion ?
Duration 32-bit millisecond timer for drivers
AbsoluteTime 64-bit clock
ScriptCode A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding
LangCode A particular language (e.g. English), as represented using a particular ScriptCode
RegionCode Designates a language as used in a particular region (e.g. British vs American
English) together with other region-dependent characteristics (e.g. date format)
FourCharCode A 32-bit value made by packing four 1 byte characters together
OSType A FourCharCode used in the OS and file system (e.g. creator)
ResType A FourCharCode used to tag resources (e.g. 'DLOG')
*********************************************************************************/
typedef SInt16 OSErr;
typedef SInt32 OSStatus;
typedef void * LogicalAddress;
typedef const void * ConstLogicalAddress;
typedef void * PhysicalAddress;
typedef UInt8 * BytePtr;
typedef unsigned long ByteCount;
typedef unsigned long ByteOffset;
typedef SInt32 Duration;
typedef UnsignedWide AbsoluteTime;
typedef UInt32 OptionBits;
typedef unsigned long ItemCount;
typedef UInt32 PBVersion;
typedef SInt16 ScriptCode;
typedef SInt16 LangCode;
typedef SInt16 RegionCode;
typedef UInt32 FourCharCode;
typedef FourCharCode OSType;
typedef FourCharCode ResType;
typedef OSType * OSTypePtr;
typedef ResType * ResTypePtr;
/********************************************************************************
Boolean types and values
Boolean Mac OS historic type, sizeof(Boolean)==1
bool Defined in stdbool.h, ISO C/C++ standard type
false Now defined in stdbool.h
true Now defined in stdbool.h
*********************************************************************************/
typedef unsigned char Boolean;
/********************************************************************************
Function Pointer Types
ProcPtr Generic pointer to a function
Register68kProcPtr Pointer to a 68K function that expects parameters in registers
UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor
ProcHandle Pointer to a ProcPtr
UniversalProcHandle Pointer to a UniversalProcPtr
*********************************************************************************/
typedef CALLBACK_API_C( long , ProcPtr )(void);
typedef CALLBACK_API( void , Register68kProcPtr )(void);
#if TARGET_RT_MAC_CFM
/* The RoutineDescriptor structure is defined in MixedMode.h */
typedef struct RoutineDescriptor *UniversalProcPtr;
#else
typedef ProcPtr UniversalProcPtr;
#endif /* TARGET_RT_MAC_CFM */
typedef ProcPtr * ProcHandle;
typedef UniversalProcPtr * UniversalProcHandle;
/********************************************************************************
RefCon Types
For access to private data in callbacks, etc.; refcons are generally
used as a pointer to something, but in the 32-bit world refcons in
different APIs have had various types: pointer, unsigned scalar, and
signed scalar. The RefCon types defined here support the current 32-bit
usage but provide normalization to pointer types for 64-bit.
PRefCon is preferred for new APIs; URefCon and SRefCon are primarily
for compatibility with existing APIs.
*********************************************************************************/
typedef void * PRefCon;
#if __LP64__
typedef void * URefCon;
typedef void * SRefCon;
#else
typedef UInt32 URefCon;
typedef SInt32 SRefCon;
#endif /* __LP64__ */
/********************************************************************************
Common Constants
noErr OSErr: function performed properly - no error
kNilOptions OptionBits: all flags false
kInvalidID KernelID: NULL is for pointers as kInvalidID is for ID's
kVariableLengthArray array bounds: variable length array
Note: kVariableLengthArray was used in array bounds to specify a variable length array,
usually the last field in a struct. Now that the C language supports
the concept of flexible array members, you can instead use:
struct BarList
{
short listLength;
Bar elements[];
};
However, this changes the semantics somewhat, as sizeof( BarList ) contains
no space for any of the elements, so to allocate a list with space for
the count elements
struct BarList* l = (struct BarList*) malloc( sizeof(BarList) + count * sizeof(Bar) );
*********************************************************************************/
enum {
noErr = 0
};
enum {
kNilOptions = 0
};
#define kInvalidID 0
enum {
kVariableLengthArray
#ifdef __has_extension
#if __has_extension(enumerator_attributes)
__attribute__((deprecated))
#endif
#endif
= 1
};
enum {
kUnknownType = 0x3F3F3F3F /* "????" QuickTime 3.0: default unknown ResType or OSType */
};
/********************************************************************************
String Types and Unicode Types
UnicodeScalarValue, A complete Unicode character in UTF-32 format, with
UTF32Char values from 0 through 0x10FFFF (excluding the surrogate
range 0xD800-0xDFFF and certain disallowed values).
UniChar, A 16-bit Unicode code value in the default UTF-16 format.
UTF16Char UnicodeScalarValues 0-0xFFFF are expressed in UTF-16
format using a single UTF16Char with the same value.
UnicodeScalarValues 0x10000-0x10FFFF are expressed in
UTF-16 format using a pair of UTF16Chars - one in the
high surrogate range (0xD800-0xDBFF) followed by one in
the low surrogate range (0xDC00-0xDFFF). All of the
characters defined in Unicode versions through 3.0 are
in the range 0-0xFFFF and can be expressed using a single
UTF16Char, thus the term "Unicode character" generally
refers to a UniChar = UTF16Char.
UTF8Char An 8-bit code value in UTF-8 format. UnicodeScalarValues
0-0x7F are expressed in UTF-8 format using one UTF8Char
with the same value. UnicodeScalarValues above 0x7F are
expressed in UTF-8 format using 2-4 UTF8Chars, all with
values in the range 0x80-0xF4 (UnicodeScalarValues
0x100-0xFFFF use two or three UTF8Chars,
UnicodeScalarValues 0x10000-0x10FFFF use four UTF8Chars).
UniCharCount A count of UTF-16 code values in an array or buffer.
StrNNN Pascal string holding up to NNN bytes
StringPtr Pointer to a pascal string
StringHandle Pointer to a StringPtr
ConstStringPtr Pointer to a read-only pascal string
ConstStrNNNParam For function parameters only - means string is const
CStringPtr Pointer to a C string (in C: char*)
ConstCStringPtr Pointer to a read-only C string (in C: const char*)
Note: The length of a pascal string is stored as the first byte.
A pascal string does not have a termination byte.
A pascal string can hold at most 255 bytes of data.
The first character in a pascal string is offset one byte from the start of the string.
A C string is terminated with a byte of value zero.
A C string has no length limitation.
The first character in a C string is the zeroth byte of the string.
*********************************************************************************/
typedef UInt32 UnicodeScalarValue;
typedef UInt32 UTF32Char;
typedef UInt16 UniChar;
typedef UInt16 UTF16Char;
typedef UInt8 UTF8Char;
typedef UniChar * UniCharPtr;
typedef unsigned long UniCharCount;
typedef UniCharCount * UniCharCountPtr;
typedef unsigned char Str255[256];
typedef unsigned char Str63[64];
typedef unsigned char Str32[33];
typedef unsigned char Str31[32];
typedef unsigned char Str27[28];
typedef unsigned char Str15[16];
/*
The type Str32 is used in many AppleTalk based data structures.
It holds up to 32 one byte chars. The problem is that with the
length byte it is 33 bytes long. This can cause weird alignment
problems in structures. To fix this the type "Str32Field" has
been created. It should only be used to hold 32 chars, but
it is 34 bytes long so that there are no alignment problems.
*/
typedef unsigned char Str32Field[34];
/*
QuickTime 3.0:
The type StrFileName is used to make MacOS structs work
cross-platform. For example FSSpec or SFReply previously
contained a Str63 field. They now contain a StrFileName
field which is the same when targeting the MacOS but is
a 256 char buffer for Win32 and unix, allowing them to
contain long file names.
*/
typedef Str63 StrFileName;
typedef unsigned char * StringPtr;
typedef StringPtr * StringHandle;
typedef const unsigned char * ConstStringPtr;
typedef const unsigned char * ConstStr255Param;
typedef const unsigned char * ConstStr63Param;
typedef const unsigned char * ConstStr32Param;
typedef const unsigned char * ConstStr31Param;
typedef const unsigned char * ConstStr27Param;
typedef const unsigned char * ConstStr15Param;
typedef ConstStr63Param ConstStrFileNameParam;
#ifdef __cplusplus
inline unsigned char StrLength(ConstStr255Param string) { return (*string); }
#else
#define StrLength(string) (*(const unsigned char *)(string))
#endif /* defined(__cplusplus) */
#if OLDROUTINENAMES
#define Length(string) StrLength(string)
#endif /* OLDROUTINENAMES */
/********************************************************************************
Process Manager type ProcessSerialNumber (previously in Processes.h)
*********************************************************************************/
/* type for unique process identifier */
struct ProcessSerialNumber {
UInt32 highLongOfPSN;
UInt32 lowLongOfPSN;
};
typedef struct ProcessSerialNumber ProcessSerialNumber;
typedef ProcessSerialNumber * ProcessSerialNumberPtr;
/********************************************************************************
Quickdraw Types
Point 2D Quickdraw coordinate, range: -32K to +32K
Rect Rectangular Quickdraw area
Style Quickdraw font rendering styles
StyleParameter Style when used as a parameter (historical 68K convention)
StyleField Style when used as a field (historical 68K convention)
CharParameter Char when used as a parameter (historical 68K convention)
Note: The original Macintosh toolbox in 68K Pascal defined Style as a SET.
Both Style and CHAR occupy 8-bits in packed records or 16-bits when
used as fields in non-packed records or as parameters.
*********************************************************************************/
struct Point {
short v;
short h;
};
typedef struct Point Point;
typedef Point * PointPtr;
struct Rect {
short top;
short left;
short bottom;
short right;
};
typedef struct Rect Rect;
typedef Rect * RectPtr;
struct FixedPoint {
Fixed x;
Fixed y;
};
typedef struct FixedPoint FixedPoint;
struct FixedRect {
Fixed left;
Fixed top;
Fixed right;
Fixed bottom;
};
typedef struct FixedRect FixedRect;
typedef short CharParameter;
enum {
normal = 0,
bold = 1,
italic = 2,
underline = 4,
outline = 8,
shadow = 0x10,
condense = 0x20,
extend = 0x40
};
typedef unsigned char Style;
typedef short StyleParameter;
typedef Style StyleField;
/********************************************************************************
QuickTime TimeBase types (previously in Movies.h)
TimeValue Count of units
TimeScale Units per second
CompTimeValue 64-bit count of units (always a struct)
TimeValue64 64-bit count of units (long long or struct)
TimeBase An opaque reference to a time base
TimeRecord Package of TimeBase, duration, and scale
*********************************************************************************/
typedef SInt32 TimeValue;
typedef SInt32 TimeScale;
typedef wide CompTimeValue;
typedef SInt64 TimeValue64;
typedef struct TimeBaseRecord* TimeBase;
struct TimeRecord {
CompTimeValue value; /* units (duration or absolute) */
TimeScale scale; /* units per second */
TimeBase base; /* refernce to the time base */
};
typedef struct TimeRecord TimeRecord;
/********************************************************************************
THINK C base objects
HandleObject Root class for handle based THINK C++ objects
PascalObject Root class for pascal style objects in THINK C++
*********************************************************************************/
#if defined(__SC__) && !defined(__STDC__) && defined(__cplusplus)
class __machdl HandleObject {};
#if TARGET_CPU_68K
class __pasobj PascalObject {};
#endif
#endif
/********************************************************************************
MacOS versioning structures
VersRec Contents of a 'vers' resource
VersRecPtr Pointer to a VersRecPtr
VersRecHndl Resource Handle containing a VersRec
NumVersion Packed BCD version representation (e.g. "4.2.1a3" is 0x04214003)
UniversalProcPtr Pointer to classic 68K code or a RoutineDescriptor
ProcHandle Pointer to a ProcPtr
UniversalProcHandle Pointer to a UniversalProcPtr
*********************************************************************************/
#if TARGET_RT_BIG_ENDIAN
struct NumVersion {
/* Numeric version part of 'vers' resource */
UInt8 majorRev; /*1st part of version number in BCD*/
UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/
UInt8 stage; /*stage code: dev, alpha, beta, final*/
UInt8 nonRelRev; /*revision level of non-released version*/
};
typedef struct NumVersion NumVersion;
#else
struct NumVersion {
/* Numeric version part of 'vers' resource accessable in little endian format */
UInt8 nonRelRev; /*revision level of non-released version*/
UInt8 stage; /*stage code: dev, alpha, beta, final*/
UInt8 minorAndBugRev; /*2nd & 3rd part of version number share a byte*/
UInt8 majorRev; /*1st part of version number in BCD*/
};
typedef struct NumVersion NumVersion;
#endif /* TARGET_RT_BIG_ENDIAN */
enum {
/* Version Release Stage Codes */
developStage = 0x20,
alphaStage = 0x40,
betaStage = 0x60,
finalStage = 0x80
};
union NumVersionVariant {
/* NumVersionVariant is a wrapper so NumVersion can be accessed as a 32-bit value */
NumVersion parts;
UInt32 whole;
};
typedef union NumVersionVariant NumVersionVariant;
typedef NumVersionVariant * NumVersionVariantPtr;
typedef NumVersionVariantPtr * NumVersionVariantHandle;
struct VersRec {
/* 'vers' resource format */
NumVersion numericVersion; /*encoded version number*/
short countryCode; /*country code from intl utilities*/
Str255 shortVersion; /*version number string - worst case*/
Str255 reserved; /*longMessage string packed after shortVersion*/
};
typedef struct VersRec VersRec;
typedef VersRec * VersRecPtr;
typedef VersRecPtr * VersRecHndl;
/*********************************************************************************
Old names for types
*********************************************************************************/
typedef UInt8 Byte;
typedef SInt8 SignedByte;
typedef wide * WidePtr;
typedef UnsignedWide * UnsignedWidePtr;
typedef Float80 extended80;
typedef Float96 extended96;
typedef SInt8 VHSelect;
/*********************************************************************************
Debugger functions
*********************************************************************************/
/*
* Debugger()
*
* Availability:
* Mac OS X: in version 10.0 and later in CoreServices.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void
Debugger(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
/*
* DebugStr()
*
* Availability:
* Mac OS X: in version 10.0 and later in CoreServices.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void
DebugStr(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
/*
* debugstr()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
#if TARGET_CPU_PPC
/* Only for Mac OS native drivers */
/*
* SysDebug()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: in DriverServicesLib 1.0 and later
*/
/*
* SysDebugStr()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: in DriverServicesLib 1.0 and later
*/
#endif /* TARGET_CPU_PPC */
/* SADE break points */
/*
* SysBreak()
*
* Availability:
* Mac OS X: in version 10.0 and later in CoreServices.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void
SysBreak(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
/*
* SysBreakStr()
*
* Availability:
* Mac OS X: in version 10.0 and later in CoreServices.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void
SysBreakStr(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
/*
* SysBreakFunc()
*
* Availability:
* Mac OS X: in version 10.0 and later in CoreServices.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void
SysBreakFunc(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
/* old names for Debugger and DebugStr */
#if OLDROUTINENAMES && TARGET_CPU_68K
#define Debugger68k() Debugger()
#define DebugStr68k(s) DebugStr(s)
#endif
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif /* __MACTYPES__ */

View File

@@ -35,71 +35,72 @@
#ifndef __TARGETCONDITIONALS__
#define __TARGETCONDITIONALS__
/****************************************************************************************************
TARGET_CPU_*
These conditionals specify which microprocessor instruction set is being
generated. At most one of these is true, the rest are false.
TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode
TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode
TARGET_CPU_68K - Compiler is generating 680x0 instructions
TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode
TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode
TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode
TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode
TARGET_CPU_MIPS - Compiler is generating MIPS instructions
TARGET_CPU_SPARC - Compiler is generating Sparc instructions
TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions
TARGET_OS_*
These conditionals specify in which Operating System the generated code will
run. Indention is used to show which conditionals are evolutionary subclasses.
The MAC/WIN32/UNIX conditionals are mutually exclusive.
The IOS/TV/WATCH conditionals are mutually exclusive.
TARGET_OS_WIN32 - Generated code will run under 32-bit Windows
TARGET_OS_UNIX - Generated code will run under some Unix (not OSX)
TARGET_OS_MAC - Generated code will run under Mac OS X variant
TARGET_OS_OSX - Generated code will run under OS X devices
TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator
TARGET_OS_IOS - Generated code will run under iOS
TARGET_OS_TV - Generated code will run under Apple TV OS
TARGET_OS_WATCH - Generated code will run under Apple Watch OS
TARGET_OS_BRIDGE - Generated code will run under Bridge devices
TARGET_OS_MACCATALYST - Generated code will run under macOS
TARGET_OS_SIMULATOR - Generated code will run under a simulator
TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead
TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR
TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH
+----------------------------------------------------------------+
| TARGET_OS_MAC |
| +---+ +-----------------------------------------------------+ |
| | | | TARGET_OS_IPHONE | |
| |OSX| | +-----+ +----+ +-------+ +--------+ +-------------+ | |
| | | | | IOS | | TV | | WATCH | | BRIDGE | | MACCATALYST | | |
| | | | +-----+ +----+ +-------+ +--------+ +-------------+ | |
| +---+ +-----------------------------------------------------+ |
+----------------------------------------------------------------+
TARGET_RT_*
These conditionals specify in which runtime the generated code will
run. This is needed when the OS and CPU support more than one runtime
(e.g. Mac OS X supports CFM and mach-o).
TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers
TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers
TARGET_RT_64_BIT - Generated code uses 64-bit pointers
TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used
TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used
****************************************************************************************************/
/*
*
* TARGET_CPU_*
* These conditionals specify which microprocessor instruction set is being
* generated. At most one of these is true, the rest are false.
*
* TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode
* TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode
* TARGET_CPU_68K - Compiler is generating 680x0 instructions
* TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode
* TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode
* TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode
* TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode
* TARGET_CPU_MIPS - Compiler is generating MIPS instructions
* TARGET_CPU_SPARC - Compiler is generating Sparc instructions
* TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions
*
*
* TARGET_OS_*
* These conditionals specify in which Operating System the generated code will
* run. Indention is used to show which conditionals are evolutionary subclasses.
*
* The MAC/WIN32/UNIX conditionals are mutually exclusive.
* The IOS/TV/WATCH conditionals are mutually exclusive.
*
*
* TARGET_OS_WIN32 - Generated code will run under 32-bit Windows
* TARGET_OS_UNIX - Generated code will run under some Unix (not OSX)
* TARGET_OS_MAC - Generated code will run under Mac OS X variant
* TARGET_OS_OSX - Generated code will run under OS X devices
* TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator
* TARGET_OS_IOS - Generated code will run under iOS
* TARGET_OS_TV - Generated code will run under Apple TV OS
* TARGET_OS_WATCH - Generated code will run under Apple Watch OS
* TARGET_OS_BRIDGE - Generated code will run under Bridge devices
* TARGET_OS_MACCATALYST - Generated code will run under macOS
* TARGET_OS_SIMULATOR - Generated code will run under a simulator
*
* TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead
* TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR
* TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH
*
* +---------------------------------------------------------------------+
* | TARGET_OS_MAC |
* | +---+ +-----------------------------------------------+ +---------+ |
* | | | | TARGET_OS_IPHONE | | | |
* | | | | +---------------+ +----+ +-------+ +--------+ | | | |
* | | | | | IOS | | | | | | | | | | |
* | |OSX| | |+-------------+| | TV | | WATCH | | BRIDGE | | |DRIVERKIT| |
* | | | | || MACCATALYST || | | | | | | | | | |
* | | | | |+-------------+| | | | | | | | | | |
* | | | | +---------------+ +----+ +-------+ +--------+ | | | |
* | +---+ +-----------------------------------------------+ +---------+ |
* +---------------------------------------------------------------------+
*
* TARGET_RT_*
* These conditionals specify in which runtime the generated code will
* run. This is needed when the OS and CPU support more than one runtime
* (e.g. Mac OS X supports CFM and mach-o).
*
* TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers
* TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers
* TARGET_RT_64_BIT - Generated code uses 64-bit pointers
* TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used
* TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used
*/
/*
* TARGET_OS conditionals can be enabled via clang preprocessor extensions:
@@ -133,7 +134,9 @@
#if __has_builtin(__is_target_environment)
/* “-target=x86_64-apple-ios12-macabi” */
#if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi)
/* “-target=arm64-apple-ios12-macabi” */
/* “-target=arm64e-apple-ios12-macabi” */
#if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi)
#define TARGET_OS_OSX 0
#define TARGET_OS_IPHONE 1
#define TARGET_OS_IOS 1
@@ -173,7 +176,9 @@
#endif
/* -target=x86_64-apple-driverkit19.0 */
#if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(driverkit)
/* -target=arm64-apple-driverkit19.0 */
/* -target=arm64e-apple-driverkit19.0 */
#if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(driverkit)
#define TARGET_OS_OSX 0
#define TARGET_OS_IPHONE 0
#define TARGET_OS_IOS 0
@@ -231,7 +236,8 @@
#define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */
#define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */
#define TARGET_ABI_USES_IOS_VALUES (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST)
#define TARGET_ABI_USES_IOS_VALUES (!TARGET_CPU_X86_64 || (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST))
#if defined(__ppc__)
#define TARGET_CPU_PPC 1
#define TARGET_CPU_PPC64 0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2002-2006, 2008-2010, 2012 Apple Inc. All rights reserved.
* Copyright (c) 2000, 2002-2006, 2008-2010, 2012, 2020 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@@ -23,5 +23,13 @@
#ifndef _CTERMID_H_
#define _CTERMID_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
char *ctermid(char *);
__END_DECLS
#endif

View File

@@ -332,13 +332,24 @@ struct au_evclass_map {
};
typedef struct au_evclass_map au_evclass_map_t;
#if !defined(_KERNEL) && !defined(KERNEL)
#include <Availability.h>
#define __AUDIT_API_DEPRECATED __API_DEPRECATED("audit is deprecated", macos(10.4, 11.0))
#else
#define __AUDIT_API_DEPRECATED
#endif
/*
* Audit system calls.
*/
#if !defined(_KERNEL) && !defined(KERNEL)
int audit(const void *, int);
int auditon(int, void *, int);
int auditctl(const char *);
int audit(const void *, int)
__AUDIT_API_DEPRECATED;
int auditon(int, void *, int)
__AUDIT_API_DEPRECATED;
int auditctl(const char *)
__AUDIT_API_DEPRECATED;
int getauid(au_id_t *);
int setauid(const au_id_t *);
int getaudit_addr(struct auditinfo_addr *, int);
@@ -360,8 +371,10 @@ __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8,
__IPHONE_2_0, __IPHONE_6_0);
#else
int getaudit(struct auditinfo *);
int setaudit(const struct auditinfo *);
int getaudit(struct auditinfo *)
__AUDIT_API_DEPRECATED;
int setaudit(const struct auditinfo *)
__AUDIT_API_DEPRECATED;
#endif /* !__APPLE__ */
#ifdef __APPLE_API_PRIVATE

View File

@@ -0,0 +1,118 @@
/*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Author: David B. Golub, Carnegie Mellon University
* Date: 3/89
*/
#ifndef DEVICE_TYPES_H
#define DEVICE_TYPES_H
/*
* Types for device interface.
*/
#include <mach/std_types.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/port.h>
/*
* IO buffer - out-of-line array of characters.
*/
typedef char * io_buf_ptr_t;
/*
* Some types for IOKit.
*/
#ifdef IOKIT
/* must match device_types.defs */
typedef char io_name_t[128];
typedef char io_string_t[512];
typedef char io_string_inband_t[4096];
typedef char io_struct_inband_t[4096];
#if __LP64__
typedef uint64_t io_user_scalar_t;
typedef uint64_t io_user_reference_t;
typedef io_user_scalar_t io_scalar_inband_t[16];
typedef io_user_reference_t io_async_ref_t[8];
typedef io_user_scalar_t io_scalar_inband64_t[16];
typedef io_user_reference_t io_async_ref64_t[8];
#else
typedef int io_user_scalar_t;
typedef natural_t io_user_reference_t;
typedef io_user_scalar_t io_scalar_inband_t[16];
typedef io_user_reference_t io_async_ref_t[8];
typedef uint64_t io_scalar_inband64_t[16];
typedef uint64_t io_async_ref64_t[8];
#endif // __LP64__
#ifndef __IOKIT_PORTS_DEFINED__
#define __IOKIT_PORTS_DEFINED__
typedef mach_port_t io_object_t;
#endif /* __IOKIT_PORTS_DEFINED__ */
#endif /* IOKIT */
#endif /* DEVICE_TYPES_H */

View File

@@ -0,0 +1,306 @@
/*
* Copyright (c) 2008-2012 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_BASE__
#define __DISPATCH_BASE__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#endif
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_include
#define __has_include(x) 0
#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#if __GNUC__
#define DISPATCH_NORETURN __attribute__((__noreturn__))
#define DISPATCH_NOTHROW __attribute__((__nothrow__))
#define DISPATCH_NONNULL1 __attribute__((__nonnull__(1)))
#define DISPATCH_NONNULL2 __attribute__((__nonnull__(2)))
#define DISPATCH_NONNULL3 __attribute__((__nonnull__(3)))
#define DISPATCH_NONNULL4 __attribute__((__nonnull__(4)))
#define DISPATCH_NONNULL5 __attribute__((__nonnull__(5)))
#define DISPATCH_NONNULL6 __attribute__((__nonnull__(6)))
#define DISPATCH_NONNULL7 __attribute__((__nonnull__(7)))
#if __clang__ && __clang_major__ < 3
// rdar://problem/6857843
#define DISPATCH_NONNULL_ALL
#else
#define DISPATCH_NONNULL_ALL __attribute__((__nonnull__))
#endif
#define DISPATCH_SENTINEL __attribute__((__sentinel__))
#define DISPATCH_PURE __attribute__((__pure__))
#define DISPATCH_CONST __attribute__((__const__))
#define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
#define DISPATCH_MALLOC __attribute__((__malloc__))
#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__))
#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg)))
#elif defined(_MSC_VER)
#define DISPATCH_NORETURN __declspec(noreturn)
#define DISPATCH_NOTHROW __declspec(nothrow)
#define DISPATCH_NONNULL1
#define DISPATCH_NONNULL2
#define DISPATCH_NONNULL3
#define DISPATCH_NONNULL4
#define DISPATCH_NONNULL5
#define DISPATCH_NONNULL6
#define DISPATCH_NONNULL7
#define DISPATCH_NONNULL_ALL
#define DISPATCH_SENTINEL
#define DISPATCH_PURE
#define DISPATCH_CONST
#if (_MSC_VER >= 1700)
#define DISPATCH_WARN_RESULT _Check_return_
#else
#define DISPATCH_WARN_RESULT
#endif
#define DISPATCH_MALLOC
#define DISPATCH_ALWAYS_INLINE __forceinline
#define DISPATCH_UNAVAILABLE
#define DISPATCH_UNAVAILABLE_MSG(msg)
#else
/*! @parseOnly */
#define DISPATCH_NORETURN
/*! @parseOnly */
#define DISPATCH_NOTHROW
/*! @parseOnly */
#define DISPATCH_NONNULL1
/*! @parseOnly */
#define DISPATCH_NONNULL2
/*! @parseOnly */
#define DISPATCH_NONNULL3
/*! @parseOnly */
#define DISPATCH_NONNULL4
/*! @parseOnly */
#define DISPATCH_NONNULL5
/*! @parseOnly */
#define DISPATCH_NONNULL6
/*! @parseOnly */
#define DISPATCH_NONNULL7
/*! @parseOnly */
#define DISPATCH_NONNULL_ALL
/*! @parseOnly */
#define DISPATCH_SENTINEL
/*! @parseOnly */
#define DISPATCH_PURE
/*! @parseOnly */
#define DISPATCH_CONST
/*! @parseOnly */
#define DISPATCH_WARN_RESULT
/*! @parseOnly */
#define DISPATCH_MALLOC
/*! @parseOnly */
#define DISPATCH_ALWAYS_INLINE
/*! @parseOnly */
#define DISPATCH_UNAVAILABLE
/*! @parseOnly */
#define DISPATCH_UNAVAILABLE_MSG(msg)
#endif
#define DISPATCH_LINUX_UNAVAILABLE()
#ifdef __FreeBSD__
#define DISPATCH_FREEBSD_UNAVAILABLE() \
DISPATCH_UNAVAILABLE_MSG( \
"This interface is unavailable on FreeBSD systems")
#else
#define DISPATCH_FREEBSD_UNAVAILABLE()
#endif
#ifndef DISPATCH_ALIAS_V2
#if TARGET_OS_MAC
#define DISPATCH_ALIAS_V2(sym) __asm__("_" #sym "$V2")
#else
#define DISPATCH_ALIAS_V2(sym)
#endif
#endif
#if defined(_WIN32)
#if defined(__cplusplus)
#define DISPATCH_EXPORT extern "C" __declspec(dllimport)
#else
#define DISPATCH_EXPORT extern __declspec(dllimport)
#endif
#elif __GNUC__
#define DISPATCH_EXPORT extern __attribute__((visibility("default")))
#else
#define DISPATCH_EXPORT extern
#endif
#if __GNUC__
#define DISPATCH_INLINE static __inline__
#else
#define DISPATCH_INLINE static inline
#endif
#if __GNUC__
#define DISPATCH_EXPECT(x, v) __builtin_expect((x), (v))
#define dispatch_compiler_barrier() __asm__ __volatile__("" ::: "memory")
#else
#define DISPATCH_EXPECT(x, v) (x)
#define dispatch_compiler_barrier() do { } while (0)
#endif
#if __has_attribute(not_tail_called)
#define DISPATCH_NOT_TAIL_CALLED __attribute__((__not_tail_called__))
#else
#define DISPATCH_NOT_TAIL_CALLED
#endif
#if __has_builtin(__builtin_assume)
#define DISPATCH_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
#else
#define DISPATCH_COMPILER_CAN_ASSUME(expr) ((void)(expr))
#endif
#if __has_attribute(noescape)
#define DISPATCH_NOESCAPE __attribute__((__noescape__))
#else
#define DISPATCH_NOESCAPE
#endif
#if __has_attribute(cold)
#define DISPATCH_COLD __attribute__((__cold__))
#else
#define DISPATCH_COLD
#endif
#if __has_feature(assume_nonnull)
#define DISPATCH_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define DISPATCH_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#else
#define DISPATCH_ASSUME_NONNULL_BEGIN
#define DISPATCH_ASSUME_NONNULL_END
#endif
#if !__has_feature(nullability)
#ifndef _Nullable
#define _Nullable
#endif
#ifndef _Nonnull
#define _Nonnull
#endif
#ifndef _Null_unspecified
#define _Null_unspecified
#endif
#endif
#ifndef DISPATCH_RETURNS_RETAINED_BLOCK
#if __has_attribute(ns_returns_retained)
#define DISPATCH_RETURNS_RETAINED_BLOCK __attribute__((__ns_returns_retained__))
#else
#define DISPATCH_RETURNS_RETAINED_BLOCK
#endif
#endif
#if __has_attribute(enum_extensibility)
#define __DISPATCH_ENUM_ATTR __attribute__((__enum_extensibility__(open)))
#define __DISPATCH_ENUM_ATTR_CLOSED __attribute__((__enum_extensibility__(closed)))
#else
#define __DISPATCH_ENUM_ATTR
#define __DISPATCH_ENUM_ATTR_CLOSED
#endif // __has_attribute(enum_extensibility)
#if __has_attribute(flag_enum)
#define __DISPATCH_OPTIONS_ATTR __attribute__((__flag_enum__))
#else
#define __DISPATCH_OPTIONS_ATTR
#endif // __has_attribute(flag_enum)
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums) || \
__has_extension(cxx_fixed_enum) || defined(_WIN32)
#define DISPATCH_ENUM(name, type, ...) \
typedef enum : type { __VA_ARGS__ } __DISPATCH_ENUM_ATTR name##_t
#define DISPATCH_OPTIONS(name, type, ...) \
typedef enum : type { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR name##_t
#else
#define DISPATCH_ENUM(name, type, ...) \
enum { __VA_ARGS__ } __DISPATCH_ENUM_ATTR; typedef type name##_t
#define DISPATCH_OPTIONS(name, type, ...) \
enum { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR; typedef type name##_t
#endif // __has_feature(objc_fixed_enum) ...
#if __has_feature(enumerator_attributes)
#define DISPATCH_ENUM_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__)
#define DISPATCH_ENUM_API_DEPRECATED(...) API_DEPRECATED(__VA_ARGS__)
#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...) \
API_DEPRECATED_WITH_REPLACEMENT(__VA_ARGS__)
#else
#define DISPATCH_ENUM_API_AVAILABLE(...)
#define DISPATCH_ENUM_API_DEPRECATED(...)
#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...)
#endif
#ifdef __swift__
#define DISPATCH_SWIFT3_OVERLAY 1
#else // __swift__
#define DISPATCH_SWIFT3_OVERLAY 0
#endif // __swift__
#if __has_feature(attribute_availability_swift)
#define DISPATCH_SWIFT_UNAVAILABLE(_msg) \
__attribute__((__availability__(swift, unavailable, message=_msg)))
#else
#define DISPATCH_SWIFT_UNAVAILABLE(_msg)
#endif
#if DISPATCH_SWIFT3_OVERLAY
#define DISPATCH_SWIFT3_UNAVAILABLE(_msg) DISPATCH_SWIFT_UNAVAILABLE(_msg)
#else
#define DISPATCH_SWIFT3_UNAVAILABLE(_msg)
#endif
#if __has_attribute(swift_private)
#define DISPATCH_REFINED_FOR_SWIFT __attribute__((__swift_private__))
#else
#define DISPATCH_REFINED_FOR_SWIFT
#endif
#if __has_attribute(swift_name)
#define DISPATCH_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
#else
#define DISPATCH_SWIFT_NAME(_name)
#endif
#ifndef __cplusplus
#define DISPATCH_TRANSPARENT_UNION __attribute__((__transparent_union__))
#else
#define DISPATCH_TRANSPARENT_UNION
#endif
typedef void (*dispatch_function_t)(void *_Nullable);
#endif

View File

@@ -0,0 +1,428 @@
/*
* Copyright (c) 2014 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_BLOCK__
#define __DISPATCH_BLOCK__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
#ifdef __BLOCKS__
/*!
* @group Dispatch block objects
*/
DISPATCH_ASSUME_NONNULL_BEGIN
__BEGIN_DECLS
/*!
* @typedef dispatch_block_flags_t
* Flags to pass to the dispatch_block_create* functions.
*
* @const DISPATCH_BLOCK_BARRIER
* Flag indicating that a dispatch block object should act as a barrier block
* when submitted to a DISPATCH_QUEUE_CONCURRENT queue.
* See dispatch_barrier_async() for details.
* This flag has no effect when the dispatch block object is invoked directly.
*
* @const DISPATCH_BLOCK_DETACHED
* Flag indicating that a dispatch block object should execute disassociated
* from current execution context attributes such as os_activity_t
* and properties of the current IPC request (if any). With regard to QoS class,
* the behavior is the same as for DISPATCH_BLOCK_NO_QOS. If invoked directly,
* the block object will remove the other attributes from the calling thread for
* the duration of the block body (before applying attributes assigned to the
* block object, if any). If submitted to a queue, the block object will be
* executed with the attributes of the queue (or any attributes specifically
* assigned to the block object).
*
* @const DISPATCH_BLOCK_ASSIGN_CURRENT
* Flag indicating that a dispatch block object should be assigned the execution
* context attributes that are current at the time the block object is created.
* This applies to attributes such as QOS class, os_activity_t and properties of
* the current IPC request (if any). If invoked directly, the block object will
* apply these attributes to the calling thread for the duration of the block
* body. If the block object is submitted to a queue, this flag replaces the
* default behavior of associating the submitted block instance with the
* execution context attributes that are current at the time of submission.
* If a specific QOS class is assigned with DISPATCH_BLOCK_NO_QOS_CLASS or
* dispatch_block_create_with_qos_class(), that QOS class takes precedence over
* the QOS class assignment indicated by this flag.
*
* @const DISPATCH_BLOCK_NO_QOS_CLASS
* Flag indicating that a dispatch block object should be not be assigned a QOS
* class. If invoked directly, the block object will be executed with the QOS
* class of the calling thread. If the block object is submitted to a queue,
* this replaces the default behavior of associating the submitted block
* instance with the QOS class current at the time of submission.
* This flag is ignored if a specific QOS class is assigned with
* dispatch_block_create_with_qos_class().
*
* @const DISPATCH_BLOCK_INHERIT_QOS_CLASS
* Flag indicating that execution of a dispatch block object submitted to a
* queue should prefer the QOS class assigned to the queue over the QOS class
* assigned to the block (resp. associated with the block at the time of
* submission). The latter will only be used if the queue in question does not
* have an assigned QOS class, as long as doing so does not result in a QOS
* class lower than the QOS class inherited from the queue's target queue.
* This flag is the default when a dispatch block object is submitted to a queue
* for asynchronous execution and has no effect when the dispatch block object
* is invoked directly. It is ignored if DISPATCH_BLOCK_ENFORCE_QOS_CLASS is
* also passed.
*
* @const DISPATCH_BLOCK_ENFORCE_QOS_CLASS
* Flag indicating that execution of a dispatch block object submitted to a
* queue should prefer the QOS class assigned to the block (resp. associated
* with the block at the time of submission) over the QOS class assigned to the
* queue, as long as doing so will not result in a lower QOS class.
* This flag is the default when a dispatch block object is submitted to a queue
* for synchronous execution or when the dispatch block object is invoked
* directly.
*/
DISPATCH_OPTIONS(dispatch_block_flags, unsigned long,
DISPATCH_BLOCK_BARRIER
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x1,
DISPATCH_BLOCK_DETACHED
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x2,
DISPATCH_BLOCK_ASSIGN_CURRENT
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x4,
DISPATCH_BLOCK_NO_QOS_CLASS
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x8,
DISPATCH_BLOCK_INHERIT_QOS_CLASS
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x10,
DISPATCH_BLOCK_ENFORCE_QOS_CLASS
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x20,
);
/*!
* @function dispatch_block_create
*
* @abstract
* Create a new dispatch block object on the heap from an existing block and
* the given flags.
*
* @discussion
* The provided block is Block_copy'ed to the heap and retained by the newly
* created dispatch block object.
*
* The returned dispatch block object is intended to be submitted to a dispatch
* queue with dispatch_async() and related functions, but may also be invoked
* directly. Both operations can be performed an arbitrary number of times but
* only the first completed execution of a dispatch block object can be waited
* on with dispatch_block_wait() or observed with dispatch_block_notify().
*
* If the returned dispatch block object is submitted to a dispatch queue, the
* submitted block instance will be associated with the QOS class current at the
* time of submission, unless one of the following flags assigned a specific QOS
* class (or no QOS class) at the time of block creation:
* - DISPATCH_BLOCK_ASSIGN_CURRENT
* - DISPATCH_BLOCK_NO_QOS_CLASS
* - DISPATCH_BLOCK_DETACHED
* The QOS class the block object will be executed with also depends on the QOS
* class assigned to the queue and which of the following flags was specified or
* defaulted to:
* - DISPATCH_BLOCK_INHERIT_QOS_CLASS (default for asynchronous execution)
* - DISPATCH_BLOCK_ENFORCE_QOS_CLASS (default for synchronous execution)
* See description of dispatch_block_flags_t for details.
*
* If the returned dispatch block object is submitted directly to a serial queue
* and is configured to execute with a specific QOS class, the system will make
* a best effort to apply the necessary QOS overrides to ensure that blocks
* submitted earlier to the serial queue are executed at that same QOS class or
* higher.
*
* @param flags
* Configuration flags for the block object.
* Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t
* results in NULL being returned.
*
* @param block
* The block to create the dispatch block object from.
*
* @result
* The newly created dispatch block object, or NULL.
* When not building with Objective-C ARC, must be released with a -[release]
* message or the Block_release() function.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_RETURNS_RETAINED_BLOCK
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_block_t
dispatch_block_create(dispatch_block_flags_t flags, dispatch_block_t block);
/*!
* @function dispatch_block_create_with_qos_class
*
* @abstract
* Create a new dispatch block object on the heap from an existing block and
* the given flags, and assign it the specified QOS class and relative priority.
*
* @discussion
* The provided block is Block_copy'ed to the heap and retained by the newly
* created dispatch block object.
*
* The returned dispatch block object is intended to be submitted to a dispatch
* queue with dispatch_async() and related functions, but may also be invoked
* directly. Both operations can be performed an arbitrary number of times but
* only the first completed execution of a dispatch block object can be waited
* on with dispatch_block_wait() or observed with dispatch_block_notify().
*
* If invoked directly, the returned dispatch block object will be executed with
* the assigned QOS class as long as that does not result in a lower QOS class
* than what is current on the calling thread.
*
* If the returned dispatch block object is submitted to a dispatch queue, the
* QOS class it will be executed with depends on the QOS class assigned to the
* block, the QOS class assigned to the queue and which of the following flags
* was specified or defaulted to:
* - DISPATCH_BLOCK_INHERIT_QOS_CLASS: default for asynchronous execution
* - DISPATCH_BLOCK_ENFORCE_QOS_CLASS: default for synchronous execution
* See description of dispatch_block_flags_t for details.
*
* If the returned dispatch block object is submitted directly to a serial queue
* and is configured to execute with a specific QOS class, the system will make
* a best effort to apply the necessary QOS overrides to ensure that blocks
* submitted earlier to the serial queue are executed at that same QOS class or
* higher.
*
* @param flags
* Configuration flags for the new block object.
* Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t
* results in NULL being returned.
*
* @param qos_class
* A QOS class value:
* - QOS_CLASS_USER_INTERACTIVE
* - QOS_CLASS_USER_INITIATED
* - QOS_CLASS_DEFAULT
* - QOS_CLASS_UTILITY
* - QOS_CLASS_BACKGROUND
* - QOS_CLASS_UNSPECIFIED
* Passing QOS_CLASS_UNSPECIFIED is equivalent to specifying the
* DISPATCH_BLOCK_NO_QOS_CLASS flag. Passing any other value results in NULL
* being returned.
*
* @param relative_priority
* A relative priority within the QOS class. This value is a negative
* offset from the maximum supported scheduler priority for the given class.
* Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
* results in NULL being returned.
*
* @param block
* The block to create the dispatch block object from.
*
* @result
* The newly created dispatch block object, or NULL.
* When not building with Objective-C ARC, must be released with a -[release]
* message or the Block_release() function.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_RETURNS_RETAINED_BLOCK
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_block_t
dispatch_block_create_with_qos_class(dispatch_block_flags_t flags,
dispatch_qos_class_t qos_class, int relative_priority,
dispatch_block_t block);
/*!
* @function dispatch_block_perform
*
* @abstract
* Create, synchronously execute and release a dispatch block object from the
* specified block and flags.
*
* @discussion
* Behaves identically to the sequence
* <code>
* dispatch_block_t b = dispatch_block_create(flags, block);
* b();
* Block_release(b);
* </code>
* but may be implemented more efficiently internally by not requiring a copy
* to the heap of the specified block or the allocation of a new block object.
*
* @param flags
* Configuration flags for the temporary block object.
* The result of passing a value that is not a bitwise OR of flags from
* dispatch_block_flags_t is undefined.
*
* @param block
* The block to create the temporary block object from.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
void
dispatch_block_perform(dispatch_block_flags_t flags,
DISPATCH_NOESCAPE dispatch_block_t block);
/*!
* @function dispatch_block_wait
*
* @abstract
* Wait synchronously until execution of the specified dispatch block object has
* completed or until the specified timeout has elapsed.
*
* @discussion
* This function will return immediately if execution of the block object has
* already completed.
*
* It is not possible to wait for multiple executions of the same block object
* with this interface; use dispatch_group_wait() for that purpose. A single
* dispatch block object may either be waited on once and executed once,
* or it may be executed any number of times. The behavior of any other
* combination is undefined. Submission to a dispatch queue counts as an
* execution, even if cancellation (dispatch_block_cancel) means the block's
* code never runs.
*
* The result of calling this function from multiple threads simultaneously
* with the same dispatch block object is undefined, but note that doing so
* would violate the rules described in the previous paragraph.
*
* If this function returns indicating that the specified timeout has elapsed,
* then that invocation does not count as the one allowed wait.
*
* If at the time this function is called, the specified dispatch block object
* has been submitted directly to a serial queue, the system will make a best
* effort to apply the necessary QOS overrides to ensure that the block and any
* blocks submitted earlier to that serial queue are executed at the QOS class
* (or higher) of the thread calling dispatch_block_wait().
*
* @param block
* The dispatch block object to wait on.
* The result of passing NULL or a block object not returned by one of the
* dispatch_block_create* functions is undefined.
*
* @param timeout
* When to timeout (see dispatch_time). As a convenience, there are the
* DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
*
* @result
* Returns zero on success (the dispatch block object completed within the
* specified timeout) or non-zero on error (i.e. timed out).
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
intptr_t
dispatch_block_wait(dispatch_block_t block, dispatch_time_t timeout);
/*!
* @function dispatch_block_notify
*
* @abstract
* Schedule a notification block to be submitted to a queue when the execution
* of a specified dispatch block object has completed.
*
* @discussion
* This function will submit the notification block immediately if execution of
* the observed block object has already completed.
*
* It is not possible to be notified of multiple executions of the same block
* object with this interface, use dispatch_group_notify() for that purpose.
*
* A single dispatch block object may either be observed one or more times
* and executed once, or it may be executed any number of times. The behavior
* of any other combination is undefined. Submission to a dispatch queue
* counts as an execution, even if cancellation (dispatch_block_cancel) means
* the block's code never runs.
*
* If multiple notification blocks are scheduled for a single block object,
* there is no defined order in which the notification blocks will be submitted
* to their associated queues.
*
* @param block
* The dispatch block object to observe.
* The result of passing NULL or a block object not returned by one of the
* dispatch_block_create* functions is undefined.
*
* @param queue
* The queue to which the supplied notification block will be submitted when
* the observed block completes.
*
* @param notification_block
* The notification block to submit when the observed block object completes.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_block_notify(dispatch_block_t block, dispatch_queue_t queue,
dispatch_block_t notification_block);
/*!
* @function dispatch_block_cancel
*
* @abstract
* Asynchronously cancel the specified dispatch block object.
*
* @discussion
* Cancellation causes any future execution of the dispatch block object to
* return immediately, but does not affect any execution of the block object
* that is already in progress.
*
* Release of any resources associated with the block object will be delayed
* until execution of the block object is next attempted (or any execution
* already in progress completes).
*
* NOTE: care needs to be taken to ensure that a block object that may be
* canceled does not capture any resources that require execution of the
* block body in order to be released (e.g. memory allocated with
* malloc(3) that the block body calls free(3) on). Such resources will
* be leaked if the block body is never executed due to cancellation.
*
* @param block
* The dispatch block object to cancel.
* The result of passing NULL or a block object not returned by one of the
* dispatch_block_create* functions is undefined.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_block_cancel(dispatch_block_t block);
/*!
* @function dispatch_block_testcancel
*
* @abstract
* Tests whether the given dispatch block object has been canceled.
*
* @param block
* The dispatch block object to test.
* The result of passing NULL or a block object not returned by one of the
* dispatch_block_create* functions is undefined.
*
* @result
* Non-zero if canceled and zero if not canceled.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
DISPATCH_NOTHROW
intptr_t
dispatch_block_testcancel(dispatch_block_t block);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif // __BLOCKS__
#endif // __DISPATCH_BLOCK__

View File

@@ -0,0 +1,278 @@
/*
* Copyright (c) 2009-2013 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_DATA__
#define __DISPATCH_DATA__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
__BEGIN_DECLS
/*! @header
* Dispatch data objects describe contiguous or sparse regions of memory that
* may be managed by the system or by the application.
* Dispatch data objects are immutable, any direct access to memory regions
* represented by dispatch objects must not modify that memory.
*/
/*!
* @typedef dispatch_data_t
* A dispatch object representing memory regions.
*/
DISPATCH_DATA_DECL(dispatch_data);
/*!
* @var dispatch_data_empty
* @discussion The singleton dispatch data object representing a zero-length
* memory region.
*/
#define dispatch_data_empty \
DISPATCH_GLOBAL_OBJECT(dispatch_data_t, _dispatch_data_empty)
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT struct dispatch_data_s _dispatch_data_empty;
/*!
* @const DISPATCH_DATA_DESTRUCTOR_DEFAULT
* @discussion The default destructor for dispatch data objects.
* Used at data object creation to indicate that the supplied buffer should
* be copied into internal storage managed by the system.
*/
#define DISPATCH_DATA_DESTRUCTOR_DEFAULT NULL
#ifdef __BLOCKS__
/*! @parseOnly */
#define DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(name) \
DISPATCH_EXPORT const dispatch_block_t _dispatch_data_destructor_##name
#else
#define DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(name) \
DISPATCH_EXPORT const dispatch_function_t \
_dispatch_data_destructor_##name
#endif /* __BLOCKS__ */
/*!
* @const DISPATCH_DATA_DESTRUCTOR_FREE
* @discussion The destructor for dispatch data objects created from a malloc'd
* buffer. Used at data object creation to indicate that the supplied buffer
* was allocated by the malloc() family and should be destroyed with free(3).
*/
#define DISPATCH_DATA_DESTRUCTOR_FREE (_dispatch_data_destructor_free)
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(free);
/*!
* @const DISPATCH_DATA_DESTRUCTOR_MUNMAP
* @discussion The destructor for dispatch data objects that have been created
* from buffers that require deallocation with munmap(2).
*/
#define DISPATCH_DATA_DESTRUCTOR_MUNMAP (_dispatch_data_destructor_munmap)
API_AVAILABLE(macos(10.9), ios(7.0))
DISPATCH_DATA_DESTRUCTOR_TYPE_DECL(munmap);
#ifdef __BLOCKS__
/*!
* @function dispatch_data_create
* Creates a dispatch data object from the given contiguous buffer of memory. If
* a non-default destructor is provided, ownership of the buffer remains with
* the caller (i.e. the bytes will not be copied). The last release of the data
* object will result in the invocation of the specified destructor on the
* specified queue to free the buffer.
*
* If the DISPATCH_DATA_DESTRUCTOR_FREE destructor is provided the buffer will
* be freed via free(3) and the queue argument ignored.
*
* If the DISPATCH_DATA_DESTRUCTOR_DEFAULT destructor is provided, data object
* creation will copy the buffer into internal memory managed by the system.
*
* @param buffer A contiguous buffer of data.
* @param size The size of the contiguous buffer of data.
* @param queue The queue to which the destructor should be submitted.
* @param destructor The destructor responsible for freeing the data when it
* is no longer needed.
* @result A newly created dispatch data object.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_data_t
dispatch_data_create(const void *buffer,
size_t size,
dispatch_queue_t _Nullable queue,
dispatch_block_t _Nullable destructor);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_data_get_size
* Returns the logical size of the memory region(s) represented by the specified
* dispatch data object.
*
* @param data The dispatch data object to query.
* @result The number of bytes represented by the data object.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_PURE DISPATCH_NONNULL1 DISPATCH_NOTHROW
size_t
dispatch_data_get_size(dispatch_data_t data);
/*!
* @function dispatch_data_create_map
* Maps the memory represented by the specified dispatch data object as a single
* contiguous memory region and returns a new data object representing it.
* If non-NULL references to a pointer and a size variable are provided, they
* are filled with the location and extent of that region. These allow direct
* read access to the represented memory, but are only valid until the returned
* object is released. Under ARC, if that object is held in a variable with
* automatic storage, care needs to be taken to ensure that it is not released
* by the compiler before memory access via the pointer has been completed.
*
* @param data The dispatch data object to map.
* @param buffer_ptr A pointer to a pointer variable to be filled with the
* location of the mapped contiguous memory region, or
* NULL.
* @param size_ptr A pointer to a size_t variable to be filled with the
* size of the mapped contiguous memory region, or NULL.
* @result A newly created dispatch data object.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_data_t
dispatch_data_create_map(dispatch_data_t data,
const void *_Nullable *_Nullable buffer_ptr,
size_t *_Nullable size_ptr);
/*!
* @function dispatch_data_create_concat
* Returns a new dispatch data object representing the concatenation of the
* specified data objects. Those objects may be released by the application
* after the call returns (however, the system might not deallocate the memory
* region(s) described by them until the newly created object has also been
* released).
*
* @param data1 The data object representing the region(s) of memory to place
* at the beginning of the newly created object.
* @param data2 The data object representing the region(s) of memory to place
* at the end of the newly created object.
* @result A newly created object representing the concatenation of the
* data1 and data2 objects.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_RETURNS_RETAINED
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_data_t
dispatch_data_create_concat(dispatch_data_t data1, dispatch_data_t data2);
/*!
* @function dispatch_data_create_subrange
* Returns a new dispatch data object representing a subrange of the specified
* data object, which may be released by the application after the call returns
* (however, the system might not deallocate the memory region(s) described by
* that object until the newly created object has also been released).
*
* @param data The data object representing the region(s) of memory to
* create a subrange of.
* @param offset The offset into the data object where the subrange
* starts.
* @param length The length of the range.
* @result A newly created object representing the specified
* subrange of the data object.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_data_t
dispatch_data_create_subrange(dispatch_data_t data,
size_t offset,
size_t length);
#ifdef __BLOCKS__
/*!
* @typedef dispatch_data_applier_t
* A block to be invoked for every contiguous memory region in a data object.
*
* @param region A data object representing the current region.
* @param offset The logical offset of the current region to the start
* of the data object.
* @param buffer The location of the memory for the current region.
* @param size The size of the memory for the current region.
* @result A Boolean indicating whether traversal should continue.
*/
typedef bool (^dispatch_data_applier_t)(dispatch_data_t region,
size_t offset,
const void *buffer,
size_t size);
/*!
* @function dispatch_data_apply
* Traverse the memory regions represented by the specified dispatch data object
* in logical order and invoke the specified block once for every contiguous
* memory region encountered.
*
* Each invocation of the block is passed a data object representing the current
* region and its logical offset, along with the memory location and extent of
* the region. These allow direct read access to the memory region, but are only
* valid until the passed-in region object is released. Note that the region
* object is released by the system when the block returns, it is the
* responsibility of the application to retain it if the region object or the
* associated memory location are needed after the block returns.
*
* @param data The data object to traverse.
* @param applier The block to be invoked for every contiguous memory
* region in the data object.
* @result A Boolean indicating whether traversal completed
* successfully.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
bool
dispatch_data_apply(dispatch_data_t data,
DISPATCH_NOESCAPE dispatch_data_applier_t applier);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_data_copy_region
* Finds the contiguous memory region containing the specified location among
* the regions represented by the specified object and returns a copy of the
* internal dispatch data object representing that region along with its logical
* offset in the specified object.
*
* @param data The dispatch data object to query.
* @param location The logical position in the data object to query.
* @param offset_ptr A pointer to a size_t variable to be filled with the
* logical offset of the returned region object to the
* start of the queried data object.
* @result A newly created dispatch data object.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_RETURNS_RETAINED
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_data_t
dispatch_data_copy_region(dispatch_data_t data,
size_t location,
size_t *offset_ptr);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif /* __DISPATCH_DATA__ */

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_PUBLIC__
#define __DISPATCH_PUBLIC__
#ifdef __APPLE__
#include <Availability.h>
#include <os/availability.h>
#include <TargetConditionals.h>
#include <os/base.h>
#elif defined(_WIN32)
#include <os/generic_win_base.h>
#elif defined(__unix__)
#include <os/generic_unix_base.h>
#endif
#include <sys/types.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <string.h>
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#include <unistd.h>
#endif
#include <fcntl.h>
#if defined(_WIN32)
#include <time.h>
#endif
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__has_feature)
#if __has_feature(modules)
#if !defined(__arm__)
#include <stdio.h> // for off_t (to match Glibc.modulemap)
#endif
#endif
#endif
#define DISPATCH_API_VERSION 20181008
#ifndef __DISPATCH_INDIRECT__
#define __DISPATCH_INDIRECT__
#endif
#include <os/object.h>
#include <os/workgroup.h>
#include <dispatch/base.h>
#include <dispatch/time.h>
#include <dispatch/object.h>
#include <dispatch/queue.h>
#include <dispatch/block.h>
#include <dispatch/source.h>
#include <dispatch/group.h>
#include <dispatch/semaphore.h>
#include <dispatch/once.h>
#include <dispatch/data.h>
#include <dispatch/io.h>
#include <dispatch/workloop.h>
#undef __DISPATCH_INDIRECT__
#endif

View File

@@ -0,0 +1,279 @@
/*
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_GROUP__
#define __DISPATCH_GROUP__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
/*!
* @typedef dispatch_group_t
* @abstract
* A group of blocks submitted to queues for asynchronous invocation.
*/
DISPATCH_DECL(dispatch_group);
__BEGIN_DECLS
/*!
* @function dispatch_group_create
*
* @abstract
* Creates new group with which blocks may be associated.
*
* @discussion
* This function creates a new group with which blocks may be associated.
* The dispatch group may be used to wait for the completion of the blocks it
* references. The group object memory is freed with dispatch_release().
*
* @result
* The newly created group, or NULL on failure.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
dispatch_group_t
dispatch_group_create(void);
/*!
* @function dispatch_group_async
*
* @abstract
* Submits a block to a dispatch queue and associates the block with the given
* dispatch group.
*
* @discussion
* Submits a block to a dispatch queue and associates the block with the given
* dispatch group. The dispatch group may be used to wait for the completion
* of the blocks it references.
*
* @param group
* A dispatch group to associate with the submitted block.
* The result of passing NULL in this parameter is undefined.
*
* @param queue
* The dispatch queue to which the block will be submitted for asynchronous
* invocation.
*
* @param block
* The block to perform asynchronously.
*/
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_group_async(dispatch_group_t group,
dispatch_queue_t queue,
dispatch_block_t block);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_group_async_f
*
* @abstract
* Submits a function to a dispatch queue and associates the block with the
* given dispatch group.
*
* @discussion
* See dispatch_group_async() for details.
*
* @param group
* A dispatch group to associate with the submitted function.
* The result of passing NULL in this parameter is undefined.
*
* @param queue
* The dispatch queue to which the function will be submitted for asynchronous
* invocation.
*
* @param context
* The application-defined context parameter to pass to the function.
*
* @param work
* The application-defined function to invoke on the target queue. The first
* parameter passed to this function is the context provided to
* dispatch_group_async_f().
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4
DISPATCH_NOTHROW
void
dispatch_group_async_f(dispatch_group_t group,
dispatch_queue_t queue,
void *_Nullable context,
dispatch_function_t work);
/*!
* @function dispatch_group_wait
*
* @abstract
* Wait synchronously until all the blocks associated with a group have
* completed or until the specified timeout has elapsed.
*
* @discussion
* This function waits for the completion of the blocks associated with the
* given dispatch group, and returns after all blocks have completed or when
* the specified timeout has elapsed.
*
* This function will return immediately if there are no blocks associated
* with the dispatch group (i.e. the group is empty).
*
* The result of calling this function from multiple threads simultaneously
* with the same dispatch group is undefined.
*
* After the successful return of this function, the dispatch group is empty.
* It may either be released with dispatch_release() or re-used for additional
* blocks. See dispatch_group_async() for more information.
*
* @param group
* The dispatch group to wait on.
* The result of passing NULL in this parameter is undefined.
*
* @param timeout
* When to timeout (see dispatch_time). As a convenience, there are the
* DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
*
* @result
* Returns zero on success (all blocks associated with the group completed
* within the specified timeout) or non-zero on error (i.e. timed out).
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
intptr_t
dispatch_group_wait(dispatch_group_t group, dispatch_time_t timeout);
/*!
* @function dispatch_group_notify
*
* @abstract
* Schedule a block to be submitted to a queue when all the blocks associated
* with a group have completed.
*
* @discussion
* This function schedules a notification block to be submitted to the specified
* queue once all blocks associated with the dispatch group have completed.
*
* If no blocks are associated with the dispatch group (i.e. the group is empty)
* then the notification block will be submitted immediately.
*
* The group will be empty at the time the notification block is submitted to
* the target queue. The group may either be released with dispatch_release()
* or reused for additional operations.
* See dispatch_group_async() for more information.
*
* @param group
* The dispatch group to observe.
* The result of passing NULL in this parameter is undefined.
*
* @param queue
* The queue to which the supplied block will be submitted when the group
* completes.
*
* @param block
* The block to submit when the group completes.
*/
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_group_notify(dispatch_group_t group,
dispatch_queue_t queue,
dispatch_block_t block);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_group_notify_f
*
* @abstract
* Schedule a function to be submitted to a queue when all the blocks
* associated with a group have completed.
*
* @discussion
* See dispatch_group_notify() for details.
*
* @param group
* The dispatch group to observe.
* The result of passing NULL in this parameter is undefined.
*
* @param context
* The application-defined context parameter to pass to the function.
*
* @param work
* The application-defined function to invoke on the target queue. The first
* parameter passed to this function is the context provided to
* dispatch_group_notify_f().
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4
DISPATCH_NOTHROW
void
dispatch_group_notify_f(dispatch_group_t group,
dispatch_queue_t queue,
void *_Nullable context,
dispatch_function_t work);
/*!
* @function dispatch_group_enter
*
* @abstract
* Manually indicate a block has entered the group
*
* @discussion
* Calling this function indicates another block has joined the group through
* a means other than dispatch_group_async(). Calls to this function must be
* balanced with dispatch_group_leave().
*
* @param group
* The dispatch group to update.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_group_enter(dispatch_group_t group);
/*!
* @function dispatch_group_leave
*
* @abstract
* Manually indicate a block in the group has completed
*
* @discussion
* Calling this function indicates block has completed and left the dispatch
* group by a means other than dispatch_group_async().
*
* @param group
* The dispatch group to update.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_group_leave(dispatch_group_t group);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,597 @@
/*
* Copyright (c) 2009-2013 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_IO__
#define __DISPATCH_IO__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
__BEGIN_DECLS
/*! @header
* Dispatch I/O provides both stream and random access asynchronous read and
* write operations on file descriptors. One or more dispatch I/O channels may
* be created from a file descriptor as either the DISPATCH_IO_STREAM type or
* DISPATCH_IO_RANDOM type. Once a channel has been created the application may
* schedule asynchronous read and write operations.
*
* The application may set policies on the dispatch I/O channel to indicate the
* desired frequency of I/O handlers for long-running operations.
*
* Dispatch I/O also provides a memory management model for I/O buffers that
* avoids unnecessary copying of data when pipelined between channels. Dispatch
* I/O monitors the overall memory pressure and I/O access patterns for the
* application to optimize resource utilization.
*/
/*!
* @typedef dispatch_fd_t
* Native file descriptor type for the platform.
*/
#if defined(_WIN32)
typedef intptr_t dispatch_fd_t;
#else
typedef int dispatch_fd_t;
#endif
/*!
* @functiongroup Dispatch I/O Convenience API
* Convenience wrappers around the dispatch I/O channel API, with simpler
* callback handler semantics and no explicit management of channel objects.
* File descriptors passed to the convenience API are treated as streams, and
* scheduling multiple operations on one file descriptor via the convenience API
* may incur more overhead than by using the dispatch I/O channel API directly.
*/
#ifdef __BLOCKS__
/*!
* @function dispatch_read
* Schedule a read operation for asynchronous execution on the specified file
* descriptor. The specified handler is enqueued with the data read from the
* file descriptor when the operation has completed or an error occurs.
*
* The data object passed to the handler will be automatically released by the
* system when the handler returns. It is the responsibility of the application
* to retain, concatenate or copy the data object if it is needed after the
* handler returns.
*
* The data object passed to the handler will only contain as much data as is
* currently available from the file descriptor (up to the specified length).
*
* If an unrecoverable error occurs on the file descriptor, the handler will be
* enqueued with the appropriate error code along with a data object of any data
* that could be read successfully.
*
* An invocation of the handler with an error code of zero and an empty data
* object indicates that EOF was reached.
*
* The system takes control of the file descriptor until the handler is
* enqueued, and during this time file descriptor flags such as O_NONBLOCK will
* be modified by the system on behalf of the application. It is an error for
* the application to modify a file descriptor directly while it is under the
* control of the system, but it may create additional dispatch I/O convenience
* operations or dispatch I/O channels associated with that file descriptor.
*
* @param fd The file descriptor from which to read the data.
* @param length The length of data to read from the file descriptor,
* or SIZE_MAX to indicate that all of the data currently
* available from the file descriptor should be read.
* @param queue The dispatch queue to which the handler should be
* submitted.
* @param handler The handler to enqueue when data is ready to be
* delivered.
* param data The data read from the file descriptor.
* param error An errno condition for the read operation or
* zero if the read was successful.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
void
dispatch_read(dispatch_fd_t fd,
size_t length,
dispatch_queue_t queue,
void (^handler)(dispatch_data_t data, int error));
/*!
* @function dispatch_write
* Schedule a write operation for asynchronous execution on the specified file
* descriptor. The specified handler is enqueued when the operation has
* completed or an error occurs.
*
* If an unrecoverable error occurs on the file descriptor, the handler will be
* enqueued with the appropriate error code along with the data that could not
* be successfully written.
*
* An invocation of the handler with an error code of zero indicates that the
* data was fully written to the channel.
*
* The system takes control of the file descriptor until the handler is
* enqueued, and during this time file descriptor flags such as O_NONBLOCK will
* be modified by the system on behalf of the application. It is an error for
* the application to modify a file descriptor directly while it is under the
* control of the system, but it may create additional dispatch I/O convenience
* operations or dispatch I/O channels associated with that file descriptor.
*
* @param fd The file descriptor to which to write the data.
* @param data The data object to write to the file descriptor.
* @param queue The dispatch queue to which the handler should be
* submitted.
* @param handler The handler to enqueue when the data has been written.
* param data The data that could not be written to the I/O
* channel, or NULL.
* param error An errno condition for the write operation or
* zero if the write was successful.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NONNULL4
DISPATCH_NOTHROW
void
dispatch_write(dispatch_fd_t fd,
dispatch_data_t data,
dispatch_queue_t queue,
void (^handler)(dispatch_data_t _Nullable data, int error));
#endif /* __BLOCKS__ */
/*!
* @functiongroup Dispatch I/O Channel API
*/
/*!
* @typedef dispatch_io_t
* A dispatch I/O channel represents the asynchronous I/O policy applied to a
* file descriptor. I/O channels are first class dispatch objects and may be
* retained and released, suspended and resumed, etc.
*/
DISPATCH_DECL(dispatch_io);
/*!
* @typedef dispatch_io_type_t
* The type of a dispatch I/O channel:
*
* @const DISPATCH_IO_STREAM A dispatch I/O channel representing a stream of
* bytes. Read and write operations on a channel of this type are performed
* serially (in order of creation) and read/write data at the file pointer
* position that is current at the time the operation starts executing.
* Operations of different type (read vs. write) may be performed simultaneously.
* Offsets passed to operations on a channel of this type are ignored.
*
* @const DISPATCH_IO_RANDOM A dispatch I/O channel representing a random
* access file. Read and write operations on a channel of this type may be
* performed concurrently and read/write data at the specified offset. Offsets
* are interpreted relative to the file pointer position current at the time the
* I/O channel is created. Attempting to create a channel of this type for a
* file descriptor that is not seekable will result in an error.
*/
#define DISPATCH_IO_STREAM 0
#define DISPATCH_IO_RANDOM 1
typedef unsigned long dispatch_io_type_t;
#ifdef __BLOCKS__
/*!
* @function dispatch_io_create
* Create a dispatch I/O channel associated with a file descriptor. The system
* takes control of the file descriptor until the channel is closed, an error
* occurs on the file descriptor or all references to the channel are released.
* At that time the specified cleanup handler will be enqueued and control over
* the file descriptor relinquished.
*
* While a file descriptor is under the control of a dispatch I/O channel, file
* descriptor flags such as O_NONBLOCK will be modified by the system on behalf
* of the application. It is an error for the application to modify a file
* descriptor directly while it is under the control of a dispatch I/O channel,
* but it may create additional channels associated with that file descriptor.
*
* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
* or DISPATCH_IO_RANDOM).
* @param fd The file descriptor to associate with the I/O channel.
* @param queue The dispatch queue to which the handler should be submitted.
* @param cleanup_handler The handler to enqueue when the system
* relinquishes control over the file descriptor.
* param error An errno condition if control is relinquished
* because channel creation failed, zero otherwise.
* @result The newly created dispatch I/O channel or NULL if an error
* occurred (invalid type specified).
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
dispatch_io_t
dispatch_io_create(dispatch_io_type_t type,
dispatch_fd_t fd,
dispatch_queue_t queue,
void (^cleanup_handler)(int error));
/*!
* @function dispatch_io_create_with_path
* Create a dispatch I/O channel associated with a path name. The specified
* path, oflag and mode parameters will be passed to open(2) when the first I/O
* operation on the channel is ready to execute and the resulting file
* descriptor will remain open and under the control of the system until the
* channel is closed, an error occurs on the file descriptor or all references
* to the channel are released. At that time the file descriptor will be closed
* and the specified cleanup handler will be enqueued.
*
* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
* or DISPATCH_IO_RANDOM).
* @param path The absolute path to associate with the I/O channel.
* @param oflag The flags to pass to open(2) when opening the file at
* path.
* @param mode The mode to pass to open(2) when creating the file at
* path (i.e. with flag O_CREAT), zero otherwise.
* @param queue The dispatch queue to which the handler should be
* submitted.
* @param cleanup_handler The handler to enqueue when the system
* has closed the file at path.
* param error An errno condition if control is relinquished
* because channel creation or opening of the
* specified file failed, zero otherwise.
* @result The newly created dispatch I/O channel or NULL if an error
* occurred (invalid type or non-absolute path specified).
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_io_t
dispatch_io_create_with_path(dispatch_io_type_t type,
const char *path, int oflag, mode_t mode,
dispatch_queue_t queue,
void (^cleanup_handler)(int error));
/*!
* @function dispatch_io_create_with_io
* Create a new dispatch I/O channel from an existing dispatch I/O channel.
* The new channel inherits the file descriptor or path name associated with
* the existing channel, but not its channel type or policies.
*
* If the existing channel is associated with a file descriptor, control by the
* system over that file descriptor is extended until the new channel is also
* closed, an error occurs on the file descriptor, or all references to both
* channels are released. At that time the specified cleanup handler will be
* enqueued and control over the file descriptor relinquished.
*
* While a file descriptor is under the control of a dispatch I/O channel, file
* descriptor flags such as O_NONBLOCK will be modified by the system on behalf
* of the application. It is an error for the application to modify a file
* descriptor directly while it is under the control of a dispatch I/O channel,
* but it may create additional channels associated with that file descriptor.
*
* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
* or DISPATCH_IO_RANDOM).
* @param io The existing channel to create the new I/O channel from.
* @param queue The dispatch queue to which the handler should be submitted.
* @param cleanup_handler The handler to enqueue when the system
* relinquishes control over the file descriptor
* (resp. closes the file at path) associated with
* the existing channel.
* param error An errno condition if control is relinquished
* because channel creation failed, zero otherwise.
* @result The newly created dispatch I/O channel or NULL if an error
* occurred (invalid type specified).
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_io_t
dispatch_io_create_with_io(dispatch_io_type_t type,
dispatch_io_t io,
dispatch_queue_t queue,
void (^cleanup_handler)(int error));
/*!
* @typedef dispatch_io_handler_t
* The prototype of I/O handler blocks for dispatch I/O operations.
*
* @param done A flag indicating whether the operation is complete.
* @param data The data object to be handled.
* @param error An errno condition for the operation.
*/
typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t _Nullable data,
int error);
/*!
* @function dispatch_io_read
* Schedule a read operation for asynchronous execution on the specified I/O
* channel. The I/O handler is enqueued one or more times depending on the
* general load of the system and the policy specified on the I/O channel.
*
* Any data read from the channel is described by the dispatch data object
* passed to the I/O handler. This object will be automatically released by the
* system when the I/O handler returns. It is the responsibility of the
* application to retain, concatenate or copy the data object if it is needed
* after the I/O handler returns.
*
* Dispatch I/O handlers are not reentrant. The system will ensure that no new
* I/O handler instance is invoked until the previously enqueued handler block
* has returned.
*
* An invocation of the I/O handler with the done flag set indicates that the
* read operation is complete and that the handler will not be enqueued again.
*
* If an unrecoverable error occurs on the I/O channel's underlying file
* descriptor, the I/O handler will be enqueued with the done flag set, the
* appropriate error code and a NULL data object.
*
* An invocation of the I/O handler with the done flag set, an error code of
* zero and an empty data object indicates that EOF was reached.
*
* @param channel The dispatch I/O channel from which to read the data.
* @param offset The offset relative to the channel position from which
* to start reading (only for DISPATCH_IO_RANDOM).
* @param length The length of data to read from the I/O channel, or
* SIZE_MAX to indicate that data should be read until EOF
* is reached.
* @param queue The dispatch queue to which the I/O handler should be
* submitted.
* @param io_handler The I/O handler to enqueue when data is ready to be
* delivered.
* param done A flag indicating whether the operation is complete.
* param data An object with the data most recently read from the
* I/O channel as part of this read operation, or NULL.
* param error An errno condition for the read operation or zero if
* the read was successful.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL4 DISPATCH_NONNULL5
DISPATCH_NOTHROW
void
dispatch_io_read(dispatch_io_t channel,
off_t offset,
size_t length,
dispatch_queue_t queue,
dispatch_io_handler_t io_handler);
/*!
* @function dispatch_io_write
* Schedule a write operation for asynchronous execution on the specified I/O
* channel. The I/O handler is enqueued one or more times depending on the
* general load of the system and the policy specified on the I/O channel.
*
* Any data remaining to be written to the I/O channel is described by the
* dispatch data object passed to the I/O handler. This object will be
* automatically released by the system when the I/O handler returns. It is the
* responsibility of the application to retain, concatenate or copy the data
* object if it is needed after the I/O handler returns.
*
* Dispatch I/O handlers are not reentrant. The system will ensure that no new
* I/O handler instance is invoked until the previously enqueued handler block
* has returned.
*
* An invocation of the I/O handler with the done flag set indicates that the
* write operation is complete and that the handler will not be enqueued again.
*
* If an unrecoverable error occurs on the I/O channel's underlying file
* descriptor, the I/O handler will be enqueued with the done flag set, the
* appropriate error code and an object containing the data that could not be
* written.
*
* An invocation of the I/O handler with the done flag set and an error code of
* zero indicates that the data was fully written to the channel.
*
* @param channel The dispatch I/O channel on which to write the data.
* @param offset The offset relative to the channel position from which
* to start writing (only for DISPATCH_IO_RANDOM).
* @param data The data to write to the I/O channel. The data object
* will be retained by the system until the write operation
* is complete.
* @param queue The dispatch queue to which the I/O handler should be
* submitted.
* @param io_handler The I/O handler to enqueue when data has been delivered.
* param done A flag indicating whether the operation is complete.
* param data An object of the data remaining to be
* written to the I/O channel as part of this write
* operation, or NULL.
* param error An errno condition for the write operation or zero
* if the write was successful.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NONNULL4
DISPATCH_NONNULL5 DISPATCH_NOTHROW
void
dispatch_io_write(dispatch_io_t channel,
off_t offset,
dispatch_data_t data,
dispatch_queue_t queue,
dispatch_io_handler_t io_handler);
#endif /* __BLOCKS__ */
/*!
* @typedef dispatch_io_close_flags_t
* The type of flags you can set on a dispatch_io_close() call
*
* @const DISPATCH_IO_STOP Stop outstanding operations on a channel when
* the channel is closed.
*/
#define DISPATCH_IO_STOP 0x1
typedef unsigned long dispatch_io_close_flags_t;
/*!
* @function dispatch_io_close
* Close the specified I/O channel to new read or write operations; scheduling
* operations on a closed channel results in their handler returning an error.
*
* If the DISPATCH_IO_STOP flag is provided, the system will make a best effort
* to interrupt any outstanding read and write operations on the I/O channel,
* otherwise those operations will run to completion normally.
* Partial results of read and write operations may be returned even after a
* channel is closed with the DISPATCH_IO_STOP flag.
* The final invocation of an I/O handler of an interrupted operation will be
* passed an ECANCELED error code, as will the I/O handler of an operation
* scheduled on a closed channel.
*
* @param channel The dispatch I/O channel to close.
* @param flags The flags for the close operation.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_io_close(dispatch_io_t channel, dispatch_io_close_flags_t flags);
#ifdef __BLOCKS__
/*!
* @function dispatch_io_barrier
* Schedule a barrier operation on the specified I/O channel; all previously
* scheduled operations on the channel will complete before the provided
* barrier block is enqueued onto the global queue determined by the channel's
* target queue, and no subsequently scheduled operations will start until the
* barrier block has returned.
*
* If multiple channels are associated with the same file descriptor, a barrier
* operation scheduled on any of these channels will act as a barrier across all
* channels in question, i.e. all previously scheduled operations on any of the
* channels will complete before the barrier block is enqueued, and no
* operations subsequently scheduled on any of the channels will start until the
* barrier block has returned.
*
* While the barrier block is running, it may safely operate on the channel's
* underlying file descriptor with fsync(2), lseek(2) etc. (but not close(2)).
*
* @param channel The dispatch I/O channel to schedule the barrier on.
* @param barrier The barrier block.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_io_barrier(dispatch_io_t channel, dispatch_block_t barrier);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_io_get_descriptor
* Returns the file descriptor underlying a dispatch I/O channel.
*
* Will return -1 for a channel closed with dispatch_io_close() and for a
* channel associated with a path name that has not yet been open(2)ed.
*
* If called from a barrier block scheduled on a channel associated with a path
* name that has not yet been open(2)ed, this will trigger the channel open(2)
* operation and return the resulting file descriptor.
*
* @param channel The dispatch I/O channel to query.
* @result The file descriptor underlying the channel, or -1.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_fd_t
dispatch_io_get_descriptor(dispatch_io_t channel);
/*!
* @function dispatch_io_set_high_water
* Set a high water mark on the I/O channel for all operations.
*
* The system will make a best effort to enqueue I/O handlers with partial
* results as soon the number of bytes processed by an operation (i.e. read or
* written) reaches the high water mark.
*
* The size of data objects passed to I/O handlers for this channel will never
* exceed the specified high water mark.
*
* The default value for the high water mark is unlimited (i.e. SIZE_MAX).
*
* @param channel The dispatch I/O channel on which to set the policy.
* @param high_water The number of bytes to use as a high water mark.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_io_set_high_water(dispatch_io_t channel, size_t high_water);
/*!
* @function dispatch_io_set_low_water
* Set a low water mark on the I/O channel for all operations.
*
* The system will process (i.e. read or write) at least the low water mark
* number of bytes for an operation before enqueueing I/O handlers with partial
* results.
*
* The size of data objects passed to intermediate I/O handler invocations for
* this channel (i.e. excluding the final invocation) will never be smaller than
* the specified low water mark, except if the channel has an interval with the
* DISPATCH_IO_STRICT_INTERVAL flag set or if EOF or an error was encountered.
*
* I/O handlers should be prepared to receive amounts of data significantly
* larger than the low water mark in general. If an I/O handler requires
* intermediate results of fixed size, set both the low and and the high water
* mark to that size.
*
* The default value for the low water mark is unspecified, but must be assumed
* to be such that intermediate handler invocations may occur.
* If I/O handler invocations with partial results are not desired, set the
* low water mark to SIZE_MAX.
*
* @param channel The dispatch I/O channel on which to set the policy.
* @param low_water The number of bytes to use as a low water mark.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_io_set_low_water(dispatch_io_t channel, size_t low_water);
/*!
* @typedef dispatch_io_interval_flags_t
* Type of flags to set on dispatch_io_set_interval()
*
* @const DISPATCH_IO_STRICT_INTERVAL Enqueue I/O handlers at a channel's
* interval setting even if the amount of data ready to be delivered is inferior
* to the low water mark (or zero).
*/
#define DISPATCH_IO_STRICT_INTERVAL 0x1
typedef unsigned long dispatch_io_interval_flags_t;
/*!
* @function dispatch_io_set_interval
* Set a nanosecond interval at which I/O handlers are to be enqueued on the
* I/O channel for all operations.
*
* This allows an application to receive periodic feedback on the progress of
* read and write operations, e.g. for the purposes of displaying progress bars.
*
* If the amount of data ready to be delivered to an I/O handler at the interval
* is inferior to the channel low water mark, the handler will only be enqueued
* if the DISPATCH_IO_STRICT_INTERVAL flag is set.
*
* Note that the system may defer enqueueing interval I/O handlers by a small
* unspecified amount of leeway in order to align with other system activity for
* improved system performance or power consumption.
*
* @param channel The dispatch I/O channel on which to set the policy.
* @param interval The interval in nanoseconds at which delivery of the I/O
* handler is desired.
* @param flags Flags indicating desired data delivery behavior at
* interval time.
*/
API_AVAILABLE(macos(10.7), ios(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_io_set_interval(dispatch_io_t channel,
uint64_t interval,
dispatch_io_interval_flags_t flags);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif /* __DISPATCH_IO__ */

View File

@@ -0,0 +1,606 @@
/*
* Copyright (c) 2008-2012 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_OBJECT__
#define __DISPATCH_OBJECT__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
#if __has_include(<sys/qos.h>)
#include <sys/qos.h>
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
/*!
* @typedef dispatch_object_t
*
* @abstract
* Abstract base type for all dispatch objects.
* The details of the type definition are language-specific.
*
* @discussion
* Dispatch objects are reference counted via calls to dispatch_retain() and
* dispatch_release().
*/
#if OS_OBJECT_USE_OBJC
/*
* By default, dispatch objects are declared as Objective-C types when building
* with an Objective-C compiler. This allows them to participate in ARC, in RR
* management by the Blocks runtime and in leaks checking by the static
* analyzer, and enables them to be added to Cocoa collections.
* See <os/object.h> for details.
*/
OS_OBJECT_DECL_CLASS(dispatch_object);
#if OS_OBJECT_SWIFT3
#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, dispatch_object)
#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, base)
#else // OS_OBJECT_SWIFT3
#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object)
#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS(name, base)
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
_dispatch_object_validate(dispatch_object_t object)
{
void *isa = *(void *volatile*)(OS_OBJECT_BRIDGE void*)object;
(void)isa;
}
#endif // OS_OBJECT_SWIFT3
#define DISPATCH_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object))
#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
#elif defined(__cplusplus) && !defined(__DISPATCH_BUILDING_DISPATCH__)
/*
* Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++
* aware of type compatibility.
*/
typedef struct dispatch_object_s {
private:
dispatch_object_s();
~dispatch_object_s();
dispatch_object_s(const dispatch_object_s &);
void operator=(const dispatch_object_s &);
} *dispatch_object_t;
#define DISPATCH_DECL(name) \
typedef struct name##_s : public dispatch_object_s {} *name##_t
#define DISPATCH_DECL_SUBCLASS(name, base) \
typedef struct name##_s : public base##_s {} *name##_t
#define DISPATCH_GLOBAL_OBJECT(type, object) (static_cast<type>(&(object)))
#define DISPATCH_RETURNS_RETAINED
#else /* Plain C */
typedef union {
struct _os_object_s *_os_obj;
struct dispatch_object_s *_do;
struct dispatch_queue_s *_dq;
struct dispatch_queue_attr_s *_dqa;
struct dispatch_group_s *_dg;
struct dispatch_source_s *_ds;
struct dispatch_channel_s *_dch;
struct dispatch_mach_s *_dm;
struct dispatch_mach_msg_s *_dmsg;
struct dispatch_semaphore_s *_dsema;
struct dispatch_data_s *_ddata;
struct dispatch_io_s *_dchannel;
} dispatch_object_t DISPATCH_TRANSPARENT_UNION;
#define DISPATCH_DECL(name) typedef struct name##_s *name##_t
#define DISPATCH_DECL_SUBCLASS(name, base) typedef base##_t name##_t
#define DISPATCH_GLOBAL_OBJECT(type, object) ((type)&(object))
#define DISPATCH_RETURNS_RETAINED
#endif
#if OS_OBJECT_SWIFT3 && OS_OBJECT_USE_OBJC
#define DISPATCH_SOURCE_TYPE_DECL(name) \
DISPATCH_EXPORT struct dispatch_source_type_s \
_dispatch_source_type_##name; \
OS_OBJECT_DECL_PROTOCOL(dispatch_source_##name, <OS_dispatch_source>); \
OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL( \
dispatch_source, dispatch_source_##name)
#define DISPATCH_SOURCE_DECL(name) \
DISPATCH_DECL(name); \
OS_OBJECT_DECL_PROTOCOL(name, <NSObject>); \
OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, name)
#ifndef DISPATCH_DATA_DECL
#define DISPATCH_DATA_DECL(name) OS_OBJECT_DECL_SWIFT(name)
#endif // DISPATCH_DATA_DECL
#else
#define DISPATCH_SOURCE_DECL(name) \
DISPATCH_DECL(name);
#define DISPATCH_DATA_DECL(name) DISPATCH_DECL(name)
#define DISPATCH_SOURCE_TYPE_DECL(name) \
DISPATCH_EXPORT const struct dispatch_source_type_s \
_dispatch_source_type_##name
#endif
#ifdef __BLOCKS__
/*!
* @typedef dispatch_block_t
*
* @abstract
* The type of blocks submitted to dispatch queues, which take no arguments
* and have no return value.
*
* @discussion
* When not building with Objective-C ARC, a block object allocated on or
* copied to the heap must be released with a -[release] message or the
* Block_release() function.
*
* The declaration of a block literal allocates storage on the stack.
* Therefore, this is an invalid construct:
* <code>
* dispatch_block_t block;
* if (x) {
* block = ^{ printf("true\n"); };
* } else {
* block = ^{ printf("false\n"); };
* }
* block(); // unsafe!!!
* </code>
*
* What is happening behind the scenes:
* <code>
* if (x) {
* struct Block __tmp_1 = ...; // setup details
* block = &__tmp_1;
* } else {
* struct Block __tmp_2 = ...; // setup details
* block = &__tmp_2;
* }
* </code>
*
* As the example demonstrates, the address of a stack variable is escaping the
* scope in which it is allocated. That is a classic C bug.
*
* Instead, the block literal must be copied to the heap with the Block_copy()
* function or by sending it a -[copy] message.
*/
typedef void (^dispatch_block_t)(void);
#endif // __BLOCKS__
__BEGIN_DECLS
/*!
* @typedef dispatch_qos_class_t
* Alias for qos_class_t type.
*/
#if __has_include(<sys/qos.h>)
typedef qos_class_t dispatch_qos_class_t;
#else
typedef unsigned int dispatch_qos_class_t;
#endif
/*!
* @function dispatch_retain
*
* @abstract
* Increment the reference count of a dispatch object.
*
* @discussion
* Calls to dispatch_retain() must be balanced with calls to
* dispatch_release().
*
* @param object
* The object to retain.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC")
void
dispatch_retain(dispatch_object_t object);
#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
#undef dispatch_retain
#define dispatch_retain(object) \
__extension__({ dispatch_object_t _o = (object); \
_dispatch_object_validate(_o); (void)[_o retain]; })
#endif
/*!
* @function dispatch_release
*
* @abstract
* Decrement the reference count of a dispatch object.
*
* @discussion
* A dispatch object is asynchronously deallocated once all references are
* released (i.e. the reference count becomes zero). The system does not
* guarantee that a given client is the last or only reference to a given
* object.
*
* @param object
* The object to release.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC")
void
dispatch_release(dispatch_object_t object);
#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
#undef dispatch_release
#define dispatch_release(object) \
__extension__({ dispatch_object_t _o = (object); \
_dispatch_object_validate(_o); [_o release]; })
#endif
/*!
* @function dispatch_get_context
*
* @abstract
* Returns the application defined context of the object.
*
* @param object
* The result of passing NULL in this parameter is undefined.
*
* @result
* The context of the object; may be NULL.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_PURE DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
void *_Nullable
dispatch_get_context(dispatch_object_t object);
/*!
* @function dispatch_set_context
*
* @abstract
* Associates an application defined context with the object.
*
* @param object
* The result of passing NULL in this parameter is undefined.
*
* @param context
* The new client defined context for the object. This may be NULL.
*
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NOTHROW
void
dispatch_set_context(dispatch_object_t object, void *_Nullable context);
/*!
* @function dispatch_set_finalizer_f
*
* @abstract
* Set the finalizer function for a dispatch object.
*
* @param object
* The dispatch object to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param finalizer
* The finalizer function pointer.
*
* @discussion
* A dispatch object's finalizer will be invoked on the object's target queue
* after all references to the object have been released. This finalizer may be
* used by the application to release any resources associated with the object,
* such as freeing the object's context.
* The context parameter passed to the finalizer function is the current
* context of the dispatch object at the time the finalizer call is made.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NOTHROW
void
dispatch_set_finalizer_f(dispatch_object_t object,
dispatch_function_t _Nullable finalizer);
/*!
* @function dispatch_activate
*
* @abstract
* Activates the specified dispatch object.
*
* @discussion
* Dispatch objects such as queues and sources may be created in an inactive
* state. Objects in this state have to be activated before any blocks
* associated with them will be invoked.
*
* The target queue of inactive objects can be changed using
* dispatch_set_target_queue(). Change of target queue is no longer permitted
* once an initially inactive object has been activated.
*
* Calling dispatch_activate() on an active object has no effect.
* Releasing the last reference count on an inactive object is undefined.
*
* @param object
* The object to be activated.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_activate(dispatch_object_t object);
/*!
* @function dispatch_suspend
*
* @abstract
* Suspends the invocation of blocks on a dispatch object.
*
* @discussion
* A suspended object will not invoke any blocks associated with it. The
* suspension of an object will occur after any running block associated with
* the object completes.
*
* Calls to dispatch_suspend() must be balanced with calls
* to dispatch_resume().
*
* @param object
* The object to be suspended.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_suspend(dispatch_object_t object);
/*!
* @function dispatch_resume
*
* @abstract
* Resumes the invocation of blocks on a dispatch object.
*
* @discussion
* Dispatch objects can be suspended with dispatch_suspend(), which increments
* an internal suspension count. dispatch_resume() is the inverse operation,
* and consumes suspension counts. When the last suspension count is consumed,
* blocks associated with the object will be invoked again.
*
* For backward compatibility reasons, dispatch_resume() on an inactive and not
* otherwise suspended dispatch source object has the same effect as calling
* dispatch_activate(). For new code, using dispatch_activate() is preferred.
*
* If the specified object has zero suspension count and is not an inactive
* source, this function will result in an assertion and the process being
* terminated.
*
* @param object
* The object to be resumed.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_resume(dispatch_object_t object);
/*!
* @function dispatch_set_qos_class_floor
*
* @abstract
* Sets the QOS class floor on a dispatch queue, source or workloop.
*
* @discussion
* The QOS class of workitems submitted to this object asynchronously will be
* elevated to at least the specified QOS class floor. The QOS of the workitem
* will be used if higher than the floor even when the workitem has been created
* without "ENFORCE" semantics.
*
* Setting the QOS class floor is equivalent to the QOS effects of configuring
* a queue whose target queue has a QoS class set to the same value.
*
* @param object
* A dispatch queue, workloop, or source to configure.
* The object must be inactive.
*
* Passing another object type or an object that has been activated is undefined
* and will cause the process to be terminated.
*
* @param qos_class
* A QOS class value:
* - QOS_CLASS_USER_INTERACTIVE
* - QOS_CLASS_USER_INITIATED
* - QOS_CLASS_DEFAULT
* - QOS_CLASS_UTILITY
* - QOS_CLASS_BACKGROUND
* Passing any other value is undefined.
*
* @param relative_priority
* A relative priority within the QOS class. This value is a negative
* offset from the maximum supported scheduler priority for the given class.
* Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
* is undefined.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
DISPATCH_EXPORT DISPATCH_NOTHROW
void
dispatch_set_qos_class_floor(dispatch_object_t object,
dispatch_qos_class_t qos_class, int relative_priority);
#ifdef __BLOCKS__
/*!
* @function dispatch_wait
*
* @abstract
* Wait synchronously for an object or until the specified timeout has elapsed.
*
* @discussion
* Type-generic macro that maps to dispatch_block_wait, dispatch_group_wait or
* dispatch_semaphore_wait, depending on the type of the first argument.
* See documentation for these functions for more details.
* This function is unavailable for any other object type.
*
* @param object
* The object to wait on.
* The result of passing NULL in this parameter is undefined.
*
* @param timeout
* When to timeout (see dispatch_time). As a convenience, there are the
* DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
*
* @result
* Returns zero on success or non-zero on error (i.e. timed out).
*/
DISPATCH_UNAVAILABLE
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
intptr_t
dispatch_wait(void *object, dispatch_time_t timeout);
#if __has_extension(c_generic_selections)
#define dispatch_wait(object, timeout) \
_Generic((object), \
dispatch_block_t:dispatch_block_wait, \
dispatch_group_t:dispatch_group_wait, \
dispatch_semaphore_t:dispatch_semaphore_wait \
)((object),(timeout))
#endif
/*!
* @function dispatch_notify
*
* @abstract
* Schedule a notification block to be submitted to a queue when the execution
* of a specified object has completed.
*
* @discussion
* Type-generic macro that maps to dispatch_block_notify or
* dispatch_group_notify, depending on the type of the first argument.
* See documentation for these functions for more details.
* This function is unavailable for any other object type.
*
* @param object
* The object to observe.
* The result of passing NULL in this parameter is undefined.
*
* @param queue
* The queue to which the supplied notification block will be submitted when
* the observed object completes.
*
* @param notification_block
* The block to submit when the observed object completes.
*/
DISPATCH_UNAVAILABLE
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_notify(void *object, dispatch_object_t queue,
dispatch_block_t notification_block);
#if __has_extension(c_generic_selections)
#define dispatch_notify(object, queue, notification_block) \
_Generic((object), \
dispatch_block_t:dispatch_block_notify, \
dispatch_group_t:dispatch_group_notify \
)((object),(queue), (notification_block))
#endif
/*!
* @function dispatch_cancel
*
* @abstract
* Cancel the specified object.
*
* @discussion
* Type-generic macro that maps to dispatch_block_cancel or
* dispatch_source_cancel, depending on the type of the first argument.
* See documentation for these functions for more details.
* This function is unavailable for any other object type.
*
* @param object
* The object to cancel.
* The result of passing NULL in this parameter is undefined.
*/
DISPATCH_UNAVAILABLE
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_cancel(void *object);
#if __has_extension(c_generic_selections)
#define dispatch_cancel(object) \
_Generic((object), \
dispatch_block_t:dispatch_block_cancel, \
dispatch_source_t:dispatch_source_cancel \
)((object))
#endif
/*!
* @function dispatch_testcancel
*
* @abstract
* Test whether the specified object has been canceled
*
* @discussion
* Type-generic macro that maps to dispatch_block_testcancel or
* dispatch_source_testcancel, depending on the type of the first argument.
* See documentation for these functions for more details.
* This function is unavailable for any other object type.
*
* @param object
* The object to test.
* The result of passing NULL in this parameter is undefined.
*
* @result
* Non-zero if canceled and zero if not canceled.
*/
DISPATCH_UNAVAILABLE
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
DISPATCH_NOTHROW
intptr_t
dispatch_testcancel(void *object);
#if __has_extension(c_generic_selections)
#define dispatch_testcancel(object) \
_Generic((object), \
dispatch_block_t:dispatch_block_testcancel, \
dispatch_source_t:dispatch_source_testcancel \
)((object))
#endif
#endif // __BLOCKS__
/*!
* @function dispatch_debug
*
* @abstract
* Programmatically log debug information about a dispatch object.
*
* @discussion
* Programmatically log debug information about a dispatch object. By default,
* the log output is sent to syslog at notice level. In the debug version of
* the library, the log output is sent to a file in /var/tmp.
* The log output destination can be configured via the LIBDISPATCH_LOG
* environment variable, valid values are: YES, NO, syslog, stderr, file.
*
* This function is deprecated and will be removed in a future release.
* Objective-C callers may use -debugDescription instead.
*
* @param object
* The object to introspect.
*
* @param message
* The message to log above and beyond the introspection.
*/
API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD
__attribute__((__format__(printf,2,3)))
void
dispatch_debug(dispatch_object_t object, const char *message, ...);
API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0))
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD
__attribute__((__format__(printf,2,0)))
void
dispatch_debugv(dispatch_object_t object, const char *message, va_list ap);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 2008-2010 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_ONCE__
#define __DISPATCH_ONCE__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
__BEGIN_DECLS
/*!
* @typedef dispatch_once_t
*
* @abstract
* A predicate for use with dispatch_once(). It must be initialized to zero.
* Note: static and global variables default to zero.
*/
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
typedef intptr_t dispatch_once_t;
#if defined(__x86_64__) || defined(__i386__) || defined(__s390x__)
#define DISPATCH_ONCE_INLINE_FASTPATH 1
#elif defined(__APPLE__)
#define DISPATCH_ONCE_INLINE_FASTPATH 1
#else
#define DISPATCH_ONCE_INLINE_FASTPATH 0
#endif
/*!
* @function dispatch_once
*
* @abstract
* Execute a block once and only once.
*
* @param predicate
* A pointer to a dispatch_once_t that is used to test whether the block has
* completed or not.
*
* @param block
* The block to execute once.
*
* @discussion
* Always call dispatch_once() before using or testing any variables that are
* initialized by the block.
*/
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
void
dispatch_once(dispatch_once_t *predicate,
DISPATCH_NOESCAPE dispatch_block_t block);
#if DISPATCH_ONCE_INLINE_FASTPATH
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
void
_dispatch_once(dispatch_once_t *predicate,
DISPATCH_NOESCAPE dispatch_block_t block)
{
if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
dispatch_once(predicate, block);
} else {
dispatch_compiler_barrier();
}
DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l);
}
#undef dispatch_once
#define dispatch_once _dispatch_once
#endif
#endif // DISPATCH_ONCE_INLINE_FASTPATH
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
void
dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context,
dispatch_function_t function);
#if DISPATCH_ONCE_INLINE_FASTPATH
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL1 DISPATCH_NONNULL3
DISPATCH_NOTHROW
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
void
_dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context,
dispatch_function_t function)
{
if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
dispatch_once_f(predicate, context, function);
} else {
dispatch_compiler_barrier();
}
DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l);
}
#undef dispatch_once_f
#define dispatch_once_f _dispatch_once_f
#endif // DISPATCH_ONCE_INLINE_FASTPATH
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,117 @@
/*
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_SEMAPHORE__
#define __DISPATCH_SEMAPHORE__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
/*!
* @typedef dispatch_semaphore_t
*
* @abstract
* A counting semaphore.
*/
DISPATCH_DECL(dispatch_semaphore);
__BEGIN_DECLS
/*!
* @function dispatch_semaphore_create
*
* @abstract
* Creates new counting semaphore with an initial value.
*
* @discussion
* Passing zero for the value is useful for when two threads need to reconcile
* the completion of a particular event. Passing a value greater than zero is
* useful for managing a finite pool of resources, where the pool size is equal
* to the value.
*
* @param value
* The starting value for the semaphore. Passing a value less than zero will
* cause NULL to be returned.
*
* @result
* The newly created semaphore, or NULL on failure.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
dispatch_semaphore_t
dispatch_semaphore_create(intptr_t value);
/*!
* @function dispatch_semaphore_wait
*
* @abstract
* Wait (decrement) for a semaphore.
*
* @discussion
* Decrement the counting semaphore. If the resulting value is less than zero,
* this function waits for a signal to occur before returning.
*
* @param dsema
* The semaphore. The result of passing NULL in this parameter is undefined.
*
* @param timeout
* When to timeout (see dispatch_time). As a convenience, there are the
* DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.
*
* @result
* Returns zero on success, or non-zero if the timeout occurred.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
intptr_t
dispatch_semaphore_wait(dispatch_semaphore_t dsema, dispatch_time_t timeout);
/*!
* @function dispatch_semaphore_signal
*
* @abstract
* Signal (increment) a semaphore.
*
* @discussion
* Increment the counting semaphore. If the previous value was less than zero,
* this function wakes a waiting thread before returning.
*
* @param dsema The counting semaphore.
* The result of passing NULL in this parameter is undefined.
*
* @result
* This function returns non-zero if a thread is woken. Otherwise, zero is
* returned.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
intptr_t
dispatch_semaphore_signal(dispatch_semaphore_t dsema);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif /* __DISPATCH_SEMAPHORE__ */

View File

@@ -0,0 +1,780 @@
/*
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_SOURCE__
#define __DISPATCH_SOURCE__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
#if TARGET_OS_MAC
#include <mach/port.h>
#include <mach/message.h>
#endif
#if !defined(_WIN32)
#include <sys/signal.h>
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
/*!
* @header
* The dispatch framework provides a suite of interfaces for monitoring low-
* level system objects (file descriptors, Mach ports, signals, VFS nodes, etc.)
* for activity and automatically submitting event handler blocks to dispatch
* queues when such activity occurs.
*
* This suite of interfaces is known as the Dispatch Source API.
*/
/*!
* @typedef dispatch_source_t
*
* @abstract
* Dispatch sources are used to automatically submit event handler blocks to
* dispatch queues in response to external events.
*/
DISPATCH_SOURCE_DECL(dispatch_source);
__BEGIN_DECLS
/*!
* @typedef dispatch_source_type_t
*
* @abstract
* Constants of this type represent the class of low-level system object that
* is being monitored by the dispatch source. Constants of this type are
* passed as a parameter to dispatch_source_create() and determine how the
* handle argument is interpreted (i.e. as a file descriptor, mach port,
* signal number, process identifier, etc.), and how the mask argument is
* interpreted.
*/
typedef const struct dispatch_source_type_s *dispatch_source_type_t;
/*!
* @const DISPATCH_SOURCE_TYPE_DATA_ADD
* @discussion A dispatch source that coalesces data obtained via calls to
* dispatch_source_merge_data(). An ADD is used to coalesce the data.
* The handle is unused (pass zero for now).
* The mask is unused (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_DATA_ADD (&_dispatch_source_type_data_add)
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_SOURCE_TYPE_DECL(data_add);
/*!
* @const DISPATCH_SOURCE_TYPE_DATA_OR
* @discussion A dispatch source that coalesces data obtained via calls to
* dispatch_source_merge_data(). A bitwise OR is used to coalesce the data.
* The handle is unused (pass zero for now).
* The mask is unused (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_DATA_OR (&_dispatch_source_type_data_or)
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_SOURCE_TYPE_DECL(data_or);
/*!
* @const DISPATCH_SOURCE_TYPE_DATA_REPLACE
* @discussion A dispatch source that tracks data obtained via calls to
* dispatch_source_merge_data(). Newly obtained data values replace existing
* data values not yet delivered to the source handler
*
* A data value of zero will cause the source handler to not be invoked.
*
* The handle is unused (pass zero for now).
* The mask is unused (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_DATA_REPLACE (&_dispatch_source_type_data_replace)
API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
DISPATCH_SOURCE_TYPE_DECL(data_replace);
/*!
* @const DISPATCH_SOURCE_TYPE_MACH_SEND
* @discussion A dispatch source that monitors a Mach port for dead name
* notifications (send right no longer has any corresponding receive right).
* The handle is a Mach port with a send or send-once right (mach_port_t).
* The mask is a mask of desired events from dispatch_source_mach_send_flags_t.
*/
#define DISPATCH_SOURCE_TYPE_MACH_SEND (&_dispatch_source_type_mach_send)
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
DISPATCH_SOURCE_TYPE_DECL(mach_send);
/*!
* @const DISPATCH_SOURCE_TYPE_MACH_RECV
* @discussion A dispatch source that monitors a Mach port for pending messages.
* The handle is a Mach port with a receive right (mach_port_t).
* The mask is a mask of desired events from dispatch_source_mach_recv_flags_t,
* but no flags are currently defined (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_MACH_RECV (&_dispatch_source_type_mach_recv)
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
DISPATCH_SOURCE_TYPE_DECL(mach_recv);
/*!
* @const DISPATCH_SOURCE_TYPE_MEMORYPRESSURE
* @discussion A dispatch source that monitors the system for changes in
* memory pressure condition.
* The handle is unused (pass zero for now).
* The mask is a mask of desired events from
* dispatch_source_memorypressure_flags_t.
*/
#define DISPATCH_SOURCE_TYPE_MEMORYPRESSURE \
(&_dispatch_source_type_memorypressure)
API_AVAILABLE(macos(10.9), ios(8.0)) DISPATCH_LINUX_UNAVAILABLE()
DISPATCH_SOURCE_TYPE_DECL(memorypressure);
/*!
* @const DISPATCH_SOURCE_TYPE_PROC
* @discussion A dispatch source that monitors an external process for events
* defined by dispatch_source_proc_flags_t.
* The handle is a process identifier (pid_t).
* The mask is a mask of desired events from dispatch_source_proc_flags_t.
*/
#define DISPATCH_SOURCE_TYPE_PROC (&_dispatch_source_type_proc)
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
DISPATCH_SOURCE_TYPE_DECL(proc);
/*!
* @const DISPATCH_SOURCE_TYPE_READ
* @discussion A dispatch source that monitors a file descriptor for pending
* bytes available to be read.
* The handle is a file descriptor (int).
* The mask is unused (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read)
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_SOURCE_TYPE_DECL(read);
/*!
* @const DISPATCH_SOURCE_TYPE_SIGNAL
* @discussion A dispatch source that monitors the current process for signals.
* The handle is a signal number (int).
* The mask is unused (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_SIGNAL (&_dispatch_source_type_signal)
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_SOURCE_TYPE_DECL(signal);
/*!
* @const DISPATCH_SOURCE_TYPE_TIMER
* @discussion A dispatch source that submits the event handler block based
* on a timer.
* The handle is unused (pass zero for now).
* The mask specifies which flags from dispatch_source_timer_flags_t to apply.
*/
#define DISPATCH_SOURCE_TYPE_TIMER (&_dispatch_source_type_timer)
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_SOURCE_TYPE_DECL(timer);
/*!
* @const DISPATCH_SOURCE_TYPE_VNODE
* @discussion A dispatch source that monitors a file descriptor for events
* defined by dispatch_source_vnode_flags_t.
* The handle is a file descriptor (int).
* The mask is a mask of desired events from dispatch_source_vnode_flags_t.
*/
#define DISPATCH_SOURCE_TYPE_VNODE (&_dispatch_source_type_vnode)
API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE()
DISPATCH_SOURCE_TYPE_DECL(vnode);
/*!
* @const DISPATCH_SOURCE_TYPE_WRITE
* @discussion A dispatch source that monitors a file descriptor for available
* buffer space to write bytes.
* The handle is a file descriptor (int).
* The mask is unused (pass zero for now).
*/
#define DISPATCH_SOURCE_TYPE_WRITE (&_dispatch_source_type_write)
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_SOURCE_TYPE_DECL(write);
/*!
* @typedef dispatch_source_mach_send_flags_t
* Type of dispatch_source_mach_send flags
*
* @constant DISPATCH_MACH_SEND_DEAD
* The receive right corresponding to the given send right was destroyed.
*/
#define DISPATCH_MACH_SEND_DEAD 0x1
typedef unsigned long dispatch_source_mach_send_flags_t;
/*!
* @typedef dispatch_source_mach_recv_flags_t
* Type of dispatch_source_mach_recv flags
*/
typedef unsigned long dispatch_source_mach_recv_flags_t;
/*!
* @typedef dispatch_source_memorypressure_flags_t
* Type of dispatch_source_memorypressure flags
*
* @constant DISPATCH_MEMORYPRESSURE_NORMAL
* The system memory pressure condition has returned to normal.
*
* @constant DISPATCH_MEMORYPRESSURE_WARN
* The system memory pressure condition has changed to warning.
*
* @constant DISPATCH_MEMORYPRESSURE_CRITICAL
* The system memory pressure condition has changed to critical.
*
* @discussion
* Elevated memory pressure is a system-wide condition that applications
* registered for this source should react to by changing their future memory
* use behavior, e.g. by reducing cache sizes of newly initiated operations
* until memory pressure returns back to normal.
* NOTE: applications should NOT traverse and discard existing caches for past
* operations when the system memory pressure enters an elevated state, as that
* is likely to trigger VM operations that will further aggravate system memory
* pressure.
*/
#define DISPATCH_MEMORYPRESSURE_NORMAL 0x01
#define DISPATCH_MEMORYPRESSURE_WARN 0x02
#define DISPATCH_MEMORYPRESSURE_CRITICAL 0x04
typedef unsigned long dispatch_source_memorypressure_flags_t;
/*!
* @typedef dispatch_source_proc_flags_t
* Type of dispatch_source_proc flags
*
* @constant DISPATCH_PROC_EXIT
* The process has exited (perhaps cleanly, perhaps not).
*
* @constant DISPATCH_PROC_FORK
* The process has created one or more child processes.
*
* @constant DISPATCH_PROC_EXEC
* The process has become another executable image via
* exec*() or posix_spawn*().
*
* @constant DISPATCH_PROC_SIGNAL
* A Unix signal was delivered to the process.
*/
#define DISPATCH_PROC_EXIT 0x80000000
#define DISPATCH_PROC_FORK 0x40000000
#define DISPATCH_PROC_EXEC 0x20000000
#define DISPATCH_PROC_SIGNAL 0x08000000
typedef unsigned long dispatch_source_proc_flags_t;
/*!
* @typedef dispatch_source_vnode_flags_t
* Type of dispatch_source_vnode flags
*
* @constant DISPATCH_VNODE_DELETE
* The filesystem object was deleted from the namespace.
*
* @constant DISPATCH_VNODE_WRITE
* The filesystem object data changed.
*
* @constant DISPATCH_VNODE_EXTEND
* The filesystem object changed in size.
*
* @constant DISPATCH_VNODE_ATTRIB
* The filesystem object metadata changed.
*
* @constant DISPATCH_VNODE_LINK
* The filesystem object link count changed.
*
* @constant DISPATCH_VNODE_RENAME
* The filesystem object was renamed in the namespace.
*
* @constant DISPATCH_VNODE_REVOKE
* The filesystem object was revoked.
*
* @constant DISPATCH_VNODE_FUNLOCK
* The filesystem object was unlocked.
*/
#define DISPATCH_VNODE_DELETE 0x1
#define DISPATCH_VNODE_WRITE 0x2
#define DISPATCH_VNODE_EXTEND 0x4
#define DISPATCH_VNODE_ATTRIB 0x8
#define DISPATCH_VNODE_LINK 0x10
#define DISPATCH_VNODE_RENAME 0x20
#define DISPATCH_VNODE_REVOKE 0x40
#define DISPATCH_VNODE_FUNLOCK 0x100
typedef unsigned long dispatch_source_vnode_flags_t;
/*!
* @typedef dispatch_source_timer_flags_t
* Type of dispatch_source_timer flags
*
* @constant DISPATCH_TIMER_STRICT
* Specifies that the system should make a best effort to strictly observe the
* leeway value specified for the timer via dispatch_source_set_timer(), even
* if that value is smaller than the default leeway value that would be applied
* to the timer otherwise. A minimal amount of leeway will be applied to the
* timer even if this flag is specified.
*
* CAUTION: Use of this flag may override power-saving techniques employed by
* the system and cause higher power consumption, so it must be used with care
* and only when absolutely necessary.
*/
#define DISPATCH_TIMER_STRICT 0x1
typedef unsigned long dispatch_source_timer_flags_t;
/*!
* @function dispatch_source_create
*
* @abstract
* Creates a new dispatch source to monitor low-level system objects and auto-
* matically submit a handler block to a dispatch queue in response to events.
*
* @discussion
* Dispatch sources are not reentrant. Any events received while the dispatch
* source is suspended or while the event handler block is currently executing
* will be coalesced and delivered after the dispatch source is resumed or the
* event handler block has returned.
*
* Dispatch sources are created in an inactive state. After creating the
* source and setting any desired attributes (i.e. the handler, context, etc.),
* a call must be made to dispatch_activate() in order to begin event delivery.
*
* Calling dispatch_set_target_queue() on a source once it has been activated
* is not allowed (see dispatch_activate() and dispatch_set_target_queue()).
*
* For backward compatibility reasons, dispatch_resume() on an inactive,
* and not otherwise suspended source has the same effect as calling
* dispatch_activate(). For new code, using dispatch_activate() is preferred.
*
* @param type
* Declares the type of the dispatch source. Must be one of the defined
* dispatch_source_type_t constants.
*
* @param handle
* The underlying system handle to monitor. The interpretation of this argument
* is determined by the constant provided in the type parameter.
*
* @param mask
* A mask of flags specifying which events are desired. The interpretation of
* this argument is determined by the constant provided in the type parameter.
*
* @param queue
* The dispatch queue to which the event handler block will be submitted.
* If queue is DISPATCH_TARGET_QUEUE_DEFAULT, the source will submit the event
* handler block to the default priority global queue.
*
* @result
* The newly created dispatch source. Or NULL if invalid arguments are passed.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
dispatch_source_t
dispatch_source_create(dispatch_source_type_t type,
uintptr_t handle,
uintptr_t mask,
dispatch_queue_t _Nullable queue);
/*!
* @function dispatch_source_set_event_handler
*
* @abstract
* Sets the event handler block for the given dispatch source.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The event handler block to submit to the source's target queue.
*/
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_event_handler(dispatch_source_t source,
dispatch_block_t _Nullable handler);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_source_set_event_handler_f
*
* @abstract
* Sets the event handler function for the given dispatch source.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The event handler function to submit to the source's target queue.
* The context parameter passed to the event handler function is the context of
* the dispatch source current at the time the event handler was set.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_event_handler_f(dispatch_source_t source,
dispatch_function_t _Nullable handler);
/*!
* @function dispatch_source_set_cancel_handler
*
* @abstract
* Sets the cancellation handler block for the given dispatch source.
*
* @discussion
* The cancellation handler (if specified) will be submitted to the source's
* target queue in response to a call to dispatch_source_cancel() once the
* system has released all references to the source's underlying handle and
* the source's event handler block has returned.
*
* IMPORTANT:
* Source cancellation and a cancellation handler are required for file
* descriptor and mach port based sources in order to safely close the
* descriptor or destroy the port.
* Closing the descriptor or port before the cancellation handler is invoked may
* result in a race condition. If a new descriptor is allocated with the same
* value as the recently closed descriptor while the source's event handler is
* still running, the event handler may read/write data to the wrong descriptor.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The cancellation handler block to submit to the source's target queue.
*/
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_cancel_handler(dispatch_source_t source,
dispatch_block_t _Nullable handler);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_source_set_cancel_handler_f
*
* @abstract
* Sets the cancellation handler function for the given dispatch source.
*
* @discussion
* See dispatch_source_set_cancel_handler() for more details.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The cancellation handler function to submit to the source's target queue.
* The context parameter passed to the event handler function is the current
* context of the dispatch source at the time the handler call is made.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_cancel_handler_f(dispatch_source_t source,
dispatch_function_t _Nullable handler);
/*!
* @function dispatch_source_cancel
*
* @abstract
* Asynchronously cancel the dispatch source, preventing any further invocation
* of its event handler block.
*
* @discussion
* Cancellation prevents any further invocation of the event handler block for
* the specified dispatch source, but does not interrupt an event handler
* block that is already in progress.
*
* The cancellation handler is submitted to the source's target queue once the
* the source's event handler has finished, indicating it is now safe to close
* the source's handle (i.e. file descriptor or mach port).
*
* See dispatch_source_set_cancel_handler() for more information.
*
* @param source
* The dispatch source to be canceled.
* The result of passing NULL in this parameter is undefined.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_source_cancel(dispatch_source_t source);
/*!
* @function dispatch_source_testcancel
*
* @abstract
* Tests whether the given dispatch source has been canceled.
*
* @param source
* The dispatch source to be tested.
* The result of passing NULL in this parameter is undefined.
*
* @result
* Non-zero if canceled and zero if not canceled.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
DISPATCH_NOTHROW
intptr_t
dispatch_source_testcancel(dispatch_source_t source);
/*!
* @function dispatch_source_get_handle
*
* @abstract
* Returns the underlying system handle associated with this dispatch source.
*
* @param source
* The result of passing NULL in this parameter is undefined.
*
* @result
* The return value should be interpreted according to the type of the dispatch
* source, and may be one of the following handles:
*
* DISPATCH_SOURCE_TYPE_DATA_ADD: n/a
* DISPATCH_SOURCE_TYPE_DATA_OR: n/a
* DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a
* DISPATCH_SOURCE_TYPE_MACH_SEND: mach port (mach_port_t)
* DISPATCH_SOURCE_TYPE_MACH_RECV: mach port (mach_port_t)
* DISPATCH_SOURCE_TYPE_MEMORYPRESSURE n/a
* DISPATCH_SOURCE_TYPE_PROC: process identifier (pid_t)
* DISPATCH_SOURCE_TYPE_READ: file descriptor (int)
* DISPATCH_SOURCE_TYPE_SIGNAL: signal number (int)
* DISPATCH_SOURCE_TYPE_TIMER: n/a
* DISPATCH_SOURCE_TYPE_VNODE: file descriptor (int)
* DISPATCH_SOURCE_TYPE_WRITE: file descriptor (int)
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
DISPATCH_NOTHROW
uintptr_t
dispatch_source_get_handle(dispatch_source_t source);
/*!
* @function dispatch_source_get_mask
*
* @abstract
* Returns the mask of events monitored by the dispatch source.
*
* @param source
* The result of passing NULL in this parameter is undefined.
*
* @result
* The return value should be interpreted according to the type of the dispatch
* source, and may be one of the following flag sets:
*
* DISPATCH_SOURCE_TYPE_DATA_ADD: n/a
* DISPATCH_SOURCE_TYPE_DATA_OR: n/a
* DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a
* DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t
* DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t
* DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t
* DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t
* DISPATCH_SOURCE_TYPE_READ: n/a
* DISPATCH_SOURCE_TYPE_SIGNAL: n/a
* DISPATCH_SOURCE_TYPE_TIMER: dispatch_source_timer_flags_t
* DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t
* DISPATCH_SOURCE_TYPE_WRITE: n/a
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
DISPATCH_NOTHROW
uintptr_t
dispatch_source_get_mask(dispatch_source_t source);
/*!
* @function dispatch_source_get_data
*
* @abstract
* Returns pending data for the dispatch source.
*
* @discussion
* This function is intended to be called from within the event handler block.
* The result of calling this function outside of the event handler callback is
* undefined.
*
* @param source
* The result of passing NULL in this parameter is undefined.
*
* @result
* The return value should be interpreted according to the type of the dispatch
* source, and may be one of the following:
*
* DISPATCH_SOURCE_TYPE_DATA_ADD: application defined data
* DISPATCH_SOURCE_TYPE_DATA_OR: application defined data
* DISPATCH_SOURCE_TYPE_DATA_REPLACE: application defined data
* DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t
* DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t
* DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t
* DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t
* DISPATCH_SOURCE_TYPE_READ: estimated bytes available to read
* DISPATCH_SOURCE_TYPE_SIGNAL: number of signals delivered since
* the last handler invocation
* DISPATCH_SOURCE_TYPE_TIMER: number of times the timer has fired
* since the last handler invocation
* DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t
* DISPATCH_SOURCE_TYPE_WRITE: estimated buffer space available
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE
DISPATCH_NOTHROW
uintptr_t
dispatch_source_get_data(dispatch_source_t source);
/*!
* @function dispatch_source_merge_data
*
* @abstract
* Merges data into a dispatch source of type DISPATCH_SOURCE_TYPE_DATA_ADD,
* DISPATCH_SOURCE_TYPE_DATA_OR or DISPATCH_SOURCE_TYPE_DATA_REPLACE,
* and submits its event handler block to its target queue.
*
* @param source
* The result of passing NULL in this parameter is undefined.
*
* @param value
* The value to coalesce with the pending data using a logical OR or an ADD
* as specified by the dispatch source type. A value of zero has no effect
* and will not result in the submission of the event handler block.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_source_merge_data(dispatch_source_t source, uintptr_t value);
/*!
* @function dispatch_source_set_timer
*
* @abstract
* Sets a start time, interval, and leeway value for a timer source.
*
* @discussion
* Once this function returns, any pending source data accumulated for the
* previous timer values has been cleared; the next fire of the timer will
* occur at 'start', and every 'interval' nanoseconds thereafter until the
* timer source is canceled.
*
* Any fire of the timer may be delayed by the system in order to improve power
* consumption and system performance. The upper limit to the allowable delay
* may be configured with the 'leeway' argument, the lower limit is under the
* control of the system.
*
* For the initial timer fire at 'start', the upper limit to the allowable
* delay is set to 'leeway' nanoseconds. For the subsequent timer fires at
* 'start' + N * 'interval', the upper limit is MIN('leeway','interval'/2).
*
* The lower limit to the allowable delay may vary with process state such as
* visibility of application UI. If the specified timer source was created with
* a mask of DISPATCH_TIMER_STRICT, the system will make a best effort to
* strictly observe the provided 'leeway' value even if it is smaller than the
* current lower limit. Note that a minimal amount of delay is to be expected
* even if this flag is specified.
*
* The 'start' argument also determines which clock will be used for the timer:
* If 'start' is DISPATCH_TIME_NOW or was created with dispatch_time(3), the
* timer is based on up time (which is obtained from mach_absolute_time() on
* Apple platforms). If 'start' was created with dispatch_walltime(3), the
* timer is based on gettimeofday(3).
*
* Calling this function has no effect if the timer source has already been
* canceled.
*
* @param start
* The start time of the timer. See dispatch_time() and dispatch_walltime()
* for more information.
*
* @param interval
* The nanosecond interval for the timer. Use DISPATCH_TIME_FOREVER for a
* one-shot timer.
*
* @param leeway
* The nanosecond leeway for the timer.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_source_set_timer(dispatch_source_t source,
dispatch_time_t start,
uint64_t interval,
uint64_t leeway);
/*!
* @function dispatch_source_set_registration_handler
*
* @abstract
* Sets the registration handler block for the given dispatch source.
*
* @discussion
* The registration handler (if specified) will be submitted to the source's
* target queue once the corresponding kevent() has been registered with the
* system, following the initial dispatch_resume() of the source.
*
* If a source is already registered when the registration handler is set, the
* registration handler will be invoked immediately.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The registration handler block to submit to the source's target queue.
*/
#ifdef __BLOCKS__
API_AVAILABLE(macos(10.7), ios(4.3))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_registration_handler(dispatch_source_t source,
dispatch_block_t _Nullable handler);
#endif /* __BLOCKS__ */
/*!
* @function dispatch_source_set_registration_handler_f
*
* @abstract
* Sets the registration handler function for the given dispatch source.
*
* @discussion
* See dispatch_source_set_registration_handler() for more details.
*
* @param source
* The dispatch source to modify.
* The result of passing NULL in this parameter is undefined.
*
* @param handler
* The registration handler function to submit to the source's target queue.
* The context parameter passed to the registration handler function is the
* current context of the dispatch source at the time the handler call is made.
*/
API_AVAILABLE(macos(10.7), ios(4.3))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
void
dispatch_source_set_registration_handler_f(dispatch_source_t source,
dispatch_function_t _Nullable handler);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,136 @@
/*
* Copyright (c) 2008-2011 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_TIME__
#define __DISPATCH_TIME__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
#include <stdint.h>
// <rdar://problem/6368156&7563559>
#if TARGET_OS_MAC
#include <mach/clock_types.h>
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
#ifdef NSEC_PER_SEC
#undef NSEC_PER_SEC
#endif
#ifdef USEC_PER_SEC
#undef USEC_PER_SEC
#endif
#ifdef NSEC_PER_USEC
#undef NSEC_PER_USEC
#endif
#ifdef NSEC_PER_MSEC
#undef NSEC_PER_MSEC
#endif
#define NSEC_PER_SEC 1000000000ull
#define NSEC_PER_MSEC 1000000ull
#define USEC_PER_SEC 1000000ull
#define NSEC_PER_USEC 1000ull
__BEGIN_DECLS
struct timespec;
/*!
* @typedef dispatch_time_t
*
* @abstract
* A somewhat abstract representation of time; where zero means "now" and
* DISPATCH_TIME_FOREVER means "infinity" and every value in between is an
* opaque encoding.
*/
typedef uint64_t dispatch_time_t;
enum {
DISPATCH_WALLTIME_NOW DISPATCH_ENUM_API_AVAILABLE
(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = ~1ull,
};
#define DISPATCH_TIME_NOW (0ull)
#define DISPATCH_TIME_FOREVER (~0ull)
/*!
* @function dispatch_time
*
* @abstract
* Create a dispatch_time_t relative to the current value of the default or
* wall time clock, or modify an existing dispatch_time_t.
*
* @discussion
* On Apple platforms, the default clock is based on mach_absolute_time().
*
* @param when
* An optional dispatch_time_t to add nanoseconds to. If DISPATCH_TIME_NOW is
* passed, then dispatch_time() will use the default clock (which is based on
* mach_absolute_time() on Apple platforms). If DISPATCH_WALLTIME_NOW is used,
* dispatch_time() will use the value returned by gettimeofday(3).
* dispatch_time(DISPATCH_WALLTIME_NOW, delta) is equivalent to
* dispatch_walltime(NULL, delta).
*
* @param delta
* Nanoseconds to add.
*
* @result
* A new dispatch_time_t.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_time_t
dispatch_time(dispatch_time_t when, int64_t delta);
/*!
* @function dispatch_walltime
*
* @abstract
* Create a dispatch_time_t using the wall clock.
*
* @discussion
* On Mac OS X the wall clock is based on gettimeofday(3).
*
* @param when
* A struct timespec to add time to. If NULL is passed, then
* dispatch_walltime() will use the result of gettimeofday(3).
* dispatch_walltime(NULL, delta) returns the same value as
* dispatch_time(DISPATCH_WALLTIME_NOW, delta).
*
* @param delta
* Nanoseconds to add.
*
* @result
* A new dispatch_time_t.
*/
API_AVAILABLE(macos(10.6), ios(4.0))
DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NOTHROW
dispatch_time_t
dispatch_walltime(const struct timespec *_Nullable when, int64_t delta);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,163 @@
/*
* Copyright (c) 2017-2019 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __DISPATCH_WORKLOOP__
#define __DISPATCH_WORKLOOP__
#ifndef __DISPATCH_INDIRECT__
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
#include <dispatch/base.h> // for HeaderDoc
#endif
DISPATCH_ASSUME_NONNULL_BEGIN
__BEGIN_DECLS
/*!
* @typedef dispatch_workloop_t
*
* @abstract
* Dispatch workloops invoke workitems submitted to them in priority order.
*
* @discussion
* A dispatch workloop is a flavor of dispatch_queue_t that is a priority
* ordered queue (using the QOS class of the submitted workitems as the
* ordering).
*
* Between each workitem invocation, the workloop will evaluate whether higher
* priority workitems have since been submitted, either directly to the
* workloop or to any queues that target the workloop, and execute these first.
*
* Serial queues targeting a workloop maintain FIFO execution of their
* workitems. However, the workloop may reorder workitems submitted to
* independent serial queues targeting it with respect to each other,
* based on their priorities, while preserving FIFO execution with respect to
* each serial queue.
*
* A dispatch workloop is a "subclass" of dispatch_queue_t which can be passed
* to all APIs accepting a dispatch queue, except for functions from the
* dispatch_sync() family. dispatch_async_and_wait() must be used for workloop
* objects. Functions from the dispatch_sync() family on queues targeting
* a workloop are still permitted but discouraged for performance reasons.
*/
DISPATCH_DECL_SUBCLASS(dispatch_workloop, dispatch_queue);
/*!
* @function dispatch_workloop_create
*
* @abstract
* Creates a new dispatch workloop to which workitems may be submitted.
*
* @param label
* A string label to attach to the workloop.
*
* @result
* The newly created dispatch workloop.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
dispatch_workloop_t
dispatch_workloop_create(const char *_Nullable label);
/*!
* @function dispatch_workloop_create_inactive
*
* @abstract
* Creates a new inactive dispatch workloop that can be setup and then
* activated.
*
* @discussion
* Creating an inactive workloop allows for it to receive further configuration
* before it is activated, and workitems can be submitted to it.
*
* Submitting workitems to an inactive workloop is undefined and will cause the
* process to be terminated.
*
* @param label
* A string label to attach to the workloop.
*
* @result
* The newly created dispatch workloop.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
DISPATCH_NOTHROW
dispatch_workloop_t
dispatch_workloop_create_inactive(const char *_Nullable label);
/*!
* @function dispatch_workloop_set_autorelease_frequency
*
* @abstract
* Sets the autorelease frequency of the workloop.
*
* @discussion
* See dispatch_queue_attr_make_with_autorelease_frequency().
* The default policy for a workloop is
* DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM.
*
* @param workloop
* The dispatch workloop to modify.
*
* This workloop must be inactive, passing an activated object is undefined
* and will cause the process to be terminated.
*
* @param frequency
* The requested autorelease frequency.
*/
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop,
dispatch_autorelease_frequency_t frequency);
/*!
* @function dispatch_workloop_set_os_workgroup
*
* @abstract
* Associates an os_workgroup_t with the specified dispatch workloop.
*
* The worker thread will be a member of the specified os_workgroup_t while executing
* work items submitted to the workloop.
*
* @param workloop
* The dispatch workloop to modify.
*
* This workloop must be inactive, passing an activated object is undefined
* and will cause the process to be terminated.
*
* @param workgroup
* The workgroup to associate with this workloop.
*
* The workgroup specified is retained and the previously associated workgroup
* (if any) is released.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop,
os_workgroup_t workgroup);
__END_DECLS
DISPATCH_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,818 @@
/*
* Copyright (c) 2000-2015 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __HFS_FORMAT__
#define __HFS_FORMAT__
#include <sys/types.h>
#include <sys/appleapiopts.h>
#include "hfs_unistr.h"
/*
* hfs_format.h
*
* This file describes the on-disk format for HFS and HFS Plus volumes.
*
* Note: Starting 10.9, definition of struct HFSUniStr255 exists in hfs_unitstr.h
*
*/
#ifdef __cplusplus
extern "C" {
#endif
/* some on-disk hfs structures have 68K alignment (misaligned) */
/* Signatures used to differentiate between HFS and HFS Plus volumes */
enum {
kHFSSigWord = 0x4244, /* 'BD' in ASCII */
kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */
kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */
};
#ifdef __APPLE_API_PRIVATE
/*
* Mac OS X has two special directories on HFS+ volumes for hardlinked files
* and hardlinked directories as well as for open-unlinked files.
*
* These directories and their contents are not exported from the filesystem
* under Mac OS X.
*/
#define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data"
#define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd"
/*
* Files in the "HFS+ Private Data" folder have one of the following prefixes
* followed by a decimal number (no leading zeros) for the file ID.
*
* Note: Earlier version of Mac OS X used a 32 bit random number for the link
* ref number instead of the file id.
*
* e.g. iNode7182000 and temp3296
*/
#define HFS_INODE_PREFIX "iNode"
#define HFS_DELETE_PREFIX "temp"
/*
* Files in the ".HFS+ Private Directory Data" folder have the following
* prefix followed by a decimal number (no leading zeros) for the file ID.
*
* e.g. dir_555
*/
#define HFS_DIRINODE_PREFIX "dir_"
/*
* Hardlink inodes save the head of the link chain in
* an extended attribute named FIRST_LINK_XATTR_NAME.
* The attribute data is the decimal value in ASCII
* of the cnid for the first link in the chain.
*
* This extended attribute is private (i.e. its not
* exported in the getxattr/listxattr POSIX APIs).
*/
#define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink"
#define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12)
/*
* The name space ID for generating an HFS volume UUID
*
* B3E20F39-F292-11D6-97A4-00306543ECAC
*/
#define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC"
#endif /* __APPLE_API_PRIVATE */
/*
* Indirect link files (hard links) have the following type/creator.
*/
enum {
kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
kHFSPlusCreator = 0x6866732B /* 'hfs+' */
};
/*
* File type and creator for symbolic links
*/
enum {
kSymLinkFileType = 0x736C6E6B, /* 'slnk' */
kSymLinkCreator = 0x72686170 /* 'rhap' */
};
enum {
kHFSMaxVolumeNameChars = 27,
kHFSMaxFileNameChars = 31,
kHFSPlusMaxFileNameChars = 255
};
/* Extent overflow file data structures */
/* HFS Extent key */
struct HFSExtentKey {
u_int8_t keyLength; /* length of key, excluding this field */
u_int8_t forkType; /* 0 = data fork, FF = resource fork */
u_int32_t fileID; /* file ID */
u_int16_t startBlock; /* first file allocation block number in this extent */
} __attribute__((aligned(2), packed));
typedef struct HFSExtentKey HFSExtentKey;
/* HFS Plus Extent key */
struct HFSPlusExtentKey {
u_int16_t keyLength; /* length of key, excluding this field */
u_int8_t forkType; /* 0 = data fork, FF = resource fork */
u_int8_t pad; /* make the other fields align on 32-bit boundary */
u_int32_t fileID; /* file ID */
u_int32_t startBlock; /* first file allocation block number in this extent */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusExtentKey HFSPlusExtentKey;
/* Number of extent descriptors per extent record */
enum {
kHFSExtentDensity = 3,
kHFSPlusExtentDensity = 8
};
/* HFS extent descriptor */
struct HFSExtentDescriptor {
u_int16_t startBlock; /* first allocation block */
u_int16_t blockCount; /* number of allocation blocks */
} __attribute__((aligned(2), packed));
typedef struct HFSExtentDescriptor HFSExtentDescriptor;
/* HFS Plus extent descriptor */
struct HFSPlusExtentDescriptor {
u_int32_t startBlock; /* first allocation block */
u_int32_t blockCount; /* number of allocation blocks */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
/* HFS extent record */
typedef HFSExtentDescriptor HFSExtentRecord[3];
/* HFS Plus extent record */
typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
/* Finder information */
struct FndrFileInfo {
u_int32_t fdType; /* file type */
u_int32_t fdCreator; /* file creator */
u_int16_t fdFlags; /* Finder flags */
struct {
int16_t v; /* file's location */
int16_t h;
} fdLocation;
int16_t opaque;
} __attribute__((aligned(2), packed));
typedef struct FndrFileInfo FndrFileInfo;
struct FndrDirInfo {
struct { /* folder's window rectangle */
int16_t top;
int16_t left;
int16_t bottom;
int16_t right;
} frRect;
unsigned short frFlags; /* Finder flags */
struct {
u_int16_t v; /* folder's location */
u_int16_t h;
} frLocation;
int16_t opaque;
} __attribute__((aligned(2), packed));
typedef struct FndrDirInfo FndrDirInfo;
struct FndrOpaqueInfo {
int8_t opaque[16];
} __attribute__((aligned(2), packed));
typedef struct FndrOpaqueInfo FndrOpaqueInfo;
struct FndrExtendedDirInfo {
u_int32_t document_id;
u_int32_t date_added;
u_int16_t extended_flags;
u_int16_t reserved3;
u_int32_t write_gen_counter;
} __attribute__((aligned(2), packed));
struct FndrExtendedFileInfo {
u_int32_t document_id;
u_int32_t date_added;
u_int16_t extended_flags;
u_int16_t reserved2;
u_int32_t write_gen_counter;
} __attribute__((aligned(2), packed));
/* HFS Plus Fork data info - 80 bytes */
struct HFSPlusForkData {
u_int64_t logicalSize; /* fork's logical size in bytes */
u_int32_t clumpSize; /* fork's clump size in bytes */
u_int32_t totalBlocks; /* total blocks used by this fork */
HFSPlusExtentRecord extents; /* initial set of extents */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusForkData HFSPlusForkData;
/* Mac OS X has 16 bytes worth of "BSD" info.
*
* Note: Mac OS 9 implementations and applications
* should preserve, but not change, this information.
*/
struct HFSPlusBSDInfo {
u_int32_t ownerID; /* user-id of owner or hard link chain previous link */
u_int32_t groupID; /* group-id of owner or hard link chain next link */
u_int8_t adminFlags; /* super-user changeable flags */
u_int8_t ownerFlags; /* owner changeable flags */
u_int16_t fileMode; /* file type and permission bits */
union {
u_int32_t iNodeNum; /* indirect node number (hard links only) */
u_int32_t linkCount; /* links that refer to this indirect node */
u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */
} special;
} __attribute__((aligned(2), packed));
typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
/*
* Hardlink "links" resolve to an inode
* and the actual uid/gid comes from that
* inode.
*
* We repurpose the links's uid/gid fields
* for the hardlink link chain. The chain
* consists of a doubly linked list of file
* ids.
*/
#define hl_firstLinkID reserved1 /* Valid only if HasLinkChain flag is set (indirect nodes only) */
#define hl_prevLinkID bsdInfo.ownerID /* Valid only if HasLinkChain flag is set */
#define hl_nextLinkID bsdInfo.groupID /* Valid only if HasLinkChain flag is set */
#define hl_linkReference bsdInfo.special.iNodeNum
#define hl_linkCount bsdInfo.special.linkCount
/* Catalog file data structures */
enum {
kHFSRootParentID = 1, /* Parent ID of the root folder */
kHFSRootFolderID = 2, /* Folder ID of the root folder */
kHFSExtentsFileID = 3, /* File ID of the extents file */
kHFSCatalogFileID = 4, /* File ID of the catalog file */
kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
kHFSAttributeDataFileID = 13, /* Used in Mac OS X runtime for extent based attributes */
/* kHFSAttributeDataFileID is never stored on disk. */
kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */
kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
kHFSFirstUserCatalogNodeID = 16
};
/* HFS catalog key */
struct HFSCatalogKey {
u_int8_t keyLength; /* key length (in bytes) */
u_int8_t reserved; /* reserved (set to zero) */
u_int32_t parentID; /* parent folder ID */
u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
} __attribute__((aligned(2), packed));
typedef struct HFSCatalogKey HFSCatalogKey;
/* HFS Plus catalog key */
struct HFSPlusCatalogKey {
u_int16_t keyLength; /* key length (in bytes) */
u_int32_t parentID; /* parent folder ID */
HFSUniStr255 nodeName; /* catalog node name */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
/* Catalog record types */
enum {
/* HFS Catalog Records */
kHFSFolderRecord = 0x0100, /* Folder record */
kHFSFileRecord = 0x0200, /* File record */
kHFSFolderThreadRecord = 0x0300, /* Folder thread record */
kHFSFileThreadRecord = 0x0400, /* File thread record */
/* HFS Plus Catalog Records */
kHFSPlusFolderRecord = 1, /* Folder record */
kHFSPlusFileRecord = 2, /* File record */
kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
kHFSPlusFileThreadRecord = 4 /* File thread record */
};
/* Catalog file record flags */
enum {
kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
kHFSFileLockedMask = 0x0001,
kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
kHFSThreadExistsMask = 0x0002,
kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
kHFSHasAttributesMask = 0x0004,
kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
kHFSHasSecurityMask = 0x0008,
kHFSHasFolderCountBit = 0x0004, /* only for HFSX, folder maintains a separate sub-folder count */
kHFSHasFolderCountMask = 0x0010, /* (sum of folder records and directory hard links) */
kHFSHasLinkChainBit = 0x0005, /* has hardlink chain (inode or link) */
kHFSHasLinkChainMask = 0x0020,
kHFSHasChildLinkBit = 0x0006, /* folder has a child that's a dir link */
kHFSHasChildLinkMask = 0x0040,
kHFSHasDateAddedBit = 0x0007, /* File/Folder has the date-added stored in the finder info. */
kHFSHasDateAddedMask = 0x0080,
kHFSFastDevPinnedBit = 0x0008, /* this file has been pinned to the fast-device by the hot-file code on cooperative fusion */
kHFSFastDevPinnedMask = 0x0100,
kHFSDoNotFastDevPinBit = 0x0009, /* this file can not be pinned to the fast-device */
kHFSDoNotFastDevPinMask = 0x0200,
kHFSFastDevCandidateBit = 0x000a, /* this item is a potential candidate for fast-dev pinning (as are any of its descendents */
kHFSFastDevCandidateMask = 0x0400,
kHFSAutoCandidateBit = 0x000b, /* this item was automatically marked as a fast-dev candidate by the kernel */
kHFSAutoCandidateMask = 0x0800
// There are only 4 flag bits remaining: 0x1000, 0x2000, 0x4000, 0x8000
};
/* HFS catalog folder record - 70 bytes */
struct HFSCatalogFolder {
int16_t recordType; /* == kHFSFolderRecord */
u_int16_t flags; /* folder flags */
u_int16_t valence; /* folder valence */
u_int32_t folderID; /* folder ID */
u_int32_t createDate; /* date and time of creation */
u_int32_t modifyDate; /* date and time of last modification */
u_int32_t backupDate; /* date and time of last backup */
FndrDirInfo userInfo; /* Finder information */
FndrOpaqueInfo finderInfo; /* additional Finder information */
u_int32_t reserved[4]; /* reserved - initialized as zero */
} __attribute__((aligned(2), packed));
typedef struct HFSCatalogFolder HFSCatalogFolder;
/* HFS Plus catalog folder record - 88 bytes */
struct HFSPlusCatalogFolder {
int16_t recordType; /* == kHFSPlusFolderRecord */
u_int16_t flags; /* file flags */
u_int32_t valence; /* folder's item count */
u_int32_t folderID; /* folder ID */
u_int32_t createDate; /* date and time of creation */
u_int32_t contentModDate; /* date and time of last content modification */
u_int32_t attributeModDate; /* date and time of last attribute modification */
u_int32_t accessDate; /* date and time of last access (MacOS X only) */
u_int32_t backupDate; /* date and time of last backup */
HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
FndrDirInfo userInfo; /* Finder information */
FndrOpaqueInfo finderInfo; /* additional Finder information */
u_int32_t textEncoding; /* hint for name conversions */
u_int32_t folderCount; /* number of enclosed folders, active when HasFolderCount is set */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
/* HFS catalog file record - 102 bytes */
struct HFSCatalogFile {
int16_t recordType; /* == kHFSFileRecord */
u_int8_t flags; /* file flags */
int8_t fileType; /* file type (unused ?) */
FndrFileInfo userInfo; /* Finder information */
u_int32_t fileID; /* file ID */
u_int16_t dataStartBlock; /* not used - set to zero */
int32_t dataLogicalSize; /* logical EOF of data fork */
int32_t dataPhysicalSize; /* physical EOF of data fork */
u_int16_t rsrcStartBlock; /* not used - set to zero */
int32_t rsrcLogicalSize; /* logical EOF of resource fork */
int32_t rsrcPhysicalSize; /* physical EOF of resource fork */
u_int32_t createDate; /* date and time of creation */
u_int32_t modifyDate; /* date and time of last modification */
u_int32_t backupDate; /* date and time of last backup */
FndrOpaqueInfo finderInfo; /* additional Finder information */
u_int16_t clumpSize; /* file clump size (not used) */
HFSExtentRecord dataExtents; /* first data fork extent record */
HFSExtentRecord rsrcExtents; /* first resource fork extent record */
u_int32_t reserved; /* reserved - initialized as zero */
} __attribute__((aligned(2), packed));
typedef struct HFSCatalogFile HFSCatalogFile;
/* HFS Plus catalog file record - 248 bytes */
struct HFSPlusCatalogFile {
int16_t recordType; /* == kHFSPlusFileRecord */
u_int16_t flags; /* file flags */
u_int32_t reserved1; /* reserved - initialized as zero */
u_int32_t fileID; /* file ID */
u_int32_t createDate; /* date and time of creation */
u_int32_t contentModDate; /* date and time of last content modification */
u_int32_t attributeModDate; /* date and time of last attribute modification */
u_int32_t accessDate; /* date and time of last access (MacOS X only) */
u_int32_t backupDate; /* date and time of last backup */
HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
FndrFileInfo userInfo; /* Finder information */
FndrOpaqueInfo finderInfo; /* additional Finder information */
u_int32_t textEncoding; /* hint for name conversions */
u_int32_t reserved2; /* reserved - initialized as zero */
/* Note: these start on double long (64 bit) boundary */
HFSPlusForkData dataFork; /* size and block data for data fork */
HFSPlusForkData resourceFork; /* size and block data for resource fork */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
/* HFS catalog thread record - 46 bytes */
struct HFSCatalogThread {
int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
int32_t reserved[2]; /* reserved - initialized as zero */
u_int32_t parentID; /* parent ID for this catalog node */
u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
} __attribute__((aligned(2), packed));
typedef struct HFSCatalogThread HFSCatalogThread;
/* HFS Plus catalog thread record -- 264 bytes */
struct HFSPlusCatalogThread {
int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
int16_t reserved; /* reserved - initialized as zero */
u_int32_t parentID; /* parent ID for this catalog node */
HFSUniStr255 nodeName; /* name of this catalog node (variable length) */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
#ifdef __APPLE_API_UNSTABLE
/*
* These are the types of records in the attribute B-tree. The values were
* chosen so that they wouldn't conflict with the catalog record types.
*/
enum {
kHFSPlusAttrInlineData = 0x10, /* attributes whose data fits in a b-tree node */
kHFSPlusAttrForkData = 0x20, /* extent based attributes (data lives in extents) */
kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
};
/*
* HFSPlusAttrForkData
* For larger attributes, whose value is stored in allocation blocks.
* If the attribute has more than 8 extents, there will be additional
* records (of type HFSPlusAttrExtents) for this attribute.
*/
struct HFSPlusAttrForkData {
u_int32_t recordType; /* == kHFSPlusAttrForkData*/
u_int32_t reserved;
HFSPlusForkData theFork; /* size and first extents of value*/
} __attribute__((aligned(2), packed));
typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
/*
* HFSPlusAttrExtents
* This record contains information about overflow extents for large,
* fragmented attributes.
*/
struct HFSPlusAttrExtents {
u_int32_t recordType; /* == kHFSPlusAttrExtents*/
u_int32_t reserved;
HFSPlusExtentRecord extents; /* additional extents*/
} __attribute__((aligned(2), packed));
typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
/*
* Atrributes B-tree Data Record
*
* For small attributes, whose entire value is stored
* within a single B-tree record.
*/
struct HFSPlusAttrData {
u_int32_t recordType; /* == kHFSPlusAttrInlineData */
u_int32_t reserved[2];
u_int32_t attrSize; /* size of attribute data in bytes */
u_int8_t attrData[2]; /* variable length */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusAttrData HFSPlusAttrData;
/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
struct HFSPlusAttrInlineData {
u_int32_t recordType;
u_int32_t reserved;
u_int32_t logicalSize;
u_int8_t userData[2];
} __attribute__((aligned(2), packed));
typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
/* A generic Attribute Record */
union HFSPlusAttrRecord {
u_int32_t recordType;
HFSPlusAttrInlineData inlineData; /* NOT USED */
HFSPlusAttrData attrData;
HFSPlusAttrForkData forkData;
HFSPlusAttrExtents overflowExtents;
};
typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
/* Attribute key */
enum { kHFSMaxAttrNameLen = 127 };
struct HFSPlusAttrKey {
u_int16_t keyLength; /* key length (in bytes) */
u_int16_t pad; /* set to zero */
u_int32_t fileID; /* file associated with attribute */
u_int32_t startBlock; /* first allocation block number for extents */
u_int16_t attrNameLen; /* number of unicode characters */
u_int16_t attrName[kHFSMaxAttrNameLen]; /* attribute name (Unicode) */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusAttrKey HFSPlusAttrKey;
#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t))
#endif /* __APPLE_API_UNSTABLE */
/* Key and node lengths */
enum {
kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t),
kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
kHFSPlusCatalogMinNodeSize = 4096,
kHFSPlusExtentMinNodeSize = 512,
kHFSPlusAttrMinNodeSize = 4096
};
/* HFS and HFS Plus volume attribute bits */
enum {
/* Bits 0-6 are reserved (always cleared by MountVol call) */
kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */
kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */
kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */
kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */
kHFSCatalogNodeIDsReusedBit = 12,
kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */
kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */
kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */
/*
* HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits.
* Therefore, bits 16-31 can only be used on HFS Plus.
*/
kHFSUnusedNodeFixBit = 31, /* Unused nodes in the Catalog B-tree have been zero-filled. See Radar #6947811. */
kHFSContentProtectionBit = 30, /* Volume has per-file content protection */
/*** Keep these in sync with the bits above ! ****/
kHFSVolumeHardwareLockMask = 0x00000080,
kHFSVolumeUnmountedMask = 0x00000100,
kHFSVolumeSparedBlocksMask = 0x00000200,
kHFSVolumeNoCacheRequiredMask = 0x00000400,
kHFSBootVolumeInconsistentMask = 0x00000800,
kHFSCatalogNodeIDsReusedMask = 0x00001000,
kHFSVolumeJournaledMask = 0x00002000,
kHFSVolumeInconsistentMask = 0x00004000,
kHFSVolumeSoftwareLockMask = 0x00008000,
/* Bits 16-31 are allocated from high to low */
kHFSContentProtectionMask = 0x40000000,
kHFSUnusedNodeFixMask = 0x80000000,
kHFSMDBAttributesMask = 0x8380
};
enum {
kHFSUnusedNodesFixDate = 0xc5ef2480 /* March 25, 2009 */
};
/* HFS Master Directory Block - 162 bytes */
/* Stored at sector #2 (3rd sector) and second-to-last sector. */
struct HFSMasterDirectoryBlock {
u_int16_t drSigWord; /* == kHFSSigWord */
u_int32_t drCrDate; /* date and time of volume creation */
u_int32_t drLsMod; /* date and time of last modification */
u_int16_t drAtrb; /* volume attributes */
u_int16_t drNmFls; /* number of files in root folder */
u_int16_t drVBMSt; /* first block of volume bitmap */
u_int16_t drAllocPtr; /* start of next allocation search */
u_int16_t drNmAlBlks; /* number of allocation blocks in volume */
u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */
u_int32_t drClpSiz; /* default clump size */
u_int16_t drAlBlSt; /* first allocation block in volume */
u_int32_t drNxtCNID; /* next unused catalog node ID */
u_int16_t drFreeBks; /* number of unused allocation blocks */
u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */
u_int32_t drVolBkUp; /* date and time of last backup */
u_int16_t drVSeqNum; /* volume backup sequence number */
u_int32_t drWrCnt; /* volume write count */
u_int32_t drXTClpSiz; /* clump size for extents overflow file */
u_int32_t drCTClpSiz; /* clump size for catalog file */
u_int16_t drNmRtDirs; /* number of directories in root folder */
u_int32_t drFilCnt; /* number of files in volume */
u_int32_t drDirCnt; /* number of directories in volume */
u_int32_t drFndrInfo[8]; /* information used by the Finder */
u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
u_int32_t drXTFlSize; /* size of extents overflow file */
HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */
u_int32_t drCTFlSize; /* size of catalog file */
HFSExtentRecord drCTExtRec; /* extent record for catalog file */
} __attribute__((aligned(2), packed));
typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
#ifdef __APPLE_API_UNSTABLE
#define SET_HFS_TEXT_ENCODING(hint) \
(0x656e6300 | ((hint) & 0xff))
#define GET_HFS_TEXT_ENCODING(hint) \
(((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
#endif /* __APPLE_API_UNSTABLE */
/* HFS Plus Volume Header - 512 bytes */
/* Stored at sector #2 (3rd sector) and second-to-last sector. */
struct HFSPlusVolumeHeader {
u_int16_t signature; /* == kHFSPlusSigWord */
u_int16_t version; /* == kHFSPlusVersion */
u_int32_t attributes; /* volume attributes */
u_int32_t lastMountedVersion; /* implementation version which last mounted volume */
u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */
u_int32_t createDate; /* date and time of volume creation */
u_int32_t modifyDate; /* date and time of last modification */
u_int32_t backupDate; /* date and time of last backup */
u_int32_t checkedDate; /* date and time of last disk check */
u_int32_t fileCount; /* number of files in volume */
u_int32_t folderCount; /* number of directories in volume */
u_int32_t blockSize; /* size (in bytes) of allocation blocks */
u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/
u_int32_t freeBlocks; /* number of unused allocation blocks */
u_int32_t nextAllocation; /* start of next allocation search */
u_int32_t rsrcClumpSize; /* default resource fork clump size */
u_int32_t dataClumpSize; /* default data fork clump size */
u_int32_t nextCatalogID; /* next unused catalog node ID */
u_int32_t writeCount; /* volume write count */
u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
u_int8_t finderInfo[32]; /* information used by the Finder */
HFSPlusForkData allocationFile; /* allocation bitmap file */
HFSPlusForkData extentsFile; /* extents B-tree file */
HFSPlusForkData catalogFile; /* catalog B-tree file */
HFSPlusForkData attributesFile; /* extended attributes B-tree file */
HFSPlusForkData startupFile; /* boot file (secondary loader) */
} __attribute__((aligned(2), packed));
typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
/* B-tree structures */
enum BTreeKeyLimits{
kMaxKeyLength = 520
};
union BTreeKey{
u_int8_t length8;
u_int16_t length16;
u_int8_t rawData [kMaxKeyLength+2];
};
typedef union BTreeKey BTreeKey;
/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
struct BTNodeDescriptor {
u_int32_t fLink; /* next node at this level*/
u_int32_t bLink; /* previous node at this level*/
int8_t kind; /* kind of node (leaf, index, header, map)*/
u_int8_t height; /* zero for header, map; child is one more than parent*/
u_int16_t numRecords; /* number of records in this node*/
u_int16_t reserved; /* reserved - initialized as zero */
} __attribute__((aligned(2), packed));
typedef struct BTNodeDescriptor BTNodeDescriptor;
/* Constants for BTNodeDescriptor kind */
enum {
kBTLeafNode = -1,
kBTIndexNode = 0,
kBTHeaderNode = 1,
kBTMapNode = 2
};
/* BTHeaderRec -- The first record of a B-tree header node */
struct BTHeaderRec {
u_int16_t treeDepth; /* maximum height (usually leaf nodes) */
u_int32_t rootNode; /* node number of root node */
u_int32_t leafRecords; /* number of leaf records in all leaf nodes */
u_int32_t firstLeafNode; /* node number of first leaf node */
u_int32_t lastLeafNode; /* node number of last leaf node */
u_int16_t nodeSize; /* size of a node, in bytes */
u_int16_t maxKeyLength; /* reserved */
u_int32_t totalNodes; /* total number of nodes in tree */
u_int32_t freeNodes; /* number of unused (free) nodes in tree */
u_int16_t reserved1; /* unused */
u_int32_t clumpSize; /* reserved */
u_int8_t btreeType; /* reserved */
u_int8_t keyCompareType; /* Key string Comparison Type */
u_int32_t attributes; /* persistent attributes about the tree */
u_int32_t reserved3[16]; /* reserved */
} __attribute__((aligned(2), packed));
typedef struct BTHeaderRec BTHeaderRec;
/* Constants for BTHeaderRec attributes */
enum {
kBTBadCloseMask = 0x00000001, /* reserved */
kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
};
/* Catalog Key Name Comparison Type */
enum {
kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */
kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */
};
#include <uuid/uuid.h>
/* JournalInfoBlock - Structure that describes where our journal lives */
// the original size of the reserved field in the JournalInfoBlock was
// 32*sizeof(u_int32_t). To keep the total size of the structure the
// same we subtract the size of new fields (currently: ext_jnl_uuid and
// machine_uuid). If you add additional fields, place them before the
// reserved field and subtract their size in this macro.
//
#define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48)
struct JournalInfoBlock {
u_int32_t flags;
u_int32_t device_signature[8]; // signature used to locate our device.
u_int64_t offset; // byte offset to the journal on the device
u_int64_t size; // size in bytes of the journal
uuid_string_t ext_jnl_uuid;
char machine_serial_num[48];
char reserved[JIB_RESERVED_SIZE];
} __attribute__((aligned(2), packed));
typedef struct JournalInfoBlock JournalInfoBlock;
enum {
kJIJournalInFSMask = 0x00000001,
kJIJournalOnOtherDeviceMask = 0x00000002,
kJIJournalNeedInitMask = 0x00000004
};
//
// This the content type uuid for "external journal" GPT
// partitions. Each instance of a partition also has a
// uuid that uniquely identifies that instance.
//
#define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC"
#ifdef __cplusplus
}
#endif
#endif /* __HFS_FORMAT__ */

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __HFS_UNISTR__
#define __HFS_UNISTR__
#include <sys/types.h>
/*
* hfs_unitstr.h
*
* This file contains definition of the unicode string used for HFS Plus
* files and folder names, as described by the on-disk format.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _HFSUNISTR255_DEFINED_
#define _HFSUNISTR255_DEFINED_
/* Unicode strings are used for HFS Plus file and folder names */
struct HFSUniStr255 {
u_int16_t length; /* number of unicode characters */
u_int16_t unicode[255]; /* unicode characters */
} __attribute__((aligned(2), packed));
typedef struct HFSUniStr255 HFSUniStr255;
typedef const HFSUniStr255 *ConstHFSUniStr255Param;
#endif /* _HFSUNISTR255_DEFINED_ */
#ifdef __cplusplus
}
#endif
#endif /* __HFS_UNISTR__ */

View File

@@ -37,10 +37,10 @@
* cast to any desired pointer type.
*/
#define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1)
#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
#define __DARWIN_ALIGN(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
#define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1)
#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
#endif /* _I386__PARAM_H_ */

View File

@@ -0,0 +1,409 @@
#ifndef __XPC_LAUNCH_H__
#define __XPC_LAUNCH_H__
/*!
* @header
* These interfaces were only ever documented for the purpose of allowing a
* launchd job to obtain file descriptors associated with the sockets it
* advertised in its launchd.plist(5). That functionality is now available in a
* much more straightforward fashion through the {@link launch_activate_socket}
* API.
*
* There are currently no replacements for other uses of the {@link launch_msg}
* API, including submitting, removing, starting, stopping and listing jobs.
*/
#include <os/base.h>
#include <Availability.h>
#include <mach/mach.h>
#include <stddef.h>
#include <stdbool.h>
#include <sys/cdefs.h>
#if __has_feature(assume_nonnull)
_Pragma("clang assume_nonnull begin")
#endif
__BEGIN_DECLS
#define LAUNCH_KEY_SUBMITJOB "SubmitJob"
#define LAUNCH_KEY_REMOVEJOB "RemoveJob"
#define LAUNCH_KEY_STARTJOB "StartJob"
#define LAUNCH_KEY_STOPJOB "StopJob"
#define LAUNCH_KEY_GETJOB "GetJob"
#define LAUNCH_KEY_GETJOBS "GetJobs"
#define LAUNCH_KEY_CHECKIN "CheckIn"
#define LAUNCH_JOBKEY_LABEL "Label"
#define LAUNCH_JOBKEY_DISABLED "Disabled"
#define LAUNCH_JOBKEY_USERNAME "UserName"
#define LAUNCH_JOBKEY_GROUPNAME "GroupName"
#define LAUNCH_JOBKEY_TIMEOUT "TimeOut"
#define LAUNCH_JOBKEY_EXITTIMEOUT "ExitTimeOut"
#define LAUNCH_JOBKEY_INITGROUPS "InitGroups"
#define LAUNCH_JOBKEY_SOCKETS "Sockets"
#define LAUNCH_JOBKEY_MACHSERVICES "MachServices"
#define LAUNCH_JOBKEY_MACHSERVICELOOKUPPOLICIES "MachServiceLookupPolicies"
#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility"
#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing"
#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments"
#define LAUNCH_JOBKEY_PROGRAM "Program"
#define LAUNCH_JOBKEY_ONDEMAND "OnDemand"
#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive"
#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts"
#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts"
#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType"
#define LAUNCH_JOBKEY_LIMITLOADTOHARDWARE "LimitLoadToHardware"
#define LAUNCH_JOBKEY_LIMITLOADFROMHARDWARE "LimitLoadFromHardware"
#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad"
#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory"
#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory"
#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables"
#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables"
#define LAUNCH_JOBKEY_UMASK "Umask"
#define LAUNCH_JOBKEY_NICE "Nice"
#define LAUNCH_JOBKEY_HOPEFULLYEXITSFIRST "HopefullyExitsFirst"
#define LAUNCH_JOBKEY_HOPEFULLYEXITSLAST "HopefullyExitsLast"
#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO"
#define LAUNCH_JOBKEY_LOWPRIORITYBACKGROUNDIO "LowPriorityBackgroundIO"
#define LAUNCH_JOBKEY_MATERIALIZEDATALESSFILES "MaterializeDatalessFiles"
#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate"
#define LAUNCH_JOBKEY_STARTONMOUNT "StartOnMount"
#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits"
#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits"
#define LAUNCH_JOBKEY_STANDARDINPATH "StandardInPath"
#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath"
#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath"
#define LAUNCH_JOBKEY_DEBUG "Debug"
#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger"
#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories"
#define LAUNCH_JOBKEY_HOMERELATIVEQUEUEDIRECTORIES "HomeRelativeQueueDirectories"
#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths"
#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval"
#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval"
#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs"
#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus"
#define LAUNCH_JOBKEY_PID "PID"
#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval"
#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce"
#define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup"
#define LAUNCH_JOBKEY_IGNOREPROCESSGROUPATSHUTDOWN \
"IgnoreProcessGroupAtShutdown"
#define LAUNCH_JOBKEY_LEGACYTIMERS "LegacyTimers"
#define LAUNCH_JOBKEY_ENABLEPRESSUREDEXIT "EnablePressuredExit"
#define LAUNCH_JOBKEY_ENABLETRANSACTIONS "EnableTransactions"
#define LAUNCH_JOBKEY_DRAINMESSAGESONFAILEDINIT "DrainMessagesOnFailedInit"
#define LAUNCH_JOBKEY_POLICIES "Policies"
#define LAUNCH_JOBKEY_PUBLISHESEVENTS "PublishesEvents"
#define LAUNCH_KEY_PUBLISHESEVENTS_DOMAININTERNAL "DomainInternal"
#define LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS "DenyCreatingOtherJobs"
#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait"
#define LAUNCH_JOBINETDCOMPATIBILITY_INSTANCES "Instances"
#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose"
#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn"
#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit"
#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState"
#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState"
#define LAUNCH_JOBKEY_KEEPALIVE_HOMERELATIVEPATHSTATE "HomeRelativePathState"
#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBACTIVE "OtherJobActive"
#define LAUNCH_JOBKEY_KEEPALIVE_OTHERJOBENABLED "OtherJobEnabled"
#define LAUNCH_JOBKEY_KEEPALIVE_AFTERINITIALDEMAND "AfterInitialDemand"
#define LAUNCH_JOBKEY_KEEPALIVE_CRASHED "Crashed"
#define LAUNCH_JOBKEY_LAUNCHEVENTS "LaunchEvents"
#define LAUNCH_JOBKEY_CAL_MINUTE "Minute"
#define LAUNCH_JOBKEY_CAL_HOUR "Hour"
#define LAUNCH_JOBKEY_CAL_DAY "Day"
#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday"
#define LAUNCH_JOBKEY_CAL_MONTH "Month"
#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core"
#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU"
#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data"
#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize"
#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock"
#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles"
#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses"
#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize"
#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack"
#define LAUNCH_JOBKEY_DISABLED_MACHINETYPE "MachineType"
#define LAUNCH_JOBKEY_DISABLED_MODELNAME "ModelName"
#define LAUNCH_JOBKEY_DATASTORES "Datastores"
#define LAUNCH_JOBKEY_DATASTORES_SIZELIMIT "SizeLimit"
#define LAUNCH_JOBSOCKETKEY_TYPE "SockType"
#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive"
#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour"
#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey"
#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName"
#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode"
#define LAUNCH_JOBSOCKETKEY_PATHOWNER "SockPathOwner"
#define LAUNCH_JOBSOCKETKEY_PATHGROUP "SockPathGroup"
#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName"
#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName"
#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily"
#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol"
#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup"
#define LAUNCH_JOBKEY_PROCESSTYPE "ProcessType"
#define LAUNCH_KEY_PROCESSTYPE_APP "App"
#define LAUNCH_KEY_PROCESSTYPE_STANDARD "Standard"
#define LAUNCH_KEY_PROCESSTYPE_BACKGROUND "Background"
#define LAUNCH_KEY_PROCESSTYPE_INTERACTIVE "Interactive"
#define LAUNCH_KEY_PROCESSTYPE_ADAPTIVE "Adaptive"
/*!
* @function launch_activate_socket
*
* @abstract
* Retrieves the file descriptors for sockets specified in the process'
* launchd.plist(5).
*
* @param name
* The name of the socket entry in the service's Sockets dictionary.
*
* @param fds
* On return, this parameter will be populated with an array of file
* descriptors. One socket can have many descriptors associated with it
* depending on the characteristics of the network interfaces on the system.
* The descriptors in this array are the results of calling getaddrinfo(3) with
* the parameters described in launchd.plist(5).
*
* The caller is responsible for calling free(3) on the returned pointer.
*
* @param cnt
* The number of file descriptor entries in the returned array.
*
* @result
* On success, zero is returned. Otherwise, an appropriate POSIX-domain is
* returned. Possible error codes are:
*
* ENOENT -> There was no socket of the specified name owned by the caller.
* ESRCH -> The caller is not a process managed by launchd.
* EALREADY -> The socket has already been activated by the caller.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
int
launch_activate_socket(const char *name,
int * _Nonnull * _Nullable fds, size_t *cnt);
typedef struct _launch_data *launch_data_t;
typedef void (*launch_data_dict_iterator_t)(const launch_data_t lval,
const char *key, void * _Nullable ctx);
typedef enum {
LAUNCH_DATA_DICTIONARY = 1,
LAUNCH_DATA_ARRAY,
LAUNCH_DATA_FD,
LAUNCH_DATA_INTEGER,
LAUNCH_DATA_REAL,
LAUNCH_DATA_BOOL,
LAUNCH_DATA_STRING,
LAUNCH_DATA_OPAQUE,
LAUNCH_DATA_ERRNO,
LAUNCH_DATA_MACHPORT,
} launch_data_type_t;
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_alloc(launch_data_type_t type);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT OS_NONNULL1
launch_data_t
launch_data_copy(launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
launch_data_type_t
launch_data_get_type(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
void
launch_data_free(launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1 OS_NONNULL2 OS_NONNULL3
bool
launch_data_dict_insert(launch_data_t ldict, const launch_data_t lval,
const char *key);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL2
launch_data_t _Nullable
launch_data_dict_lookup(const launch_data_t ldict, const char *key);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1 OS_NONNULL2
bool
launch_data_dict_remove(launch_data_t ldict, const char *key);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1 OS_NONNULL2
void
launch_data_dict_iterate(const launch_data_t ldict,
launch_data_dict_iterator_t iterator, void * _Nullable ctx);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
size_t
launch_data_dict_get_count(const launch_data_t ldict);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1 OS_NONNULL2
bool
launch_data_array_set_index(launch_data_t larray, const launch_data_t lval,
size_t idx);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
launch_data_t
launch_data_array_get_index(const launch_data_t larray, size_t idx);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
size_t
launch_data_array_get_count(const launch_data_t larray);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_fd(int fd);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_machport(mach_port_t val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_integer(long long val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_bool(bool val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_real(double val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_string(const char *val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT
launch_data_t
launch_data_new_opaque(const void *bytes, size_t sz);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_fd(launch_data_t ld, int fd);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_machport(launch_data_t ld, mach_port_t mp);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_integer(launch_data_t ld, long long val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_bool(launch_data_t ld, bool val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_real(launch_data_t ld, double val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_string(launch_data_t ld, const char *val);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_NONNULL1
bool
launch_data_set_opaque(launch_data_t ld, const void *bytes, size_t sz);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
int
launch_data_get_fd(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
mach_port_t
launch_data_get_machport(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
long long
launch_data_get_integer(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
bool
launch_data_get_bool(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
double
launch_data_get_real(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
const char *
launch_data_get_string(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
void *
launch_data_get_opaque(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
size_t
launch_data_get_opaque_size(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT OS_NONNULL1
int
launch_data_get_errno(const launch_data_t ld);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_WARN_RESULT
int
launch_get_fd(void);
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_2_0, __IPHONE_8_0)
OS_EXPORT OS_MALLOC OS_WARN_RESULT OS_NONNULL1
launch_data_t
launch_msg(const launch_data_t request);
__END_DECLS
#if __has_feature(assume_nonnull)
_Pragma("clang assume_nonnull end")
#endif
#endif // __XPC_LAUNCH_H__

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2020 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _DER_ITEM_H_
#define _DER_ITEM_H_
#if __has_include(<security_libDER/libDER/libDER_config.h>)
#include <security_libDER/libDER/libDER_config.h>
#else
#include <libDER/libDER_config.h>
#endif
__BEGIN_DECLS
/*
* Primary representation of a block of memory.
*/
typedef struct {
DERByte *data;
DERSize length;
} DERItem;
__END_DECLS
#endif /* _DER_ITEM_H_ */

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 2005-2007,2011-2012,2014 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* libDER_config.h - platform dependent #defines and typedefs for libDER
*
*/
#ifndef _LIB_DER_CONFIG_H_
#define _LIB_DER_CONFIG_H_
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#if defined(WIN32) && defined(__cplusplus)
#if !defined(__BEGIN_DECLS) || !defined(__END_DECLS)
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#endif // __BEGIN_DECLS || __END_DECLS
#else
#include <sys/cdefs.h>
#endif // defined(WIN32) && defined(__cplusplus)
__BEGIN_DECLS
/*
* Basic data types: unsigned 8-bit integer, unsigned 32-bit integer
*/
typedef uint8_t DERByte;
typedef uint16_t DERShort;
typedef size_t DERSize;
/*
* Use these #defines of you have memset, memmove, and memcmp; else
* write your own equivalents.
*/
#define DERMemset(ptr, c, len) memset(ptr, c, len)
#define DERMemmove(dst, src, len) memmove(dst, src, len)
#define DERMemcmp(b1, b2, len) memcmp(b1, b2, len)
/***
*** Compile time options to trim size of the library.
***/
/* enable general DER encode */
#define DER_ENCODE_ENABLE 1
/* enable general DER decode */
#define DER_DECODE_ENABLE 1
#ifndef DER_MULTIBYTE_TAGS
/* enable multibyte tag support. */
#define DER_MULTIBYTE_TAGS 1
#endif
#ifndef DER_TAG_SIZE
/* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that
tags are still encoded and decoded from a minimally encoded DER
represantation. This value maintains compatibility with libImg4Decode/Encode. */
#define DER_TAG_SIZE 8
#endif
/* ---------------------- Do not edit below this line ---------------------- */
/*
* Logical representation of a tag (the encoded representation is always in
* the minimal number of bytes). The top 3 bits encode class and method
* The remaining bits encode the tag value. To obtain smaller DERItemSpecs
* sizes, choose the smallest type that fits your needs. Most standard ASN.1
* usage only needs single byte tags, but ocasionally custom applications
* require a larger tag namespace.
*/
#if DER_MULTIBYTE_TAGS
#if DER_TAG_SIZE == 1
typedef uint8_t DERTag;
#elif DER_TAG_SIZE == 2
typedef uint16_t DERTag;
#elif DER_TAG_SIZE == 4
typedef uint32_t DERTag;
#elif DER_TAG_SIZE == 8
typedef uint64_t DERTag;
#else
#error DER_TAG_SIZE invalid
#endif
#else /* DER_MULTIBYTE_TAGS */
typedef DERByte DERTag;
#endif /* !DER_MULTIBYTE_TAGS */
__END_DECLS
#endif /* _LIB_DER_CONFIG_H_ */

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSATOMIC_H_
#define _OSATOMIC_H_
/*! @header
* These are deprecated legacy interfaces for atomic and synchronization
* operations.
*
* Define OSATOMIC_USE_INLINED=1 to get inline implementations of the
* OSAtomic interfaces in terms of the <stdatomic.h> primitives.
*
* Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the
* OSSpinLock interfaces in terms of the <os/lock.h> primitives.
*
* These are intended as a transition convenience, direct use of those
* primitives should be preferred.
*/
#include <sys/cdefs.h>
#include "OSAtomicDeprecated.h"
#include "OSSpinLockDeprecated.h"
#include "OSAtomicQueue.h"
#endif /* _OSATOMIC_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSATOMICQUEUE_H_
#define _OSATOMICQUEUE_H_
#include <stddef.h>
#include <sys/cdefs.h>
#include <stdint.h>
#include <stdbool.h>
#include "OSAtomicDeprecated.h"
#include <Availability.h>
/*! @header Lockless atomic enqueue and dequeue
* These routines manipulate singly-linked LIFO lists.
*/
__BEGIN_DECLS
/*! @abstract The data structure for a queue head.
@discussion
You should always initialize a queue head structure with the
initialization vector {@link OS_ATOMIC_QUEUE_INIT} before use.
*/
#if defined(__LP64__)
typedef volatile struct {
void *opaque1;
long opaque2;
} __attribute__ ((aligned (16))) OSQueueHead;
#else
typedef volatile struct {
void *opaque1;
long opaque2;
} OSQueueHead;
#endif
/*! @abstract The initialization vector for a queue head. */
#define OS_ATOMIC_QUEUE_INIT { NULL, 0 }
/*! @abstract Enqueue an element onto a list.
@discussion
Memory barriers are incorporated as needed to permit thread-safe access
to the queue element.
@param __list
The list on which you want to enqueue the element.
@param __new
The element to add.
@param __offset
The "offset" parameter is the offset (in bytes) of the link field
from the beginning of the data structure being queued (<code>__new</code>).
The link field should be a pointer type.
The <code>__offset</code> value needs to be same for all enqueuing and
dequeuing operations on the same list, even if different structure types
are enqueued on that list. The use of <code>offsetset()</code>, defined in
<code>stddef.h</code> is the common way to specify the <code>__offset</code>
value.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0)
void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset);
/*! @abstract Dequeue an element from a list.
@discussion
Memory barriers are incorporated as needed to permit thread-safe access
to the queue element.
@param __list
The list from which you want to dequeue an element.
@param __offset
The "offset" parameter is the offset (in bytes) of the link field
from the beginning of the data structure being dequeued (<code>__new</code>).
The link field should be a pointer type.
The <code>__offset</code> value needs to be same for all enqueuing and
dequeuing operations on the same list, even if different structure types
are enqueued on that list. The use of <code>offsetset()</code>, defined in
<code>stddef.h</code> is the common way to specify the <code>__offset</code>
value.
IMPORTANT: the memory backing the link field of a queue element must not be
unmapped after OSAtomicDequeue() returns until all concurrent calls to
OSAtomicDequeue() for the same list on other threads have also returned,
as they may still be accessing that memory location.
@result
Returns the most recently enqueued element, or <code>NULL</code> if the
list is empty.
*/
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_4_0)
void* OSAtomicDequeue( OSQueueHead *__list, size_t __offset);
__END_DECLS
#endif /* _OSATOMICQUEUE_H_ */

View File

@@ -37,10 +37,22 @@
#define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x)
#define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x)
#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define __DARWIN_OS_INLINE static inline
# else
# define __DARWIN_OS_INLINE static __inline__
# endif
#endif
#if defined(__GNUC__)
#if (defined(__i386__) || defined(__x86_64__))
#include <libkern/i386/OSByteOrder.h>
#elif defined (__arm__) || defined(__arm64__)
#include <libkern/arm/OSByteOrder.h>
#else
#include <libkern/machine/OSByteOrder.h>
#endif
@@ -61,7 +73,7 @@ enum {
OSBigEndian
};
OS_INLINE
__DARWIN_OS_INLINE
int32_t
OSHostByteOrder(void)
{
@@ -85,7 +97,7 @@ OSHostByteOrder(void)
/* Functions for loading native endian values. */
OS_INLINE
__DARWIN_OS_INLINE
uint16_t
_OSReadInt16(
const volatile void * base,
@@ -95,7 +107,7 @@ _OSReadInt16(
return *(volatile uint16_t *)((uintptr_t)base + byteOffset);
}
OS_INLINE
__DARWIN_OS_INLINE
uint32_t
_OSReadInt32(
const volatile void * base,
@@ -105,7 +117,7 @@ _OSReadInt32(
return *(volatile uint32_t *)((uintptr_t)base + byteOffset);
}
OS_INLINE
__DARWIN_OS_INLINE
uint64_t
_OSReadInt64(
const volatile void * base,
@@ -117,7 +129,7 @@ _OSReadInt64(
/* Functions for storing native endian values. */
OS_INLINE
__DARWIN_OS_INLINE
void
_OSWriteInt16(
volatile void * base,
@@ -128,7 +140,7 @@ _OSWriteInt16(
*(volatile uint16_t *)((uintptr_t)base + byteOffset) = data;
}
OS_INLINE
__DARWIN_OS_INLINE
void
_OSWriteInt32(
volatile void * base,
@@ -139,7 +151,7 @@ _OSWriteInt32(
*(volatile uint32_t *)((uintptr_t)base + byteOffset) = data;
}
OS_INLINE
__DARWIN_OS_INLINE
void
_OSWriteInt64(
volatile void * base,

View File

@@ -0,0 +1,212 @@
/*
* Copyright (c) 2004-2016 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _OSSPINLOCK_DEPRECATED_H_
#define _OSSPINLOCK_DEPRECATED_H_
/*! @header
* These are deprecated legacy interfaces for userspace spinlocks.
*
* These interfaces should no longer be used, particularily in situations where
* threads of differing priorities may contend on the same spinlock.
*
* The interfaces in <os/lock.h> should be used instead in cases where a very
* low-level lock primitive is required. In general however, using higher level
* synchronization primitives such as those provided by the pthread or dispatch
* subsystems should be preferred.
*
* Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these
* interfaces in terms of the <os/lock.h> primitives. This is intended as a
* transition convenience, direct use of those primitives is preferred.
*/
#ifndef OSSPINLOCK_DEPRECATED
#define OSSPINLOCK_DEPRECATED 1
#define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from <os/lock.h> instead"
#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \
__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \
__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r))
#else
#undef OSSPINLOCK_DEPRECATED
#define OSSPINLOCK_DEPRECATED 0
#define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r)
#endif
#if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED)
#include <sys/cdefs.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <Availability.h>
__BEGIN_DECLS
/*! @abstract The default value for an <code>OSSpinLock</code>.
@discussion
The convention is that unlocked is zero, locked is nonzero.
*/
#define OS_SPINLOCK_INIT 0
/*! @abstract Data type for a spinlock.
@discussion
You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before
using it.
*/
typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
/*! @abstract Locks a spinlock if it would not block
@result
Returns <code>false</code> if the lock was already held by another thread,
<code>true</code> if it took the lock successfully.
*/
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
bool OSSpinLockTry( volatile OSSpinLock *__lock );
/*! @abstract Locks a spinlock
@discussion
Although the lock operation spins, it employs various strategies to back
off if the lock is held.
*/
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
void OSSpinLockLock( volatile OSSpinLock *__lock );
/*! @abstract Unlocks a spinlock */
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
void OSSpinLockUnlock( volatile OSSpinLock *__lock );
__END_DECLS
#else /* OSSPINLOCK_USE_INLINED */
/*
* Inline implementations of the legacy OSSpinLock interfaces in terms of the
* of the <os/lock.h> primitives. Direct use of those primitives is preferred.
*
* NOTE: the locked value of os_unfair_lock is implementation defined and
* subject to change, code that relies on the specific locked value used by the
* legacy OSSpinLock interface WILL break when using these inline
* implementations in terms of os_unfair_lock.
*/
#if !OSSPINLOCK_USE_INLINED_TRANSPARENT
#include <os/lock.h>
__BEGIN_DECLS
#if __has_attribute(always_inline)
#define OSSPINLOCK_INLINE static __inline
#else
#define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__))
#endif
#define OS_SPINLOCK_INIT 0
typedef int32_t OSSpinLock;
#if __has_extension(c_static_assert)
_Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock),
"Incompatible os_unfair_lock type");
#endif
OSSPINLOCK_INLINE
void
OSSpinLockLock(volatile OSSpinLock *__lock)
{
os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
return os_unfair_lock_lock(lock);
}
OSSPINLOCK_INLINE
bool
OSSpinLockTry(volatile OSSpinLock *__lock)
{
os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
return os_unfair_lock_trylock(lock);
}
OSSPINLOCK_INLINE
void
OSSpinLockUnlock(volatile OSSpinLock *__lock)
{
os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
return os_unfair_lock_unlock(lock);
}
#undef OSSPINLOCK_INLINE
__END_DECLS
#else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */
#include <sys/cdefs.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <Availability.h>
#define OS_NOSPIN_LOCK_AVAILABILITY \
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \
__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
__BEGIN_DECLS
#define OS_SPINLOCK_INIT 0
typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
typedef volatile OSSpinLock *_os_nospin_lock_t
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t);
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
OS_NOSPIN_LOCK_AVAILABILITY
void _os_nospin_lock_lock(_os_nospin_lock_t lock);
#undef OSSpinLockLock
#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock)
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
OS_NOSPIN_LOCK_AVAILABILITY
bool _os_nospin_lock_trylock(_os_nospin_lock_t lock);
#undef OSSpinLockTry
#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock)
OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
OS_NOSPIN_LOCK_AVAILABILITY
void _os_nospin_lock_unlock(_os_nospin_lock_t lock);
#undef OSSpinLockUnlock
#define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock)
__END_DECLS
#endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */
#endif /* OSSPINLOCK_USE_INLINED */
#endif /* _OSSPINLOCK_DEPRECATED_H_ */

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 1999-2012 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#include <MacTypes.h>
#ifndef _OS_OSTYPES_H
#define _OS_OSTYPES_H
#define OSTYPES_K64_REV 2
typedef unsigned int UInt;
typedef signed int SInt;
#include <sys/_types/_os_inline.h>
#endif /* _OS_OSTYPES_H */

View File

@@ -41,14 +41,14 @@
/* Macros for swapping constant values in the preprocessing stage. */
#define __DARWIN_OSSwapConstInt16(x) \
((__uint16_t)((((__uint16_t)(x) & 0xff00) >> 8) | \
(((__uint16_t)(x) & 0x00ff) << 8)))
((__uint16_t)((((__uint16_t)(x) & 0xff00U) >> 8) | \
(((__uint16_t)(x) & 0x00ffU) << 8)))
#define __DARWIN_OSSwapConstInt32(x) \
((__uint32_t)((((__uint32_t)(x) & 0xff000000) >> 24) | \
(((__uint32_t)(x) & 0x00ff0000) >> 8) | \
(((__uint32_t)(x) & 0x0000ff00) << 8) | \
(((__uint32_t)(x) & 0x000000ff) << 24)))
((__uint32_t)((((__uint32_t)(x) & 0xff000000U) >> 24) | \
(((__uint32_t)(x) & 0x00ff0000U) >> 8) | \
(((__uint32_t)(x) & 0x0000ff00U) << 8) | \
(((__uint32_t)(x) & 0x000000ffU) << 24)))
#define __DARWIN_OSSwapConstInt64(x) \
((__uint64_t)((((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
@@ -62,10 +62,23 @@
#if defined(__GNUC__)
#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define __DARWIN_OS_INLINE static inline
# else
# define __DARWIN_OS_INLINE static __inline__
# endif
#endif
#if defined(__i386__) || defined(__x86_64__)
#include <libkern/i386/_OSByteOrder.h>
#endif
#if defined (__arm__) || defined(__arm64__)
#include <libkern/arm/OSByteOrder.h>
#endif
#define __DARWIN_OSSwapInt16(x) \
@@ -81,16 +94,6 @@
#if defined(__i386__) || defined(__x86_64__)
#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
# define __DARWIN_OS_INLINE static inline
# else
# define __DARWIN_OS_INLINE static __inline__
# endif
#endif
__DARWIN_OS_INLINE
uint16_t
_OSSwapInt16(

View File

@@ -112,6 +112,15 @@ extern void _tlv_atexit(void (*termFunc)(void* objAddr), void* objAddr) __O
*/
extern void _tlv_bootstrap(void) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) DYLD_DRIVERKIT_UNAVAILABLE ;
/*
* Dylibs that are incorporated into the dyld cache are removed from disk. That means code
* cannot stat() the file to see if it "exists". This function is like a stat() call that checks if a
* path is to a dylib that was removed from disk and is incorporated into the active dyld cache.
*/
extern bool _dyld_shared_cache_contains_path(const char* path) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) DYLD_DRIVERKIT_UNAVAILABLE;
/*
* The following dyld API's are deprecated as of Mac OS X 10.5. They are either
* no longer necessary or are superceeded by dlopen and friends in <dlfcn.h>.

View File

@@ -115,11 +115,14 @@ struct mach_header_64 {
#define MH_DYLIB 0x6 /* dynamically bound shared library */
#define MH_DYLINKER 0x7 /* dynamic link editor */
#define MH_BUNDLE 0x8 /* dynamically bound bundle file */
#define MH_DYLIB_STUB 0x9 /* shared library stub for static */
/* linking only, no section contents */
#define MH_DSYM 0xa /* companion file with only debug */
/* sections */
#define MH_DYLIB_STUB 0x9 /* shared library stub for static
linking only, no section contents */
#define MH_DSYM 0xa /* companion file with only debug
sections */
#define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */
#define MH_FILESET 0xc /* a file composed of other Mach-Os to
be run in the same userspace sharing
a single linkedit. */
/* Constants for the flags field of the mach_header */
#define MH_NOUNDEFS 0x1 /* the object file has no undefined
@@ -322,6 +325,7 @@ struct load_command {
#define LC_BUILD_VERSION 0x32 /* build for platform min OS version */
#define LC_DYLD_EXPORTS_TRIE (0x33 | LC_REQ_DYLD) /* used with linkedit_data_command, payload is trie */
#define LC_DYLD_CHAINED_FIXUPS (0x34 | LC_REQ_DYLD) /* used with linkedit_data_command */
#define LC_FILESET_ENTRY (0x35 | LC_REQ_DYLD) /* used with fileset_entry_command */
/*
* A variable length string in a load command is represented by an lc_str
@@ -1265,9 +1269,6 @@ struct build_tool_version {
#define PLATFORM_WATCHOS 4
#define PLATFORM_BRIDGEOS 5
#define PLATFORM_MACCATALYST 6
#if (!defined(PLATFORM_MACCATALYST))
#define PLATFORM_MACCATALYST 6
#endif
#define PLATFORM_IOSSIMULATOR 7
#define PLATFORM_TVOSSIMULATOR 8
#define PLATFORM_WATCHOSSIMULATOR 9
@@ -1574,4 +1575,27 @@ struct note_command {
uint64_t size; /* length of data region */
};
/*
* LC_FILESET_ENTRY commands describe constituent Mach-O files that are part
* of a fileset. In one implementation, entries are dylibs with individual
* mach headers and repositionable text and data segments. Each entry is
* further described by its own mach header.
*/
struct fileset_entry_command {
uint32_t cmd; /* LC_FILESET_ENTRY */
uint32_t cmdsize; /* includes entry_id string */
uint64_t vmaddr; /* memory address of the entry */
uint64_t fileoff; /* file offset of the entry */
union lc_str entry_id; /* contained entry id */
uint32_t reserved; /* reserved */
};
/*
* These deprecated values may still be used within Apple but are mechanically
* removed from public API. The mechanical process may produce unusual results.
*/
#if (!defined(PLATFORM_MACCATALYST))
#define PLATFORM_MACCATALYST PLATFORM_MACCATALYST
#endif
#endif /* _MACHO_LOADER_H_ */

View File

@@ -603,7 +603,48 @@ _STRUCT_X86_DEBUG_STATE32
unsigned int __dr6;
unsigned int __dr7;
};
#define _STRUCT_X86_INSTRUCTION_STATE struct __x86_instruction_state
_STRUCT_X86_INSTRUCTION_STATE
{
int __insn_stream_valid_bytes;
int __insn_offset;
int __out_of_synch; /*
* non-zero when the cacheline that includes the insn_offset
* is replaced in the insn_bytes array due to a mismatch
* detected when comparing it with the same cacheline in memory
*/
#define _X86_INSTRUCTION_STATE_MAX_INSN_BYTES (2448 - 64 - 4)
__uint8_t __insn_bytes[_X86_INSTRUCTION_STATE_MAX_INSN_BYTES];
#define _X86_INSTRUCTION_STATE_CACHELINE_SIZE 64
__uint8_t __insn_cacheline[_X86_INSTRUCTION_STATE_CACHELINE_SIZE];
};
#define _STRUCT_LAST_BRANCH_RECORD struct __last_branch_record
_STRUCT_LAST_BRANCH_RECORD
{
__uint64_t __from_ip;
__uint64_t __to_ip;
__uint32_t __mispredict : 1,
__tsx_abort : 1,
__in_tsx : 1,
__cycle_count: 16,
__reserved : 13;
};
#define _STRUCT_LAST_BRANCH_STATE struct __last_branch_state
_STRUCT_LAST_BRANCH_STATE
{
int __lbr_count;
__uint32_t __lbr_supported_tsx : 1,
__lbr_supported_cycle_count : 1,
__reserved : 30;
#define __LASTBRANCH_MAX 32
_STRUCT_LAST_BRANCH_RECORD __lbrs[__LASTBRANCH_MAX];
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_X86_DEBUG_STATE32 struct x86_debug_state32
_STRUCT_X86_DEBUG_STATE32
{
@@ -616,6 +657,45 @@ _STRUCT_X86_DEBUG_STATE32
unsigned int dr6;
unsigned int dr7;
};
#define _STRUCT_X86_INSTRUCTION_STATE struct __x86_instruction_state
_STRUCT_X86_INSTRUCTION_STATE
{
int insn_stream_valid_bytes;
int insn_offset;
int out_of_synch; /*
* non-zero when the cacheline that includes the insn_offset
* is replaced in the insn_bytes array due to a mismatch
* detected when comparing it with the same cacheline in memory
*/
#define x86_INSTRUCTION_STATE_MAX_INSN_BYTES (2448 - 64 - 4)
__uint8_t insn_bytes[x86_INSTRUCTION_STATE_MAX_INSN_BYTES];
#define x86_INSTRUCTION_STATE_CACHELINE_SIZE 64
__uint8_t insn_cacheline[x86_INSTRUCTION_STATE_CACHELINE_SIZE];
};
#define _STRUCT_LAST_BRANCH_RECORD struct __last_branch_record
_STRUCT_LAST_BRANCH_RECORD
{
__uint64_t from_ip;
__uint64_t to_ip;
__uint32_t mispredict : 1,
tsx_abort : 1,
in_tsx : 1,
cycle_count: 16,
reserved : 13;
};
#define _STRUCT_LAST_BRANCH_STATE struct __last_branch_state
_STRUCT_LAST_BRANCH_STATE
{
int lbr_count;
__uint32_t lbr_supported_tsx : 1,
lbr_supported_cycle_count : 1,
reserved : 30;
#define __LASTBRANCH_MAX 32
_STRUCT_LAST_BRANCH_RECORD lbrs[__LASTBRANCH_MAX];
};
#endif /* !__DARWIN_UNIX03 */
#define _STRUCT_X86_PAGEIN_STATE struct __x86_pagein_state

View File

@@ -32,7 +32,7 @@
#ifndef _MACH_I386_THREAD_STATE_H_
#define _MACH_I386_THREAD_STATE_H_
/* Size of maximum exported thread state in words */
/* Size of maximum exported thread state in 32-bit words */
#define I386_THREAD_STATE_MAX (614) /* Size of biggest state possible */
#if defined (__i386__) || defined(__x86_64__)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
* Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@@ -121,6 +121,8 @@
#define x86_AVX512_STATE (x86_AVX512_STATE32 + 2)
#define x86_PAGEIN_STATE 22
#define x86_THREAD_FULL_STATE64 23
#define x86_INSTRUCTION_STATE 24
#define x86_LAST_BRANCH_STATE 25
/*
* Largest state on this machine:
@@ -155,6 +157,8 @@
(x == x86_AVX512_STATE64) || \
(x == x86_AVX512_STATE) || \
(x == x86_PAGEIN_STATE) || \
(x == x86_INSTRUCTION_STATE) || \
(x == x86_LAST_BRANCH_STATE) || \
(x == THREAD_STATE_NONE))
struct x86_state_hdr {
@@ -259,6 +263,19 @@ typedef _STRUCT_X86_PAGEIN_STATE x86_pagein_state_t;
#define X86_PAGEIN_STATE_COUNT x86_PAGEIN_STATE_COUNT
typedef _STRUCT_X86_INSTRUCTION_STATE x86_instruction_state_t;
#define x86_INSTRUCTION_STATE_COUNT \
((mach_msg_type_number_t)(sizeof(x86_instruction_state_t) / sizeof(int)))
#define X86_INSTRUCTION_STATE_COUNT x86_INSTRUCTION_STATE_COUNT
typedef _STRUCT_LAST_BRANCH_STATE last_branch_state_t;
#define x86_LAST_BRANCH_STATE_COUNT \
((mach_msg_type_number_t)(sizeof(last_branch_state_t) / sizeof(int)))
#define X86_LAST_BRANCH_STATE_COUNT x86_LAST_BRANCH_STATE_COUNT
/*
* Combined thread, float and exception states
*/

View File

@@ -90,47 +90,34 @@
#ifndef _MACH_I386_VM_PARAM_H_
#define _MACH_I386_VM_PARAM_H_
#if !defined(KERNEL) && !defined(__ASSEMBLER__)
#include <mach/vm_page_size.h>
#endif
#define BYTE_SIZE 8 /* byte size in bits */
#define I386_PGBYTES 4096 /* bytes per 80386 page */
#define I386_PGSHIFT 12 /* bitshift for pages */
#define PAGE_SIZE I386_PGBYTES
#if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600)
#define PAGE_SHIFT I386_PGSHIFT
#define PAGE_MASK (PAGE_SIZE - 1)
#define PAGE_SIZE I386_PGBYTES
#define PAGE_MASK (PAGE_SIZE-1)
#else /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */
#define PAGE_SHIFT vm_page_shift
#define PAGE_SIZE vm_page_size
#define PAGE_MASK vm_page_mask
#endif /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */
#define PAGE_MAX_SHIFT PAGE_SHIFT
#define PAGE_MAX_SIZE PAGE_SIZE
#define PAGE_MAX_MASK PAGE_MASK
#define PAGE_MIN_SHIFT PAGE_SHIFT
#define PAGE_MIN_SIZE PAGE_SIZE
#define PAGE_MIN_MASK PAGE_MASK
#define I386_LPGBYTES 2*1024*1024 /* bytes per large page */
#define I386_LPGSHIFT 21 /* bitshift for large pages */
#define I386_LPGMASK (I386_LPGBYTES-1)
/*
* Convert bytes to pages and convert pages to bytes.
* No rounding is used.
*/
#define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT))
#define machine_btop(x) i386_btop(x)
#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
#define machine_ptob(x) i386_ptob(x)
/*
* Round off or truncate to the nearest page. These will work
* for either addresses or counts. (i.e. 1 byte rounds to 1 page
* bytes.
*/
#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
~(I386_PGBYTES-1))
#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
#define PAGE_MAX_SHIFT 14
#define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT)
#define PAGE_MAX_MASK (PAGE_MAX_SIZE-1)
#define PAGE_MIN_SHIFT 12
#define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT)
#define PAGE_MIN_MASK (PAGE_MIN_SIZE-1)
#define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)

View File

@@ -70,7 +70,6 @@
#ifndef ASSEMBLER
#include <i386/_types.h>
#include <mach/i386/vm_param.h>
#include <stdint.h>
/*

View File

@@ -323,6 +323,10 @@
/* The provided buffer is of insufficient size for the requested data.
*/
#define KERN_DENIED 53
/* Denied by security policy
*/
#define KERN_RETURN_MAX 0x100
/* Maximum return value allowable
*/

View File

@@ -226,7 +226,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_get_set_status
(
ipc_space_inspect_t task,
ipc_space_read_t task,
mach_port_name_t name,
mach_port_name_array_t *members,
mach_msg_type_number_t *membersCnt
@@ -312,7 +312,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_get_attributes
(
ipc_space_inspect_t task,
ipc_space_read_t task,
mach_port_name_t name,
mach_port_flavor_t flavor,
mach_port_info_t port_info_out,
@@ -398,7 +398,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_space_info
(
ipc_space_inspect_t task,
ipc_space_read_t space,
ipc_info_space_t *space_info,
ipc_info_name_array_t *table_info,
mach_msg_type_number_t *table_infoCnt,
@@ -428,7 +428,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_kernel_object
(
ipc_space_inspect_t task,
ipc_space_read_t task,
mach_port_name_t name,
unsigned *object_type,
unsigned *object_addr
@@ -468,7 +468,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_get_context
(
ipc_space_inspect_t task,
ipc_space_read_t task,
mach_port_name_t name,
mach_port_context_t *context
);
@@ -494,7 +494,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_kobject
(
ipc_space_inspect_t task,
ipc_space_read_t task,
mach_port_name_t name,
natural_t *object_type,
mach_vm_address_t *object_addr
@@ -603,7 +603,7 @@ extern
#endif /* mig_external */
kern_return_t mach_port_kobject_description
(
ipc_space_inspect_t task,
ipc_space_read_t task,
mach_port_name_t name,
natural_t *object_type,
mach_vm_address_t *object_addr,

View File

@@ -131,12 +131,6 @@ extern kern_return_t _kernelrpc_mach_port_allocate_trap(
mach_port_name_t *name
);
extern kern_return_t _kernelrpc_mach_port_destroy_trap(
mach_port_name_t target,
mach_port_name_t name
);
extern kern_return_t _kernelrpc_mach_port_deallocate_trap(
mach_port_name_t target,
mach_port_name_t name

View File

@@ -117,12 +117,17 @@
*/
typedef mach_port_t task_t;
typedef mach_port_t task_name_t;
typedef mach_port_t task_policy_set_t;
typedef mach_port_t task_policy_get_t;
typedef mach_port_t task_inspect_t;
typedef mach_port_t task_read_t;
typedef mach_port_t task_suspension_token_t;
typedef mach_port_t thread_t;
typedef mach_port_t thread_act_t;
typedef mach_port_t thread_inspect_t;
typedef mach_port_t thread_read_t;
typedef mach_port_t ipc_space_t;
typedef mach_port_t ipc_space_read_t;
typedef mach_port_t ipc_space_inspect_t;
typedef mach_port_t coalition_t;
typedef mach_port_t host_t;
@@ -138,6 +143,8 @@ typedef mach_port_t alarm_t;
typedef mach_port_t clock_serv_t;
typedef mach_port_t clock_ctrl_t;
typedef mach_port_t arcade_register_t;
typedef mach_port_t ipc_eventlink_t;
typedef mach_port_t eventlink_port_pair_t[2];
typedef mach_port_t suid_cred_t;
@@ -159,6 +166,7 @@ typedef exception_handler_t *exception_handler_array_t;
typedef mach_port_t vm_task_entry_t;
typedef mach_port_t io_master_t;
typedef mach_port_t UNDServerRef;
typedef mach_port_t mach_eventlink_t;
/*
* Mig doesn't translate the components of an array.
@@ -212,12 +220,15 @@ typedef uint32_t suid_cred_uid_t;
#define TASK_NULL ((task_t) 0)
#define TASK_NAME_NULL ((task_name_t) 0)
#define TASK_INSPECT_NULL ((task_inspect_t) 0)
#define TASK_INSPECT_NULL ((task_inspect_t) 0)
#define TASK_READ_NULL ((task_read_t) 0)
#define THREAD_NULL ((thread_t) 0)
#define THREAD_INSPECT_NULL ((thread_inspect_t) 0)
#define THREAD_READ_NULL ((thread_read_t) 0)
#define TID_NULL ((uint64_t) 0)
#define THR_ACT_NULL ((thread_act_t) 0)
#define IPC_SPACE_NULL ((ipc_space_t) 0)
#define IPC_SPACE_READ_NULL ((ipc_space_read_t) 0)
#define IPC_SPACE_INSPECT_NULL ((ipc_space_inspect_t) 0)
#define COALITION_NULL ((coalition_t) 0)
#define HOST_NULL ((host_t) 0)
@@ -232,7 +243,25 @@ typedef uint32_t suid_cred_uid_t;
#define CLOCK_NULL ((clock_t) 0)
#define UND_SERVER_NULL ((UNDServerRef) 0)
#define ARCADE_REG_NULL ((arcade_register_t) 0)
#define SUID_CRED_NULL ((suid_cred_t) 0)
#define MACH_EVENTLINK_NULL ((mach_eventlink_t) 0)
#define IPC_EVENTLINK_NULL ((ipc_eventlink_t) 0)
#define SUID_CRED_NULL ((suid_cred_t) 0)
/* capability strictly _DECREASING_.
* not ordered the other way around because we want TASK_FLAVOR_CONTROL
* to be closest to the itk_lock. see task.h.
*/
typedef unsigned int mach_task_flavor_t;
#define TASK_FLAVOR_CONTROL 0 /* a task_t */
#define TASK_FLAVOR_READ 1 /* a task_read_t */
#define TASK_FLAVOR_INSPECT 2 /* a task_inspect_t */
#define TASK_FLAVOR_NAME 3 /* a task_name_t */
/* capability strictly _DECREASING_ */
typedef unsigned int mach_thread_flavor_t;
#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */
#define THREAD_FLAVOR_READ 1 /* a thread_read_t */
#define THREAD_FLAVOR_INSPECT 2 /* a thread_inspect_t */
/* DEPRECATED */
typedef natural_t ledger_item_t;

View File

@@ -118,6 +118,9 @@ typedef integer_t cpu_threadtype_t;
#define CPU_TYPE_POWERPC ((cpu_type_t) 18)
#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
/* skip ((cpu_type_t) 19) */
/* skip ((cpu_type_t) 20 */
/* skip ((cpu_type_t) 21 */
/* skip ((cpu_type_t) 22 */
/*
* Machine subtypes (these are defined here, instead of in a machine
@@ -130,7 +133,14 @@ typedef integer_t cpu_threadtype_t;
*/
#define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */
#define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */
#define CPU_SUBTYPE_PTRAUTH_ABI 0x80000000 /* pointer authentication with versioned ABI */
/*
* When selecting a slice, ANY will pick the slice with the best
* grading for the selected cpu_type_t, unlike the "ALL" subtypes,
* which are the slices that can run on any hardware for that cpu type.
*/
#define CPU_SUBTYPE_ANY ((cpu_subtype_t) -1)
/*
* Object files that are hand-crafted to run on any
@@ -365,9 +375,7 @@ typedef integer_t cpu_threadtype_t;
#define CPUFAMILY_INTEL_BROADWELL 0x582ed09c
#define CPUFAMILY_INTEL_SKYLAKE 0x37fc219f
#define CPUFAMILY_INTEL_KABYLAKE 0x0f817246
#if !defined(RC_HIDE_XNU_ICELAKE)
#define CPUFAMILY_INTEL_ICELAKE 0x38435547
#endif /* not RC_HIDE_XNU_ICELAKE */
#if !defined(RC_HIDE_XNU_COMETLAKE)
#define CPUFAMILY_INTEL_COMETLAKE 0x1cf8a03e
#endif /* not RC_HIDE_XNU_COMETLAKE */
@@ -386,6 +394,14 @@ typedef integer_t cpu_threadtype_t;
#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
#define CPUSUBFAMILY_UNKNOWN 0
#define CPUSUBFAMILY_ARM_HP 1
#define CPUSUBFAMILY_ARM_HG 2
#define CPUSUBFAMILY_ARM_M 3
#define CPUSUBFAMILY_ARM_HS 4
#define CPUSUBFAMILY_ARM_HC_HD 5
/* The following synonyms are deprecated: */
#define CPUFAMILY_INTEL_6_23 CPUFAMILY_INTEL_PENRYN

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/_structs.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/_structs.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/boolean.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/boolean.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/exception.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/exception.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/kern_return.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/kern_return.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/processor_info.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/processor_info.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/rpc.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/rpc.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/thread_state.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/thread_state.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/thread_status.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/thread_status.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/vm_param.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/vm_param.h"
#else
#error architecture not supported
#endif

View File

@@ -31,6 +31,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "mach/i386/vm_types.h"
#elif defined (__arm__) || defined (__arm64__)
#include "mach/arm/vm_types.h"
#else
#error architecture not supported
#endif

View File

@@ -228,6 +228,7 @@ typedef unsigned int mach_msg_priority_t;
#define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0
typedef unsigned int mach_msg_type_name_t;
#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
@@ -499,6 +500,9 @@ typedef struct{
mach_port_name_t sender;
} msg_labels_t;
typedef int mach_msg_filter_id;
#define MACH_MSG_FILTER_POLICY_ALLOW (mach_msg_filter_id)0
/*
* Trailer type to pass MAC policy label info as a mach message trailer.
*
@@ -511,7 +515,7 @@ typedef struct{
security_token_t msgh_sender;
audit_token_t msgh_audit;
mach_port_context_t msgh_context;
int msgh_ad;
mach_msg_filter_id msgh_ad;
msg_labels_t msgh_labels;
} mach_msg_mac_trailer_t;
@@ -799,6 +803,8 @@ typedef kern_return_t mach_msg_return_t;
/* compatibility: no longer a returned error */
#define MACH_SEND_NO_GRANT_DEST 0x10000016
/* The destination port doesn't accept ports in body */
#define MACH_SEND_MSG_FILTERED 0x10000017
/* Message send was rejected by message filter */
#define MACH_RCV_IN_PROGRESS 0x10004001
/* Thread is waiting for receive. (Internal use only.) */

View File

@@ -339,6 +339,9 @@ typedef struct mach_port_qos {
#define MPO_STRICT 0x20 /* Apply strict guarding for port */
#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */
#define MPO_IMMOVABLE_RECEIVE 0x80 /* Mark the port as immovable; protected by the guard context */
#define MPO_FILTER_MSG 0x100 /* Allow message filtering */
#define MPO_TG_BLOCK_TRACKING 0x200 /* Track blocking relationship for thread group during sync IPC */
/*
* Structure to define optional attributes for a newly
* constructed port.
@@ -346,7 +349,10 @@ typedef struct mach_port_qos {
typedef struct mach_port_options {
uint32_t flags; /* Flags defining attributes for port */
mach_port_limits_t mpl; /* Message queue limit for port */
uint64_t reserved[2]; /* Reserved */
union {
uint64_t reserved[2]; /* Reserved */
mach_port_name_t work_interval_port; /* Work interval port */
};
}mach_port_options_t;
typedef mach_port_options_t *mach_port_options_ptr_t;
@@ -367,6 +373,7 @@ enum mach_port_guard_exception_codes {
kGUARD_EXC_INCORRECT_GUARD = 1u << 4,
kGUARD_EXC_IMMOVABLE = 1u << 5,
kGUARD_EXC_STRICT_REPLY = 1u << 6,
kGUARD_EXC_MSG_FILTERED = 1u << 7,
/* start of [optionally] non-fatal guards */
kGUARD_EXC_INVALID_RIGHT = 1u << 8,
kGUARD_EXC_INVALID_NAME = 1u << 9,

View File

@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
#endif /* AUTOTEST */
#ifndef processor_set_MSG_COUNT
#define processor_set_MSG_COUNT 10
#define processor_set_MSG_COUNT 11
#endif /* processor_set_MSG_COUNT */
#include <mach/std_types.h>
@@ -200,6 +200,20 @@ kern_return_t processor_set_info
mach_msg_type_number_t *info_outCnt
);
/* Routine processor_set_tasks_with_flavor */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t processor_set_tasks_with_flavor
(
processor_set_t processor_set,
mach_task_flavor_t flavor,
task_array_t *task_list,
mach_msg_type_number_t *task_listCnt
);
__END_DECLS
/********************** Caution **************************/
@@ -336,6 +350,18 @@ __END_DECLS
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
mach_task_flavor_t flavor;
} __Request__processor_set_tasks_with_flavor_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__processor_set_subsystem__defined */
/* union of all requests */
@@ -353,6 +379,7 @@ union __RequestUnion__processor_set_subsystem {
__Request__processor_set_policy_control_t Request_processor_set_policy_control;
__Request__processor_set_stack_usage_t Request_processor_set_stack_usage;
__Request__processor_set_info_t Request_processor_set_info;
__Request__processor_set_tasks_with_flavor_t Request_processor_set_tasks_with_flavor;
};
#endif /* !__RequestUnion__processor_set_subsystem__defined */
/* typedefs for all replies */
@@ -499,6 +526,22 @@ union __RequestUnion__processor_set_subsystem {
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_ool_ports_descriptor_t task_list;
/* end of the kernel processed data */
NDR_record_t NDR;
mach_msg_type_number_t task_listCnt;
} __Reply__processor_set_tasks_with_flavor_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__processor_set_subsystem__defined */
/* union of all replies */
@@ -516,6 +559,7 @@ union __ReplyUnion__processor_set_subsystem {
__Reply__processor_set_policy_control_t Reply_processor_set_policy_control;
__Reply__processor_set_stack_usage_t Reply_processor_set_stack_usage;
__Reply__processor_set_info_t Reply_processor_set_info;
__Reply__processor_set_tasks_with_flavor_t Reply_processor_set_tasks_with_flavor;
};
#endif /* !__RequestUnion__processor_set_subsystem__defined */
@@ -530,7 +574,8 @@ union __ReplyUnion__processor_set_subsystem {
{ "processor_set_threads", 4006 },\
{ "processor_set_policy_control", 4007 },\
{ "processor_set_stack_usage", 4008 },\
{ "processor_set_info", 4009 }
{ "processor_set_info", 4009 },\
{ "processor_set_tasks_with_flavor", 4010 }
#endif
#ifdef __AfterMigUserHeader

View File

@@ -279,7 +279,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_get_exception_ports
(
task_inspect_t task,
task_t task,
exception_mask_t exception_mask,
exception_mask_array_t masks,
mach_msg_type_number_t *masksCnt,
@@ -372,7 +372,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_policy_set
(
task_t task,
task_policy_set_t task,
task_policy_flavor_t flavor,
task_policy_t policy_info,
mach_msg_type_number_t policy_infoCnt
@@ -388,7 +388,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_policy_get
(
task_t task,
task_policy_get_t task,
task_policy_flavor_t flavor,
task_policy_t policy_info,
mach_msg_type_number_t *policy_infoCnt,
@@ -487,7 +487,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_zone_info
(
task_t target_task,
task_inspect_t target_task,
mach_zone_name_array_t *names,
mach_msg_type_number_t *namesCnt,
task_zone_info_array_t *info,
@@ -527,7 +527,7 @@ extern
#endif /* mig_external */
kern_return_t task_get_assignment
(
task_t task,
task_inspect_t task,
processor_set_name_t *assigned_set
);
@@ -559,7 +559,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_get_state
(
task_t task,
task_read_t task,
thread_state_flavor_t flavor,
thread_state_t old_state,
mach_msg_type_number_t *old_stateCnt
@@ -631,7 +631,7 @@ extern
#endif /* mig_external */
kern_return_t task_purgable_info
(
task_t task,
task_inspect_t task,
task_purgable_info_t *stats
);
@@ -645,7 +645,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t task_get_mach_voucher
(
task_t task,
task_read_t task,
mach_voucher_selector_t which,
ipc_voucher_t *voucher
);
@@ -700,7 +700,7 @@ extern
kern_return_t task_map_corpse_info
(
task_t task,
task_t corspe_task,
task_read_t corspe_task,
vm_address_t *kcd_addr_begin,
uint32_t *kcd_size
);
@@ -739,7 +739,7 @@ extern
#endif /* mig_external */
kern_return_t task_get_dyld_image_infos
(
task_inspect_t task,
task_read_t task,
dyld_kernel_image_info_array_t *dyld_images,
mach_msg_type_number_t *dyld_imagesCnt
);
@@ -791,7 +791,7 @@ extern
kern_return_t task_map_corpse_info_64
(
task_t task,
task_t corspe_task,
task_read_t corspe_task,
mach_vm_address_t *kcd_addr_begin,
mach_vm_size_t *kcd_size
);
@@ -1022,7 +1022,7 @@ __END_DECLS
NDR_record_t NDR;
thread_state_flavor_t flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[614];
natural_t new_state[1296];
} __Request__thread_create_running_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
@@ -1331,7 +1331,7 @@ __END_DECLS
NDR_record_t NDR;
thread_state_flavor_t flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[614];
natural_t new_state[1296];
} __Request__task_set_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
@@ -2111,7 +2111,7 @@ union __RequestUnion__task_subsystem {
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[614];
natural_t old_state[1296];
} __Reply__task_get_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)

View File

@@ -112,8 +112,13 @@ typedef struct task_basic_info_32 *task_basic_info_32_t;
/* Don't use this, use MACH_TASK_BASIC_INFO instead */
struct task_basic_info_64 {
integer_t suspend_count; /* suspend count for task */
#if defined(__arm__) || defined(__arm64__)
mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
mach_vm_size_t resident_size; /* resident memory size (bytes) */
#else /* defined(__arm__) || defined(__arm64__) */
mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
mach_vm_size_t resident_size; /* resident memory size (bytes) */
#endif /* defined(__arm__) || defined(__arm64__) */
time_value_t user_time; /* total user run time for
* terminated threads */
time_value_t system_time; /* total system run time for
@@ -123,9 +128,26 @@ struct task_basic_info_64 {
typedef struct task_basic_info_64 task_basic_info_64_data_t;
typedef struct task_basic_info_64 *task_basic_info_64_t;
#if defined(__arm__) || defined(__arm64__)
#if defined(__arm__) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0)
/*
* Note: arm64 can't use the old flavor. If you somehow manage to,
* you can cope with the nonsense data yourself.
*/
#define TASK_BASIC_INFO_64 5
#define TASK_BASIC_INFO_64_COUNT \
(sizeof(task_basic_info_64_data_t) / sizeof(natural_t))
#else
#define TASK_BASIC_INFO_64 TASK_BASIC_INFO_64_2
#define TASK_BASIC_INFO_64_COUNT TASK_BASIC_INFO_64_2_COUNT
#endif
#else /* defined(__arm__) || defined(__arm64__) */
#define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */
#define TASK_BASIC_INFO_64_COUNT \
(sizeof(task_basic_info_64_data_t) / sizeof(natural_t))
#endif
/* localized structure - cannot be safely passed between tasks of differing sizes */
@@ -249,6 +271,27 @@ typedef struct task_dyld_info *task_dyld_info_t;
#define TASK_DYLD_ALL_IMAGE_INFO_32 0 /* format value */
#define TASK_DYLD_ALL_IMAGE_INFO_64 1 /* format value */
#if defined(__arm__) || defined(__arm64__)
/* Don't use this, use MACH_TASK_BASIC_INFO instead */
/* Compatibility for old 32-bit mach_vm_*_t */
#define TASK_BASIC_INFO_64_2 18 /* 64-bit capable basic info */
struct task_basic_info_64_2 {
integer_t suspend_count; /* suspend count for task */
mach_vm_size_t virtual_size; /* virtual memory size (bytes) */
mach_vm_size_t resident_size; /* resident memory size (bytes) */
time_value_t user_time; /* total user run time for
* terminated threads */
time_value_t system_time; /* total system run time for
* terminated threads */
policy_t policy; /* default policy for new threads */
};
typedef struct task_basic_info_64_2 task_basic_info_64_2_data_t;
typedef struct task_basic_info_64_2 *task_basic_info_64_2_t;
#define TASK_BASIC_INFO_64_2_COUNT \
(sizeof(task_basic_info_64_2_data_t) / sizeof(natural_t))
#endif
#define TASK_EXTMOD_INFO 19
@@ -377,7 +420,7 @@ typedef struct task_vm_info *task_vm_info_t;
typedef struct vm_purgeable_info task_purgable_info_t;
#define TASK_TRACE_MEMORY_INFO 24
#define TASK_TRACE_MEMORY_INFO 24 /* no longer supported */
struct task_trace_memory_info {
uint64_t user_memory_address; /* address of start of trace memory buffer */
uint64_t buffer_size; /* size of buffer in bytes */
@@ -412,6 +455,9 @@ typedef gpu_energy_data *gpu_energy_data_t;
struct task_power_info_v2 {
task_power_info_data_t cpu_energy;
gpu_energy_data gpu_energy;
#if defined(__arm__) || defined(__arm64__)
uint64_t task_energy;
#endif /* defined(__arm__) || defined(__arm64__) */
uint64_t task_ptime;
uint64_t task_pset_switches;
};

View File

@@ -110,8 +110,7 @@ typedef integer_t *task_policy_t;
#define TASK_BASE_LATENCY_QOS_POLICY 10
#define TASK_BASE_THROUGHPUT_QOS_POLICY 11
enum task_role {
typedef enum task_role {
TASK_RENICED = -1,
TASK_UNSPECIFIED = 0,
TASK_FOREGROUND_APPLICATION = 1,
@@ -122,9 +121,7 @@ enum task_role {
TASK_NONUI_APPLICATION = 6,
TASK_DEFAULT_APPLICATION = 7,
TASK_DARWINBG_APPLICATION = 8,
};
typedef integer_t task_role_t;
} task_role_t;
struct task_category_policy {
task_role_t role;

View File

@@ -69,18 +69,19 @@
typedef int task_special_port_t;
#define TASK_KERNEL_PORT 1 /* Represents task to the outside
* world.*/
#define TASK_KERNEL_PORT 1 /* The full task port for task. */
#define TASK_HOST_PORT 2 /* The host (priv) port for task. */
#define TASK_NAME_PORT 3 /* the name (unpriv) port for task */
#define TASK_NAME_PORT 3 /* The name port for task. */
#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */
/*
* Evolving and likely to change.
*/
#define TASK_INSPECT_PORT 5 /* The inspect port for task. */
#define TASK_READ_PORT 6 /* The read port for task. */
#define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */

View File

@@ -49,7 +49,7 @@ typedef function_table_entry *function_table_t;
#endif /* AUTOTEST */
#ifndef thread_act_MSG_COUNT
#define thread_act_MSG_COUNT 28
#define thread_act_MSG_COUNT 29
#endif /* thread_act_MSG_COUNT */
#include <mach/std_types.h>
@@ -88,7 +88,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t act_get_state
(
thread_act_t target_act,
thread_read_t target_act,
int flavor,
thread_state_t old_state,
mach_msg_type_number_t *old_stateCnt
@@ -119,7 +119,7 @@ extern
__WATCHOS_PROHIBITED
kern_return_t thread_get_state
(
thread_act_t target_act,
thread_read_t target_act,
thread_state_flavor_t flavor,
thread_state_t old_state,
mach_msg_type_number_t *old_stateCnt
@@ -211,7 +211,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t thread_get_special_port
(
thread_act_t thr_act,
thread_inspect_t thr_act,
int which_port,
mach_port_t *special_port
);
@@ -272,7 +272,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t thread_get_exception_ports
(
thread_inspect_t thread,
thread_act_t thread,
exception_mask_t exception_mask,
exception_mask_array_t masks,
mach_msg_type_number_t *masksCnt,
@@ -402,7 +402,7 @@ extern
#endif /* mig_external */
kern_return_t thread_get_assignment
(
thread_act_t thread,
thread_inspect_t thread,
processor_set_name_t *assigned_set
);
@@ -433,7 +433,7 @@ __WATCHOS_PROHIBITED
__TVOS_PROHIBITED
kern_return_t thread_get_mach_voucher
(
thread_act_t thr_act,
thread_read_t thr_act,
mach_voucher_selector_t which,
ipc_voucher_t *voucher
);
@@ -467,6 +467,23 @@ kern_return_t thread_swap_mach_voucher
ipc_voucher_t *old_voucher
);
/* Routine thread_convert_thread_state */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t thread_convert_thread_state
(
thread_act_t thread,
int direction,
thread_state_flavor_t flavor,
thread_state_t in_state,
mach_msg_type_number_t in_stateCnt,
thread_state_t out_state,
mach_msg_type_number_t *out_stateCnt
);
__END_DECLS
/********************** Caution **************************/
@@ -516,7 +533,7 @@ __END_DECLS
NDR_record_t NDR;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[614];
natural_t new_state[1296];
} __Request__act_set_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
@@ -543,7 +560,7 @@ __END_DECLS
NDR_record_t NDR;
thread_state_flavor_t flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[614];
natural_t new_state[1296];
} __Request__thread_set_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
@@ -851,6 +868,22 @@ __END_DECLS
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int direction;
thread_state_flavor_t flavor;
mach_msg_type_number_t in_stateCnt;
natural_t in_state[1296];
mach_msg_type_number_t out_stateCnt;
} __Request__thread_convert_thread_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__thread_act_subsystem__defined */
/* union of all requests */
@@ -886,6 +919,7 @@ union __RequestUnion__thread_act_subsystem {
__Request__thread_get_mach_voucher_t Request_thread_get_mach_voucher;
__Request__thread_set_mach_voucher_t Request_thread_set_mach_voucher;
__Request__thread_swap_mach_voucher_t Request_thread_swap_mach_voucher;
__Request__thread_convert_thread_state_t Request_thread_convert_thread_state;
};
#endif /* !__RequestUnion__thread_act_subsystem__defined */
/* typedefs for all replies */
@@ -913,7 +947,7 @@ union __RequestUnion__thread_act_subsystem {
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[614];
natural_t old_state[1296];
} __Reply__act_get_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
@@ -939,7 +973,7 @@ union __RequestUnion__thread_act_subsystem {
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[614];
natural_t old_state[1296];
} __Reply__thread_get_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
@@ -1259,6 +1293,20 @@ union __RequestUnion__thread_act_subsystem {
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t out_stateCnt;
natural_t out_state[1296];
} __Reply__thread_convert_thread_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__thread_act_subsystem__defined */
/* union of all replies */
@@ -1294,6 +1342,7 @@ union __ReplyUnion__thread_act_subsystem {
__Reply__thread_get_mach_voucher_t Reply_thread_get_mach_voucher;
__Reply__thread_set_mach_voucher_t Reply_thread_set_mach_voucher;
__Reply__thread_swap_mach_voucher_t Reply_thread_swap_mach_voucher;
__Reply__thread_convert_thread_state_t Reply_thread_convert_thread_state;
};
#endif /* !__RequestUnion__thread_act_subsystem__defined */
@@ -1326,7 +1375,8 @@ union __ReplyUnion__thread_act_subsystem {
{ "thread_set_policy", 3624 },\
{ "thread_get_mach_voucher", 3625 },\
{ "thread_set_mach_voucher", 3626 },\
{ "thread_swap_mach_voucher", 3627 }
{ "thread_swap_mach_voucher", 3627 },\
{ "thread_convert_thread_state", 3628 }
#endif
#ifdef __AfterMigUserHeader

View File

@@ -67,8 +67,11 @@
#ifndef _MACH_THREAD_SPECIAL_PORTS_H_
#define _MACH_THREAD_SPECIAL_PORTS_H_
#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside
* world.*/
#define THREAD_KERNEL_PORT 1 /* The full thread port for thread. */
#define THREAD_INSPECT_PORT 2 /* The inspect port for thread. */
#define THREAD_READ_PORT 3 /* The read port for thread. */
/*
* Definitions for ease of use

View File

@@ -94,4 +94,7 @@ typedef natural_t thread_state_data_t[THREAD_STATE_MAX];
typedef int thread_state_flavor_t;
typedef thread_state_flavor_t *thread_state_flavor_array_t;
#define THREAD_CONVERT_THREAD_STATE_TO_SELF 1
#define THREAD_CONVERT_THREAD_STATE_FROM_SELF 2
#endif /* _MACH_THREAD_STATUS_H_ */

View File

@@ -149,4 +149,5 @@ typedef int vm_prot_t;
#define VM_PROT_STRIP_READ ((vm_prot_t) 0x80)
#define VM_PROT_EXECUTE_ONLY (VM_PROT_EXECUTE|VM_PROT_STRIP_READ)
#endif /* _MACH_VM_PROT_H_ */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
* Copyright (c) 2000-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@@ -66,8 +66,12 @@
#ifndef _MACH_VM_STATISTICS_H_
#define _MACH_VM_STATISTICS_H_
#include <mach/machine/vm_types.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <mach/machine/vm_types.h>
#include <mach/machine/kern_return.h>
/*
* vm_statistics
@@ -167,6 +171,8 @@ struct vm_statistics64 {
typedef struct vm_statistics64 *vm_statistics64_t;
typedef struct vm_statistics64 vm_statistics64_data_t;
kern_return_t vm_stats(void *info, unsigned int *count);
/*
* VM_STATISTICS_TRUNCATE_TO_32_BIT
*
@@ -352,6 +358,7 @@ enum virtual_memory_guard_exception_codes {
#define VM_MEMORY_MALLOC_NANO 11
#define VM_MEMORY_MALLOC_MEDIUM 12
#define VM_MEMORY_MALLOC_PGUARD 13
#define VM_MEMORY_MACH_MSG 20
#define VM_MEMORY_IOKIT 21
@@ -512,6 +519,22 @@ enum virtual_memory_guard_exception_codes {
/* memory allocated by CoreMedia for global image registration of frames */
#define VM_MEMORY_CM_REGWARP 101
/* memory allocated by EmbeddedAcousticRecognition for speech decoder */
#define VM_MEMORY_EAR_DECODER 102
/* CoreUI cached image data */
#define VM_MEMORY_COREUI_CACHED_IMAGE_DATA 103
/* Reserve 230-239 for Rosetta */
#define VM_MEMORY_ROSETTA 230
#define VM_MEMORY_ROSETTA_THREAD_CONTEXT 231
#define VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP 232
#define VM_MEMORY_ROSETTA_RETURN_STACK 233
#define VM_MEMORY_ROSETTA_EXECUTABLE_HEAP 234
#define VM_MEMORY_ROSETTA_USER_LDT 235
#define VM_MEMORY_ROSETTA_ARENA 236
#define VM_MEMORY_ROSETTA_10 239
/* Reserve 240-255 for application */
#define VM_MEMORY_APPLICATION_SPECIFIC_1 240
#define VM_MEMORY_APPLICATION_SPECIFIC_16 255
@@ -520,4 +543,8 @@ enum virtual_memory_guard_exception_codes {
#ifdef __cplusplus
}
#endif
#endif /* _MACH_VM_STATISTICS_H_ */

View File

@@ -70,10 +70,12 @@ typedef uint32_t ppnum_t; /* Physical page number */
typedef mach_port_t vm_map_t;
typedef mach_port_t vm_map_t, vm_map_read_t, vm_map_inspect_t;
#define VM_MAP_NULL ((vm_map_t) 0)
#define VM_MAP_INSPECT_NULL ((vm_map_inspect_t) 0)
#define VM_MAP_READ_NULL ((vm_map_read_t) 0)
/*
* Evolving definitions, likely to change.

View File

@@ -27,6 +27,8 @@
*/
#if defined (__i386__) || defined (__x86_64__)
#include "i386/_mcontext.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/_mcontext.h"
#else
#error architecture not supported
#endif

View File

@@ -26,7 +26,9 @@
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#if defined (__i386__) || defined (__x86_64__)
#include "i386/_param.h"
#include <i386/_param.h>
#elif defined (__arm__) || defined (__arm64__)
#include <arm/_param.h>
#else
#error architecture not supported
#endif

View File

@@ -30,6 +30,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "i386/_types.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/_types.h"
#else
#error architecture not supported
#endif

View File

@@ -33,6 +33,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "i386/endian.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/endian.h"
#else
#error architecture not supported
#endif

View File

@@ -4,6 +4,8 @@
* This file is public domain. */
#if defined (__i386__) || defined(__x86_64__)
#include <i386/limits.h>
#elif defined (__arm__) || defined (__arm64__)
#include <arm/limits.h>
#else
#error architecture not supported
#endif

View File

@@ -32,7 +32,9 @@
#define _BSD_MACHINE_PARAM_H_
#if defined (__i386__) || defined(__x86_64__)
#include "i386/param.h"
#include <i386/param.h>
#elif defined (__arm__) || defined (__arm64__)
#include <arm/param.h>
#else
#error architecture not supported
#endif

View File

@@ -30,6 +30,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "i386/signal.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/signal.h"
#else
#error architecture not supported
#endif

View File

@@ -33,6 +33,8 @@
#if defined (__i386__) || defined(__x86_64__)
#include "i386/types.h"
#elif defined (__arm__) || defined (__arm64__)
#include "arm/types.h"
#else
#error architecture not supported
#endif

View File

@@ -44,9 +44,9 @@ void *realloc(void *__ptr, size_t __size) __result_use_check __alloc_size(2);
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
void *valloc(size_t) __alloc_size(1);
#endif // !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) && \
((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L))
#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__cplusplus) && __cplusplus >= 201703L)
void *aligned_alloc(size_t __alignment, size_t __size) __result_use_check __alloc_size(2) __OSX_AVAILABLE(10.15) __IOS_AVAILABLE(13.0) __TVOS_AVAILABLE(13.0) __WATCHOS_AVAILABLE(6.0);
#endif
int posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);

View File

@@ -547,6 +547,7 @@ extern long double fmal(long double, long double, long double);
#define islessgreater(x, y) __builtin_islessgreater((x),(y))
#define isunordered(x, y) __builtin_isunordered((x),(y))
#if defined __i386__ || defined __x86_64__
/* Deprecated functions; use the INFINITY and NAN macros instead. */
extern float __inff(void)
__API_DEPRECATED("use `(float)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
@@ -556,6 +557,7 @@ extern long double __infl(void)
__API_DEPRECATED("use `(long double)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
extern float __nan(void)
__API_DEPRECATED("use `NAN` instead", macos(10.0, 10.14)) __API_UNAVAILABLE(ios, watchos, tvos);
#endif
/******************************************************************************
* Reentrant variants of lgamma[fl] *
@@ -736,6 +738,7 @@ extern int signgam;
#define TLOSS 5
#define PLOSS 6
#if defined __i386__ || defined __x86_64__
/* Legacy BSD API; use the C99 `lrint( )` function instead. */
extern long int rinttol(double)
__API_DEPRECATED_WITH_REPLACEMENT("lrint", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
@@ -754,6 +757,7 @@ __API_DEPRECATED_WITH_REPLACEMENT("tgamma", macos(10.0, 10.9)) __API_UNAVAILABLE
/* Legacy BSD API; use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead. */
extern double significand(double)
__API_DEPRECATED("Use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos);
#endif
#if !defined __cplusplus
struct exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
* Copyright (c) 2000-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
* Copyright (c) 2000-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@@ -70,6 +70,7 @@
#include <sys/time.h>
#include <sys/queue.h> /* get TAILQ macros */
#ifdef BSD_KERN_PRIVATE
#include <net/pktsched/pktsched.h>
#include <sys/eventhandler.h>
#endif

View File

@@ -63,14 +63,14 @@
#ifndef _NETINET_IN_H_
#define _NETINET_IN_H_
#include <sys/appleapiopts.h>
#include <sys/_types.h>
#include <stdint.h> /* uint(8|16|32)_t */
#include <Availability.h>
#include <sys/_types/_in_addr_t.h>
#include <sys/_types/_in_addr_t.h>
#include <sys/_types/_in_port_t.h>
/*
@@ -435,6 +435,7 @@ struct ip_opts {
#define IP_PKTINFO 26 /* get pktinfo on recv socket, set src on sent dgram */
#define IP_RECVPKTINFO IP_PKTINFO /* receive pktinfo w/dgram */
#define IP_RECVTOS 27 /* bool; receive IP TOS w/dgram */
#define IP_DONTFRAG 28 /* don't fragment packet */
#define IP_FW_ADD 40 /* add a firewall rule to chain */
#define IP_FW_DEL 41 /* delete a firewall rule from chain */

View File

@@ -63,11 +63,13 @@
#ifndef _NETINET_TCP_H_
#define _NETINET_TCP_H_
#include <sys/types.h>
#include <sys/appleapiopts.h>
#include <machine/endian.h>
#include <machine/types.h> /* __uint32_t */
#include <sys/types.h>
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
typedef __uint32_t tcp_seq;
typedef __uint32_t tcp_cc; /* connection count per rfc1644 */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2018 Apple Inc. All rights reserved.
* Copyright (c) 2008-2020 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
@@ -98,6 +98,7 @@
#ifndef _NETINET6_IN6_H_
#define _NETINET6_IN6_H_
#include <sys/appleapiopts.h>
#include <sys/_types.h>
#include <sys/_types/_sa_family_t.h>
@@ -178,6 +179,7 @@ struct sockaddr_in6 {
/*
* Definition of some useful macros to handle IP6 addresses
*/
@@ -206,6 +208,7 @@ struct sockaddr_in6 {
#define IN6ADDR_V4MAPPED_INIT \
{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
#define IN6ADDR_MULTICAST_PREFIX IN6MASK8
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
extern const struct in6_addr in6addr_any;
@@ -297,6 +300,16 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
*/
#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
#define IPV6_ADDR_MC_FLAGS(a) ((a)->s6_addr[1] & 0xf0)
#define IPV6_ADDR_MC_FLAGS_TRANSIENT 0x10
#define IPV6_ADDR_MC_FLAGS_PREFIX 0x20
#define IPV6_ADDR_MC_FLAGS_UNICAST_BASED (IPV6_ADDR_MC_FLAGS_TRANSIENT | IPV6_ADDR_MC_FLAGS_PREFIX)
#define IN6_IS_ADDR_UNICAST_BASED_MULTICAST(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(IPV6_ADDR_MC_FLAGS(a) == IPV6_ADDR_MC_FLAGS_UNICAST_BASED))
/*
* Unique Local IPv6 Unicast Addresses (per RFC 4193)
*/
@@ -311,8 +324,9 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(IPV6_ADDR_MC_FLAGS(a) != IPV6_ADDR_MC_FLAGS_UNICAST_BASED) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
@@ -369,9 +383,9 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
#define IPV6_MULTICAST_IF 9 /* __uint8_t; set/get IP6 multicast i/f */
#define IPV6_MULTICAST_HOPS 10 /* __uint8_t; set/get IP6 multicast hops */
#define IPV6_MULTICAST_LOOP 11 /* __uint8_t; set/get IP6 mcast loopback */
#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */
#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */
#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 mcast loopback */
#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
@@ -663,5 +677,5 @@ extern int inet6_rth_segments(const void *);
extern struct in6_addr *inet6_rth_getaddr(const void *, int);
__END_DECLS
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
#endif /* PLATFORM_DriverKit */
#endif /* !_NETINET6_IN6_H_ */

View File

@@ -0,0 +1,33 @@
/* NSObjCRuntime.h
Copyright (c) 1994-2012, Apple Inc. All rights reserved.
*/
#ifndef _OBJC_NSOBJCRUNTIME_H_
#define _OBJC_NSOBJCRUNTIME_H_
#include <TargetConditionals.h>
#include <objc/objc.h>
#if __LP64__ || 0 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
#define NSIntegerMax LONG_MAX
#define NSIntegerMin LONG_MIN
#define NSUIntegerMax ULONG_MAX
#define NSINTEGER_DEFINED 1
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
#endif

View File

@@ -0,0 +1,112 @@
/* NSObject.h
Copyright (c) 1994-2012, Apple Inc. All rights reserved.
*/
#ifndef _OBJC_NSOBJECT_H_
#define _OBJC_NSOBJECT_H_
#if __OBJC__
#include <objc/objc.h>
#include <objc/NSObjCRuntime.h>
@class NSString, NSMethodSignature, NSInvocation;
@protocol NSObject
- (BOOL)isEqual:(id)object;
@property (readonly) NSUInteger hash;
@property (readonly) Class superclass;
- (Class)class OBJC_SWIFT_UNAVAILABLE("use 'type(of: anObject)' instead");
- (instancetype)self;
- (id)performSelector:(SEL)aSelector;
- (id)performSelector:(SEL)aSelector withObject:(id)object;
- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
- (BOOL)isProxy;
- (BOOL)isKindOfClass:(Class)aClass;
- (BOOL)isMemberOfClass:(Class)aClass;
- (BOOL)conformsToProtocol:(Protocol *)aProtocol;
- (BOOL)respondsToSelector:(SEL)aSelector;
- (instancetype)retain OBJC_ARC_UNAVAILABLE;
- (oneway void)release OBJC_ARC_UNAVAILABLE;
- (instancetype)autorelease OBJC_ARC_UNAVAILABLE;
- (NSUInteger)retainCount OBJC_ARC_UNAVAILABLE;
- (struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
@property (readonly, copy) NSString *description;
@optional
@property (readonly, copy) NSString *debugDescription;
@end
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0)
OBJC_ROOT_CLASS
OBJC_EXPORT
@interface NSObject <NSObject> {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-interface-ivars"
Class isa OBJC_ISA_AVAILABILITY;
#pragma clang diagnostic pop
}
+ (void)load;
+ (void)initialize;
- (instancetype)init
#if NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER
NS_DESIGNATED_INITIALIZER
#endif
;
+ (instancetype)new OBJC_SWIFT_UNAVAILABLE("use object initializers instead");
+ (instancetype)allocWithZone:(struct _NSZone *)zone OBJC_SWIFT_UNAVAILABLE("use object initializers instead");
+ (instancetype)alloc OBJC_SWIFT_UNAVAILABLE("use object initializers instead");
- (void)dealloc OBJC_SWIFT_UNAVAILABLE("use 'deinit' to define a de-initializer");
- (void)finalize OBJC_DEPRECATED("Objective-C garbage collection is no longer supported");
- (id)copy;
- (id)mutableCopy;
+ (id)copyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
+ (id)mutableCopyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
+ (BOOL)instancesRespondToSelector:(SEL)aSelector;
+ (BOOL)conformsToProtocol:(Protocol *)protocol;
- (IMP)methodForSelector:(SEL)aSelector;
+ (IMP)instanceMethodForSelector:(SEL)aSelector;
- (void)doesNotRecognizeSelector:(SEL)aSelector;
- (id)forwardingTargetForSelector:(SEL)aSelector OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
- (void)forwardInvocation:(NSInvocation *)anInvocation OBJC_SWIFT_UNAVAILABLE("");
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector OBJC_SWIFT_UNAVAILABLE("");
+ (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)aSelector OBJC_SWIFT_UNAVAILABLE("");
- (BOOL)allowsWeakReference UNAVAILABLE_ATTRIBUTE;
- (BOOL)retainWeakReference UNAVAILABLE_ATTRIBUTE;
+ (BOOL)isSubclassOfClass:(Class)aClass;
+ (BOOL)resolveClassMethod:(SEL)sel OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
+ (BOOL)resolveInstanceMethod:(SEL)sel OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
+ (NSUInteger)hash;
+ (Class)superclass;
+ (Class)class OBJC_SWIFT_UNAVAILABLE("use 'aClass.self' instead");
+ (NSString *)description;
+ (NSString *)debugDescription;
@end
#endif
#endif

View File

@@ -0,0 +1,286 @@
/*
* Copyright (c) 1999-2006 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
// Copyright 1988-1996 NeXT Software, Inc.
#ifndef _OBJC_OBJC_API_H_
#define _OBJC_OBJC_API_H_
#include <Availability.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
#include <sys/types.h>
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#ifndef __has_extension
# define __has_extension __has_feature
#endif
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
#if !__has_feature(nullability)
# ifndef _Nullable
# define _Nullable
# endif
# ifndef _Nonnull
# define _Nonnull
# endif
# ifndef _Null_unspecified
# define _Null_unspecified
# endif
#endif
/*
* OBJC_API_VERSION 0 or undef: Tiger and earlier API only
* OBJC_API_VERSION 2: Leopard and later API available
*/
#if !defined(OBJC_API_VERSION)
# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5
# define OBJC_API_VERSION 0
# else
# define OBJC_API_VERSION 2
# endif
#endif
/*
* OBJC_NO_GC 1: GC is not supported
* OBJC_NO_GC undef: GC is supported. This SDK no longer supports this mode.
*
* OBJC_NO_GC_API undef: Libraries must export any symbols that
* dual-mode code may links to.
* OBJC_NO_GC_API 1: Libraries need not export GC-related symbols.
*/
#if defined(__OBJC_GC__)
# error Objective-C garbage collection is not supported.
#elif TARGET_OS_OSX
/* GC is unsupported. GC API symbols are exported. */
# define OBJC_NO_GC 1
# undef OBJC_NO_GC_API
#else
/* GC is unsupported. GC API symbols are not exported. */
# define OBJC_NO_GC 1
# define OBJC_NO_GC_API 1
#endif
/* NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER == 1
* marks -[NSObject init] as a designated initializer. */
#if !defined(NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER)
# define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1
#endif
/* The arm64 ABI requires proper casting to ensure arguments are passed
* * correctly. */
#if defined(__arm64__) && !__swift__
# undef OBJC_OLD_DISPATCH_PROTOTYPES
# define OBJC_OLD_DISPATCH_PROTOTYPES 0
#endif
/* OBJC_OLD_DISPATCH_PROTOTYPES == 0 enforces the rule that the dispatch
* functions must be cast to an appropriate function pointer type. */
#if !defined(OBJC_OLD_DISPATCH_PROTOTYPES)
# if __swift__
// Existing Swift code expects IMP to be Comparable.
// Variadic IMP is comparable via OpaquePointer; non-variadic IMP isn't.
# define OBJC_OLD_DISPATCH_PROTOTYPES 1
# else
# define OBJC_OLD_DISPATCH_PROTOTYPES 0
# endif
#endif
/* OBJC_AVAILABLE: shorthand for all-OS availability */
# if !defined(OBJC_AVAILABLE)
# define OBJC_AVAILABLE(x, i, t, w, b) \
__OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \
__WATCHOS_AVAILABLE(w)
# endif
/* OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE: Deprecated on OS X,
* unavailable everywhere else. */
# if !defined(OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE)
# define OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(_start, _dep, _msg) \
__OSX_DEPRECATED(_start, _dep, _msg) \
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
__WATCHOS_UNAVAILABLE
# endif
/* OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE: Available on OS X,
* unavailable everywhere else. */
# if !defined(OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE)
# define OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(vers) \
__OSX_AVAILABLE(vers) \
__IOS_UNAVAILABLE __TVOS_UNAVAILABLE \
__WATCHOS_UNAVAILABLE
# endif
/* OBJC_ISA_AVAILABILITY: `isa` will be deprecated or unavailable
* in the future */
#if !defined(OBJC_ISA_AVAILABILITY)
# if __OBJC2__
# define OBJC_ISA_AVAILABILITY __attribute__((deprecated))
# else
# define OBJC_ISA_AVAILABILITY /* still available */
# endif
#endif
/* OBJC2_UNAVAILABLE: unavailable in objc 2.0, deprecated in Leopard */
#if !defined(OBJC2_UNAVAILABLE)
# if __OBJC2__
# define OBJC2_UNAVAILABLE UNAVAILABLE_ATTRIBUTE
# else
/* plain C code also falls here, but this is close enough */
# define OBJC2_UNAVAILABLE \
__OSX_DEPRECATED(10.5, 10.5, "not available in __OBJC2__") \
__IOS_DEPRECATED(2.0, 2.0, "not available in __OBJC2__") \
__TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
# endif
#endif
/* OBJC_UNAVAILABLE: unavailable, with a message where supported */
#if !defined(OBJC_UNAVAILABLE)
# if __has_extension(attribute_unavailable_with_message)
# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable(_msg)))
# else
# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable))
# endif
#endif
/* OBJC_DEPRECATED: deprecated, with a message where supported */
#if !defined(OBJC_DEPRECATED)
# if __has_extension(attribute_deprecated_with_message)
# define OBJC_DEPRECATED(_msg) __attribute__((deprecated(_msg)))
# else
# define OBJC_DEPRECATED(_msg) __attribute__((deprecated))
# endif
#endif
/* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */
#if !defined(OBJC_ARC_UNAVAILABLE)
# if __has_feature(objc_arc)
# define OBJC_ARC_UNAVAILABLE OBJC_UNAVAILABLE("not available in automatic reference counting mode")
# else
# define OBJC_ARC_UNAVAILABLE
# endif
#endif
/* OBJC_SWIFT_UNAVAILABLE: unavailable in Swift */
#if !defined(OBJC_SWIFT_UNAVAILABLE)
# if __has_feature(attribute_availability_swift)
# define OBJC_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg)))
# else
# define OBJC_SWIFT_UNAVAILABLE(_msg)
# endif
#endif
/* OBJC_ARM64_UNAVAILABLE: unavailable on arm64 (i.e. stret dispatch) */
#if !defined(OBJC_ARM64_UNAVAILABLE)
# if defined(__arm64__)
# define OBJC_ARM64_UNAVAILABLE OBJC_UNAVAILABLE("not available in arm64")
# else
# define OBJC_ARM64_UNAVAILABLE
# endif
#endif
/* OBJC_GC_UNAVAILABLE: unavailable with -fobjc-gc or -fobjc-gc-only */
#if !defined(OBJC_GC_UNAVAILABLE)
# define OBJC_GC_UNAVAILABLE
#endif
#if !defined(OBJC_EXTERN)
# if defined(__cplusplus)
# define OBJC_EXTERN extern "C"
# else
# define OBJC_EXTERN extern
# endif
#endif
#if !defined(OBJC_VISIBLE)
# define OBJC_VISIBLE __attribute__((visibility("default")))
#endif
#if !defined(OBJC_EXPORT)
# define OBJC_EXPORT OBJC_EXTERN OBJC_VISIBLE
#endif
#if !defined(OBJC_IMPORT)
# define OBJC_IMPORT extern
#endif
#if !defined(OBJC_ROOT_CLASS)
# if __has_attribute(objc_root_class)
# define OBJC_ROOT_CLASS __attribute__((objc_root_class))
# else
# define OBJC_ROOT_CLASS
# endif
#endif
#ifndef __DARWIN_NULL
#define __DARWIN_NULL NULL
#endif
#if !defined(OBJC_INLINE)
# define OBJC_INLINE __inline
#endif
// Declares an enum type or option bits type as appropriate for each language.
#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
#define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
#if (__cplusplus)
#define OBJC_OPTIONS(_type, _name) _type _name; enum : _type
#else
#define OBJC_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
#endif
#else
#define OBJC_ENUM(_type, _name) _type _name; enum
#define OBJC_OPTIONS(_type, _name) _type _name; enum
#endif
#if !defined(OBJC_RETURNS_RETAINED)
# if __OBJC__ && __has_attribute(ns_returns_retained)
# define OBJC_RETURNS_RETAINED __attribute__((ns_returns_retained))
# else
# define OBJC_RETURNS_RETAINED
# endif
#endif
#endif

View File

@@ -0,0 +1,259 @@
/*
* Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* objc.h
* Copyright 1988-1996, NeXT Software, Inc.
*/
#ifndef _OBJC_OBJC_H_
#define _OBJC_OBJC_H_
#include <sys/types.h> // for __DARWIN_NULL
#include <Availability.h>
#include <objc/objc-api.h>
#include <stdbool.h>
#if !OBJC_TYPES_DEFINED
/// An opaque type that represents an Objective-C class.
typedef struct objc_class *Class;
/// Represents an instance of a class.
struct objc_object {
Class _Nonnull isa OBJC_ISA_AVAILABILITY;
};
/// A pointer to an instance of a class.
typedef struct objc_object *id;
#endif
/// An opaque type that represents a method selector.
typedef struct objc_selector *SEL;
/// A pointer to the function of a method implementation.
#if !OBJC_OLD_DISPATCH_PROTOTYPES
typedef void (*IMP)(void /* id, SEL, ... */ );
#else
typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...);
#endif
/// Type to represent a boolean value.
#if defined(__OBJC_BOOL_IS_BOOL)
// Honor __OBJC_BOOL_IS_BOOL when available.
# if __OBJC_BOOL_IS_BOOL
# define OBJC_BOOL_IS_BOOL 1
# else
# define OBJC_BOOL_IS_BOOL 0
# endif
#else
// __OBJC_BOOL_IS_BOOL not set.
# if TARGET_OS_OSX || TARGET_OS_MACCATALYST || ((TARGET_OS_IOS || 0) && !__LP64__ && !__ARM_ARCH_7K)
# define OBJC_BOOL_IS_BOOL 0
# else
# define OBJC_BOOL_IS_BOOL 1
# endif
#endif
#if OBJC_BOOL_IS_BOOL
typedef bool BOOL;
#else
# define OBJC_BOOL_IS_CHAR 1
typedef signed char BOOL;
// BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
// even if -funsigned-char is used.
#endif
#define OBJC_BOOL_DEFINED
#if __has_feature(objc_bool)
#define YES __objc_yes
#define NO __objc_no
#else
#define YES ((BOOL)1)
#define NO ((BOOL)0)
#endif
#ifndef Nil
# if __has_feature(cxx_nullptr)
# define Nil nullptr
# else
# define Nil __DARWIN_NULL
# endif
#endif
#ifndef nil
# if __has_feature(cxx_nullptr)
# define nil nullptr
# else
# define nil __DARWIN_NULL
# endif
#endif
#ifndef __strong
# if !__has_feature(objc_arc)
# define __strong /* empty */
# endif
#endif
#ifndef __unsafe_unretained
# if !__has_feature(objc_arc)
# define __unsafe_unretained /* empty */
# endif
#endif
#ifndef __autoreleasing
# if !__has_feature(objc_arc)
# define __autoreleasing /* empty */
# endif
#endif
/**
* Returns the name of the method specified by a given selector.
*
* @param sel A pointer of type \c SEL. Pass the selector whose name you wish to determine.
*
* @return A C string indicating the name of the selector.
*/
OBJC_EXPORT const char * _Nonnull sel_getName(SEL _Nonnull sel)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Registers a method with the Objective-C runtime system, maps the method
* name to a selector, and returns the selector value.
*
* @param str A pointer to a C string. Pass the name of the method you wish to register.
*
* @return A pointer of type SEL specifying the selector for the named method.
*
* @note You must register a method name with the Objective-C runtime system to obtain the
* methods selector before you can add the method to a class definition. If the method name
* has already been registered, this function simply returns the selector.
*/
OBJC_EXPORT SEL _Nonnull sel_registerName(const char * _Nonnull str)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Returns the class name of a given object.
*
* @param obj An Objective-C object.
*
* @return The name of the class of which \e obj is an instance.
*/
OBJC_EXPORT const char * _Nonnull object_getClassName(id _Nullable obj)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Returns a pointer to any extra bytes allocated with an instance given object.
*
* @param obj An Objective-C object.
*
* @return A pointer to any extra bytes allocated with \e obj. If \e obj was
* not allocated with any extra bytes, then dereferencing the returned pointer is undefined.
*
* @note This function returns a pointer to any extra bytes allocated with the instance
* (as specified by \c class_createInstance with extraBytes>0). This memory follows the
* object's ordinary ivars, but may not be adjacent to the last ivar.
* @note The returned pointer is guaranteed to be pointer-size aligned, even if the area following
* the object's last ivar is less aligned than that. Alignment greater than pointer-size is never
* guaranteed, even if the area following the object's last ivar is more aligned than that.
* @note In a garbage-collected environment, the memory is scanned conservatively.
*/
OBJC_EXPORT void * _Nullable object_getIndexedIvars(id _Nullable obj)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Identifies a selector as being valid or invalid.
*
* @param sel The selector you want to identify.
*
* @return YES if selector is valid and has a function implementation, NO otherwise.
*
* @warning On some platforms, an invalid reference (to invalid memory addresses) can cause
* a crash.
*/
OBJC_EXPORT BOOL sel_isMapped(SEL _Nonnull sel)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
/**
* Registers a method name with the Objective-C runtime system.
*
* @param str A pointer to a C string. Pass the name of the method you wish to register.
*
* @return A pointer of type SEL specifying the selector for the named method.
*
* @note The implementation of this method is identical to the implementation of \c sel_registerName.
* @note Prior to OS X version 10.0, this method tried to find the selector mapped to the given name
* and returned \c NULL if the selector was not found. This was changed for safety, because it was
* observed that many of the callers of this function did not check the return value for \c NULL.
*/
OBJC_EXPORT SEL _Nonnull sel_getUid(const char * _Nonnull str)
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
typedef const void* objc_objectptr_t;
// Obsolete ARC conversions.
OBJC_EXPORT id _Nullable objc_retainedObject(objc_objectptr_t _Nullable obj)
#if !OBJC_DECLARE_SYMBOLS
OBJC_UNAVAILABLE("use CFBridgingRelease() or a (__bridge_transfer id) cast instead")
#endif
;
OBJC_EXPORT id _Nullable objc_unretainedObject(objc_objectptr_t _Nullable obj)
#if !OBJC_DECLARE_SYMBOLS
OBJC_UNAVAILABLE("use a (__bridge id) cast instead")
#endif
;
OBJC_EXPORT objc_objectptr_t _Nullable objc_unretainedPointer(id _Nullable obj)
#if !OBJC_DECLARE_SYMBOLS
OBJC_UNAVAILABLE("use a __bridge cast instead")
#endif
;
#if !__OBJC2__
// The following declarations are provided here for source compatibility.
#if defined(__LP64__)
typedef long arith_t;
typedef unsigned long uarith_t;
# define ARITH_SHIFT 32
#else
typedef int arith_t;
typedef unsigned uarith_t;
# define ARITH_SHIFT 16
#endif
typedef char *STR;
#define ISSELECTOR(sel) sel_isMapped(sel)
#define SELNAME(sel) sel_getName(sel)
#define SELUID(str) sel_getUid(str)
#define NAMEOF(obj) object_getClassName(obj)
#define IV(obj) object_getIndexedIvars(obj)
#endif
#endif /* _OBJC_OBJC_H_ */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2013 Apple Inc. All rights reserved.
* Copyright (c) 2008-2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
@@ -23,6 +23,7 @@
#include <sys/cdefs.h>
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
@@ -73,7 +74,7 @@
#define OS_ALWAYS_INLINE __attribute__((__always_inline__))
#define OS_TRANSPARENT_UNION __attribute__((__transparent_union__))
#define OS_ALIGNED(n) __attribute__((__aligned__((n))))
#define OS_FORMAT_PRINTF(x,y) __attribute__((__format__(printf,x,y)))
#define OS_FORMAT_PRINTF(x, y) __attribute__((__format__(printf,x,y)))
#define OS_EXPORT extern __attribute__((__visibility__("default")))
#define OS_INLINE static __inline__
#define OS_EXPECT(x, v) __builtin_expect((x), (v))
@@ -110,7 +111,7 @@
#define OS_ALWAYS_INLINE
#define OS_TRANSPARENT_UNION
#define OS_ALIGNED(n)
#define OS_FORMAT_PRINTF(x,y)
#define OS_FORMAT_PRINTF(x, y)
#define OS_EXPORT extern
#define OS_INLINE static inline
#define OS_EXPECT(x, v) (x)
@@ -124,6 +125,8 @@
#if defined(__cplusplus) && defined(__clang__)
#define OS_FALLTHROUGH [[clang::fallthrough]]
#elif __has_attribute(fallthrough)
#define OS_FALLTHROUGH __attribute__((__fallthrough__))
#else
#define OS_FALLTHROUGH
#endif
@@ -164,30 +167,21 @@
* -Wassign-enum prevents you from assigning illegal values to a variable of the
* enum type.
*/
#ifndef __OPEN_SOURCE__
/*!
* @internal
* <rdar://problem/37799789>
*/
#endif // __OPEN_SOURCE__
#define __OS_OPTIONS_ATTR __attribute__((flag_enum))
#else
#define __OS_OPTIONS_ATTR
#endif // __has_attribute(flag_enum)
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \
__has_extension(cxx_strong_enums)
__has_extension(cxx_strong_enums)
#define OS_ENUM(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } _name##_t
typedef enum : _type { __VA_ARGS__ } _name##_t
#define OS_CLOSED_ENUM(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } \
__OS_ENUM_ATTR_CLOSED _name##_t
typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED _name##_t
#define OS_OPTIONS(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } \
__OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t
typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR __OS_OPTIONS_ATTR _name##_t
#define OS_CLOSED_OPTIONS(_name, _type, ...) \
typedef enum : _type { __VA_ARGS__ } \
__OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t
typedef enum : _type { __VA_ARGS__ } __OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR _name##_t
#else
/*!
* There is unfortunately no good way in plain C to have both fixed-type enums
@@ -220,25 +214,25 @@
* When compiling in ObjC or C++, both of the above assignments are illegal.
*/
#define __OS_ENUM_C_FALLBACK(_name, _type, ...) \
typedef _type _name##_t; enum _name { __VA_ARGS__ }
typedef _type _name##_t; enum _name { __VA_ARGS__ }
#define OS_ENUM(_name, _type, ...) \
typedef _type _name##_t; enum { __VA_ARGS__ }
typedef _type _name##_t; enum { __VA_ARGS__ }
#define OS_CLOSED_ENUM(_name, _type, ...) \
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR_CLOSED
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR_CLOSED
#define OS_OPTIONS(_name, _type, ...) \
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR __OS_OPTIONS_ATTR
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR __OS_OPTIONS_ATTR
#define OS_CLOSED_OPTIONS(_name, _type, ...) \
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR
__OS_ENUM_C_FALLBACK(_name, _type, ## __VA_ARGS__) \
__OS_ENUM_ATTR_CLOSED __OS_OPTIONS_ATTR
#endif // __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
#if __has_feature(attribute_availability_swift)
// equivalent to __SWIFT_UNAVAILABLE from Availability.h
#define OS_SWIFT_UNAVAILABLE(_msg) \
__attribute__((__availability__(swift, unavailable, message=_msg)))
__attribute__((__availability__(swift, unavailable, message=_msg)))
#else
#define OS_SWIFT_UNAVAILABLE(_msg)
#endif
@@ -262,12 +256,12 @@
#ifdef __GNUC__
#define os_prevent_tail_call_optimization() __asm__("")
#define os_is_compile_time_constant(expr) __builtin_constant_p(expr)
#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory")
#define os_is_compile_time_constant(expr) __builtin_constant_p(expr)
#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory")
#else
#define os_prevent_tail_call_optimization() do { } while (0)
#define os_is_compile_time_constant(expr) 0
#define os_compiler_barrier() do { } while (0)
#define os_is_compile_time_constant(expr) 0
#define os_compiler_barrier() do { } while (0)
#endif
#if __has_attribute(not_tail_called)
@@ -276,6 +270,7 @@
#define OS_NOT_TAIL_CALLED
#endif
typedef void (*os_function_t)(void *_Nullable);
#ifdef __BLOCKS__
@@ -322,4 +317,6 @@ typedef void (*os_function_t)(void *_Nullable);
typedef void (^os_block_t)(void);
#endif
#endif // __OS_BASE__

View File

@@ -0,0 +1,18 @@
#ifndef __OS_CLOCK__
#define __OS_CLOCK__
#include <os/base.h>
#include <stdint.h>
/*
* @typedef os_clockid_t
*
* @abstract
* Describes the kind of clock that the workgroup timestamp parameters are
* specified in
*/
OS_ENUM(os_clockid, uint32_t,
OS_CLOCK_MACH_ABSOLUTE_TIME = 32,
);
#endif /* __OS_CLOCK__ */

View File

@@ -0,0 +1,189 @@
/*
* Copyright (c) 2016 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_LOCK__
#define __OS_LOCK__
#include <Availability.h>
#include <sys/cdefs.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <os/base.h>
OS_ASSUME_NONNULL_BEGIN
/*! @header
* Low-level lock API.
*/
#define OS_LOCK_API_VERSION 20160309
__BEGIN_DECLS
#define OS_UNFAIR_LOCK_AVAILABILITY \
__API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
/*!
* @typedef os_unfair_lock
*
* @abstract
* Low-level lock that allows waiters to block efficiently on contention.
*
* In general, higher level synchronization primitives such as those provided by
* the pthread or dispatch subsystems should be preferred.
*
* The values stored in the lock should be considered opaque and implementation
* defined, they contain thread ownership information that the system may use
* to attempt to resolve priority inversions.
*
* This lock must be unlocked from the same thread that locked it, attempts to
* unlock from a different thread will cause an assertion aborting the process.
*
* This lock must not be accessed from multiple processes or threads via shared
* or multiply-mapped memory, the lock implementation relies on the address of
* the lock value and owning process.
*
* Must be initialized with OS_UNFAIR_LOCK_INIT
*
* @discussion
* Replacement for the deprecated OSSpinLock. Does not spin on contention but
* waits in the kernel to be woken up by an unlock.
*
* As with OSSpinLock there is no attempt at fairness or lock ordering, e.g. an
* unlocker can potentially immediately reacquire the lock before a woken up
* waiter gets an opportunity to attempt to acquire the lock. This may be
* advantageous for performance reasons, but also makes starvation of waiters a
* possibility.
*/
OS_UNFAIR_LOCK_AVAILABILITY
typedef struct os_unfair_lock_s {
uint32_t _os_unfair_lock_opaque;
} os_unfair_lock, *os_unfair_lock_t;
#ifndef OS_UNFAIR_LOCK_INIT
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define OS_UNFAIR_LOCK_INIT ((os_unfair_lock){0})
#elif defined(__cplusplus) && __cplusplus >= 201103L
#define OS_UNFAIR_LOCK_INIT (os_unfair_lock{})
#elif defined(__cplusplus)
#define OS_UNFAIR_LOCK_INIT (os_unfair_lock())
#else
#define OS_UNFAIR_LOCK_INIT {0}
#endif
#endif // OS_UNFAIR_LOCK_INIT
/*!
* @function os_unfair_lock_lock
*
* @abstract
* Locks an os_unfair_lock.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_lock(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_trylock
*
* @abstract
* Locks an os_unfair_lock if it is not already locked.
*
* @discussion
* It is invalid to surround this function with a retry loop, if this function
* returns false, the program must be able to proceed without having acquired
* the lock, or it must call os_unfair_lock_lock() directly (a retry loop around
* os_unfair_lock_trylock() amounts to an inefficient implementation of
* os_unfair_lock_lock() that hides the lock waiter from the system and prevents
* resolution of priority inversions).
*
* @param lock
* Pointer to an os_unfair_lock.
*
* @result
* Returns true if the lock was succesfully locked and false if the lock was
* already locked.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NONNULL_ALL
bool os_unfair_lock_trylock(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_unlock
*
* @abstract
* Unlocks an os_unfair_lock.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_unlock(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_assert_owner
*
* @abstract
* Asserts that the calling thread is the current owner of the specified
* unfair lock.
*
* @discussion
* If the lock is currently owned by the calling thread, this function returns.
*
* If the lock is unlocked or owned by a different thread, this function
* asserts and terminates the process.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_assert_owner(os_unfair_lock_t lock);
/*!
* @function os_unfair_lock_assert_not_owner
*
* @abstract
* Asserts that the calling thread is not the current owner of the specified
* unfair lock.
*
* @discussion
* If the lock is unlocked or owned by a different thread, this function
* returns.
*
* If the lock is currently owned by the current thread, this function asserts
* and terminates the process.
*
* @param lock
* Pointer to an os_unfair_lock.
*/
OS_UNFAIR_LOCK_AVAILABILITY
OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
void os_unfair_lock_assert_not_owner(os_unfair_lock_t lock);
__END_DECLS
OS_ASSUME_NONNULL_END
#endif // __OS_LOCK__

View File

@@ -0,0 +1,303 @@
/*
* Copyright (c) 2011-2014 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_OBJECT__
#define __OS_OBJECT__
#ifdef __APPLE__
#include <Availability.h>
#include <os/availability.h>
#include <TargetConditionals.h>
#include <os/base.h>
#elif defined(_WIN32)
#include <os/generic_win_base.h>
#elif defined(__unix__)
#include <os/generic_unix_base.h>
#endif
/*!
* @header
*
* @preprocinfo
* By default, libSystem objects such as GCD and XPC objects are declared as
* Objective-C types when building with an Objective-C compiler. This allows
* them to participate in ARC, in RR management by the Blocks runtime and in
* leaks checking by the static analyzer, and enables them to be added to Cocoa
* collections.
*
* NOTE: this requires explicit cancellation of dispatch sources and xpc
* connections whose handler blocks capture the source/connection object,
* resp. ensuring that such captures do not form retain cycles (e.g. by
* declaring the source as __weak).
*
* To opt-out of this default behavior, add -DOS_OBJECT_USE_OBJC=0 to your
* compiler flags.
*
* This mode requires a platform with the modern Objective-C runtime, the
* Objective-C GC compiler option to be disabled, and at least a Mac OS X 10.8
* or iOS 6.0 deployment target.
*/
#ifndef OS_OBJECT_HAVE_OBJC_SUPPORT
#if !defined(__OBJC__) || defined(__OBJC_GC__)
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#elif !defined(TARGET_OS_MAC) || !TARGET_OS_MAC
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#elif TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#elif TARGET_OS_MAC && !TARGET_OS_IPHONE
# if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
# elif defined(__i386__) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12
# define OS_OBJECT_HAVE_OBJC_SUPPORT 0
# else
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
# endif
#else
# define OS_OBJECT_HAVE_OBJC_SUPPORT 1
#endif
#endif // OS_OBJECT_HAVE_OBJC_SUPPORT
#if OS_OBJECT_HAVE_OBJC_SUPPORT
#if defined(__swift__) && __swift__ && !OS_OBJECT_USE_OBJC
#define OS_OBJECT_USE_OBJC 1
#endif
#ifndef OS_OBJECT_USE_OBJC
#define OS_OBJECT_USE_OBJC 1
#endif
#elif defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
/* Unsupported platform for OS_OBJECT_USE_OBJC=1 */
#undef OS_OBJECT_USE_OBJC
#define OS_OBJECT_USE_OBJC 0
#else
#define OS_OBJECT_USE_OBJC 0
#endif
#ifndef OS_OBJECT_SWIFT3
#ifdef __swift__
#define OS_OBJECT_SWIFT3 1
#else // __swift__
#define OS_OBJECT_SWIFT3 0
#endif // __swift__
#endif // OS_OBJECT_SWIFT3
#if __has_feature(assume_nonnull)
#define OS_OBJECT_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define OS_OBJECT_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#else
#define OS_OBJECT_ASSUME_NONNULL_BEGIN
#define OS_OBJECT_ASSUME_NONNULL_END
#endif
#define OS_OBJECT_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#if OS_OBJECT_USE_OBJC
#import <objc/NSObject.h>
#if __has_attribute(objc_independent_class)
#define OS_OBJC_INDEPENDENT_CLASS __attribute__((objc_independent_class))
#endif // __has_attribute(objc_independent_class)
#ifndef OS_OBJC_INDEPENDENT_CLASS
#define OS_OBJC_INDEPENDENT_CLASS
#endif
#define OS_OBJECT_CLASS(name) OS_##name
#define OS_OBJECT_DECL_PROTOCOL(name, ...) \
@protocol OS_OBJECT_CLASS(name) __VA_ARGS__ \
@end
#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL(name, proto) \
@interface name () <proto> \
@end
#define OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, proto) \
OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL_IMPL( \
OS_OBJECT_CLASS(name), OS_OBJECT_CLASS(proto))
#define OS_OBJECT_DECL_IMPL(name, adhere, ...) \
OS_OBJECT_DECL_PROTOCOL(name, __VA_ARGS__) \
typedef adhere<OS_OBJECT_CLASS(name)> \
* OS_OBJC_INDEPENDENT_CLASS name##_t
#define OS_OBJECT_DECL_BASE(name, ...) \
@interface OS_OBJECT_CLASS(name) : __VA_ARGS__ \
- (instancetype)init OS_SWIFT_UNAVAILABLE("Unavailable in Swift"); \
@end
#define OS_OBJECT_DECL_IMPL_CLASS(name, ...) \
OS_OBJECT_DECL_BASE(name, ## __VA_ARGS__) \
typedef OS_OBJECT_CLASS(name) \
* OS_OBJC_INDEPENDENT_CLASS name##_t
#define OS_OBJECT_DECL(name, ...) \
OS_OBJECT_DECL_IMPL(name, NSObject, <NSObject>)
#define OS_OBJECT_DECL_SUBCLASS(name, super) \
OS_OBJECT_DECL_IMPL(name, NSObject, <OS_OBJECT_CLASS(super)>)
#if __has_attribute(ns_returns_retained)
#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
#else
#define OS_OBJECT_RETURNS_RETAINED
#endif
#if __has_attribute(ns_consumed)
#define OS_OBJECT_CONSUMED __attribute__((__ns_consumed__))
#else
#define OS_OBJECT_CONSUMED
#endif
#if __has_feature(objc_arc)
#define OS_OBJECT_BRIDGE __bridge
#define OS_WARN_RESULT_NEEDS_RELEASE
#else
#define OS_OBJECT_BRIDGE
#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
#endif
#if __has_attribute(objc_runtime_visible) && \
((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
!defined(__TV_OS_VERSION_MIN_REQUIRED) && \
!defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) || \
(defined(__TV_OS_VERSION_MIN_REQUIRED) && \
__TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) || \
(defined(__WATCH_OS_VERSION_MIN_REQUIRED) && \
__WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0))
/*
* To provide backward deployment of ObjC objects in Swift on pre-10.12
* SDKs, OS_object classes can be marked as OS_OBJECT_OBJC_RUNTIME_VISIBLE.
* When compiling with a deployment target earlier than OS X 10.12 (iOS 10.0,
* tvOS 10.0, watchOS 3.0) the Swift compiler will only refer to this type at
* runtime (using the ObjC runtime).
*/
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE __attribute__((objc_runtime_visible))
#else
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
#endif
#ifndef OS_OBJECT_USE_OBJC_RETAIN_RELEASE
#if defined(__clang_analyzer__)
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
#elif __has_feature(objc_arc) && !OS_OBJECT_SWIFT3
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 1
#else
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
#endif
#endif
#if OS_OBJECT_SWIFT3
#define OS_OBJECT_DECL_SWIFT(name) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_IMPL_CLASS(name, NSObject)
#define OS_OBJECT_DECL_SUBCLASS_SWIFT(name, super) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_IMPL_CLASS(name, OS_OBJECT_CLASS(super))
#endif // OS_OBJECT_SWIFT3
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE
OS_OBJECT_DECL_BASE(object, NSObject);
#else
/*! @parseOnly */
#define OS_OBJECT_RETURNS_RETAINED
/*! @parseOnly */
#define OS_OBJECT_CONSUMED
/*! @parseOnly */
#define OS_OBJECT_BRIDGE
/*! @parseOnly */
#define OS_WARN_RESULT_NEEDS_RELEASE OS_WARN_RESULT
/*! @parseOnly */
#define OS_OBJECT_OBJC_RUNTIME_VISIBLE
#define OS_OBJECT_USE_OBJC_RETAIN_RELEASE 0
#endif
#if OS_OBJECT_SWIFT3
#define OS_OBJECT_DECL_CLASS(name) \
OS_OBJECT_DECL_SUBCLASS_SWIFT(name, object)
#elif OS_OBJECT_USE_OBJC
#define OS_OBJECT_DECL_CLASS(name) \
OS_OBJECT_DECL(name)
#else
#define OS_OBJECT_DECL_CLASS(name) \
typedef struct name##_s *name##_t
#endif
#if OS_OBJECT_USE_OBJC
/* Declares a class of the specific name and exposes the interface and typedefs
* name##_t to the pointer to the class */
#define OS_OBJECT_SHOW_CLASS(name, ...) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_IMPL_CLASS(name, ## __VA_ARGS__ )
/* Declares a subclass of the same name, and
* subclass adheres to protocol specified. Typedefs baseclass<proto> * to subclass##_t */
#define OS_OBJECT_SHOW_SUBCLASS(subclass_name, super, proto_name) \
OS_EXPORT OS_OBJECT_OBJC_RUNTIME_VISIBLE \
OS_OBJECT_DECL_BASE(subclass_name, OS_OBJECT_CLASS(super)<OS_OBJECT_CLASS(proto_name)>); \
typedef OS_OBJECT_CLASS(super)<OS_OBJECT_CLASS(proto_name)> \
* OS_OBJC_INDEPENDENT_CLASS subclass_name##_t
#else /* Plain C */
#define OS_OBJECT_DECL_PROTOCOL(name, ...)
#define OS_OBJECT_SHOW_CLASS(name, ...) \
typedef struct name##_s *name##_t
#define OS_OBJECT_SHOW_SUBCLASS(name, super, ...) \
typedef super##_t name##_t
#endif
#define OS_OBJECT_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object))
__BEGIN_DECLS
/*!
* @function os_retain
*
* @abstract
* Increment the reference count of an os_object.
*
* @discussion
* On a platform with the modern Objective-C runtime this is exactly equivalent
* to sending the object the -[retain] message.
*
* @param object
* The object to retain.
*
* @result
* The retained object.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
OS_EXPORT OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
void*
os_retain(void *object);
#if OS_OBJECT_USE_OBJC
#undef os_retain
#define os_retain(object) [object retain]
#endif
/*!
* @function os_release
*
* @abstract
* Decrement the reference count of a os_object.
*
* @discussion
* On a platform with the modern Objective-C runtime this is exactly equivalent
* to sending the object the -[release] message.
*
* @param object
* The object to release.
*/
API_AVAILABLE(macos(10.10), ios(8.0))
OS_EXPORT
void OS_SWIFT_UNAVAILABLE("Can't be used with ARC")
os_release(void *object);
#if OS_OBJECT_USE_OBJC
#undef os_release
#define os_release(object) [object release]
#endif
__END_DECLS
#endif

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_WORKGROUP__
#define __OS_WORKGROUP__
#ifndef __DISPATCH_BUILDING_DISPATCH__
#ifndef __OS_WORKGROUP_INDIRECT__
#define __OS_WORKGROUP_INDIRECT__
#endif /* __OS_WORKGROUP_INDIRECT__ */
#include <os/workgroup_base.h>
#include <os/workgroup_object.h>
#include <os/workgroup_interval.h>
#include <os/workgroup_parallel.h>
#undef __OS_WORKGROUP_INDIRECT__
#endif /* __DISPATCH_BUILDING_DISPATCH__ */
#endif /* __OS_WORKGROUP__ */

View File

@@ -0,0 +1,78 @@
#ifndef __OS_WORKGROUP_BASE__
#define __OS_WORKGROUP_BASE__
#ifndef __OS_WORKGROUP_INDIRECT__
#error "Please #include <os/workgroup.h> instead of this file directly."
#endif
#include <sys/types.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <mach/port.h>
#include <Availability.h>
#include <os/base.h>
#include <os/object.h>
#include <os/clock.h>
#if __has_feature(assume_nonnull)
#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define OS_WORKGROUP_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#else
#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN
#define OS_WORKGROUP_ASSUME_NONNULL_END
#endif
#define OS_WORKGROUP_WARN_RESULT __attribute__((__warn_unused_result__))
#define OS_WORKGROUP_EXPORT OS_EXPORT
#define OS_WORKGROUP_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
#define OS_WORKGROUP_DECL(name, swift_name) \
OS_SWIFT_NAME(swift_name) \
OS_OBJECT_SHOW_CLASS(name, OS_OBJECT_CLASS(object))
#if OS_OBJECT_USE_OBJC
#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) \
OS_SWIFT_NAME(swift_name) \
OS_OBJECT_DECL_PROTOCOL(name ## __VA_ARGS__ )
#else
#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...)
#endif
#define OS_WORKGROUP_SUBCLASS_DECL(name, super, swift_name, ...) \
OS_SWIFT_NAME(swift_name) \
OS_OBJECT_SHOW_SUBCLASS(name, super, name, ## __VA_ARGS__)
#if defined(__LP64__)
#define __OS_WORKGROUP_ATTR_SIZE__ 60
#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56
#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 36
#else
#define __OS_WORKGROUP_ATTR_SIZE__ 60
#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56
#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 28
#endif
#define _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT 0x2FA863B4
#define _OS_WORKGROUP_ATTR_SIG_EMPTY_INIT 0x2FA863C4
struct OS_REFINED_FOR_SWIFT os_workgroup_attr_opaque_s {
uint32_t sig;
char opaque[__OS_WORKGROUP_ATTR_SIZE__];
};
#define _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT 0x52A74C4D
struct OS_REFINED_FOR_SWIFT os_workgroup_interval_data_opaque_s {
uint32_t sig;
char opaque[__OS_WORKGROUP_INTERVAL_DATA_SIZE__];
};
struct OS_REFINED_FOR_SWIFT os_workgroup_join_token_opaque_s {
uint32_t sig;
char opaque[__OS_WORKGROUP_JOIN_TOKEN_SIZE__];
};
#endif /* __OS_WORKGROUP_BASE__ */

View File

@@ -0,0 +1,155 @@
/*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_WORKGROUP_INTERVAL__
#define __OS_WORKGROUP_INTERVAL__
#ifndef __OS_WORKGROUP_INDIRECT__
#error "Please #include <os/workgroup.h> instead of this file directly."
#include <os/workgroup_base.h> // For header doc
#endif
__BEGIN_DECLS
OS_WORKGROUP_ASSUME_NONNULL_BEGIN
/*!
* @typedef os_workgroup_interval_t
*
* @abstract
* A subclass of an os_workgroup_t for tracking work performed as part of
* a repeating interval-driven workload.
*/
OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_interval, Repeatable);
OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_interval, os_workgroup, WorkGroupInterval);
/* During the first instance of this API, the only supported interval
* workgroups are for audio workloads. Please refer to the AudioToolbox
* framework for more information.
*/
/*
* @typedef os_workgroup_interval_data, os_workgroup_interval_data_t
*
* @abstract
* An opaque structure containing additional configuration for the workgroup
* interval.
*/
typedef struct os_workgroup_interval_data_opaque_s os_workgroup_interval_data_s;
typedef struct os_workgroup_interval_data_opaque_s *os_workgroup_interval_data_t;
#define OS_WORKGROUP_INTERVAL_DATA_INITIALIZER \
{ .sig = _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT }
/*!
* @function os_workgroup_interval_start
*
* @abstract
* Indicates to the system that the member threads of this
* os_workgroup_interval_t have begun working on an instance of the repeatable
* interval workload with the specified timestamps. This function is real time
* safe.
*
* This function will set and return an errno in the following cases:
*
* - The current thread is not a member of the os_workgroup_interval_t
* - The os_workgroup_interval_t has been cancelled
* - The timestamps passed in are malformed
* - os_workgroup_interval_start() was previously called on the
* os_workgroup_interval_t without an intervening os_workgroup_interval_finish()
* - A concurrent workgroup interval configuration operation is taking place.
*
* @param start
* Start timestamp specified in the os_clockid_t with which the
* os_workgroup_interval_t was created. This is generally a time in the past and
* indicates when the workgroup started working on an interval period
*
* @param deadline
* Deadline timestamp specified in the os_clockid_t with which the
* os_workgroup_interval_t was created. This specifies the deadline which the
* interval period would like to meet.
*
* @param data
* This field is currently unused and should be NULL
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
int
os_workgroup_interval_start(os_workgroup_interval_t wg, uint64_t start, uint64_t
deadline, os_workgroup_interval_data_t _Nullable data);
/*!
* @function os_workgroup_interval_update
*
* @abstract
* Updates an already started interval workgroup to have the new
* deadline specified. This function is real time safe.
*
* This function will return an error in the following cases:
* - The current thread is not a member of the os_workgroup_interval_t
* - The os_workgroup_interval_t has been cancelled
* - The timestamp passed in is malformed
* - os_workgroup_interval_start() was not previously called on the
* os_workgroup_interval_t or was already matched with an
* os_workgroup_interval_finish()
* - A concurrent workgroup interval configuration operation is taking place
*
* @param deadline
* Timestamp specified in the os_clockid_t with
* which the os_workgroup_interval_t was created.
*
* @param data
* This field is currently unused and should be NULL
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
int
os_workgroup_interval_update(os_workgroup_interval_t wg, uint64_t deadline,
os_workgroup_interval_data_t _Nullable data);
/*!
* @function os_workgroup_interval_finish
*
* @abstract
* Indicates to the system that the member threads of
* this os_workgroup_interval_t have finished working on the current instance
* of the interval workload. This function is real time safe.
*
* This function will return an error in the following cases:
* - The current thread is not a member of the os_workgroup_interval_t
* - os_workgroup_interval_start() was not previously called on the
* os_workgroup_interval_t or was already matched with an
* os_workgroup_interval_finish()
* - A concurrent workgroup interval configuration operation is taking place.
*
* @param data
* This field is currently unused and should be NULL
*
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
int
os_workgroup_interval_finish(os_workgroup_interval_t wg,
os_workgroup_interval_data_t _Nullable data);
OS_WORKGROUP_ASSUME_NONNULL_END
__END_DECLS
#endif /* __OS_WORKGROUP_INTERVAL__ */

View File

@@ -0,0 +1,357 @@
/*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_WORKGROUP_OBJECT__
#define __OS_WORKGROUP_OBJECT__
#ifndef __OS_WORKGROUP_INDIRECT__
#error "Please #include <os/workgroup.h> instead of this file directly."
#include <os/workgroup_base.h> // For header doc
#endif
__BEGIN_DECLS
OS_WORKGROUP_ASSUME_NONNULL_BEGIN
/*!
* @typedef os_workgroup_t
*
* @abstract
* A reference counted os object representing a workload that needs to
* be distinctly recognized and tracked by the system. The workgroup
* tracks a collection of threads all working cooperatively. An os_workgroup
* object - when not an instance of a specific os_workgroup_t subclass -
* represents a generic workload and makes no assumptions about the kind of
* work done.
*
* @discussion
* Threads can explicitly join an os_workgroup_t to mark themselves as
* participants in the workload.
*/
OS_WORKGROUP_DECL(os_workgroup, WorkGroup);
/* Attribute creation and specification */
/*!
* @typedef os_workgroup_attr_t
*
* @abstract
* Pointer to an opaque structure for describing attributes that can be
* configured on a workgroup at creation.
*/
typedef struct os_workgroup_attr_opaque_s os_workgroup_attr_s;
typedef struct os_workgroup_attr_opaque_s *os_workgroup_attr_t;
/* os_workgroup_t attributes need to be initialized before use. This initializer
* allows you to create a workgroup with the system default attributes. */
#define OS_WORKGROUP_ATTR_INITIALIZER_DEFAULT \
{ .sig = _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT }
/* The main use of the workgroup API is through instantiations of the concrete
* subclasses - please refer to os/workgroup_interval.h and
* os/workgroup_parallel.h for more information on creating workgroups.
*
* The functions below operate on all subclasses of os_workgroup_t.
*/
/*!
* @function os_workgroup_copy_port
*
* @abstract
* Returns a reference to a send right representing this workgroup that is to be
* sent to other processes. This port is to be passed to
* os_workgroup_create_with_port() to create a workgroup object.
*
* It is the client's responsibility to release the send right reference.
*
* If an error is encountered, errno is set and returned.
*/
API_AVAILABLE(macos(11.0))
API_UNAVAILABLE(ios, tvos, watchos)
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
int
os_workgroup_copy_port(os_workgroup_t wg, mach_port_t *mach_port_out);
/*!
* @function os_workgroup_create_with_port
*
* @abstract
* Create an os_workgroup_t object from a send right returned by a previous
* call to os_workgroup_copy_port, potentially in a different process.
*
* A newly created os_workgroup_t has no initial member threads - in particular
* the creating thread does not join the os_workgroup_t implicitly.
*
* @param name
* A client specified string for labelling the workgroup. This parameter is
* optional and can be NULL.
*
* @param mach_port
* The send right to create the workgroup from. No reference is consumed
* on the specified send right.
*/
API_AVAILABLE(macos(11.0))
API_UNAVAILABLE(ios, tvos, watchos)
OS_SWIFT_NAME(WorkGroup.init(__name:port:)) OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
os_workgroup_t _Nullable
os_workgroup_create_with_port(const char *_Nullable name, mach_port_t mach_port);
/*!
* @function os_workgroup_create_with_workgroup
*
* @abstract
* Create a new os_workgroup object from an existing os_workgroup.
*
* The newly created os_workgroup has no initial member threads - in particular
* the creating threaad does not join the os_workgroup_t implicitly.
*
* @param name
* A client specified string for labelling the workgroup. This parameter is
* optional and can be NULL.
*
* @param wg
* The existing workgroup to create a new workgroup object from.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
os_workgroup_t _Nullable
os_workgroup_create_with_workgroup(const char * _Nullable name, os_workgroup_t wg);
/*!
* @typedef os_workgroup_join_token, os_workgroup_join_token_t
*
* @abstract
* An opaque join token which the client needs to pass to os_workgroup_join
* and os_workgroup_leave
*/
OS_REFINED_FOR_SWIFT
typedef struct os_workgroup_join_token_opaque_s os_workgroup_join_token_s;
OS_REFINED_FOR_SWIFT
typedef struct os_workgroup_join_token_opaque_s *os_workgroup_join_token_t;
/*!
* @function os_workgroup_join
*
* @abstract
* Joins the current thread to the specified workgroup and populates the join
* token that has been passed in. This API is real-time safe.
*
* @param wg
* The workgroup that the current thread would like to join
*
* @param token_out
* Pointer to a client allocated struct which the function will populate
* with the join token. This token must be passed in by the thread when it calls
* os_workgroup_leave().
*
* Errors will be returned in the following cases:
*
* EALREADY The thread is already part of a workgroup that the specified
* workgroup does not nest with
* EINVAL The workgroup has been cancelled
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
int
os_workgroup_join(os_workgroup_t wg, os_workgroup_join_token_t token_out);
/*!
* @function os_workgroup_leave
*
* @abstract
* This removes the current thread from a workgroup it has previously
* joined. Threads must leave all workgroups in the reverse order that they
* have joined them. Failing to do so before exiting will result in undefined
* behavior.
*
* If the join token is malformed, the process will be aborted.
*
* This API is real time safe.
*
* @param wg
* The workgroup that the current thread would like to leave.
*
* @param token
* This is the join token populated by the most recent call to
* os_workgroup_join().
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
void
os_workgroup_leave(os_workgroup_t wg, os_workgroup_join_token_t token);
/* Working Arena index of a thread in a workgroup */
typedef uint32_t os_workgroup_index;
/* Destructor for Working Arena */
typedef void (*os_workgroup_working_arena_destructor_t)(void * _Nullable);
/*!
* @function os_workgroup_set_working_arena
*
* @abstract
* Associates a client defined working arena with the workgroup. The arena
* is local to the workgroup object in the process. This is intended for
* distributing a manually managed memory allocation between member threads
* of the workgroup.
*
* This function can be called multiple times and the client specified
* destructor will be called on the previously assigned arena, if any. This
* function can only be called when no threads have currently joined the
* workgroup and all workloops associated with the workgroup are idle.
*
* @param wg
* The workgroup to associate the working arena with
*
* @param arena
* The client managed arena to associate with the workgroup. This value can
* be NULL.
*
* @param max_workers
* The maximum number of threads that will ever query the workgroup for the
* arena and request an index into it. If the arena is not used to partition
* work amongst member threads, then this field can be 0.
*
* @param destructor
* A destructor to call on the previously assigned working arena, if any
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT
int
os_workgroup_set_working_arena(os_workgroup_t wg, void * _Nullable arena,
uint32_t max_workers, os_workgroup_working_arena_destructor_t destructor);
/*!
* @function os_workgroup_get_working_arena
*
* @abstract
* Returns the working arena associated with the workgroup and the current
* thread's index in the workgroup. This function can only be called by a member
* of the workgroup. Multiple calls to this API by a member thread will return
* the same arena and index until the thread leaves the workgroup.
*
* For workloops with an associated workgroup, every work item on the workloop
* will receive the same index in the arena.
*
* This method returns NULL if no arena is set on the workgroup. The index
* returned by this function is zero-based and is namespaced per workgroup
* object in the process. The indices provided are strictly monotonic and never
* reused until a future call to os_workgroup_set_working_arena.
*
* @param wg
* The workgroup to get the working arena from.
*
* @param index_out
* A pointer to a os_workgroup_index which will be populated by the caller's
* index in the workgroup.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
void * _Nullable
os_workgroup_get_working_arena(os_workgroup_t wg,
os_workgroup_index * _Nullable index_out);
/*!
* @function os_workgroup_cancel
*
* @abstract
* This API invalidates a workgroup and indicates to the system that the
* workload is no longer relevant to the caller.
*
* No new work should be initiated for a cancelled workgroup and
* work that is already underway should periodically check for
* cancellation with os_workgroup_testcancel and initiate cleanup if needed.
*
* Threads currently in the workgroup continue to be tracked together but no
* new threads may join this workgroup - the only possible operation allowed is
* to leave the workgroup. Other actions may have undefined behavior or
* otherwise fail.
*
* This API is idempotent. Cancellation is local to the workgroup object
* it is called on and does not affect other workgroups.
*
* @param wg
* The workgroup that that the thread would like to cancel
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
void
os_workgroup_cancel(os_workgroup_t wg);
/*!
* @function os_workgroup_testcancel
*
* @abstract
* Returns true if the workgroup object has been cancelled. See also
* os_workgroup_cancel
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
bool
os_workgroup_testcancel(os_workgroup_t wg);
/*!
* @typedef os_workgroup_max_parallel_threads_attr_t
*
* @abstract
* A pointer to a structure describing the set of properties of a workgroup to
* override with the explicitly specified values in the structure.
*
* See also os_workgroup_max_parallel_threads.
*/
OS_REFINED_FOR_SWIFT
typedef struct os_workgroup_max_parallel_threads_attr_s os_workgroup_mpt_attr_s;
OS_REFINED_FOR_SWIFT
typedef struct os_workgroup_max_parallel_threads_attr_s *os_workgroup_mpt_attr_t;
/*!
* @function os_workgroup_max_parallel_threads
*
* @abstract
* Returns the system's recommendation for maximum number of threads the client
* should make for a multi-threaded workload in a given workgroup.
*
* This API takes into consideration the current hardware the code is running on
* and the attributes of the workgroup. It does not take into consideration the
* current load of the system and therefore always provides the most optimal
* recommendation for the workload.
*
* @param wg
* The workgroup in which the multi-threaded workload will be performed in. The
* threads performing the multi-threaded workload are expected to join this
* workgroup.
*
* @param attr
* This value is currently unused and should be NULL.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT
int
os_workgroup_max_parallel_threads(os_workgroup_t wg, os_workgroup_mpt_attr_t
_Nullable attr);
OS_WORKGROUP_ASSUME_NONNULL_END
__END_DECLS
#endif /* __OS_WORKGROUP_OBJECT__ */

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2020 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
#ifndef __OS_WORKGROUP_PARALLEL__
#define __OS_WORKGROUP_PARALLEL__
#ifndef __OS_WORKGROUP_INDIRECT__
#error "Please #include <os/workgroup.h> instead of this file directly."
#include <os/workgroup_base.h> // For header doc
#endif
#include <os/workgroup_object.h>
__BEGIN_DECLS
OS_WORKGROUP_ASSUME_NONNULL_BEGIN
/*!
* @typedef os_workgroup_parallel_t
*
* @abstract
* A subclass of an os_workgroup_t for tracking parallel work.
*/
OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_parallel, Parallelizable);
OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_parallel, os_workgroup, WorkGroupParallel);
/*!
* @function os_workgroup_parallel_create
*
* @abstract
* Creates an os_workgroup_t which tracks a parallel workload.
* A newly created os_workgroup_interval_t has no initial member threads -
* in particular the creating thread does not join the os_workgroup_parallel_t
* implicitly.
*
* See also os_workgroup_max_parallel_threads().
*
* @param name
* A client specified string for labelling the workgroup. This parameter is
* optional and can be NULL.
*
* @param attr
* The requested set of workgroup attributes. NULL is to be specified for the
* default set of attributes.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED
OS_SWIFT_NAME(WorkGroupParallel.init(__name:attr:))
os_workgroup_parallel_t _Nullable
os_workgroup_parallel_create(const char * _Nullable name,
os_workgroup_attr_t _Nullable attr);
OS_WORKGROUP_ASSUME_NONNULL_END
__END_DECLS
#endif /* __OS_WORKGROUP_PARALLEL__ */

Some files were not shown because too many files have changed in this diff Show More