macos: add unfiltered aarch64 libc headers

This commit is contained in:
Jakub Konka
2020-12-05 13:25:53 +01:00
parent 2e7883c597
commit 3971522fee
443 changed files with 120672 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,483 @@
/*
* Copyright (c) 2007-2016 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__
#define __AVAILABILITY__
/*
These macros are for use in OS header files. They enable function prototypes
and Objective-C methods to be tagged with the OS version in which they
were first available; and, if applicable, the OS version in which they
became deprecated.
The desktop Mac OS X and iOS each have different version numbers.
The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop
and iOS version numbers. For instance:
__OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0)
means the function/method was first available on Mac OS X 10.2 on the desktop
and first available in iOS 2.0 on the iPhone.
If a function is available on one platform, but not the other a _NA (not
applicable) parameter is used. For instance:
__OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA)
means that the function/method was first available on Mac OS X 10.3, and it
currently not implemented on the iPhone.
At some point, a function/method may be deprecated. That means Apple
recommends applications stop using the function, either because there is a
better replacement or the functionality is being phased out. Deprecated
functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED()
macro which specifies the OS version where the function became available
as well as the OS version in which it became deprecated. For instance:
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA)
means that the function/method was introduced in Mac OS X 10.0, then
became deprecated beginning in Mac OS X 10.5. On iOS the function
has never been available.
For these macros to function properly, a program must specify the OS version range
it is targeting. The min OS version is specified as an option to the compiler:
-mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z
when building for the iPhone. The upper bound for the OS version is rarely needed,
but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for
Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS.
Examples:
A function available in Mac OS X 10.5 and later, but not on the phone:
extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
An Objective-C method in Mac OS X 10.5 and later, but not on the phone:
@interface MyClass : NSObject
-(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
@end
An enum available on the phone, but not available on Mac OS X:
#if __IPHONE_OS_VERSION_MIN_REQUIRED
enum { myEnum = 1 };
#endif
Note: this works when targeting the Mac OS X platform because
__IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero.
An enum with values added in different iPhoneOS versions:
enum {
myX = 1, // Usable on iPhoneOS 2.1 and later
myY = 2, // Usable on iPhoneOS 3.0 and later
myZ = 3, // Usable on iPhoneOS 3.0 and later
...
Note: you do not want to use #if with enumeration values
when a client needs to see all values at compile time
and use runtime logic to only use the viable values.
It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one
source base that can be compiled to target a range of OS versions. It is best
to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values.
That is because you might get compiled on an old OS that does not define a later
OS version macro, and in the C preprocessor undefined values evaluate to zero
in expresssions, which could cause the #if expression to evaluate in an unexpected
way.
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
// code only compiled when targeting Mac OS X and not iPhone
// note use of 1050 instead of __MAC_10_5
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
// code in here might run on pre-Leopard OS
#else
// code here can assume Leopard or later
#endif
#endif
*/
/*
* __API_TO_BE_DEPRECATED is used as a version number in API that will be deprecated
* in an upcoming release. This soft deprecation is an intermediate step before formal
* deprecation to notify developers about the API before compiler warnings are generated.
* You can find all places in your code that use soft deprecated API by redefining the
* value of this macro to your current minimum deployment target, for example:
* (macOS)
* clang -D__API_TO_BE_DEPRECATED=10.12 <other compiler flags>
* (iOS)
* clang -D__API_TO_BE_DEPRECATED=11.0 <other compiler flags>
*/
#ifndef __API_TO_BE_DEPRECATED
#define __API_TO_BE_DEPRECATED 100000
#endif
#include <AvailabilityVersions.h>
#include <AvailabilityInternal.h>
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_ios
#define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
__AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
__AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep##_MSG(_msg)
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
#if defined(__has_builtin)
#if __has_builtin(__is_target_arch)
#if __has_builtin(__is_target_vendor)
#if __has_builtin(__is_target_os)
#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)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi))))
#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx __AVAILABILITY_INTERNAL##_ios
#define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
__AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
__AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg) __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep##_MSG(_msg)
#endif /* # if __is_target_arch... */
#endif /* #if __has_builtin(__is_target_variant_environment) */
#endif /* #if __has_builtin(__is_target_variant_os) */
#endif /* #if __has_builtin(__is_target_environment) */
#endif /* #if __has_builtin(__is_target_os) */
#endif /* #if __has_builtin(__is_target_vendor) */
#endif /* #if __has_builtin(__is_target_arch) */
#endif /* #if defined(__has_builtin) */
#ifndef __OSX_AVAILABLE_STARTING
#if defined(__has_attribute) && defined(__has_feature)
#if __has_attribute(availability)
#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx
#define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
__AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
__AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg)
#else
#define __OSX_AVAILABLE_STARTING(_osx, _ios)
#define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep)
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg)
#endif
#else
#define __OSX_AVAILABLE_STARTING(_osx, _ios)
#define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep)
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg)
#endif
#endif /* __OSX_AVAILABLE_STARTING */
#else
#define __OSX_AVAILABLE_STARTING(_osx, _ios)
#define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep)
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg)
#endif
#if defined(__has_feature)
#if __has_feature(attribute_availability_with_message)
#define __OS_AVAILABILITY(_target, _availability) __attribute__((availability(_target,_availability)))
#define __OS_AVAILABILITY_MSG(_target, _availability, _msg) __attribute__((availability(_target,_availability,message=_msg)))
#elif __has_feature(attribute_availability)
#define __OS_AVAILABILITY(_target, _availability) __attribute__((availability(_target,_availability)))
#define __OS_AVAILABILITY_MSG(_target, _availability, _msg) __attribute__((availability(_target,_availability)))
#else
#define __OS_AVAILABILITY(_target, _availability)
#define __OS_AVAILABILITY_MSG(_target, _availability, _msg)
#endif
#else
#define __OS_AVAILABILITY(_target, _availability)
#define __OS_AVAILABILITY_MSG(_target, _availability, _msg)
#endif
/* for use to document app extension usage */
#if defined(__has_feature)
#if __has_feature(attribute_availability_app_extension)
#define __OSX_EXTENSION_UNAVAILABLE(_msg) __OS_AVAILABILITY_MSG(macosx_app_extension,unavailable,_msg)
#define __IOS_EXTENSION_UNAVAILABLE(_msg) __OS_AVAILABILITY_MSG(ios_app_extension,unavailable,_msg)
#else
#define __OSX_EXTENSION_UNAVAILABLE(_msg)
#define __IOS_EXTENSION_UNAVAILABLE(_msg)
#endif
#else
#define __OSX_EXTENSION_UNAVAILABLE(_msg)
#define __IOS_EXTENSION_UNAVAILABLE(_msg)
#endif
#define __OS_EXTENSION_UNAVAILABLE(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg)
/* for use marking APIs available info for Mac OSX */
#if defined(__has_attribute)
#if __has_attribute(availability)
#define __OSX_UNAVAILABLE __OS_AVAILABILITY(macosx,unavailable)
#define __OSX_AVAILABLE(_vers) __OS_AVAILABILITY(macosx,introduced=_vers)
#define __OSX_DEPRECATED(_start, _dep, _msg) __OSX_AVAILABLE(_start) __OS_AVAILABILITY_MSG(macosx,deprecated=_dep,_msg)
#endif
#endif
#ifndef __OSX_UNAVAILABLE
#define __OSX_UNAVAILABLE
#endif
#ifndef __OSX_AVAILABLE
#define __OSX_AVAILABLE(_vers)
#endif
#ifndef __OSX_DEPRECATED
#define __OSX_DEPRECATED(_start, _dep, _msg)
#endif
/* for use marking APIs available info for iOS */
#if defined(__has_attribute)
#if __has_attribute(availability)
#define __IOS_UNAVAILABLE __OS_AVAILABILITY(ios,unavailable)
#define __IOS_PROHIBITED __OS_AVAILABILITY(ios,unavailable)
#define __IOS_AVAILABLE(_vers) __OS_AVAILABILITY(ios,introduced=_vers)
#define __IOS_DEPRECATED(_start, _dep, _msg) __IOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(ios,deprecated=_dep,_msg)
#endif
#endif
#ifndef __IOS_UNAVAILABLE
#define __IOS_UNAVAILABLE
#endif
#ifndef __IOS_PROHIBITED
#define __IOS_PROHIBITED
#endif
#ifndef __IOS_AVAILABLE
#define __IOS_AVAILABLE(_vers)
#endif
#ifndef __IOS_DEPRECATED
#define __IOS_DEPRECATED(_start, _dep, _msg)
#endif
/* for use marking APIs available info for tvOS */
#if defined(__has_feature)
#if __has_feature(attribute_availability_tvos)
#define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,unavailable)
#define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,unavailable)
#define __TVOS_AVAILABLE(_vers) __OS_AVAILABILITY(tvos,introduced=_vers)
#define __TVOS_DEPRECATED(_start, _dep, _msg) __TVOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(tvos,deprecated=_dep,_msg)
#endif
#endif
#ifndef __TVOS_UNAVAILABLE
#define __TVOS_UNAVAILABLE
#endif
#ifndef __TVOS_PROHIBITED
#define __TVOS_PROHIBITED
#endif
#ifndef __TVOS_AVAILABLE
#define __TVOS_AVAILABLE(_vers)
#endif
#ifndef __TVOS_DEPRECATED
#define __TVOS_DEPRECATED(_start, _dep, _msg)
#endif
/* for use marking APIs available info for Watch OS */
#if defined(__has_feature)
#if __has_feature(attribute_availability_watchos)
#define __WATCHOS_UNAVAILABLE __OS_AVAILABILITY(watchos,unavailable)
#define __WATCHOS_PROHIBITED __OS_AVAILABILITY(watchos,unavailable)
#define __WATCHOS_AVAILABLE(_vers) __OS_AVAILABILITY(watchos,introduced=_vers)
#define __WATCHOS_DEPRECATED(_start, _dep, _msg) __WATCHOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(watchos,deprecated=_dep,_msg)
#endif
#endif
#ifndef __WATCHOS_UNAVAILABLE
#define __WATCHOS_UNAVAILABLE
#endif
#ifndef __WATCHOS_PROHIBITED
#define __WATCHOS_PROHIBITED
#endif
#ifndef __WATCHOS_AVAILABLE
#define __WATCHOS_AVAILABLE(_vers)
#endif
#ifndef __WATCHOS_DEPRECATED
#define __WATCHOS_DEPRECATED(_start, _dep, _msg)
#endif
/* for use marking APIs unavailable for swift */
#if defined(__has_feature)
#if __has_feature(attribute_availability_swift)
#define __SWIFT_UNAVAILABLE __OS_AVAILABILITY(swift,unavailable)
#define __SWIFT_UNAVAILABLE_MSG(_msg) __OS_AVAILABILITY_MSG(swift,unavailable,_msg)
#endif
#endif
#ifndef __SWIFT_UNAVAILABLE
#define __SWIFT_UNAVAILABLE
#endif
#ifndef __SWIFT_UNAVAILABLE_MSG
#define __SWIFT_UNAVAILABLE_MSG(_msg)
#endif
/*
Macros for defining which versions/platform a given symbol can be used.
@see http://clang.llvm.org/docs/AttributeReference.html#availability
* Note that these macros are only compatible with clang compilers that
* support the following target selection options:
*
* -mmacosx-version-min
* -miphoneos-version-min
* -mwatchos-version-min
* -mtvos-version-min
*/
#if defined(__has_feature) && defined(__has_attribute)
#if __has_attribute(availability)
/*
* API Introductions
*
* Use to specify the release that a particular API became available.
*
* Platform names:
* macos, ios, tvos, watchos
*
* Examples:
* __API_AVAILABLE(macos(10.10))
* __API_AVAILABLE(macos(10.9), ios(10.0))
* __API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
* __API_AVAILABLE(driverkit(19.0))
*/
#define __API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE7, __API_AVAILABLE6, __API_AVAILABLE5, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1, 0)(__VA_ARGS__)
#define __API_AVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_AVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_AVAILABLE_BEGIN7, __API_AVAILABLE_BEGIN6, __API_AVAILABLE_BEGIN5, __API_AVAILABLE_BEGIN4, __API_AVAILABLE_BEGIN3, __API_AVAILABLE_BEGIN2, __API_AVAILABLE_BEGIN1, 0)(__VA_ARGS__)
#define __API_AVAILABLE_END _Pragma("clang attribute pop")
/*
* API Deprecations
*
* Use to specify the release that a particular API became unavailable.
*
* Platform names:
* macos, ios, tvos, watchos
*
* Examples:
*
* __API_DEPRECATED("No longer supported", macos(10.4, 10.8))
* __API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
*
* __API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
* __API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
*/
#define __API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG8,__API_DEPRECATED_MSG7,__API_DEPRECATED_MSG6,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1, 0)(__VA_ARGS__)
#define __API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP8,__API_DEPRECATED_REP7,__API_DEPRECATED_REP6,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1, 0)(__VA_ARGS__)
#define __API_DEPRECATED_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN_MSG8,__API_DEPRECATED_BEGIN_MSG7, __API_DEPRECATED_BEGIN_MSG6, __API_DEPRECATED_BEGIN_MSG5, __API_DEPRECATED_BEGIN_MSG4, __API_DEPRECATED_BEGIN_MSG3, __API_DEPRECATED_BEGIN_MSG2, __API_DEPRECATED_BEGIN_MSG1, 0)(__VA_ARGS__)
#define __API_DEPRECATED_END _Pragma("clang attribute pop")
#define __API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...) _Pragma("clang attribute push") __API_DEPRECATED_BEGIN_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_BEGIN_REP8,__API_DEPRECATED_BEGIN_REP7, __API_DEPRECATED_BEGIN_REP6, __API_DEPRECATED_BEGIN_REP5, __API_DEPRECATED_BEGIN_REP4, __API_DEPRECATED_BEGIN_REP3, __API_DEPRECATED_BEGIN_REP2, __API_DEPRECATED_BEGIN_REP1, 0)(__VA_ARGS__)
#define __API_DEPRECATED_WITH_REPLACEMENT_END _Pragma("clang attribute pop")
/*
* API Unavailability
* Use to specify that an API is unavailable for a particular platform.
*
* Example:
* __API_UNAVAILABLE(macos)
* __API_UNAVAILABLE(watchos, tvos)
*/
#define __API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE7,__API_UNAVAILABLE6,__API_UNAVAILABLE5,__API_UNAVAILABLE4,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1, 0)(__VA_ARGS__)
#define __API_UNAVAILABLE_BEGIN(...) _Pragma("clang attribute push") __API_UNAVAILABLE_BEGIN_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE_BEGIN7,__API_UNAVAILABLE_BEGIN6, __API_UNAVAILABLE_BEGIN5, __API_UNAVAILABLE_BEGIN4, __API_UNAVAILABLE_BEGIN3, __API_UNAVAILABLE_BEGIN2, __API_UNAVAILABLE_BEGIN1, 0)(__VA_ARGS__)
#define __API_UNAVAILABLE_END _Pragma("clang attribute pop")
#else
/*
* Evaluate to nothing for compilers that don't support availability.
*/
#define __API_AVAILABLE(...)
#define __API_AVAILABLE_BEGIN(...)
#define __API_AVAILABLE_END
#define __API_DEPRECATED(...)
#define __API_DEPRECATED_WITH_REPLACEMENT(...)
#define __API_DEPRECATED_BEGIN(...)
#define __API_DEPRECATED_END
#define __API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...)
#define __API_DEPRECATED_WITH_REPLACEMENT_END
#define __API_UNAVAILABLE(...)
#define __API_UNAVAILABLE_BEGIN(...)
#define __API_UNAVAILABLE_END
#endif /* __has_attribute(availability) */
#else
/*
* Evaluate to nothing for compilers that don't support clang language extensions.
*/
#define __API_AVAILABLE(...)
#define __API_AVAILABLE_BEGIN(...)
#define __API_AVAILABLE_END
#define __API_DEPRECATED(...)
#define __API_DEPRECATED_WITH_REPLACEMENT(...)
#define __API_DEPRECATED_BEGIN(...)
#define __API_DEPRECATED_END
#define __API_DEPRECATED_WITH_REPLACEMENT_BEGIN(...)
#define __API_DEPRECATED_WITH_REPLACEMENT_END
#define __API_UNAVAILABLE(...)
#define __API_UNAVAILABLE_BEGIN(...)
#define __API_UNAVAILABLE_END
#endif /* #if defined(__has_feature) && defined(__has_attribute) */
#if __has_include(<AvailabilityProhibitedInternal.h>)
#include <AvailabilityProhibitedInternal.h>
#endif
/*
* If SPI decorations have not been defined elsewhere, disable them.
*/
#ifndef __SPI_AVAILABLE
#define __SPI_AVAILABLE(...)
#endif
#ifndef __SPI_DEPRECATED
#define __SPI_DEPRECATED(...)
#endif
#ifndef __SPI_DEPRECATED_WITH_REPLACEMENT
#define __SPI_DEPRECATED_WITH_REPLACEMENT(...)
#endif
#endif /* __AVAILABILITY__ */

File diff suppressed because it is too large Load Diff

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,64 @@
/*
* Block.h
*
* Copyright (c) 2008-2010 Apple Inc. All rights reserved.
*
* @APPLE_LLVM_LICENSE_HEADER@
*
*/
#ifndef _Block_H_
#define _Block_H_
#if !defined(BLOCK_EXPORT)
# if defined(__cplusplus)
# define BLOCK_EXPORT extern "C"
# else
# define BLOCK_EXPORT extern
# endif
#endif
#include <Availability.h>
#include <TargetConditionals.h>
#if __cplusplus
extern "C" {
#endif
// Create a heap based copy of a Block or simply add a reference to an existing one.
// This must be paired with Block_release to recover memory, even when running
// under Objective-C Garbage Collection.
BLOCK_EXPORT void *_Block_copy(const void *aBlock)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
// Lose the reference, and if heap based and last reference, recover the memory
BLOCK_EXPORT void _Block_release(const void *aBlock)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
// Used by the compiler. Do not call this function yourself.
BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
// Used by the compiler. Do not call this function yourself.
BLOCK_EXPORT void _Block_object_dispose(const void *, const int)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
// Used by the compiler. Do not use these variables yourself.
BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
BLOCK_EXPORT void * _NSConcreteStackBlock[32]
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#if __cplusplus
}
#endif
// Type correct macros
#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))
#endif

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

@@ -0,0 +1,508 @@
/*
* Copyright (c) 2000-2014 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: TargetConditionals.h
Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone
Note: TargetConditionals.h in 3.4 Universal Interfaces works
with all compilers. This header only recognizes compilers
known to run on Mac OS X.
*/
#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 | | | |
* | | | | +---------------+ +----+ +-------+ +--------+ | | | |
* | | | | | 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:
*
* __is_target_arch
* __is_target_vendor
* __is_target_os
* __is_target_environment
*
* “-target=x86_64-apple-ios12-macabi”
* TARGET_OS_MAC=1
* TARGET_OS_IPHONE=1
* TARGET_OS_IOS=1
* TARGET_OS_MACCATALYST=1
*
* “-target=x86_64-apple-ios12-simulator”
* TARGET_OS_MAC=1
* TARGET_OS_IPHONE=1
* TARGET_OS_IOS=1
* TARGET_OS_SIMULATOR=1
*
* DYNAMIC_TARGETS_ENABLED indicates that the core TARGET_OS macros were enabled via clang preprocessor extensions.
* If this value is not set, the macro enablements will fall back to the static behavior.
* It is disabled by default.
*/
#if defined(__has_builtin)
#if __has_builtin(__is_target_arch)
#if __has_builtin(__is_target_vendor)
#if __has_builtin(__is_target_os)
#if __has_builtin(__is_target_environment)
/* “-target=x86_64-apple-ios12-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
#define TARGET_OS_WATCH 0
#define TARGET_OS_TV 0
#define TARGET_OS_SIMULATOR 0
#define TARGET_OS_EMBEDDED 0
#define TARGET_OS_RTKIT 0
#define TARGET_OS_MACCATALYST 1
#define TARGET_OS_MACCATALYST 1
#ifndef TARGET_OS_UIKITFORMAC
#define TARGET_OS_UIKITFORMAC 1
#endif
#define TARGET_OS_DRIVERKIT 0
#define DYNAMIC_TARGETS_ENABLED 1
#endif
/* “-target=x86_64-apple-ios12-simulator” */
#if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(simulator)
#define TARGET_OS_OSX 0
#define TARGET_OS_IPHONE 1
#define TARGET_OS_IOS 1
#define TARGET_OS_WATCH 0
#define TARGET_OS_TV 0
#define TARGET_OS_SIMULATOR 1
#define TARGET_OS_EMBEDDED 0
#define TARGET_OS_RTKIT 0
#define TARGET_OS_MACCATALYST 0
#define TARGET_OS_MACCATALYST 0
#ifndef TARGET_OS_UIKITFORMAC
#define TARGET_OS_UIKITFORMAC 0
#endif
#define TARGET_OS_DRIVERKIT 0
#define DYNAMIC_TARGETS_ENABLED 1
#endif
/* -target=x86_64-apple-driverkit19.0 */
/* -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
#define TARGET_OS_WATCH 0
#define TARGET_OS_TV 0
#define TARGET_OS_SIMULATOR 0
#define TARGET_OS_EMBEDDED 0
#define TARGET_OS_RTKIT 0
#define TARGET_OS_MACCATALYST 0
#define TARGET_OS_MACCATALYST 0
#ifndef TARGET_OS_UIKITFORMAC
#define TARGET_OS_UIKITFORMAC 0
#endif
#define TARGET_OS_DRIVERKIT 1
#define DYNAMIC_TARGETS_ENABLED 1
#endif
#endif /* #if __has_builtin(__is_target_environment) */
#endif /* #if __has_builtin(__is_target_os) */
#endif /* #if __has_builtin(__is_target_vendor) */
#endif /* #if __has_builtin(__is_target_arch) */
#endif /* #if defined(__has_builtin) */
#ifndef DYNAMIC_TARGETS_ENABLED
#define DYNAMIC_TARGETS_ENABLED 0
#endif /* DYNAMIC_TARGETS_ENABLED */
/*
* gcc based compiler used on Mac OS X
*/
#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) )
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#if !DYNAMIC_TARGETS_ENABLED
#define TARGET_OS_OSX 1
#define TARGET_OS_IPHONE 0
#define TARGET_OS_IOS 0
#define TARGET_OS_WATCH 0
#define TARGET_OS_TV 0
#define TARGET_OS_MACCATALYST 0
#define TARGET_OS_MACCATALYST 0
#ifndef TARGET_OS_UIKITFORMAC
#define TARGET_OS_UIKITFORMAC 0
#endif
#define TARGET_OS_SIMULATOR 0
#define TARGET_OS_EMBEDDED 0
#define TARGET_OS_RTKIT 0
#define TARGET_OS_DRIVERKIT 0
#endif
#define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */
#define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */
#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
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_LITTLE_ENDIAN 0
#define TARGET_RT_BIG_ENDIAN 1
#define TARGET_RT_64_BIT 0
#ifdef __MACOS_CLASSIC__
#define TARGET_RT_MAC_CFM 1
#define TARGET_RT_MAC_MACHO 0
#else
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#endif
#elif defined(__ppc64__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 1
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_LITTLE_ENDIAN 0
#define TARGET_RT_BIG_ENDIAN 1
#define TARGET_RT_64_BIT 1
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#elif defined(__i386__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 1
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 0
#elif defined(__x86_64__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 1
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 1
#elif defined(__arm__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 1
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 0
#elif defined(__arm64__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 1
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#if __LP64__
#define TARGET_RT_64_BIT 1
#else
#define TARGET_RT_64_BIT 0
#endif
#else
#error unrecognized GNU C compiler
#endif
/*
* CodeWarrior compiler from Metrowerks/Motorola
*/
#elif defined(__MWERKS__)
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_EMBEDDED 0
#if defined(__POWERPC__)
#define TARGET_CPU_PPC 1
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_LITTLE_ENDIAN 0
#define TARGET_RT_BIG_ENDIAN 1
#elif defined(__INTEL__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 1
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#else
#error unknown Metrowerks CPU type
#endif
#define TARGET_RT_64_BIT 0
#ifdef __MACH__
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#else
#define TARGET_RT_MAC_CFM 1
#define TARGET_RT_MAC_MACHO 0
#endif
/*
* unknown compiler
*/
#else
#if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#elif defined(TARGET_CPU_PPC64) && TARGET_CPU_PPC64
#define TARGET_CPU_PPC 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#elif defined(TARGET_CPU_X86) && TARGET_CPU_X86
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#elif defined(TARGET_CPU_X86_64) && TARGET_CPU_X86_64
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#elif defined(TARGET_CPU_ARM) && TARGET_CPU_ARM
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#elif defined(TARGET_CPU_ARM64) && TARGET_CPU_ARM64
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#else
/*
NOTE: If your compiler errors out here then support for your compiler
has not yet been added to TargetConditionals.h.
TargetConditionals.h is designed to be plug-and-play. It auto detects
which compiler is being run and configures the TARGET_ conditionals
appropriately.
The short term work around is to set the TARGET_CPU_ and TARGET_OS_
on the command line to the compiler (e.g. -DTARGET_CPU_MIPS=1 -DTARGET_OS_UNIX=1)
The long term solution is to add a new case to this file which
auto detects your compiler and sets up the TARGET_ conditionals.
Then submit the changes to Apple Computer.
*/
#error TargetConditionals.h: unknown compiler (see comment above)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#endif
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_EMBEDDED 0
#if TARGET_CPU_PPC || TARGET_CPU_PPC64
#define TARGET_RT_BIG_ENDIAN 1
#define TARGET_RT_LITTLE_ENDIAN 0
#else
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_LITTLE_ENDIAN 1
#endif
#if TARGET_CPU_PPC64 || TARGET_CPU_X86_64
#define TARGET_RT_64_BIT 1
#else
#define TARGET_RT_64_BIT 0
#endif
#ifdef __MACH__
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_MAC_CFM 0
#else
#define TARGET_RT_MAC_MACHO 0
#define TARGET_RT_MAC_CFM 1
#endif
#endif
#endif /* __TARGETCONDITIONALS__ */

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2017 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 (c)1999 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*
* Common header for _wctype.h and xlocale/__wctype.h
*/
#ifndef ___WCTYPE_H_
#define ___WCTYPE_H_
#include <sys/cdefs.h>
#include <_types.h>
#include <sys/_types/_wint_t.h>
#include <sys/_types/_wint_t.h>
#include <_types/_wctype_t.h>
#ifndef WEOF
#define WEOF __DARWIN_WEOF
#endif
#ifndef __DARWIN_WCTYPE_TOP_inline
#define __DARWIN_WCTYPE_TOP_inline __header_inline
#endif
#include <ctype.h>
#endif /* ___WCTYPE_H_ */

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2000, 2002-2006, 2008-2010, 2012, 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 _CTERMID_H_
#define _CTERMID_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
char *ctermid(char *);
__END_DECLS
#endif

View File

@@ -0,0 +1,387 @@
/*
* Copyright (c) 2000, 2005, 2008 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 (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ctype.h 8.4 (Berkeley) 1/21/94
*/
#ifndef __CTYPE_H_
#define __CTYPE_H_
#include <sys/cdefs.h>
#include <runetype.h>
#define _CTYPE_A 0x00000100L /* Alpha */
#define _CTYPE_C 0x00000200L /* Control */
#define _CTYPE_D 0x00000400L /* Digit */
#define _CTYPE_G 0x00000800L /* Graph */
#define _CTYPE_L 0x00001000L /* Lower */
#define _CTYPE_P 0x00002000L /* Punct */
#define _CTYPE_S 0x00004000L /* Space */
#define _CTYPE_U 0x00008000L /* Upper */
#define _CTYPE_X 0x00010000L /* X digit */
#define _CTYPE_B 0x00020000L /* Blank */
#define _CTYPE_R 0x00040000L /* Print */
#define _CTYPE_I 0x00080000L /* Ideogram */
#define _CTYPE_T 0x00100000L /* Special */
#define _CTYPE_Q 0x00200000L /* Phonogram */
#define _CTYPE_SW0 0x20000000L /* 0 width character */
#define _CTYPE_SW1 0x40000000L /* 1 width character */
#define _CTYPE_SW2 0x80000000L /* 2 width character */
#define _CTYPE_SW3 0xc0000000L /* 3 width character */
#define _CTYPE_SWM 0xe0000000L /* Mask for screen width data */
#define _CTYPE_SWS 30 /* Bits to shift to get width */
#ifdef _NONSTD_SOURCE
/*
* Backward compatibility
*/
#define _A _CTYPE_A /* Alpha */
#define _C _CTYPE_C /* Control */
#define _D _CTYPE_D /* Digit */
#define _G _CTYPE_G /* Graph */
#define _L _CTYPE_L /* Lower */
#define _P _CTYPE_P /* Punct */
#define _S _CTYPE_S /* Space */
#define _U _CTYPE_U /* Upper */
#define _X _CTYPE_X /* X digit */
#define _B _CTYPE_B /* Blank */
#define _R _CTYPE_R /* Print */
#define _I _CTYPE_I /* Ideogram */
#define _T _CTYPE_T /* Special */
#define _Q _CTYPE_Q /* Phonogram */
#define _SW0 _CTYPE_SW0 /* 0 width character */
#define _SW1 _CTYPE_SW1 /* 1 width character */
#define _SW2 _CTYPE_SW2 /* 2 width character */
#define _SW3 _CTYPE_SW3 /* 3 width character */
#endif /* _NONSTD_SOURCE */
#define __DARWIN_CTYPE_inline __header_inline
#define __DARWIN_CTYPE_TOP_inline __header_inline
/*
* Use inline functions if we are allowed to and the compiler supports them.
*/
#if !defined(_DONT_USE_CTYPE_INLINE_) && \
(defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
/* See comments in <machine/_type.h> about __darwin_ct_rune_t. */
__BEGIN_DECLS
unsigned long ___runetype(__darwin_ct_rune_t);
__darwin_ct_rune_t ___tolower(__darwin_ct_rune_t);
__darwin_ct_rune_t ___toupper(__darwin_ct_rune_t);
__END_DECLS
__DARWIN_CTYPE_TOP_inline int
isascii(int _c)
{
return ((_c & ~0x7F) == 0);
}
#ifdef USE_ASCII
__DARWIN_CTYPE_inline int
__maskrune(__darwin_ct_rune_t _c, unsigned long _f)
{
return (int)_DefaultRuneLocale.__runetype[_c & 0xff] & (__uint32_t)_f;
}
#else /* !USE_ASCII */
__BEGIN_DECLS
int __maskrune(__darwin_ct_rune_t, unsigned long);
__END_DECLS
#endif /* USE_ASCII */
__DARWIN_CTYPE_inline int
__istype(__darwin_ct_rune_t _c, unsigned long _f)
{
#ifdef USE_ASCII
return !!(__maskrune(_c, _f));
#else /* USE_ASCII */
return (isascii(_c) ? !!(_DefaultRuneLocale.__runetype[_c] & _f)
: !!__maskrune(_c, _f));
#endif /* USE_ASCII */
}
__DARWIN_CTYPE_inline __darwin_ct_rune_t
__isctype(__darwin_ct_rune_t _c, unsigned long _f)
{
#ifdef USE_ASCII
return !!(__maskrune(_c, _f));
#else /* USE_ASCII */
return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
!!(_DefaultRuneLocale.__runetype[_c] & _f);
#endif /* USE_ASCII */
}
#ifdef USE_ASCII
__DARWIN_CTYPE_inline __darwin_ct_rune_t
__toupper(__darwin_ct_rune_t _c)
{
return _DefaultRuneLocale.__mapupper[_c & 0xff];
}
__DARWIN_CTYPE_inline __darwin_ct_rune_t
__tolower(__darwin_ct_rune_t _c)
{
return _DefaultRuneLocale.__maplower[_c & 0xff];
}
#else /* !USE_ASCII */
__BEGIN_DECLS
__darwin_ct_rune_t __toupper(__darwin_ct_rune_t);
__darwin_ct_rune_t __tolower(__darwin_ct_rune_t);
__END_DECLS
#endif /* USE_ASCII */
__DARWIN_CTYPE_inline int
__wcwidth(__darwin_ct_rune_t _c)
{
unsigned int _x;
if (_c == 0)
return (0);
_x = (unsigned int)__maskrune(_c, _CTYPE_SWM|_CTYPE_R);
if ((_x & _CTYPE_SWM) != 0)
return ((_x & _CTYPE_SWM) >> _CTYPE_SWS);
return ((_x & _CTYPE_R) != 0 ? 1 : -1);
}
#ifndef _EXTERNALIZE_CTYPE_INLINES_
#define _tolower(c) __tolower(c)
#define _toupper(c) __toupper(c)
__DARWIN_CTYPE_TOP_inline int
isalnum(int _c)
{
return (__istype(_c, _CTYPE_A|_CTYPE_D));
}
__DARWIN_CTYPE_TOP_inline int
isalpha(int _c)
{
return (__istype(_c, _CTYPE_A));
}
__DARWIN_CTYPE_TOP_inline int
isblank(int _c)
{
return (__istype(_c, _CTYPE_B));
}
__DARWIN_CTYPE_TOP_inline int
iscntrl(int _c)
{
return (__istype(_c, _CTYPE_C));
}
/* ANSI -- locale independent */
__DARWIN_CTYPE_TOP_inline int
isdigit(int _c)
{
return (__isctype(_c, _CTYPE_D));
}
__DARWIN_CTYPE_TOP_inline int
isgraph(int _c)
{
return (__istype(_c, _CTYPE_G));
}
__DARWIN_CTYPE_TOP_inline int
islower(int _c)
{
return (__istype(_c, _CTYPE_L));
}
__DARWIN_CTYPE_TOP_inline int
isprint(int _c)
{
return (__istype(_c, _CTYPE_R));
}
__DARWIN_CTYPE_TOP_inline int
ispunct(int _c)
{
return (__istype(_c, _CTYPE_P));
}
__DARWIN_CTYPE_TOP_inline int
isspace(int _c)
{
return (__istype(_c, _CTYPE_S));
}
__DARWIN_CTYPE_TOP_inline int
isupper(int _c)
{
return (__istype(_c, _CTYPE_U));
}
/* ANSI -- locale independent */
__DARWIN_CTYPE_TOP_inline int
isxdigit(int _c)
{
return (__isctype(_c, _CTYPE_X));
}
__DARWIN_CTYPE_TOP_inline int
toascii(int _c)
{
return (_c & 0x7F);
}
__DARWIN_CTYPE_TOP_inline int
tolower(int _c)
{
return (__tolower(_c));
}
__DARWIN_CTYPE_TOP_inline int
toupper(int _c)
{
return (__toupper(_c));
}
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
__DARWIN_CTYPE_TOP_inline int
digittoint(int _c)
{
return (__maskrune(_c, 0x0F));
}
__DARWIN_CTYPE_TOP_inline int
ishexnumber(int _c)
{
return (__istype(_c, _CTYPE_X));
}
__DARWIN_CTYPE_TOP_inline int
isideogram(int _c)
{
return (__istype(_c, _CTYPE_I));
}
__DARWIN_CTYPE_TOP_inline int
isnumber(int _c)
{
return (__istype(_c, _CTYPE_D));
}
__DARWIN_CTYPE_TOP_inline int
isphonogram(int _c)
{
return (__istype(_c, _CTYPE_Q));
}
__DARWIN_CTYPE_TOP_inline int
isrune(int _c)
{
return (__istype(_c, 0xFFFFFFF0L));
}
__DARWIN_CTYPE_TOP_inline int
isspecial(int _c)
{
return (__istype(_c, _CTYPE_T));
}
#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
#endif /* _EXTERNALIZE_CTYPE_INLINES_ */
#else /* not using inlines */
__BEGIN_DECLS
int isalnum(int);
int isalpha(int);
int isblank(int);
int iscntrl(int);
int isdigit(int);
int isgraph(int);
int islower(int);
int isprint(int);
int ispunct(int);
int isspace(int);
int isupper(int);
int isxdigit(int);
int tolower(int);
int toupper(int);
int isascii(int);
int toascii(int);
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
int _tolower(int);
int _toupper(int);
int digittoint(int);
int ishexnumber(int);
int isideogram(int);
int isnumber(int);
int isphonogram(int);
int isrune(int);
int isspecial(int);
#endif
__END_DECLS
#endif /* using inlines */
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_ctype.h>
#endif /* _USE_EXTENDED_LOCALES_ */
#endif /* !_CTYPE_H_ */

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)locale.h 8.1 (Berkeley) 6/2/93
* $FreeBSD: /repoman/r/ncvs/src/include/locale.h,v 1.7 2002/10/09 09:19:27 tjr Exp $
*/
#ifndef __LOCALE_H_
#define __LOCALE_H_
#include <sys/cdefs.h>
#include <_types.h>
struct lconv {
char *decimal_point;
char *thousands_sep;
char *grouping;
char *int_curr_symbol;
char *currency_symbol;
char *mon_decimal_point;
char *mon_thousands_sep;
char *mon_grouping;
char *positive_sign;
char *negative_sign;
char int_frac_digits;
char frac_digits;
char p_cs_precedes;
char p_sep_by_space;
char n_cs_precedes;
char n_sep_by_space;
char p_sign_posn;
char n_sign_posn;
char int_p_cs_precedes;
char int_n_cs_precedes;
char int_p_sep_by_space;
char int_n_sep_by_space;
char int_p_sign_posn;
char int_n_sign_posn;
};
#include <sys/_types/_null.h>
__BEGIN_DECLS
struct lconv *localeconv(void);
__END_DECLS
#endif /* __LOCALE_H_ */

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 2000, 2011 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 (c) 2001-2009 Ville Laurikari <vl@iki.fi>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 1992 Henry Spencer.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Henry Spencer of the University of Toronto.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)regex.h 8.2 (Berkeley) 1/3/94
*/
/*
* Common header for regex.h and xlocale/_regex.h
*/
#ifndef __REGEX_H_
#define __REGEX_H_
#include <_types.h>
#include <Availability.h>
#include <sys/_types/_size_t.h>
/*********/
/* types */
/*********/
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#include <sys/_types/_wchar_t.h>
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
typedef __darwin_off_t regoff_t;
typedef struct {
int re_magic;
size_t re_nsub; /* number of parenthesized subexpressions */
const char *re_endp; /* end pointer for REG_PEND */
struct re_guts *re_g; /* none of your business :-) */
} regex_t;
typedef struct {
regoff_t rm_so; /* start of match */
regoff_t rm_eo; /* end of match */
} regmatch_t;
#endif /* !__REGEX_H_ */

View File

@@ -0,0 +1,159 @@
/*
* Copyright (c) 2000, 2005, 2007, 2009, 2010 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 (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)stdio.h 8.5 (Berkeley) 4/29/95
*/
/*
* Common header for stdio.h and xlocale/_stdio.h
*/
#ifndef __STDIO_H_
#define __STDIO_H_
#include <sys/cdefs.h>
#include <Availability.h>
#include <_types.h>
/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
* __gnuc_va_list and include <stdarg.h> */
#include <sys/_types/_va_list.h>
#include <sys/_types/_size_t.h>
#include <sys/_types/_null.h>
#include <sys/stdio.h>
typedef __darwin_off_t fpos_t;
#define _FSTDIO /* Define for new stdio with functions. */
/*
* NB: to fit things in six character monocase externals, the stdio
* code uses the prefix `__s' for stdio objects, typically followed
* by a three-character attempt at a mnemonic.
*/
/* stdio buffers */
struct __sbuf {
unsigned char *_base;
int _size;
};
/* hold a buncha junk that would grow the ABI */
struct __sFILEX;
/*
* stdio state variables.
*
* The following always hold:
*
* if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
* _lbfsize is -_bf._size, else _lbfsize is 0
* if _flags&__SRD, _w is 0
* if _flags&__SWR, _r is 0
*
* This ensures that the getc and putc macros (or inline functions) never
* try to write or read from a file that is in `read' or `write' mode.
* (Moreover, they can, and do, automatically switch from read mode to
* write mode, and back, on "r+" and "w+" files.)
*
* _lbfsize is used only to make the inline line-buffered output stream
* code as compact as possible.
*
* _ub, _up, and _ur are used when ungetc() pushes back more characters
* than fit in the current _bf, or when ungetc() pushes back a character
* that does not match the previous one in _bf. When this happens,
* _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
*
* NB: see WARNING above before changing the layout of this structure!
*/
typedef struct __sFILE {
unsigned char *_p; /* current position in (some) buffer */
int _r; /* read space left for getc() */
int _w; /* write space left for putc() */
short _flags; /* flags, below; this FILE is free if 0 */
short _file; /* fileno, if Unix descriptor, else -1 */
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
int _lbfsize; /* 0 or -_bf._size, for inline putc */
/* operations */
void *_cookie; /* cookie passed to io functions */
int (* _Nullable _close)(void *);
int (* _Nullable _read) (void *, char *, int);
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
int (* _Nullable _write)(void *, const char *, int);
/* separate buffer for long sequences of ungetc() */
struct __sbuf _ub; /* ungetc buffer */
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
int _ur; /* saved _r when _r is counting ungetc data */
/* tricks to meet minimum requirements even when malloc() fails */
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
unsigned char _nbuf[1]; /* guarantee a getc() buffer */
/* separate buffer for fgetln() when line crosses buffer boundary */
struct __sbuf _lb; /* buffer for fgetln() */
/* Unix stdio files get aligned to block boundaries on fseek() */
int _blksize; /* stat.st_blksize (may be != _bf._size) */
fpos_t _offset; /* current lseek offset (see WARNING) */
} FILE;
#endif /* __STDIO_H_ */

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2004, 2008, 2009 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 __TYPES_H_
#define __TYPES_H_
#include <sys/_types.h>
#include <machine/_types.h> /* __uint32_t */
#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7
#define __strfmonlike(fmtarg, firstvararg) \
__attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
#define __strftimelike(fmtarg) \
__attribute__((__format__ (__strftime__, fmtarg, 0)))
#else
#define __strfmonlike(fmtarg, firstvararg)
#define __strftimelike(fmtarg)
#endif
typedef int __darwin_nl_item;
typedef int __darwin_wctrans_t;
#ifdef __LP64__
typedef __uint32_t __darwin_wctype_t;
#else /* !__LP64__ */
typedef unsigned long __darwin_wctype_t;
#endif /* __LP64__ */
#ifdef __WCHAR_MAX__
#define __DARWIN_WCHAR_MAX __WCHAR_MAX__
#else /* ! __WCHAR_MAX__ */
#define __DARWIN_WCHAR_MAX 0x7fffffff
#endif /* __WCHAR_MAX__ */
#if __DARWIN_WCHAR_MAX > 0xffffU
#define __DARWIN_WCHAR_MIN (-0x7fffffff - 1)
#else
#define __DARWIN_WCHAR_MIN 0
#endif
#define __DARWIN_WEOF ((__darwin_wint_t)-1)
#ifndef _FORTIFY_SOURCE
# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050)
# define _FORTIFY_SOURCE 0
# else
# define _FORTIFY_SOURCE 2 /* on by default */
# endif
#endif
#endif /* __TYPES_H_ */

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2012 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 _INTMAX_T
#define _INTMAX_T
#ifdef __INTMAX_TYPE__
typedef __INTMAX_TYPE__ intmax_t;
#else
#ifdef __LP64__
typedef long int intmax_t;
#else
typedef long long int intmax_t;
#endif /* __LP64__ */
#endif /* __INTMAX_TYPE__ */
#endif /* _INTMAX_T */

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2012 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 _NL_ITEM
#define _NL_ITEM
#include <_types.h>
typedef __darwin_nl_item nl_item;
#endif /* _NL_ITEM */

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2012 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 _UINT16_T
#define _UINT16_T
typedef unsigned short uint16_t;
#endif /* _UINT16_T */

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2012 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 _UINT32_T
#define _UINT32_T
typedef unsigned int uint32_t;
#endif /* _UINT32_T */

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2012 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 _UINT64_T
#define _UINT64_T
typedef unsigned long long uint64_t;
#endif /* _UINT64_T */

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2012 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 _UINT8_T
#define _UINT8_T
typedef unsigned char uint8_t;
#endif /* _UINT8_T */

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2012 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 _UINTMAX_T
#define _UINTMAX_T
#ifdef __UINTMAX_TYPE__
typedef __UINTMAX_TYPE__ uintmax_t;
#else
#ifdef __LP64__
typedef long unsigned int uintmax_t;
#else
typedef long long unsigned int uintmax_t;
#endif /* __LP64__ */
#endif /* __UINTMAX_TYPE__ */
#endif /* _UINTMAX_T */

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2012 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 _WCTRANS_T
#define _WCTRANS_T
#include <_types.h>
typedef __darwin_wctrans_t wctrans_t;
#endif /* _WCTRANS_T */

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2012 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 _WCTYPE_T
#define _WCTYPE_T
#include <_types.h>
typedef __darwin_wctype_t wctype_t;
#endif /* _WCTYPE_T */

View File

@@ -0,0 +1,164 @@
/*-
* Copyright (c)1999 Citrus Project,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*
* Common header for wctype.h and wchar.h
*
* Contains everything required by wctype.h except:
*
* #include <_types/_wctrans_t.h>
* int iswblank(wint_t);
* wint_t towctrans(wint_t, wctrans_t);
* wctrans_t wctrans(const char *);
*/
#ifndef __WCTYPE_H_
#define __WCTYPE_H_
#include <__wctype.h>
/*
* Use inline functions if we are allowed to and the compiler supports them.
*/
#if !defined(_DONT_USE_CTYPE_INLINE_) && \
(defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
__DARWIN_WCTYPE_TOP_inline int
iswalnum(wint_t _wc)
{
return (__istype(_wc, _CTYPE_A|_CTYPE_D));
}
__DARWIN_WCTYPE_TOP_inline int
iswalpha(wint_t _wc)
{
return (__istype(_wc, _CTYPE_A));
}
__DARWIN_WCTYPE_TOP_inline int
iswcntrl(wint_t _wc)
{
return (__istype(_wc, _CTYPE_C));
}
__DARWIN_WCTYPE_TOP_inline int
iswctype(wint_t _wc, wctype_t _charclass)
{
return (__istype(_wc, _charclass));
}
__DARWIN_WCTYPE_TOP_inline int
iswdigit(wint_t _wc)
{
return (__isctype(_wc, _CTYPE_D));
}
__DARWIN_WCTYPE_TOP_inline int
iswgraph(wint_t _wc)
{
return (__istype(_wc, _CTYPE_G));
}
__DARWIN_WCTYPE_TOP_inline int
iswlower(wint_t _wc)
{
return (__istype(_wc, _CTYPE_L));
}
__DARWIN_WCTYPE_TOP_inline int
iswprint(wint_t _wc)
{
return (__istype(_wc, _CTYPE_R));
}
__DARWIN_WCTYPE_TOP_inline int
iswpunct(wint_t _wc)
{
return (__istype(_wc, _CTYPE_P));
}
__DARWIN_WCTYPE_TOP_inline int
iswspace(wint_t _wc)
{
return (__istype(_wc, _CTYPE_S));
}
__DARWIN_WCTYPE_TOP_inline int
iswupper(wint_t _wc)
{
return (__istype(_wc, _CTYPE_U));
}
__DARWIN_WCTYPE_TOP_inline int
iswxdigit(wint_t _wc)
{
return (__isctype(_wc, _CTYPE_X));
}
__DARWIN_WCTYPE_TOP_inline wint_t
towlower(wint_t _wc)
{
return (__tolower(_wc));
}
__DARWIN_WCTYPE_TOP_inline wint_t
towupper(wint_t _wc)
{
return (__toupper(_wc));
}
#else /* not using inlines */
__BEGIN_DECLS
int iswalnum(wint_t);
int iswalpha(wint_t);
int iswcntrl(wint_t);
int iswctype(wint_t, wctype_t);
int iswdigit(wint_t);
int iswgraph(wint_t);
int iswlower(wint_t);
int iswprint(wint_t);
int iswpunct(wint_t);
int iswspace(wint_t);
int iswupper(wint_t);
int iswxdigit(wint_t);
wint_t towlower(wint_t);
wint_t towupper(wint_t);
__END_DECLS
#endif /* using inlines */
__BEGIN_DECLS
wctype_t
wctype(const char *);
__END_DECLS
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/__wctype.h>
#endif /* _USE_EXTENDED_LOCALES_ */
#endif /* __WCTYPE_H_ */

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2005 Apple Computer, 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 __XLOCALE_H_
#define __XLOCALE_H_
#include <sys/cdefs.h>
struct _xlocale; /* forward reference */
typedef struct _xlocale * locale_t;
__BEGIN_DECLS
int ___mb_cur_max(void);
int ___mb_cur_max_l(locale_t);
__END_DECLS
#endif /* __XLOCALE_H_ */

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2003 Apple Computer, 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: aio.h
* Author: Umesh Vaishampayan [umeshv@apple.com]
* 05-Feb-2003 umeshv Created.
*
* Header file for POSIX Asynchronous IO APIs
*
*/
#ifndef _AIO_H_
#define _AIO_H_
#include <sys/aio.h>
#endif /* _AIO_H_ */

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2003 Apple Computer, 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 _ALLOCA_H_
#define _ALLOCA_H_
#include <sys/cdefs.h>
#include <_types.h>
#include <sys/_types/_size_t.h>
__BEGIN_DECLS
void *alloca(size_t); /* built-in for gcc */
__END_DECLS
#if defined(__GNUC__) && __GNUC__ >= 3
/* built-in for gcc 3 */
#undef alloca
#undef __alloca
#define alloca(size) __alloca(size)
#define __alloca(size) __builtin_alloca(size)
#endif
#endif /* _ALLOCA_H_ */

View File

@@ -0,0 +1,381 @@
/*
* Copyright (c) 1999-2008 Apple Computer, 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 (c) 1992 NeXT Computer, Inc.
*
* Byte ordering conversion.
*
*/
#ifndef _ARCHITECTURE_BYTE_ORDER_H_
#define _ARCHITECTURE_BYTE_ORDER_H_
/*
* Please note that the byte ordering functions in this file are deprecated.
* A replacement API exists in libkern/OSByteOrder.h
*/
#include <libkern/OSByteOrder.h>
typedef unsigned long NXSwappedFloat;
typedef unsigned long long NXSwappedDouble;
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapShort(
unsigned short inv
)
{
return (unsigned short)OSSwapInt16((uint16_t)inv);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapInt(
unsigned int inv
)
{
return (unsigned int)OSSwapInt32((uint32_t)inv);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapLong(
unsigned long inv
)
{
return (unsigned long)OSSwapInt32((uint32_t)inv);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapLongLong(
unsigned long long inv
)
{
return (unsigned long long)OSSwapInt64((uint64_t)inv);
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXConvertHostFloatToSwapped(float x)
{
union fconv {
float number;
NXSwappedFloat sf;
} u;
u.number = x;
return u.sf;
}
static __inline__ __attribute__((deprecated))
float
NXConvertSwappedFloatToHost(NXSwappedFloat x)
{
union fconv {
float number;
NXSwappedFloat sf;
} u;
u.sf = x;
return u.number;
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXConvertHostDoubleToSwapped(double x)
{
union dconv {
double number;
NXSwappedDouble sd;
} u;
u.number = x;
return u.sd;
}
static __inline__ __attribute__((deprecated))
double
NXConvertSwappedDoubleToHost(NXSwappedDouble x)
{
union dconv {
double number;
NXSwappedDouble sd;
} u;
u.sd = x;
return u.number;
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXSwapFloat(NXSwappedFloat x)
{
return (NXSwappedFloat)OSSwapInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXSwapDouble(NXSwappedDouble x)
{
return (NXSwappedDouble)OSSwapInt64((uint64_t)x);
}
/*
* Identify the byte order
* of the current host.
*/
enum NXByteOrder {
NX_UnknownByteOrder,
NX_LittleEndian,
NX_BigEndian
};
static __inline__
enum NXByteOrder
NXHostByteOrder(void)
{
#if defined(__LITTLE_ENDIAN__)
return NX_LittleEndian;
#elif defined(__BIG_ENDIAN__)
return NX_BigEndian;
#else
return NX_UnknownByteOrder;
#endif
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapBigShortToHost(
unsigned short x
)
{
return (unsigned short)OSSwapBigToHostInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapBigIntToHost(
unsigned int x
)
{
return (unsigned int)OSSwapBigToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapBigLongToHost(
unsigned long x
)
{
return (unsigned long)OSSwapBigToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapBigLongLongToHost(
unsigned long long x
)
{
return (unsigned long long)OSSwapBigToHostInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
double
NXSwapBigDoubleToHost(
NXSwappedDouble x
)
{
return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapBigToHostInt64((uint64_t)x));
}
static __inline__ __attribute__((deprecated))
float
NXSwapBigFloatToHost(
NXSwappedFloat x
)
{
return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapBigToHostInt32((uint32_t)x));
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapHostShortToBig(
unsigned short x
)
{
return (unsigned short)OSSwapHostToBigInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapHostIntToBig(
unsigned int x
)
{
return (unsigned int)OSSwapHostToBigInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapHostLongToBig(
unsigned long x
)
{
return (unsigned long)OSSwapHostToBigInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapHostLongLongToBig(
unsigned long long x
)
{
return (unsigned long long)OSSwapHostToBigInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXSwapHostDoubleToBig(
double x
)
{
return (NXSwappedDouble)OSSwapHostToBigInt64((uint64_t)NXConvertHostDoubleToSwapped(x));
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXSwapHostFloatToBig(
float x
)
{
return (NXSwappedFloat)OSSwapHostToBigInt32((uint32_t)NXConvertHostFloatToSwapped(x));
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapLittleShortToHost(
unsigned short x
)
{
return (unsigned short)OSSwapLittleToHostInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapLittleIntToHost(
unsigned int x
)
{
return (unsigned int)OSSwapLittleToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapLittleLongToHost(
unsigned long x
)
{
return (unsigned long)OSSwapLittleToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapLittleLongLongToHost(
unsigned long long x
)
{
return (unsigned long long)OSSwapLittleToHostInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
double
NXSwapLittleDoubleToHost(
NXSwappedDouble x
)
{
return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapLittleToHostInt64((uint64_t)x));
}
static __inline__ __attribute__((deprecated))
float
NXSwapLittleFloatToHost(
NXSwappedFloat x
)
{
return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapLittleToHostInt32((uint32_t)x));
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapHostShortToLittle(
unsigned short x
)
{
return (unsigned short)OSSwapHostToLittleInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapHostIntToLittle(
unsigned int x
)
{
return (unsigned int)OSSwapHostToLittleInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapHostLongToLittle(
unsigned long x
)
{
return (unsigned long)OSSwapHostToLittleInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapHostLongLongToLittle(
unsigned long long x
)
{
return (unsigned long long)OSSwapHostToLittleInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXSwapHostDoubleToLittle(
double x
)
{
return (NXSwappedDouble)OSSwapHostToLittleInt64((uint64_t)NXConvertHostDoubleToSwapped(x));
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXSwapHostFloatToLittle(
float x
)
{
return (NXSwappedFloat)OSSwapHostToLittleInt32((uint32_t)NXConvertHostFloatToSwapped(x));
}
#endif /* _ARCHITECTURE_BYTE_ORDER_H_ */

View File

@@ -0,0 +1,9 @@
/*
* Copyright (c) 2004-2007 Apple Inc. All rights reserved.
*/
#ifndef _ARM__LIMITS_H_
#define _ARM__LIMITS_H_
#define __DARWIN_CLK_TCK 100 /* ticks per second */
#endif /* _ARM__LIMITS_H_ */

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2003-2012 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 __ARM_MCONTEXT_H_
#define __ARM_MCONTEXT_H_
#include <sys/cdefs.h> /* __DARWIN_UNIX03 */
#include <sys/appleapiopts.h>
#include <mach/machine/_structs.h>
#ifndef _STRUCT_MCONTEXT32
#if __DARWIN_UNIX03
#define _STRUCT_MCONTEXT32 struct __darwin_mcontext32
_STRUCT_MCONTEXT32
{
_STRUCT_ARM_EXCEPTION_STATE __es;
_STRUCT_ARM_THREAD_STATE __ss;
_STRUCT_ARM_VFP_STATE __fs;
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_MCONTEXT32 struct mcontext32
_STRUCT_MCONTEXT32
{
_STRUCT_ARM_EXCEPTION_STATE es;
_STRUCT_ARM_THREAD_STATE ss;
_STRUCT_ARM_VFP_STATE fs;
};
#endif /* __DARWIN_UNIX03 */
#endif /* _STRUCT_MCONTEXT32 */
#ifndef _STRUCT_MCONTEXT64
#if __DARWIN_UNIX03
#define _STRUCT_MCONTEXT64 struct __darwin_mcontext64
_STRUCT_MCONTEXT64
{
_STRUCT_ARM_EXCEPTION_STATE64 __es;
_STRUCT_ARM_THREAD_STATE64 __ss;
_STRUCT_ARM_NEON_STATE64 __ns;
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_MCONTEXT64 struct mcontext64
_STRUCT_MCONTEXT64
{
_STRUCT_ARM_EXCEPTION_STATE64 es;
_STRUCT_ARM_THREAD_STATE64 ss;
_STRUCT_ARM_NEON_STATE64 ns;
};
#endif /* __DARWIN_UNIX03 */
#endif /* _STRUCT_MCONTEXT32 */
#ifndef _MCONTEXT_T
#define _MCONTEXT_T
#if defined(__arm64__)
typedef _STRUCT_MCONTEXT64 *mcontext_t;
#define _STRUCT_MCONTEXT _STRUCT_MCONTEXT64
#else
typedef _STRUCT_MCONTEXT32 *mcontext_t;
#define _STRUCT_MCONTEXT _STRUCT_MCONTEXT32
#endif
#endif /* _MCONTEXT_T */
#endif /* __ARM_MCONTEXT_H_ */

View File

@@ -0,0 +1,22 @@
/*
* Copyright (c) 2006-2007 Apple Inc. All rights reserved.
*/
#ifndef _ARM__PARAM_H_
#define _ARM__PARAM_H_
#include <arm/_types.h>
/*
* Round p (pointer or byte index) up to a correctly-aligned value for all
* data types (int, long, ...). The result is unsigned int and must be
* cast to any desired pointer type.
*/
#define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1)
#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)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
#endif /* _ARM__PARAM_H_ */

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*/
#ifndef _BSD_ARM__TYPES_H_
#define _BSD_ARM__TYPES_H_
/*
* This header file contains integer types. It's intended to also contain
* flotaing point and other arithmetic types, as needed, later.
*/
#ifdef __GNUC__
typedef __signed char __int8_t;
#else /* !__GNUC__ */
typedef char __int8_t;
#endif /* !__GNUC__ */
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
/*
* The rune type below is declared to be an ``int'' instead of the more natural
* ``unsigned long'' or ``long''. Two things are happening here. It is not
* unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
* it looks like 10646 will be a 31 bit standard. This means that if your
* ints cannot hold 32 bits, you will be in trouble. The reason an int was
* chosen over a long is that the is*() and to*() routines take ints (says
* ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it
* here, you lose a bit of ANSI conformance, but your programs will still
* work.
*
* NOTE: rune_t is not covered by ANSI nor other standards, and should not
* be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and
* rune_t must be the same type. Also wint_t must be no narrower than
* wchar_t, and should also be able to hold all members of the largest
* character set plus one extra value (WEOF). wint_t must be at least 16 bits.
*/
typedef int __darwin_ct_rune_t; /* ct_rune_t */
/*
* mbstate_t is an opaque object to keep conversion state, during multibyte
* stream conversions. The content must not be referenced by user programs.
*/
typedef union {
char __mbstate8[128];
long long _mbstateL; /* for alignment */
} __mbstate_t;
typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */
#if defined(__PTRDIFF_TYPE__)
typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */
#elif defined(__LP64__)
typedef long __darwin_ptrdiff_t; /* ptr1 - ptr2 */
#else
typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */
#endif /* __GNUC__ */
#if defined(__SIZE_TYPE__)
typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */
#else
typedef unsigned long __darwin_size_t; /* sizeof() */
#endif
#if (__GNUC__ > 2)
typedef __builtin_va_list __darwin_va_list; /* va_list */
#else
typedef void * __darwin_va_list; /* va_list */
#endif
#if defined(__WCHAR_TYPE__)
typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */
#else
typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */
#endif
typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */
#if defined(__WINT_TYPE__)
typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */
#else
typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */
#endif
typedef unsigned long __darwin_clock_t; /* clock() */
typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */
typedef long __darwin_ssize_t; /* byte count or error */
typedef long __darwin_time_t; /* time() */
#endif /* _BSD_ARM__TYPES_H_ */

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2007 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 _ARM_ARCH_H
#define _ARM_ARCH_H
/* Collect the __ARM_ARCH_*__ compiler flags into something easier to use. */
#if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7S__) || defined (__ARM_ARCH_7F__) || defined (__ARM_ARCH_7K__)
#define _ARM_ARCH_7
#endif
#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
#define _ARM_ARCH_6K
#endif
#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__)
#define _ARM_ARCH_6Z
#endif
#if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) || \
defined (_ARM_ARCH_6Z) || defined (_ARM_ARCH_6K)
#define _ARM_ARCH_6
#endif
#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5E__) || \
defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__)
#define _ARM_ARCH_5E
#endif
#if defined (_ARM_ARCH_5E) || defined (__ARM_ARCH_5__) || \
defined (__ARM_ARCH_5T__)
#define _ARM_ARCH_5
#endif
#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__)
#define _ARM_ARCH_4T
#endif
#if defined (_ARM_ARCH_4T) || defined (__ARM_ARCH_4__)
#define _ARM_ARCH_4
#endif
#endif

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*/
/*
* Copyright 1995 NeXT Computer, Inc. All rights reserved.
*/
/*
* Copyright (c) 1987, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)endian.h 8.1 (Berkeley) 6/11/93
*/
#ifndef _ARM__ENDIAN_H_
#define _ARM__ENDIAN_H_
#include <sys/cdefs.h>
/*
* Define _NOQUAD if the compiler does NOT support 64-bit integers.
*/
/* #define _NOQUAD */
/*
* Define the order of 32-bit words in 64-bit words.
*/
#define _QUAD_HIGHWORD 1
#define _QUAD_LOWWORD 0
/*
* Definitions for byte order, according to byte significance from low
* address to high.
*/
#define __DARWIN_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
#define __DARWIN_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
#define __DARWIN_PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
#define __DARWIN_BYTE_ORDER __DARWIN_LITTLE_ENDIAN
#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
#define BIG_ENDIAN __DARWIN_BIG_ENDIAN
#define PDP_ENDIAN __DARWIN_PDP_ENDIAN
#define BYTE_ORDER __DARWIN_BYTE_ORDER
#include <sys/_endian.h>
#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */
#endif /* !_ARM__ENDIAN_H_ */

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*/
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)limits.h 8.3 (Berkeley) 1/4/94
*/
#ifndef _ARM_LIMITS_H_
#define _ARM_LIMITS_H_
#include <sys/cdefs.h>
#include <arm/_limits.h>
#define CHAR_BIT 8 /* number of bits in a char */
#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define CLK_TCK __DARWIN_CLK_TCK /* ticks per second */
#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
/*
* According to ANSI (section 2.2.4.2), the values below must be usable by
* #if preprocessing directives. Additionally, the expression must have the
* same type as would an expression that is an object of the corresponding
* type converted according to the integral promotions. The subtraction for
* INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
* These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values
* are written as hex so that GCC will be quiet about large integer constants.
*/
#define SCHAR_MAX 127 /* min value for a signed char */
#define SCHAR_MIN (-128) /* max value for a signed char */
#define UCHAR_MAX 255 /* max value for an unsigned char */
#define CHAR_MAX 127 /* max value for a char */
#define CHAR_MIN (-128) /* min value for a char */
#define USHRT_MAX 65535 /* max value for an unsigned short */
#define SHRT_MAX 32767 /* max value for a short */
#define SHRT_MIN (-32768) /* min value for a short */
#define UINT_MAX 0xffffffff /* max value for an unsigned int */
#define INT_MAX 2147483647 /* max value for an int */
#define INT_MIN (-2147483647-1) /* min value for an int */
#ifdef __LP64__
#define ULONG_MAX 0xffffffffffffffffUL /* max unsigned long */
#define LONG_MAX 0x7fffffffffffffffL /* max signed long */
#define LONG_MIN (-0x7fffffffffffffffL-1) /* min signed long */
#else /* !__LP64__ */
#define ULONG_MAX 0xffffffffUL /* max unsigned long */
#define LONG_MAX 2147483647L /* max signed long */
#define LONG_MIN (-2147483647L-1) /* min signed long */
#endif /* __LP64__ */
#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */
#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */
#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */
#if !defined(_ANSI_SOURCE)
#ifdef __LP64__
#define LONG_BIT 64
#else /* !__LP64__ */
#define LONG_BIT 32
#endif /* __LP64__ */
#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */
#define WORD_BIT 32
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */
#define UQUAD_MAX ULLONG_MAX
#define QUAD_MAX LLONG_MAX
#define QUAD_MIN LLONG_MIN
#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */
#endif /* !_ANSI_SOURCE */
#endif /* _ARM_LIMITS_H_ */

View File

@@ -0,0 +1,147 @@
/*
* Copyright (c) 2000-2010 Apple Inc. All rights reserved.
*/
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)param.h 8.1 (Berkeley) 4/4/95
*/
/*
* Machine dependent constants for ARM
*/
#ifndef _ARM_PARAM_H_
#define _ARM_PARAM_H_
#include <arm/_param.h>
/*
* Round p (pointer or byte index) up to a correctly-aligned value for all
* data types (int, long, ...). The result is unsigned int and must be
* cast to any desired pointer type.
*/
#define ALIGNBYTES __DARWIN_ALIGNBYTES
#define ALIGN(p) __DARWIN_ALIGN(p)
#define NBPG 4096 /* bytes/page */
#define PGOFSET (NBPG-1) /* byte offset into page */
#define PGSHIFT 12 /* LOG2(NBPG) */
#define DEV_BSIZE 512
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define BLKDEV_IOSIZE 2048
#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
#define CLSIZE 1
#define CLSIZELOG2 0
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than CLBYTES (the software page size), and,
* on machines that exchange pages of input or output buffers with mbuf
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
#define MSIZESHIFT 8 /* 256 */
#define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */
#define MCLSHIFT 11 /* 2048 */
#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */
#define MBIGCLSHIFT 12 /* 4096 */
#define MBIGCLBYTES (1 << MBIGCLSHIFT) /* size of a big cluster */
#define M16KCLSHIFT 14 /* 16384 */
#define M16KCLBYTES (1 << M16KCLSHIFT) /* size of a jumbo cluster */
#define MCLOFSET (MCLBYTES - 1)
#ifndef NMBCLUSTERS
#define NMBCLUSTERS CONFIG_NMBCLUSTERS /* cl map size */
#endif
/*
* Some macros for units conversion
*/
/* Core clicks (NeXT_page_size bytes) to segments and vice versa */
#define ctos(x) (x)
#define stoc(x) (x)
/* Core clicks (4096 bytes) to disk blocks */
#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
#define dtob(x) ((x)<<DEV_BSHIFT)
/* clicks to bytes */
#define ctob(x) ((x)<<PGSHIFT)
/* bytes to clicks */
#define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
#ifdef __APPLE__
#define btodb(bytes, devBlockSize) \
((unsigned)(bytes) / devBlockSize)
#define dbtob(db, devBlockSize) \
((unsigned)(db) * devBlockSize)
#else
#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
((unsigned)(bytes) >> DEV_BSHIFT)
#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
((unsigned)(db) << DEV_BSHIFT)
#endif
/*
* Map a ``block device block'' to a file system block.
* This should be device dependent, and will be if we
* add an entry to cdevsw/bdevsw for that purpose.
* For now though just use DEV_BSIZE.
*/
#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
/*
* Macros to decode (and encode) processor status word.
*/
#define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl))
#define USERMODE(x) (((x) & 3) == 3)
#define BASEPRI(x) (((x) & (255 << 8)) == 0)
#if defined(KERNEL) || defined(STANDALONE)
#define DELAY(n) delay(n)
#else /* defined(KERNEL) || defined(STANDALONE) */
#define DELAY(n) { int N = (n); while (--N > 0); }
#endif /* defined(KERNEL) || defined(STANDALONE) */
#endif /* _ARM_PARAM_H_ */

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) 2000-2009 Apple, Inc. All rights reserved.
*/
/*
* Copyright (c) 1992 NeXT Computer, Inc.
*
*/
#ifndef _ARM_SIGNAL_
#define _ARM_SIGNAL_ 1
#include <sys/cdefs.h>
#ifndef _ANSI_SOURCE
typedef int sig_atomic_t;
#endif /* ! _ANSI_SOURCE */
#endif /* _ARM_SIGNAL_ */

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2000-2008 Apple Inc. All rights reserved.
*/
/*
* Copyright 1995 NeXT Computer, Inc. All rights reserved.
*/
/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)types.h 8.3 (Berkeley) 1/5/94
*/
#ifndef _MACHTYPES_H_
#define _MACHTYPES_H_
#ifndef __ASSEMBLER__
#include <arm/_types.h>
#include <sys/cdefs.h>
/*
* Basic integral types. Omit the typedef if
* not possible for a machine/compiler combination.
*/
#include <sys/_types/_int8_t.h>
#include <sys/_types/_int16_t.h>
#include <sys/_types/_int32_t.h>
#include <sys/_types/_int64_t.h>
#include <sys/_types/_u_int8_t.h>
#include <sys/_types/_u_int16_t.h>
#include <sys/_types/_u_int32_t.h>
#include <sys/_types/_u_int64_t.h>
#if __LP64__
typedef int64_t register_t;
#else
typedef int32_t register_t;
#endif
#include <sys/_types/_intptr_t.h>
#include <sys/_types/_uintptr_t.h>
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
/* These types are used for reserving the largest possible size. */
#ifdef __arm64__
typedef u_int64_t user_addr_t;
typedef u_int64_t user_size_t;
typedef int64_t user_ssize_t;
typedef int64_t user_long_t;
typedef u_int64_t user_ulong_t;
typedef int64_t user_time_t;
typedef int64_t user_off_t;
#else
typedef u_int32_t user_addr_t;
typedef u_int32_t user_size_t;
typedef int32_t user_ssize_t;
typedef int32_t user_long_t;
typedef u_int32_t user_ulong_t;
typedef int32_t user_time_t;
typedef int64_t user_off_t;
#endif
#define USER_ADDR_NULL ((user_addr_t) 0)
#define CAST_USER_ADDR_T(a_ptr) ((user_addr_t)((uintptr_t)(a_ptr)))
#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
/* This defines the size of syscall arguments after copying into the kernel: */
#if defined(__arm__)
typedef u_int32_t syscall_arg_t;
#elif defined(__arm64__)
typedef u_int64_t syscall_arg_t;
#else
#error Unknown architecture.
#endif
#endif /* __ASSEMBLER__ */
#endif /* _MACHTYPES_H_ */

View File

@@ -0,0 +1,97 @@
/*
* ++Copyright++ 1983, 1993
* -
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* -
* --Copyright--
*/
/*
* @(#)inet.h 8.1 (Berkeley) 6/2/93
* $Id: inet.h,v 1.10 2006/02/01 18:09:47 majka Exp $
*/
#ifndef _ARPA_INET_H_
#define _ARPA_INET_H_
/* External definitions for functions in inet(3), addr2ascii(3) */
#include <sys/cdefs.h>
#include <sys/_types.h>
#include <stdint.h> /* uint32_t uint16_t */
#include <machine/endian.h> /* htonl() and family if (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
#include <sys/_endian.h> /* htonl() and family if (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
#include <netinet/in.h> /* in_addr */
__BEGIN_DECLS
in_addr_t inet_addr(const char *);
char *inet_ntoa(struct in_addr);
const char *inet_ntop(int, const void *, char *, socklen_t);
int inet_pton(int, const char *, void *);
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
int ascii2addr(int, const char *, void *);
char *addr2ascii(int, const void *, int, char *);
int inet_aton(const char *, struct in_addr *);
in_addr_t inet_lnaof(struct in_addr);
struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
in_addr_t inet_netof(struct in_addr);
in_addr_t inet_network(const char *);
char *inet_net_ntop(int, const void *, int, char *, __darwin_size_t);
int inet_net_pton(int, const char *, void *, __darwin_size_t);
char *inet_neta(in_addr_t, char *, __darwin_size_t);
unsigned int inet_nsap_addr(const char *, unsigned char *, int);
char *inet_nsap_ntoa(int, const unsigned char *, char *);
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
__END_DECLS
#endif /* !_ARPA_INET_H_ */

View File

@@ -0,0 +1,111 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)assert.h 8.2 (Berkeley) 1/21/94
* $FreeBSD: src/include/assert.h,v 1.4 2002/03/23 17:24:53 imp Exp $
*/
#include <sys/cdefs.h>
#ifdef __cplusplus
#include <stdlib.h>
#endif /* __cplusplus */
/*
* Unlike other ANSI header files, <assert.h> may usefully be included
* multiple times, with and without NDEBUG defined.
*/
#undef assert
#undef __assert
#ifdef NDEBUG
#define assert(e) ((void)0)
#else
#ifndef __GNUC__
__BEGIN_DECLS
#ifndef __cplusplus
void abort(void) __dead2 __cold;
#endif /* !__cplusplus */
int printf(const char * __restrict, ...);
__END_DECLS
#define assert(e) \
((void) ((e) ? ((void)0) : __assert (#e, __FILE__, __LINE__)))
#define __assert(e, file, line) \
((void)printf ("%s:%d: failed assertion `%s'\n", file, line, e), abort())
#else /* __GNUC__ */
__BEGIN_DECLS
void __assert_rtn(const char *, const char *, int, const char *) __dead2 __cold __disable_tail_calls;
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1070)
void __eprintf(const char *, const char *, unsigned, const char *) __dead2 __cold;
#endif
__END_DECLS
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1070)
#define __assert(e, file, line) \
__eprintf ("%s:%d: failed assertion `%s'\n", file, line, e)
#else
/* 8462256: modified __assert_rtn() replaces deprecated __eprintf() */
#define __assert(e, file, line) \
__assert_rtn ((const char *)-1L, file, line, e)
#endif
#if __DARWIN_UNIX03
#define assert(e) \
(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
#else /* !__DARWIN_UNIX03 */
#define assert(e) \
(__builtin_expect(!(e), 0) ? __assert (#e, __FILE__, __LINE__) : (void)0)
#endif /* __DARWIN_UNIX03 */
#endif /* __GNUC__ */
#endif /* NDEBUG */
#ifndef _ASSERT_H_
#define _ASSERT_H_
#ifndef __cplusplus
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define static_assert _Static_assert
#endif /* __STDC_VERSION__ */
#endif /* !__cplusplus */
#endif /* _ASSERT_H_ */

View File

@@ -0,0 +1,391 @@
/*-
* Copyright (c) 2005-2009 Apple Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit.h#10 $
*/
#ifndef _BSM_AUDIT_H
#define _BSM_AUDIT_H
#include <sys/param.h>
#include <sys/types.h>
#define AUDIT_RECORD_MAGIC 0x828a0f1b
#define MAX_AUDIT_RECORDS 20
#define MAXAUDITDATA (0x8000 - 1)
#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA
#define MIN_AUDIT_FILE_SIZE (512 * 1024)
/*
* Minimum noumber of free blocks on the filesystem containing the audit
* log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0
* as the kernel does an unsigned compare, plus we want to leave a few blocks
* free so userspace can terminate the log, etc.
*/
#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4
/*
* Triggers for the audit daemon.
*/
#define AUDIT_TRIGGER_MIN 1
#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */
#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */
#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */
#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */
#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */
#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */
#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */
#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */
#define AUDIT_TRIGGER_MAX 8
/*
* The special device filename (FreeBSD).
*/
#define AUDITDEV_FILENAME "audit"
#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME)
/*
* Pre-defined audit IDs
*/
#define AU_DEFAUDITID (uid_t)(-1)
#define AU_DEFAUDITSID 0
#define AU_ASSIGN_ASID -1
/*
* IPC types.
*/
#define AT_IPC_MSG ((unsigned char)1) /* Message IPC id. */
#define AT_IPC_SEM ((unsigned char)2) /* Semaphore IPC id. */
#define AT_IPC_SHM ((unsigned char)3) /* Shared mem IPC id. */
/*
* Audit conditions.
*/
#define AUC_UNSET 0
#define AUC_AUDITING 1
#define AUC_NOAUDIT 2
#define AUC_DISABLED -1
/*
* auditon(2) commands.
*/
#define A_OLDGETPOLICY 2
#define A_OLDSETPOLICY 3
#define A_GETKMASK 4
#define A_SETKMASK 5
#define A_OLDGETQCTRL 6
#define A_OLDSETQCTRL 7
#define A_GETCWD 8
#define A_GETCAR 9
#define A_GETSTAT 12
#define A_SETSTAT 13
#define A_SETUMASK 14
#define A_SETSMASK 15
#define A_OLDGETCOND 20
#define A_OLDSETCOND 21
#define A_GETCLASS 22
#define A_SETCLASS 23
#define A_GETPINFO 24
#define A_SETPMASK 25
#define A_SETFSIZE 26
#define A_GETFSIZE 27
#define A_GETPINFO_ADDR 28
#define A_GETKAUDIT 29
#define A_SETKAUDIT 30
#define A_SENDTRIGGER 31
#define A_GETSINFO_ADDR 32
#define A_GETPOLICY 33
#define A_SETPOLICY 34
#define A_GETQCTRL 35
#define A_SETQCTRL 36
#define A_GETCOND 37
#define A_SETCOND 38
#define A_GETSFLAGS 39
#define A_SETSFLAGS 40
#define A_GETCTLMODE 41
#define A_SETCTLMODE 42
#define A_GETEXPAFTER 43
#define A_SETEXPAFTER 44
/*
* Audit policy controls.
*/
#define AUDIT_CNT 0x0001
#define AUDIT_AHLT 0x0002
#define AUDIT_ARGV 0x0004
#define AUDIT_ARGE 0x0008
#define AUDIT_SEQ 0x0010
#define AUDIT_WINDATA 0x0020
#define AUDIT_USER 0x0040
#define AUDIT_GROUP 0x0080
#define AUDIT_TRAIL 0x0100
#define AUDIT_PATH 0x0200
#define AUDIT_SCNT 0x0400
#define AUDIT_PUBLIC 0x0800
#define AUDIT_ZONENAME 0x1000
#define AUDIT_PERZONE 0x2000
/*
* Default audit queue control parameters.
*/
#define AQ_HIWATER 100
#define AQ_MAXHIGH 10000
#define AQ_LOWATER 10
#define AQ_BUFSZ MAXAUDITDATA
#define AQ_MAXBUFSZ 1048576
/*
* Default minimum percentage free space on file system.
*/
#define AU_FS_MINFREE 20
/*
* Type definitions used indicating the length of variable length addresses
* in tokens containing addresses, such as header fields.
*/
#define AU_IPv4 4
#define AU_IPv6 16
/*
* Reserved audit class mask indicating which classes are unable to have
* events added or removed by unentitled processes.
*/
#define AU_CLASS_MASK_RESERVED 0x10000000
/*
* Audit control modes
*/
#define AUDIT_CTLMODE_NORMAL ((unsigned char)1)
#define AUDIT_CTLMODE_EXTERNAL ((unsigned char)2)
/*
* Audit file expire_after op modes
*/
#define AUDIT_EXPIRE_OP_AND ((unsigned char)0)
#define AUDIT_EXPIRE_OP_OR ((unsigned char)1)
__BEGIN_DECLS
typedef uid_t au_id_t;
typedef pid_t au_asid_t;
typedef u_int16_t au_event_t;
typedef u_int16_t au_emod_t;
typedef u_int32_t au_class_t;
typedef u_int64_t au_asflgs_t __attribute__ ((aligned(8)));
typedef unsigned char au_ctlmode_t;
struct au_tid {
dev_t port;
u_int32_t machine;
};
typedef struct au_tid au_tid_t;
struct au_tid_addr {
dev_t at_port;
u_int32_t at_type;
u_int32_t at_addr[4];
};
typedef struct au_tid_addr au_tid_addr_t;
struct au_mask {
unsigned int am_success; /* Success bits. */
unsigned int am_failure; /* Failure bits. */
};
typedef struct au_mask au_mask_t;
struct auditinfo {
au_id_t ai_auid; /* Audit user ID. */
au_mask_t ai_mask; /* Audit masks. */
au_tid_t ai_termid; /* Terminal ID. */
au_asid_t ai_asid; /* Audit session ID. */
};
typedef struct auditinfo auditinfo_t;
struct auditinfo_addr {
au_id_t ai_auid; /* Audit user ID. */
au_mask_t ai_mask; /* Audit masks. */
au_tid_addr_t ai_termid; /* Terminal ID. */
au_asid_t ai_asid; /* Audit session ID. */
au_asflgs_t ai_flags; /* Audit session flags. */
};
typedef struct auditinfo_addr auditinfo_addr_t;
struct auditpinfo {
pid_t ap_pid; /* ID of target process. */
au_id_t ap_auid; /* Audit user ID. */
au_mask_t ap_mask; /* Audit masks. */
au_tid_t ap_termid; /* Terminal ID. */
au_asid_t ap_asid; /* Audit session ID. */
};
typedef struct auditpinfo auditpinfo_t;
struct auditpinfo_addr {
pid_t ap_pid; /* ID of target process. */
au_id_t ap_auid; /* Audit user ID. */
au_mask_t ap_mask; /* Audit masks. */
au_tid_addr_t ap_termid; /* Terminal ID. */
au_asid_t ap_asid; /* Audit session ID. */
au_asflgs_t ap_flags; /* Audit session flags. */
};
typedef struct auditpinfo_addr auditpinfo_addr_t;
struct au_session {
auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */
au_mask_t as_mask; /* Process Audit Masks. */
};
typedef struct au_session au_session_t;
struct au_expire_after {
time_t age; /* Age after which trail files should be expired */
size_t size; /* Aggregate trail size when files should be expired */
unsigned char op_type; /* Operator used with the above values to determine when files should be expired */
};
typedef struct au_expire_after au_expire_after_t;
/*
* Contents of token_t are opaque outside of libbsm.
*/
typedef struct au_token token_t;
/*
* Kernel audit queue control parameters:
* Default: Maximum:
* aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000)
* aq_lowater: AQ_LOWATER (10) <aq_hiwater
* aq_bufsz: AQ_BUFSZ (32767) AQ_MAXBUFSZ (1048576)
* aq_delay: 20 20000 (not used)
*/
struct au_qctrl {
int aq_hiwater; /* Max # of audit recs in queue when */
/* threads with new ARs get blocked. */
int aq_lowater; /* # of audit recs in queue when */
/* blocked threads get unblocked. */
int aq_bufsz; /* Max size of audit record for audit(2). */
int aq_delay; /* Queue delay (not used). */
int aq_minfree; /* Minimum filesystem percent free space. */
};
typedef struct au_qctrl au_qctrl_t;
/*
* Structure for the audit statistics.
*/
struct audit_stat {
unsigned int as_version;
unsigned int as_numevent;
int as_generated;
int as_nonattrib;
int as_kernel;
int as_audit;
int as_auditctl;
int as_enqueue;
int as_written;
int as_wblocked;
int as_rblocked;
int as_dropped;
int as_totalsize;
unsigned int as_memused;
};
typedef struct audit_stat au_stat_t;
/*
* Structure for the audit file statistics.
*/
struct audit_fstat {
u_int64_t af_filesz;
u_int64_t af_currsz;
};
typedef struct audit_fstat au_fstat_t;
/*
* Audit to event class mapping.
*/
struct au_evclass_map {
au_event_t ec_number;
au_class_t ec_class;
};
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)
__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);
int setaudit_addr(const struct auditinfo_addr *, int);
#if defined(__APPLE__)
#include <Availability.h>
/*
* getaudit()/setaudit() are deprecated and have been replaced with
* wrappers to the getaudit_addr()/setaudit_addr() syscalls above.
*/
int getaudit(struct auditinfo *)
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8,
__IPHONE_2_0, __IPHONE_6_0);
int setaudit(const struct auditinfo *)
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8,
__IPHONE_2_0, __IPHONE_6_0);
#else
int getaudit(struct auditinfo *)
__AUDIT_API_DEPRECATED;
int setaudit(const struct auditinfo *)
__AUDIT_API_DEPRECATED;
#endif /* !__APPLE__ */
#ifdef __APPLE_API_PRIVATE
#include <mach/port.h>
mach_port_name_t audit_session_self(void);
au_asid_t audit_session_join(mach_port_name_t port);
int audit_session_port(au_asid_t asid, mach_port_name_t *portname);
#endif /* __APPLE_API_PRIVATE */
#endif /* defined(_KERNEL) || defined(KERNEL) */
__END_DECLS
#endif /* !_BSM_AUDIT_H */

View File

@@ -0,0 +1,167 @@
/*
* Copyright (c) 2002-2013 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This 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 OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/******************************************************************************
* *
* File: complex.h *
* *
* Contains: prototypes and macros germane to C99 complex math. *
* *
******************************************************************************/
#ifndef __COMPLEX_H__
#define __COMPLEX_H__
#include <sys/cdefs.h>
#undef complex
#define complex _Complex
#undef _Complex_I
/* Constant expression of type const float _Complex */
#define _Complex_I (__extension__ 1.0iF)
#undef I
#define I _Complex_I
#if (__STDC_VERSION__ > 199901L || __DARWIN_C_LEVEL >= __DARWIN_C_FULL) \
&& defined __clang__
/* Complex initializer macros. These are a C11 feature, but are also provided
as an extension in C99 so long as strict POSIX conformance is not
requested. They are available only when building with the llvm-clang
compiler, as there is no way to support them with the gcc-4.2 frontend.
These may be used for static initialization of complex values, like so:
static const float complex someVariable = CMPLXF(1.0, INFINITY);
they may, of course, be used outside of static contexts as well. */
#define CMPLX(__real,__imag) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \
(double _Complex){(__real),(__imag)} \
_Pragma("clang diagnostic pop")
#define CMPLXF(__real,__imag) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \
(float _Complex){(__real),(__imag)} \
_Pragma("clang diagnostic pop")
#define CMPLXL(__real,__imag) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \
(long double _Complex){(__real),(__imag)} \
_Pragma("clang diagnostic pop")
#endif /* End C11 features. */
__BEGIN_DECLS
extern float complex cacosf(float complex);
extern double complex cacos(double complex);
extern long double complex cacosl(long double complex);
extern float complex casinf(float complex);
extern double complex casin(double complex);
extern long double complex casinl(long double complex);
extern float complex catanf(float complex);
extern double complex catan(double complex);
extern long double complex catanl(long double complex);
extern float complex ccosf(float complex);
extern double complex ccos(double complex);
extern long double complex ccosl(long double complex);
extern float complex csinf(float complex);
extern double complex csin(double complex);
extern long double complex csinl(long double complex);
extern float complex ctanf(float complex);
extern double complex ctan(double complex);
extern long double complex ctanl(long double complex);
extern float complex cacoshf(float complex);
extern double complex cacosh(double complex);
extern long double complex cacoshl(long double complex);
extern float complex casinhf(float complex);
extern double complex casinh(double complex);
extern long double complex casinhl(long double complex);
extern float complex catanhf(float complex);
extern double complex catanh(double complex);
extern long double complex catanhl(long double complex);
extern float complex ccoshf(float complex);
extern double complex ccosh(double complex);
extern long double complex ccoshl(long double complex);
extern float complex csinhf(float complex);
extern double complex csinh(double complex);
extern long double complex csinhl(long double complex);
extern float complex ctanhf(float complex);
extern double complex ctanh(double complex);
extern long double complex ctanhl(long double complex);
extern float complex cexpf(float complex);
extern double complex cexp(double complex);
extern long double complex cexpl(long double complex);
extern float complex clogf(float complex);
extern double complex clog(double complex);
extern long double complex clogl(long double complex);
extern float cabsf(float complex);
extern double cabs(double complex);
extern long double cabsl(long double complex);
extern float complex cpowf(float complex, float complex);
extern double complex cpow(double complex, double complex);
extern long double complex cpowl(long double complex, long double complex);
extern float complex csqrtf(float complex);
extern double complex csqrt(double complex);
extern long double complex csqrtl(long double complex);
extern float cargf(float complex);
extern double carg(double complex);
extern long double cargl(long double complex);
extern float cimagf(float complex);
extern double cimag(double complex);
extern long double cimagl(long double complex);
extern float complex conjf(float complex);
extern double complex conj(double complex);
extern long double complex conjl(long double complex);
extern float complex cprojf(float complex);
extern double complex cproj(double complex);
extern long double complex cprojl(long double complex);
extern float crealf(float complex);
extern double creal(double complex);
extern long double creall(long double complex);
__END_DECLS
#endif /* __COMPLEX_H__ */

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2004-2019 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 _COPYFILE_H_ /* version 0.1 */
#define _COPYFILE_H_
/*
* This API facilitates the copying of files and their associated
* metadata. There are several open source projects that need
* modifications to support preserving extended attributes and ACLs
* and this API collapses several hundred lines of modifications into
* one or two calls.
*/
/* private */
#include <sys/cdefs.h>
#include <stdint.h>
__BEGIN_DECLS
struct _copyfile_state;
typedef struct _copyfile_state * copyfile_state_t;
typedef uint32_t copyfile_flags_t;
/* public */
/* receives:
* from path to source file system object
* to path to destination file system object
* state opaque blob for future extensibility
* Must be NULL in current implementation
* flags (described below)
* returns:
* int negative for error
*/
int copyfile(const char *from, const char *to, copyfile_state_t state, copyfile_flags_t flags);
int fcopyfile(int from_fd, int to_fd, copyfile_state_t, copyfile_flags_t flags);
int copyfile_state_free(copyfile_state_t);
copyfile_state_t copyfile_state_alloc(void);
int copyfile_state_get(copyfile_state_t s, uint32_t flag, void * dst);
int copyfile_state_set(copyfile_state_t s, uint32_t flag, const void * src);
typedef int (*copyfile_callback_t)(int, int, copyfile_state_t, const char *, const char *, void *);
#define COPYFILE_STATE_SRC_FD 1
#define COPYFILE_STATE_SRC_FILENAME 2
#define COPYFILE_STATE_DST_FD 3
#define COPYFILE_STATE_DST_FILENAME 4
#define COPYFILE_STATE_QUARANTINE 5
#define COPYFILE_STATE_STATUS_CB 6
#define COPYFILE_STATE_STATUS_CTX 7
#define COPYFILE_STATE_COPIED 8
#define COPYFILE_STATE_XATTRNAME 9
#define COPYFILE_STATE_WAS_CLONED 10
#define COPYFILE_DISABLE_VAR "COPYFILE_DISABLE"
/* flags for copyfile */
#define COPYFILE_ACL (1<<0)
#define COPYFILE_STAT (1<<1)
#define COPYFILE_XATTR (1<<2)
#define COPYFILE_DATA (1<<3)
#define COPYFILE_SECURITY (COPYFILE_STAT | COPYFILE_ACL)
#define COPYFILE_METADATA (COPYFILE_SECURITY | COPYFILE_XATTR)
#define COPYFILE_ALL (COPYFILE_METADATA | COPYFILE_DATA)
#define COPYFILE_RECURSIVE (1<<15) /* Descend into hierarchies */
#define COPYFILE_CHECK (1<<16) /* return flags for xattr or acls if set */
#define COPYFILE_EXCL (1<<17) /* fail if destination exists */
#define COPYFILE_NOFOLLOW_SRC (1<<18) /* don't follow if source is a symlink */
#define COPYFILE_NOFOLLOW_DST (1<<19) /* don't follow if dst is a symlink */
#define COPYFILE_MOVE (1<<20) /* unlink src after copy */
#define COPYFILE_UNLINK (1<<21) /* unlink dst before copy */
#define COPYFILE_NOFOLLOW (COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST)
#define COPYFILE_PACK (1<<22)
#define COPYFILE_UNPACK (1<<23)
#define COPYFILE_CLONE (1<<24)
#define COPYFILE_CLONE_FORCE (1<<25)
#define COPYFILE_RUN_IN_PLACE (1<<26)
#define COPYFILE_DATA_SPARSE (1<<27)
#define COPYFILE_PRESERVE_DST_TRACKED (1<<28)
#define COPYFILE_VERBOSE (1<<30)
#define COPYFILE_RECURSE_ERROR 0
#define COPYFILE_RECURSE_FILE 1
#define COPYFILE_RECURSE_DIR 2
#define COPYFILE_RECURSE_DIR_CLEANUP 3
#define COPYFILE_COPY_DATA 4
#define COPYFILE_COPY_XATTR 5
#define COPYFILE_START 1
#define COPYFILE_FINISH 2
#define COPYFILE_ERR 3
#define COPYFILE_PROGRESS 4
#define COPYFILE_CONTINUE 0
#define COPYFILE_SKIP 1
#define COPYFILE_QUIT 2
__END_DECLS
#endif /* _COPYFILE_H_ */

View File

@@ -0,0 +1,55 @@
/*-
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/cpio.h,v 1.1 2002/08/01 07:18:38 mike Exp $
*/
#ifndef _CPIO_H_
#define _CPIO_H_
#define C_ISSOCK 0140000 /* Socket. */
#define C_ISLNK 0120000 /* Symbolic link. */
#define C_ISCTG 0110000 /* Reserved. */
#define C_ISREG 0100000 /* Regular file. */
#define C_ISBLK 0060000 /* Block special. */
#define C_ISDIR 0040000 /* Directory. */
#define C_ISCHR 0020000 /* Character special. */
#define C_ISFIFO 0010000 /* FIFO. */
#define C_ISUID 0004000 /* Set user ID. */
#define C_ISGID 0002000 /* Set group ID. */
#define C_ISVTX 0001000 /* On directories, restricted deletion flag. */
#define C_IRUSR 0000400 /* Read by owner. */
#define C_IWUSR 0000200 /* Write by owner. */
#define C_IXUSR 0000100 /* Execute by owner. */
#define C_IRGRP 0000040 /* Read by group. */
#define C_IWGRP 0000020 /* Write by group. */
#define C_IXGRP 0000010 /* Execute by group. */
#define C_IROTH 0000004 /* Read by others. */
#define C_IWOTH 0000002 /* Write by others. */
#define C_IXOTH 0000001 /* Execute by others. */
#define MAGIC "070707"
#endif /* _CPIO_H_ */

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1999 Apple Computer, 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 (c) 1995 NeXT Computer, Inc. All Rights Reserved
*/
/*
** Prototypes for the functions to get environment information in
** the world of dynamic libraries. Lifted from .c file of same name.
** Fri Jun 23 12:56:47 PDT 1995
** AOF (afreier@next.com)
*/
#include <sys/cdefs.h>
__BEGIN_DECLS
extern char ***_NSGetArgv(void);
extern int *_NSGetArgc(void);
extern char ***_NSGetEnviron(void);
extern char **_NSGetProgname(void);
#ifdef __LP64__
extern struct mach_header_64 *
#else /* !__LP64__ */
extern struct mach_header *
#endif /* __LP64__ */
_NSGetMachExecuteHeader(void);
__END_DECLS

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2000, 2005, 2008 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 (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ctype.h 8.4 (Berkeley) 1/21/94
*/
#ifndef _CTYPE_H_
#define _CTYPE_H_
#include <_ctype.h>
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_ctype.h>
#endif /* _USE_EXTENDED_LOCALES_ */
#endif /* !_CTYPE_H_ */

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,191 @@
/*
* Copyright (c) 2000, 2002-2008 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 (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)dirent.h 8.2 (Berkeley) 7/28/94
*/
#ifndef _DIRENT_H_
#define _DIRENT_H_
/*
* The kernel defines the format of directory entries
*/
#include <_types.h>
#include <sys/dirent.h>
#include <sys/cdefs.h>
#include <Availability.h>
#include <sys/_pthread/_pthread_types.h> /* __darwin_pthread_mutex_t */
struct _telldir; /* forward reference */
/* structure describing an open directory. */
typedef struct {
int __dd_fd; /* file descriptor associated with directory */
long __dd_loc; /* offset in current buffer */
long __dd_size; /* amount of data returned */
char *__dd_buf; /* data buffer */
int __dd_len; /* size of data buffer */
long __dd_seek; /* magic cookie returned */
__unused long __padding; /* (__dd_rewind space left for bincompat) */
int __dd_flags; /* flags for readdir */
__darwin_pthread_mutex_t __dd_lock; /* for thread locking */
struct _telldir *__dd_td; /* telldir position recording */
} DIR;
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
/* definitions for library routines operating on directories. */
#define DIRBLKSIZ 1024
/* flags for opendir2 */
#define DTF_HIDEW 0x0001 /* hide whiteout entries */
#define DTF_NODUP 0x0002 /* don't return duplicate names */
#define DTF_REWIND 0x0004 /* rewind after reading union stack */
#define __DTF_READALL 0x0008 /* everything has been read */
#define __DTF_SKIPREAD 0x0010 /* assume internal buffer is populated */
#define __DTF_ATEND 0x0020 /* there's nothing more to read in the kernel */
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
#ifndef KERNEL
__BEGIN_DECLS
int closedir(DIR *) __DARWIN_ALIAS(closedir);
DIR *opendir(const char *) __DARWIN_ALIAS_I(opendir);
struct dirent *readdir(DIR *) __DARWIN_INODE64(readdir);
int readdir_r(DIR *, struct dirent *, struct dirent **) __DARWIN_INODE64(readdir_r);
void rewinddir(DIR *) __DARWIN_ALIAS_I(rewinddir);
void seekdir(DIR *, long) __DARWIN_ALIAS_I(seekdir);
long telldir(DIR *) __DARWIN_ALIAS_I(telldir);
__END_DECLS
/* Additional functionality provided by:
* POSIX.1-2008
*/
#if __DARWIN_C_LEVEL >= 200809L
__BEGIN_DECLS
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
DIR *fdopendir(int) __DARWIN_ALIAS_I(fdopendir);
int alphasort(const struct dirent **, const struct dirent **) __DARWIN_INODE64(alphasort);
#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)
#include <errno.h>
#include <stdlib.h>
#define dirfd(dirp) ({ \
DIR *_dirp = (dirp); \
int ret = -1; \
if (_dirp == NULL || _dirp->__dd_fd < 0) \
errno = EINVAL; \
else \
ret = _dirp->__dd_fd; \
ret; \
})
#else
int dirfd(DIR *dirp) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0);
#endif
int scandir(const char *, struct dirent ***,
int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)) __DARWIN_INODE64(scandir);
#ifdef __BLOCKS__
#if __has_attribute(noescape)
#define __scandir_noescape __attribute__((__noescape__))
#else
#define __scandir_noescape
#endif
int scandir_b(const char *, struct dirent ***,
int (^)(const struct dirent *) __scandir_noescape,
int (^)(const struct dirent **, const struct dirent **) __scandir_noescape)
__DARWIN_INODE64(scandir_b) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#endif /* __BLOCKS__ */
__END_DECLS
#endif /* __DARWIN_C_LEVEL >= 200809L */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
__BEGIN_DECLS
int getdirentries(int, char *, int, long *)
#if __DARWIN_64_BIT_INO_T
/*
* getdirentries() doesn't work when 64-bit inodes is in effect, so we
* generate a link error.
*/
__asm("_getdirentries_is_not_available_when_64_bit_inodes_are_in_effect")
#else /* !__DARWIN_64_BIT_INO_T */
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_6, __IPHONE_2_0,__IPHONE_2_0)
#endif /* __DARWIN_64_BIT_INO_T */
;
DIR *__opendir2(const char *, int) __DARWIN_ALIAS_I(__opendir2);
__END_DECLS
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
#endif /* !KERNEL */
#endif /* !_DIRENT_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,97 @@
/*
* Copyright (c) 2004-2008 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@
*/
/*
Based on the dlcompat work done by:
Jorge Acereda <jacereda@users.sourceforge.net> &
Peter O'Gorman <ogorman@users.sourceforge.net>
*/
#ifndef _DLFCN_H_
#define _DLFCN_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/cdefs.h>
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#include <stdbool.h>
#include <Availability.h>
#ifdef __DRIVERKIT_19_0
#define __DYLDDL_DRIVERKIT_UNAVAILABLE __API_UNAVAILABLE(driverkit)
#else
#define __DYLDDL_DRIVERKIT_UNAVAILABLE
#endif
/*
* Structure filled in by dladdr().
*/
typedef struct dl_info {
const char *dli_fname; /* Pathname of shared object */
void *dli_fbase; /* Base address of shared object */
const char *dli_sname; /* Name of nearest symbol */
void *dli_saddr; /* Address of nearest symbol */
} Dl_info;
extern int dladdr(const void *, Dl_info *);
#else
#define __DYLDDL_DRIVERKIT_UNAVAILABLE
#endif /* not POSIX */
extern int dlclose(void * __handle) __DYLDDL_DRIVERKIT_UNAVAILABLE;
extern char * dlerror(void) __DYLDDL_DRIVERKIT_UNAVAILABLE;
extern void * dlopen(const char * __path, int __mode) __DYLDDL_DRIVERKIT_UNAVAILABLE;
extern void * dlsym(void * __handle, const char * __symbol) __DYLDDL_DRIVERKIT_UNAVAILABLE;
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
extern bool dlopen_preflight(const char* __path) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) __DYLDDL_DRIVERKIT_UNAVAILABLE;
#endif /* not POSIX */
#define RTLD_LAZY 0x1
#define RTLD_NOW 0x2
#define RTLD_LOCAL 0x4
#define RTLD_GLOBAL 0x8
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define RTLD_NOLOAD 0x10
#define RTLD_NODELETE 0x80
#define RTLD_FIRST 0x100 /* Mac OS X 10.5 and later */
/*
* Special handle arguments for dlsym().
*/
#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */
#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */
#define RTLD_SELF ((void *) -3) /* Search this and subsequent objects (Mac OS X 10.5 and later) */
#define RTLD_MAIN_ONLY ((void *) -5) /* Search main executable only (Mac OS X 10.5 and later) */
#endif /* not POSIX */
#ifdef __cplusplus
}
#endif
#endif /* _DLFCN_H_ */

View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2000 Apple Computer, 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@
*/
#include <sys/errno.h>

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 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@
*/
#ifndef _EXECINFO_H_
#define _EXECINFO_H_ 1
#include <sys/cdefs.h>
#include <Availability.h>
#include <os/base.h>
#include <os/availability.h>
#include <stdint.h>
#include <uuid/uuid.h>
__BEGIN_DECLS
int backtrace(void**,int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
API_AVAILABLE(macosx(10.14), ios(12.0), tvos(12.0), watchos(5.0))
OS_EXPORT
int backtrace_from_fp(void *startfp, void **array, int size);
char** backtrace_symbols(void* const*,int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
void backtrace_symbols_fd(void* const*,int,int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
struct image_offset {
/*
* The UUID of the image.
*/
uuid_t uuid;
/*
* The offset is relative to the __TEXT section of the image.
*/
uint32_t offset;
};
API_AVAILABLE(macosx(10.14), ios(12.0), tvos(12.0), watchos(5.0))
OS_EXPORT
void backtrace_image_offsets(void* const* array,
struct image_offset *image_offsets, int size);
__END_DECLS
#endif /* !_EXECINFO_H_ */

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2000 Apple Computer, 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@
*/
#include <sys/fcntl.h>

View File

@@ -0,0 +1,361 @@
/*
* Copyright (c) 2002-2013 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This 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 OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/******************************************************************************
* *
* File: fenv.h *
* *
* Contains: typedefs and prototypes for C99 floating point environment. *
* *
* A collection of functions designed to provide access to the floating *
* point environment for numerical programming. It is compliant with the *
* floating-point requirements in C99. *
* *
* The file <fenv.h> declares many functions in support of numerical *
* programming. Programs that test flags or run under non-default mode *
* must do so under the effect of an enabling "fenv_access" pragma: *
* *
* #pragma STDC FENV_ACCESS on *
* *
******************************************************************************/
#ifndef __FENV_H__
#define __FENV_H__
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* *
* Architecture-specific types and macros. *
* *
* fenv_t a type for representing the entire floating-point *
* environment in a single object. *
* *
* fexcept_t a type for representing the floating-point *
* exception flag state collectively. *
* *
* FE_INEXACT macros representing the various floating-point *
* FE_UNDERFLOW exceptions. *
* FE_OVERFLOW *
* FE_DIVBYZERO *
* FE_INVALID *
* FE_ALL_EXCEPT *
* *
* FE_TONEAREST macros representing the various floating-point *
* FE_UPWARD rounding modes *
* FE_DOWNWARD *
* FE_TOWARDZERO *
* *
* FE_DFL_ENV a macro expanding to a pointer to an object *
* representing the default floating-point environemnt *
* *
******************************************************************************/
/******************************************************************************
* ARM definitions of architecture-specific types and macros. *
******************************************************************************/
#if defined __arm__ && !defined __SOFTFP__
typedef struct {
unsigned int __fpscr;
unsigned int __reserved0;
unsigned int __reserved1;
unsigned int __reserved2;
} fenv_t;
typedef unsigned short fexcept_t;
#define FE_INEXACT 0x0010
#define FE_UNDERFLOW 0x0008
#define FE_OVERFLOW 0x0004
#define FE_DIVBYZERO 0x0002
#define FE_INVALID 0x0001
/* FE_FLUSHTOZERO
An ARM-specific flag that is raised when a denormal is flushed to zero.
This is also called the "input denormal exception" */
#define FE_FLUSHTOZERO 0x0080
#define FE_ALL_EXCEPT 0x009f
#define FE_TONEAREST 0x00000000
#define FE_UPWARD 0x00400000
#define FE_DOWNWARD 0x00800000
#define FE_TOWARDZERO 0x00C00000
/* Masks for values that may be controlled in the FPSCR. Modifying any other
bits invokes undefined behavior. */
enum {
__fpscr_trap_invalid = 0x00000100,
__fpscr_trap_divbyzero = 0x00000200,
__fpscr_trap_overflow = 0x00000400,
__fpscr_trap_underflow = 0x00000800,
__fpscr_trap_inexact = 0x00001000,
__fpscr_trap_denormal = 0x00008000,
__fpscr_flush_to_zero = 0x01000000,
__fpscr_default_nan = 0x02000000,
__fpscr_saturation = 0x08000000,
};
extern const fenv_t _FE_DFL_ENV;
#define FE_DFL_ENV &_FE_DFL_ENV
/******************************************************************************
* ARM64 definitions of architecture-specific types and macros. *
******************************************************************************/
#elif defined __arm64__
typedef struct {
unsigned long long __fpsr;
unsigned long long __fpcr;
} fenv_t;
typedef unsigned short fexcept_t;
#define FE_INEXACT 0x0010
#define FE_UNDERFLOW 0x0008
#define FE_OVERFLOW 0x0004
#define FE_DIVBYZERO 0x0002
#define FE_INVALID 0x0001
/* FE_FLUSHTOZERO
An ARM-specific flag that is raised when a denormal is flushed to zero.
This is also called the "input denormal exception" */
#define FE_FLUSHTOZERO 0x0080
#define FE_ALL_EXCEPT 0x009f
#define FE_TONEAREST 0x00000000
#define FE_UPWARD 0x00400000
#define FE_DOWNWARD 0x00800000
#define FE_TOWARDZERO 0x00C00000
/* Masks for values that may be controlled in the FPCR. Modifying any other
bits invokes undefined behavior. */
enum {
__fpcr_trap_invalid = 0x00000100,
__fpcr_trap_divbyzero = 0x00000200,
__fpcr_trap_overflow = 0x00000400,
__fpcr_trap_underflow = 0x00000800,
__fpcr_trap_inexact = 0x00001000,
__fpcr_trap_denormal = 0x00008000,
__fpcr_flush_to_zero = 0x01000000,
};
/* Mask for the QC bit of the FPSR */
enum { __fpsr_saturation = 0x08000000 };
extern const fenv_t _FE_DFL_ENV;
#define FE_DFL_ENV &_FE_DFL_ENV
/* FE_DFL_DISABLE_DENORMS_ENV
A pointer to a fenv_t object with the default floating-point state modified
to set the FZ (flush to zero) bit in the FPCR. When using this environment
denormals encountered by floating-point calculations will be treated as
zero. Denormal results of floating-point operations will also be treated
as zero. This calculation mode is not IEEE-754 compliant, but it may
prevent lengthy stalls that occur in code that encounters denormals. It is
suggested that you do not use this mode unless you have established that
denormals are the source of measurable performance problems.
Note that the math library, and other system libraries, are not guaranteed
to do the right thing if called in this mode. Edge cases may be incorrect.
Use at your own risk. */
extern const fenv_t _FE_DFL_DISABLE_DENORMS_ENV;
#define FE_DFL_DISABLE_DENORMS_ENV &_FE_DFL_DISABLE_DENORMS_ENV
/******************************************************************************
* x86 definitions of architecture-specific types and macros. *
******************************************************************************/
#elif defined __i386__ || defined __x86_64__
typedef struct {
unsigned short __control; /* x87 control word */
unsigned short __status; /* x87 status word */
unsigned int __mxcsr; /* SSE status/control register */
char __reserved[8]; /* Reserved for future expansion */
} fenv_t;
typedef unsigned short fexcept_t;
#define FE_INEXACT 0x0020
#define FE_UNDERFLOW 0x0010
#define FE_OVERFLOW 0x0008
#define FE_DIVBYZERO 0x0004
#define FE_INVALID 0x0001
/* FE_DENORMALOPERAND
An Intel-specific flag that is raised when an operand to a floating-point
arithmetic operation is denormal, or a single- or double-precision denormal
value is loaded on the x87 stack. This flag is not raised by SSE
arithmetic when the DAZ control bit is set. */
#define FE_DENORMALOPERAND 0x0002
#define FE_ALL_EXCEPT 0x003f
#define FE_TONEAREST 0x0000
#define FE_DOWNWARD 0x0400
#define FE_UPWARD 0x0800
#define FE_TOWARDZERO 0x0c00
extern const fenv_t _FE_DFL_ENV;
#define FE_DFL_ENV &_FE_DFL_ENV
/* FE_DFL_DISABLE_SSE_DENORMS_ENV
A pointer to a fenv_t object with the default floating-point state modifed
to set the DAZ and FZ bits in the SSE status/control register. When using
this environment, denormals encountered by SSE based calculation (which
normally should be all single and double precision scalar floating point
calculations, and all SSE/SSE2/SSE3 computation) will be treated as zero.
Calculation results that are denormals will also be truncated to zero.
This calculation mode is not IEEE-754 compliant, but may prevent lengthy
stalls that occur in code that encounters denormals. It is suggested that
you do not use this mode unless you have established that denormals are
causing trouble for your code. Please use wisely.
CAUTION: The math library currently is not architected to do the right
thing in the face of DAZ + FZ mode. For example, ceil( +denormal) might
return +denormal rather than 1.0 in some versions of MacOS X. In some
circumstances this may lead to unexpected application behavior. Use at
your own risk.
It is not possible to disable denormal stalls for calculations performed
on the x87 FPU */
extern const fenv_t _FE_DFL_DISABLE_SSE_DENORMS_ENV;
#define FE_DFL_DISABLE_SSE_DENORMS_ENV &_FE_DFL_DISABLE_SSE_DENORMS_ENV
/******************************************************************************
* Totally generic definitions and macros if we don't know anything about *
* the target platform, or if the platform does not have hardware floating- *
* point support. *
******************************************************************************/
#else /* Unknown architectures */
typedef int fenv_t;
typedef unsigned short fexcept_t;
#define FE_ALL_EXCEPT 0
#define FE_TONEAREST 0
extern const fenv_t _FE_DFL_ENV;
#define FE_DFL_ENV &_FE_DFL_ENV
#endif
/******************************************************************************
* The following functions provide high level access to the exception flags. *
* The "int" input argument can be constructed by bitwise ORs of the *
* exception macros: for example: FE_OVERFLOW | FE_INEXACT. *
* *
* The function "feclearexcept" clears the supported floating point *
* exceptions represented by its argument. *
* *
* The function "fegetexceptflag" stores a implementation-defined *
* representation of the states of the floating-point status flags indicated *
* by its integer argument excepts in the object pointed to by the argument, *
* flagp. *
* *
* The function "feraiseexcept" raises the supported floating-point *
* exceptions represented by its argument. The order in which these *
* floating-point exceptions are raised is unspecified. *
* *
* The function "fesetexceptflag" sets or clears the floating point status *
* flags indicated by the argument excepts to the states stored in the *
* object pointed to by flagp. The value of the *flagp shall have been set *
* by a previous call to fegetexceptflag whose second argument represented *
* at least those floating-point exceptions represented by the argument *
* excepts. This function does not raise floating-point exceptions; it just *
* sets the state of the flags. *
* *
* The function "fetestexcept" determines which of the specified subset of *
* the floating-point exception flags are currently set. The excepts *
* argument specifies the floating-point status flags to be queried. This *
* function returns the value of the bitwise OR of the floating-point *
* exception macros corresponding to the currently set floating-point *
* exceptions included in excepts. *
******************************************************************************/
extern int feclearexcept(int /* excepts */);
extern int fegetexceptflag(fexcept_t * /* flagp */, int /* excepts */);
extern int feraiseexcept(int /* excepts */);
extern int fesetexceptflag(const fexcept_t * /* flagp */, int /* excepts */);
extern int fetestexcept(int /* excepts */);
/******************************************************************************
* The following functions provide control of rounding direction modes. *
* *
* The function "fegetround" returns the value of the rounding direction *
* macro which represents the current rounding direction, or a negative *
* if there is no such rounding direction macro or the current rounding *
* direction is not determinable. *
* *
* The function "fesetround" establishes the rounding direction represented *
* by its argument "round". If the argument is not equal to the value of a *
* rounding direction macro, the rounding direction is not changed. It *
* returns zero if and only if the argument is equal to a rounding *
* direction macro. *
******************************************************************************/
extern int fegetround(void);
extern int fesetround(int /* round */);
/******************************************************************************
* The following functions manage the floating-point environment, exception *
* flags and dynamic modes, as one entity. *
* *
* The fegetenv function stores the current floating-point enviornment in *
* the object pointed to by envp. *
* *
* The feholdexcept function saves the current floating-point environment in *
* the object pointed to by envp, clears the floating-point status flags, *
* and then installs a non-stop (continue on floating-point exceptions) *
* mode, if available, for all floating-point exceptions. The feholdexcept *
* function returns zero if and only if non-stop floating-point exceptions *
* handling was successfully installed. *
* *
* The fesetnv function establishes the floating-point environment *
* represented by the object pointed to by envp. The argument envp shall *
* point to an object set by a call to fegetenv or feholdexcept, or equal to *
* a floating-point environment macro to be C99 standard compliant and *
* portable to other architectures. Note that fesetnv merely installs the *
* state of the floating-point status flags represented through its *
* argument, and does not raise these floating-point exceptions. *
* *
* The feupdateenv function saves the currently raised floating-point *
* exceptions in its automatic storage, installs the floating-point *
* environment represented by the object pointed to by envp, and then raises *
* the saved floating-point exceptions. The argument envp shall point to an *
* object set by a call to feholdexcept or fegetenv or equal a *
* floating-point environment macro. *
******************************************************************************/
extern int fegetenv(fenv_t * /* envp */);
extern int feholdexcept(fenv_t * /* envp */);
extern int fesetenv(const fenv_t * /* envp */);
extern int feupdateenv(const fenv_t * /* envp */);
#ifdef __cplusplus
}
#endif
#endif /* __FENV_H__ */

View File

@@ -0,0 +1,140 @@
/* Copyright (c) 2017 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This 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 OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __FLOAT_H
#define __FLOAT_H
/* Undefine anything that we'll be redefining below. */
#undef FLT_EVAL_METHOD
#undef FLT_ROUNDS
#undef FLT_RADIX
#undef FLT_MANT_DIG
#undef DBL_MANT_DIG
#undef LDBL_MANT_DIG
#undef FLT_DIG
#undef DBL_DIG
#undef LDBL_DIG
#undef FLT_MIN_EXP
#undef DBL_MIN_EXP
#undef LDBL_MIN_EXP
#undef FLT_MIN_10_EXP
#undef DBL_MIN_10_EXP
#undef LDBL_MIN_10_EXP
#undef FLT_MAX_EXP
#undef DBL_MAX_EXP
#undef LDBL_MAX_EXP
#undef FLT_MAX_10_EXP
#undef DBL_MAX_10_EXP
#undef LDBL_MAX_10_EXP
#undef FLT_MAX
#undef DBL_MAX
#undef LDBL_MAX
#undef FLT_EPSILON
#undef DBL_EPSILON
#undef LDBL_EPSILON
#undef FLT_MIN
#undef DBL_MIN
#undef LDBL_MIN
#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
# undef DECIMAL_DIG
#endif
#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
# undef FLT_HAS_SUBNORM
# undef DBL_HAS_SUBNORM
# undef LDBL_HAS_SUBNORM
# undef FLT_TRUE_MIN
# undef DBL_TRUE_MIN
# undef LDBL_TRUE_MIN
# undef FLT_DECIMAL_DIG
# undef DBL_DECIMAL_DIG
# undef LDBL_DECIMAL_DIG
#endif
/* Characteristics of floating point types, C99 5.2.4.2.2 */
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#define FLT_ROUNDS (__builtin_flt_rounds())
#define FLT_RADIX __FLT_RADIX__
#define FLT_MANT_DIG __FLT_MANT_DIG__
#define DBL_MANT_DIG __DBL_MANT_DIG__
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define FLT_DIG __FLT_DIG__
#define DBL_DIG __DBL_DIG__
#define LDBL_DIG __LDBL_DIG__
#define FLT_MIN_EXP __FLT_MIN_EXP__
#define DBL_MIN_EXP __DBL_MIN_EXP__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define FLT_MAX_EXP __FLT_MAX_EXP__
#define DBL_MAX_EXP __DBL_MAX_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define FLT_MAX __FLT_MAX__
#define DBL_MAX __DBL_MAX__
#define LDBL_MAX __LDBL_MAX__
#define FLT_EPSILON __FLT_EPSILON__
#define DBL_EPSILON __DBL_EPSILON__
#define LDBL_EPSILON __LDBL_EPSILON__
#define FLT_MIN __FLT_MIN__
#define DBL_MIN __DBL_MIN__
#define LDBL_MIN __LDBL_MIN__
#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
# define DECIMAL_DIG __DECIMAL_DIG__
#endif
#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
# if defined __arm__ /* On 32-bit arm, denorms are not supported. */
# define FLT_HAS_SUBNORM 0
# define DBL_HAS_SUBNORM 0
# define LDBL_HAS_SUBNORM 0
# define FLT_TRUE_MIN __FLT_MIN__
# define DBL_TRUE_MIN __DBL_MIN__
# define LDBL_TRUE_MIN __LDBL_MIN__
# else /* All Apple platforms except 32-bit arm have denorms. */
# define FLT_HAS_SUBNORM 1
# define DBL_HAS_SUBNORM 1
# define LDBL_HAS_SUBNORM 1
# define FLT_TRUE_MIN __FLT_DENORM_MIN__
# define DBL_TRUE_MIN __DBL_DENORM_MIN__
# define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
# endif
# define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
# define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
# define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
#endif
#endif /* __FLOAT_H */

View File

@@ -0,0 +1,73 @@
/*-
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/include/fmtmsg.h,v 1.2 2002/08/05 16:37:05 mike Exp $
*/
#ifndef _FMTMSG_H_
#define _FMTMSG_H_
/* Source of condition is... */
#define MM_HARD 0x0001 /* ...hardware. */
#define MM_SOFT 0x0002 /* ...software. */
#define MM_FIRM 0x0004 /* ...fireware. */
/* Condition detected by... */
#define MM_APPL 0x0010 /* ...application. */
#define MM_UTIL 0x0020 /* ...utility. */
#define MM_OPSYS 0x0040 /* ...operating system. */
/* Display on... */
#define MM_PRINT 0x0100 /* ...standard error. */
#define MM_CONSOLE 0x0200 /* ...system console. */
#define MM_RECOVER 0x1000 /* Recoverable error. */
#define MM_NRECOV 0x2000 /* Non-recoverable error. */
/* Severity levels. */
#define MM_NOSEV 0 /* No severity level provided. */
#define MM_HALT 1 /* Error causing application to halt. */
#define MM_ERROR 2 /* Non-fault fault. */
#define MM_WARNING 3 /* Unusual non-error condition. */
#define MM_INFO 4 /* Informative message. */
/* Null options. */
#define MM_NULLLBL (char *)0
#define MM_NULLSEV 0
#define MM_NULLMC 0L
#define MM_NULLTXT (char *)0
#define MM_NULLACT (char *)0
#define MM_NULLTAG (char *)0
/* Return values. */
#define MM_OK 0 /* Success. */
#define MM_NOMSG 1 /* Failed to output to stderr. */
#define MM_NOCON 2 /* Failed to output to console. */
#define MM_NOTOK 3 /* Failed to output anything. */
int fmtmsg(long, const char *, int, const char *, const char *,
const char *);
#endif /* !_FMTMSG_H_ */

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2000 Apple Computer, 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 (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fnmatch.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _FNMATCH_H_
#define _FNMATCH_H_
#include <sys/cdefs.h>
#define FNM_NOMATCH 1 /* Match failed. */
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
#define FNM_PERIOD 0x04 /* Period must be matched by period. */
#define FNM_NOSYS (-1) /* Reserved. */
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
#define FNM_IGNORECASE FNM_CASEFOLD
#define FNM_FILE_NAME FNM_PATHNAME
#endif
__BEGIN_DECLS
int fnmatch(const char *, const char *, int) __DARWIN_ALIAS(fnmatch);
__END_DECLS
#endif /* !_FNMATCH_H_ */

View File

@@ -0,0 +1,60 @@
/* $OpenBSD: ftw.h,v 1.1 2003/07/21 21:13:18 millert Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
#ifndef _FTW_H
#define _FTW_H
#include <sys/stat.h>
/*
* Valid flags for the 3rd argument to the function that is passed as the
* second argument to ftw(3) and nftw(3). Say it three times fast!
*/
#define FTW_F 0 /* File. */
#define FTW_D 1 /* Directory. */
#define FTW_DNR 2 /* Directory without read permission. */
#define FTW_DP 3 /* Directory with subdirectories visited. */
#define FTW_NS 4 /* Unknown type; stat() failed. */
#define FTW_SL 5 /* Symbolic link. */
#define FTW_SLN 6 /* Sym link that names a nonexistent file. */
/*
* Flags for use as the 4th argument to nftw(3). These may be ORed together.
*/
#define FTW_PHYS 0x01 /* Physical walk, don't follow sym links. */
#define FTW_MOUNT 0x02 /* The walk does not cross a mount point. */
#define FTW_DEPTH 0x04 /* Subdirs visited before the dir itself. */
#define FTW_CHDIR 0x08 /* Change to a directory before reading it. */
struct FTW {
int base;
int level;
};
__BEGIN_DECLS
int ftw(const char *, int (*)(const char *, const struct stat *, int), int)
__DARWIN_ALIAS_I(ftw);
int nftw(const char *, int (*)(const char *, const struct stat *, int,
struct FTW *), int, int) __DARWIN_ALIAS_I(nftw);
__END_DECLS
#endif /* !_FTW_H */

View File

@@ -0,0 +1,42 @@
/*
* 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 __GETHOSTUUID_H
#define __GETHOSTUUID_H
#include <sys/_types/_timespec.h>
#include <sys/_types/_uuid_t.h>
#include <Availability.h>
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0)
int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_NA, __MAC_NA, __IPHONE_2_0, __IPHONE_5_0, "gethostuuid() is no longer supported");
#else
int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
#endif
#endif /* __GETHOSTUUID_H */

View File

@@ -0,0 +1,130 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Guido van Rossum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)glob.h 8.1 (Berkeley) 6/2/93
* $FreeBSD: /repoman/r/ncvs/src/include/glob.h,v 1.7 2002/07/17 04:58:09 mikeh Exp $
*/
#ifndef _GLOB_H_
#define _GLOB_H_
#include <_types.h>
#include <sys/cdefs.h>
#include <Availability.h>
#include <sys/_types/_size_t.h>
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
struct dirent;
struct stat;
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
typedef struct {
size_t gl_pathc; /* Count of total paths so far. */
int gl_matchc; /* Count of paths matching pattern. */
size_t gl_offs; /* Reserved at beginning of gl_pathv. */
int gl_flags; /* Copy of flags parameter to glob. */
char **gl_pathv; /* List of paths matching pattern. */
/* Copy of errfunc parameter to glob. */
#ifdef __BLOCKS__
union {
#endif /* __BLOCKS__ */
int (*gl_errfunc)(const char *, int);
#ifdef __BLOCKS__
int (^gl_errblk)(const char *, int);
};
#endif /* __BLOCKS__ */
/*
* Alternate filesystem access methods for glob; replacement
* versions of closedir(3), readdir(3), opendir(3), stat(2)
* and lstat(2).
*/
void (*gl_closedir)(void *);
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
struct dirent *(*gl_readdir)(void *);
#else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
void *(*gl_readdir)(void *);
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
void *(*gl_opendir)(const char *);
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
int (*gl_lstat)(const char *, struct stat *);
int (*gl_stat)(const char *, struct stat *);
#else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
int (*gl_lstat)(const char *, void *);
int (*gl_stat)(const char *, void *);
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
} glob_t;
/* Believed to have been introduced in 1003.2-1992 */
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
#define GLOB_ERR 0x0004 /* Return on error. */
#define GLOB_MARK 0x0008 /* Append / to matching directories. */
#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */
#define GLOB_NOSORT 0x0020 /* Don't sort. */
#define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */
/* Error values returned by glob(3) */
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
#define GLOB_ABORTED (-2) /* Unignored error. */
#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */
#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
#ifdef __BLOCKS__
#define _GLOB_ERR_BLOCK 0x80000000 /* (internal) error callback is a block */
#endif /* __BLOCKS__ */
/* source compatibility, these are the old names */
#define GLOB_MAXPATH GLOB_LIMIT
#define GLOB_ABEND GLOB_ABORTED
__BEGIN_DECLS
int glob(const char * __restrict, int, int (*)(const char *, int),
glob_t * __restrict) __DARWIN_INODE64(glob);
#ifdef __BLOCKS__
#if __has_attribute(noescape)
#define __glob_noescape __attribute__((__noescape__))
#else
#define __glob_noescape
#endif
int glob_b(const char * __restrict, int, int (^)(const char *, int) __glob_noescape,
glob_t * __restrict) __DARWIN_INODE64(glob_b) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
#endif /* __BLOCKS__ */
void globfree(glob_t *);
__END_DECLS
#endif /* !_GLOB_H_ */

View File

@@ -0,0 +1,93 @@
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)grp.h 8.2 (Berkeley) 1/21/94
*/
/* Portions copyright (c) 2000-2018 Apple Inc. All rights reserved. */
#ifndef _GRP_H_
#define _GRP_H_
#include <_types.h>
#include <sys/_types/_gid_t.h> /* [XBD] */
#include <sys/_types/_size_t.h> /* SUSv4 */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define _PATH_GROUP "/etc/group"
#endif
struct group {
char *gr_name; /* [XBD] group name */
char *gr_passwd; /* [???] group password */
gid_t gr_gid; /* [XBD] group id */
char **gr_mem; /* [XBD] group members */
};
#include <sys/cdefs.h>
__BEGIN_DECLS
/* [XBD] */
struct group *getgrgid(gid_t);
struct group *getgrnam(const char *);
/* [TSF] */
int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
int getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
/* [XSI] */
struct group *getgrent(void);
void setgrent(void);
void endgrent(void);
__END_DECLS
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
#include <uuid/uuid.h>
__BEGIN_DECLS
char *group_from_gid(gid_t, int);
struct group *getgruuid(uuid_t);
int getgruuid_r(uuid_t, struct group *, char *, size_t, struct group **);
__END_DECLS
#endif
#if !defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE)
__BEGIN_DECLS
#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
void setgrfile(const char *);
#endif
int setgroupent(int);
__END_DECLS
#endif
#endif /* !_GRP_H_ */

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

@@ -0,0 +1,193 @@
/* Copyright (C) 1999-2003, 2005-2006 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
The GNU LIBICONV Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU LIBICONV Library; see the file COPYING.LIB.
If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301, USA. */
/* When installed, this file is called "iconv.h". */
#ifndef _LIBICONV_H
#define _LIBICONV_H
#include <sys/cdefs.h>
#include <_types.h>
#include <sys/_types/_size_t.h>
#define _LIBICONV_VERSION 0x010B /* version number: (major<<8) + minor */
#if BUILDING_LIBICONV
#define __LIBICONV_DLL_EXPORTED __attribute__((__visibility__("default")))
#else
#define __LIBICONV_DLL_EXPORTED
#endif
extern __LIBICONV_DLL_EXPORTED int _libiconv_version; /* Likewise */
/* We would like to #include any system header file which could define
iconv_t, 1. in order to eliminate the risk that the user gets compilation
errors because some other system header file includes /usr/include/iconv.h
which defines iconv_t or declares iconv after this file, 2. when compiling
for LIBICONV_PLUG, we need the proper iconv_t type in order to produce
binary compatible code.
But gcc's #include_next is not portable. Thus, once libiconv's iconv.h
has been installed in /usr/local/include, there is no way any more to
include the original /usr/include/iconv.h. We simply have to get away
without it.
Ad 1. The risk that a system header file does
#include "iconv.h" or #include_next "iconv.h"
is small. They all do #include <iconv.h>.
Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It
has to be a scalar type because (iconv_t)(-1) is a possible return value
from iconv_open().) */
/* Define iconv_t ourselves. */
#ifndef _ICONV_T
#define _ICONV_T
typedef void* iconv_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Allocates descriptor for code conversion from encoding `fromcode' to
encoding `tocode'. */
extern __LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* __tocode, const char* __fromcode);
/* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes
starting at `*inbuf', writing at most `*outbytesleft' bytes starting at
`*outbuf'.
Decrements `*inbytesleft' and increments `*inbuf' by the same amount.
Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */
extern __LIBICONV_DLL_EXPORTED size_t iconv (iconv_t __cd, char* * __restrict __inbuf, size_t * __restrict __inbytesleft, char* * __restrict __outbuf, size_t * __restrict __outbytesleft);
/* Frees resources allocated for conversion descriptor `cd'. */
extern __LIBICONV_DLL_EXPORTED int iconv_close (iconv_t _cd);
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
/* Nonstandard extensions. */
#include <sys/_types/_wchar_t.h>
/* Control of attributes. */
extern __LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argument);
/* Hook performed after every successful conversion of a Unicode character. */
typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data);
/* Hook performed after every successful conversion of a wide character. */
typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data);
/* Set of hooks. */
struct iconv_hooks {
iconv_unicode_char_hook uc_hook;
iconv_wide_char_hook wc_hook;
void* data;
};
/* Fallback function. Invoked when a small number of bytes could not be
converted to a Unicode character. This function should process all
bytes from inbuf and may produce replacement Unicode characters by calling
the write_replacement callback repeatedly. */
typedef void (*iconv_unicode_mb_to_uc_fallback)
(const char* inbuf, size_t inbufsize,
void (*write_replacement) (const unsigned int *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
/* Fallback function. Invoked when a Unicode character could not be converted
to the target encoding. This function should process the character and
may produce replacement bytes (in the target encoding) by calling the
write_replacement callback repeatedly. */
typedef void (*iconv_unicode_uc_to_mb_fallback)
(unsigned int code,
void (*write_replacement) (const char *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
#if 1
/* Fallback function. Invoked when a number of bytes could not be converted to
a wide character. This function should process all bytes from inbuf and may
produce replacement wide characters by calling the write_replacement
callback repeatedly. */
typedef void (*iconv_wchar_mb_to_wc_fallback)
(const char* inbuf, size_t inbufsize,
void (*write_replacement) (const wchar_t *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
/* Fallback function. Invoked when a wide character could not be converted to
the target encoding. This function should process the character and may
produce replacement bytes (in the target encoding) by calling the
write_replacement callback repeatedly. */
typedef void (*iconv_wchar_wc_to_mb_fallback)
(wchar_t code,
void (*write_replacement) (const char *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
#else
/* If the wchar_t type does not exist, these two fallback functions are never
invoked. Their argument list therefore does not matter. */
typedef void (*iconv_wchar_mb_to_wc_fallback) ();
typedef void (*iconv_wchar_wc_to_mb_fallback) ();
#endif
/* Set of fallbacks. */
struct iconv_fallbacks {
iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
void* data;
};
/* Requests for iconvctl. */
#define ICONV_TRIVIALP 0 /* int *argument */
#define ICONV_GET_TRANSLITERATE 1 /* int *argument */
#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */
#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */
#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */
#define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */
#define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */
/* Listing of locale independent encodings. */
extern __LIBICONV_DLL_EXPORTED void iconvlist (int (*do_one) (unsigned int namescount,
const char * const * names,
void* data),
void* data);
/* Canonicalize an encoding name.
The result is either a canonical encoding name, or name itself. */
extern __LIBICONV_DLL_EXPORTED const char * iconv_canonicalize (const char * name);
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern __LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
#ifdef __cplusplus
}
#endif
#endif /* _LIBICONV_H */

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*/
/* $FreeBSD: src/include/ifaddrs.h,v 1.3.32.1.4.1 2010/06/14 02:09:06 kensmith Exp $ */
/*
* Copyright (c) 1995, 1999
* Berkeley Software Design, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
*/
#ifndef _IFADDRS_H_
#define _IFADDRS_H_
#include <os/availability.h>
struct ifaddrs {
struct ifaddrs *ifa_next;
char *ifa_name;
unsigned int ifa_flags;
struct sockaddr *ifa_addr;
struct sockaddr *ifa_netmask;
struct sockaddr *ifa_dstaddr;
void *ifa_data;
};
/*
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
* to be included it must be included before this header file.
*/
#ifndef ifa_broadaddr
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
#endif
struct ifmaddrs {
struct ifmaddrs *ifma_next;
struct sockaddr *ifma_name;
struct sockaddr *ifma_addr;
struct sockaddr *ifma_lladdr;
};
#include <sys/cdefs.h>
__BEGIN_DECLS
extern int getifaddrs(struct ifaddrs **);
extern void freeifaddrs(struct ifaddrs *);
extern int getifmaddrs(struct ifmaddrs **) API_AVAILABLE(macos(10.7), ios(4.3), watchos(4.0), tvos(11.0));
extern void freeifmaddrs(struct ifmaddrs *) API_AVAILABLE(macos(10.7), ios(4.3), watchos(4.0), tvos(11.0));
__END_DECLS
#endif

View File

@@ -0,0 +1,297 @@
/*
* Copyright (c) 2000-2004, 2013 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@
*/
/*
* <inttypes.h> -- Standard C header, defined in ISO/IEC 9899:1999
* (aka "C99"), section 7.8. This defines format string conversion
* specifiers suitable for use within arguments to fprintf and fscanf
* and their ilk.
*/
#if !defined(_INTTYPES_H_)
#define _INTTYPES_H_
# define __PRI_8_LENGTH_MODIFIER__ "hh"
# define __PRI_64_LENGTH_MODIFIER__ "ll"
# define __SCN_64_LENGTH_MODIFIER__ "ll"
# define __PRI_MAX_LENGTH_MODIFIER__ "j"
# define __SCN_MAX_LENGTH_MODIFIER__ "j"
# define PRId8 __PRI_8_LENGTH_MODIFIER__ "d"
# define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i"
# define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o"
# define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u"
# define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x"
# define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X"
# define PRId16 "hd"
# define PRIi16 "hi"
# define PRIo16 "ho"
# define PRIu16 "hu"
# define PRIx16 "hx"
# define PRIX16 "hX"
# define PRId32 "d"
# define PRIi32 "i"
# define PRIo32 "o"
# define PRIu32 "u"
# define PRIx32 "x"
# define PRIX32 "X"
# define PRId64 __PRI_64_LENGTH_MODIFIER__ "d"
# define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i"
# define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o"
# define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u"
# define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x"
# define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X"
# define PRIdLEAST8 PRId8
# define PRIiLEAST8 PRIi8
# define PRIoLEAST8 PRIo8
# define PRIuLEAST8 PRIu8
# define PRIxLEAST8 PRIx8
# define PRIXLEAST8 PRIX8
# define PRIdLEAST16 PRId16
# define PRIiLEAST16 PRIi16
# define PRIoLEAST16 PRIo16
# define PRIuLEAST16 PRIu16
# define PRIxLEAST16 PRIx16
# define PRIXLEAST16 PRIX16
# define PRIdLEAST32 PRId32
# define PRIiLEAST32 PRIi32
# define PRIoLEAST32 PRIo32
# define PRIuLEAST32 PRIu32
# define PRIxLEAST32 PRIx32
# define PRIXLEAST32 PRIX32
# define PRIdLEAST64 PRId64
# define PRIiLEAST64 PRIi64
# define PRIoLEAST64 PRIo64
# define PRIuLEAST64 PRIu64
# define PRIxLEAST64 PRIx64
# define PRIXLEAST64 PRIX64
# define PRIdFAST8 PRId8
# define PRIiFAST8 PRIi8
# define PRIoFAST8 PRIo8
# define PRIuFAST8 PRIu8
# define PRIxFAST8 PRIx8
# define PRIXFAST8 PRIX8
# define PRIdFAST16 PRId16
# define PRIiFAST16 PRIi16
# define PRIoFAST16 PRIo16
# define PRIuFAST16 PRIu16
# define PRIxFAST16 PRIx16
# define PRIXFAST16 PRIX16
# define PRIdFAST32 PRId32
# define PRIiFAST32 PRIi32
# define PRIoFAST32 PRIo32
# define PRIuFAST32 PRIu32
# define PRIxFAST32 PRIx32
# define PRIXFAST32 PRIX32
# define PRIdFAST64 PRId64
# define PRIiFAST64 PRIi64
# define PRIoFAST64 PRIo64
# define PRIuFAST64 PRIu64
# define PRIxFAST64 PRIx64
# define PRIXFAST64 PRIX64
/* int32_t is 'int', but intptr_t is 'long'. */
# define PRIdPTR "ld"
# define PRIiPTR "li"
# define PRIoPTR "lo"
# define PRIuPTR "lu"
# define PRIxPTR "lx"
# define PRIXPTR "lX"
# define PRIdMAX __PRI_MAX_LENGTH_MODIFIER__ "d"
# define PRIiMAX __PRI_MAX_LENGTH_MODIFIER__ "i"
# define PRIoMAX __PRI_MAX_LENGTH_MODIFIER__ "o"
# define PRIuMAX __PRI_MAX_LENGTH_MODIFIER__ "u"
# define PRIxMAX __PRI_MAX_LENGTH_MODIFIER__ "x"
# define PRIXMAX __PRI_MAX_LENGTH_MODIFIER__ "X"
# define SCNd8 __PRI_8_LENGTH_MODIFIER__ "d"
# define SCNi8 __PRI_8_LENGTH_MODIFIER__ "i"
# define SCNo8 __PRI_8_LENGTH_MODIFIER__ "o"
# define SCNu8 __PRI_8_LENGTH_MODIFIER__ "u"
# define SCNx8 __PRI_8_LENGTH_MODIFIER__ "x"
# define SCNd16 "hd"
# define SCNi16 "hi"
# define SCNo16 "ho"
# define SCNu16 "hu"
# define SCNx16 "hx"
# define SCNd32 "d"
# define SCNi32 "i"
# define SCNo32 "o"
# define SCNu32 "u"
# define SCNx32 "x"
# define SCNd64 __SCN_64_LENGTH_MODIFIER__ "d"
# define SCNi64 __SCN_64_LENGTH_MODIFIER__ "i"
# define SCNo64 __SCN_64_LENGTH_MODIFIER__ "o"
# define SCNu64 __SCN_64_LENGTH_MODIFIER__ "u"
# define SCNx64 __SCN_64_LENGTH_MODIFIER__ "x"
# define SCNdLEAST8 SCNd8
# define SCNiLEAST8 SCNi8
# define SCNoLEAST8 SCNo8
# define SCNuLEAST8 SCNu8
# define SCNxLEAST8 SCNx8
# define SCNdLEAST16 SCNd16
# define SCNiLEAST16 SCNi16
# define SCNoLEAST16 SCNo16
# define SCNuLEAST16 SCNu16
# define SCNxLEAST16 SCNx16
# define SCNdLEAST32 SCNd32
# define SCNiLEAST32 SCNi32
# define SCNoLEAST32 SCNo32
# define SCNuLEAST32 SCNu32
# define SCNxLEAST32 SCNx32
# define SCNdLEAST64 SCNd64
# define SCNiLEAST64 SCNi64
# define SCNoLEAST64 SCNo64
# define SCNuLEAST64 SCNu64
# define SCNxLEAST64 SCNx64
# define SCNdFAST8 SCNd8
# define SCNiFAST8 SCNi8
# define SCNoFAST8 SCNo8
# define SCNuFAST8 SCNu8
# define SCNxFAST8 SCNx8
# define SCNdFAST16 SCNd16
# define SCNiFAST16 SCNi16
# define SCNoFAST16 SCNo16
# define SCNuFAST16 SCNu16
# define SCNxFAST16 SCNx16
# define SCNdFAST32 SCNd32
# define SCNiFAST32 SCNi32
# define SCNoFAST32 SCNo32
# define SCNuFAST32 SCNu32
# define SCNxFAST32 SCNx32
# define SCNdFAST64 SCNd64
# define SCNiFAST64 SCNi64
# define SCNoFAST64 SCNo64
# define SCNuFAST64 SCNu64
# define SCNxFAST64 SCNx64
# define SCNdPTR "ld"
# define SCNiPTR "li"
# define SCNoPTR "lo"
# define SCNuPTR "lu"
# define SCNxPTR "lx"
# define SCNdMAX __SCN_MAX_LENGTH_MODIFIER__ "d"
# define SCNiMAX __SCN_MAX_LENGTH_MODIFIER__ "i"
# define SCNoMAX __SCN_MAX_LENGTH_MODIFIER__ "o"
# define SCNuMAX __SCN_MAX_LENGTH_MODIFIER__ "u"
# define SCNxMAX __SCN_MAX_LENGTH_MODIFIER__ "x"
#include <sys/cdefs.h>
#include <Availability.h>
#include <_types.h>
#include <sys/_types/_wchar_t.h>
#include <stdint.h>
__BEGIN_DECLS
/* 7.8.2.1 */
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
extern intmax_t
imaxabs(intmax_t j);
/* 7.8.2.2 */
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
extern imaxdiv_t
imaxdiv(intmax_t __numer, intmax_t __denom);
/* 7.8.2.3 */
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
extern intmax_t
strtoimax(const char * __restrict __nptr,
char ** __restrict __endptr,
int __base);
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
extern uintmax_t
strtoumax(const char * __restrict __nptr,
char ** __restrict __endptr,
int __base);
/* 7.8.2.4 */
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
extern intmax_t
wcstoimax(const wchar_t * __restrict __nptr,
wchar_t ** __restrict __endptr,
int __base);
__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
extern uintmax_t
wcstoumax(const wchar_t * __restrict __nptr,
wchar_t ** __restrict __endptr,
int __base);
/* Poison the following routines if -fshort-wchar is set */
#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU
#pragma GCC poison wcstoimax wcstoumax
#endif
__END_DECLS
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_inttypes.h>
#endif /* _USE_EXTENDED_LOCALES_ */
/*
No need to #undef the __*_{8,64}_LENGTH_MODIFIER__ macros;
in fact, you can't #undef them, because later uses of any of
their dependents will *not* then do the intended substitution.
Expansion of a #define like this one:
#define x IDENT y
uses the cpp value of IDENT at the location where x is *expanded*,
not where it is #defined.
*/
#endif /* !_INTTYPES_H_ */

View File

@@ -0,0 +1,120 @@
/*-
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: /repoman/r/ncvs/src/include/langinfo.h,v 1.6 2002/09/18 05:54:25 mike Exp $
*/
#ifndef _LANGINFO_H_
#define _LANGINFO_H_
#include <_types.h>
#include <_types/_nl_item.h>
#define CODESET 0 /* codeset name */
#define D_T_FMT 1 /* string for formatting date and time */
#define D_FMT 2 /* date format string */
#define T_FMT 3 /* time format string */
#define T_FMT_AMPM 4 /* a.m. or p.m. time formatting string */
#define AM_STR 5 /* Ante Meridian affix */
#define PM_STR 6 /* Post Meridian affix */
/* week day names */
#define DAY_1 7
#define DAY_2 8
#define DAY_3 9
#define DAY_4 10
#define DAY_5 11
#define DAY_6 12
#define DAY_7 13
/* abbreviated week day names */
#define ABDAY_1 14
#define ABDAY_2 15
#define ABDAY_3 16
#define ABDAY_4 17
#define ABDAY_5 18
#define ABDAY_6 19
#define ABDAY_7 20
/* month names */
#define MON_1 21
#define MON_2 22
#define MON_3 23
#define MON_4 24
#define MON_5 25
#define MON_6 26
#define MON_7 27
#define MON_8 28
#define MON_9 29
#define MON_10 30
#define MON_11 31
#define MON_12 32
/* abbreviated month names */
#define ABMON_1 33
#define ABMON_2 34
#define ABMON_3 35
#define ABMON_4 36
#define ABMON_5 37
#define ABMON_6 38
#define ABMON_7 39
#define ABMON_8 40
#define ABMON_9 41
#define ABMON_10 42
#define ABMON_11 43
#define ABMON_12 44
#define ERA 45 /* era description segments */
#define ERA_D_FMT 46 /* era date format string */
#define ERA_D_T_FMT 47 /* era date and time format string */
#define ERA_T_FMT 48 /* era time format string */
#define ALT_DIGITS 49 /* alternative symbols for digits */
#define RADIXCHAR 50 /* radix char */
#define THOUSEP 51 /* separator for thousands */
#define YESEXPR 52 /* affirmative response expression */
#define NOEXPR 53 /* negative response expression */
#if (__DARWIN_C_LEVEL > __DARWIN_C_ANSI && __DARWIN_C_LEVEL < 200112L) || __DARWIN_C_LEVEL == __DARWIN_C_FULL
#define YESSTR 54 /* affirmative response for yes/no queries */
#define NOSTR 55 /* negative response for yes/no queries */
#endif
#define CRNCYSTR 56 /* currency symbol */
#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define D_MD_ORDER 57 /* month/day order (local extension) */
#endif
__BEGIN_DECLS
char *nl_langinfo(nl_item);
__END_DECLS
#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_langinfo.h>
#endif /* _USE_EXTENDED_LOCALES_ */
#endif /* !_LANGINFO_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,63 @@
/* $OpenBSD: libgen.h,v 1.4 1999/05/28 22:00:22 espie Exp $ */
/* $FreeBSD: src/include/libgen.h,v 1.1.2.1 2000/11/12 18:01:51 adrian Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LIBGEN_H_
#define _LIBGEN_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
#if __DARWIN_UNIX03
char *basename(char *);
char *dirname(char *);
#else /* !__DARWIN_UNIX03 */
char *basename(const char *);
char *dirname(const char *);
#endif /* __DARWIN_UNIX_03 */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#include <Availability.h>
char *basename_r(const char *, char *)
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
char *dirname_r(const char *, char *)
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
__END_DECLS
#endif /* _LIBGEN_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

@@ -0,0 +1,317 @@
/*
* Copyright (c) 2000-2006 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@
*/
#ifndef _OS_OSBYTEORDER_H
#define _OS_OSBYTEORDER_H
#include <stdint.h>
#include <libkern/_OSByteOrder.h>
/* Macros for swapping constant values in the preprocessing stage. */
#define OSSwapConstInt16(x) __DARWIN_OSSwapConstInt16(x)
#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
#else /* ! __GNUC__ */
#include <libkern/machine/OSByteOrder.h>
#endif /* __GNUC__ */
#define OSSwapInt16(x) __DARWIN_OSSwapInt16(x)
#define OSSwapInt32(x) __DARWIN_OSSwapInt32(x)
#define OSSwapInt64(x) __DARWIN_OSSwapInt64(x)
enum {
OSUnknownByteOrder,
OSLittleEndian,
OSBigEndian
};
__DARWIN_OS_INLINE
int32_t
OSHostByteOrder(void)
{
#if defined(__LITTLE_ENDIAN__)
return OSLittleEndian;
#elif defined(__BIG_ENDIAN__)
return OSBigEndian;
#else
return OSUnknownByteOrder;
#endif
}
#define OSReadBigInt(x, y) OSReadBigInt32(x, y)
#define OSWriteBigInt(x, y, z) OSWriteBigInt32(x, y, z)
#define OSSwapBigToHostInt(x) OSSwapBigToHostInt32(x)
#define OSSwapHostToBigInt(x) OSSwapHostToBigInt32(x)
#define OSReadLittleInt(x, y) OSReadLittleInt32(x, y)
#define OSWriteLittleInt(x, y, z) OSWriteLittleInt32(x, y, z)
#define OSSwapHostToLittleInt(x) OSSwapHostToLittleInt32(x)
#define OSSwapLittleToHostInt(x) OSSwapLittleToHostInt32(x)
/* Functions for loading native endian values. */
__DARWIN_OS_INLINE
uint16_t
_OSReadInt16(
const volatile void * base,
uintptr_t byteOffset
)
{
return *(volatile uint16_t *)((uintptr_t)base + byteOffset);
}
__DARWIN_OS_INLINE
uint32_t
_OSReadInt32(
const volatile void * base,
uintptr_t byteOffset
)
{
return *(volatile uint32_t *)((uintptr_t)base + byteOffset);
}
__DARWIN_OS_INLINE
uint64_t
_OSReadInt64(
const volatile void * base,
uintptr_t byteOffset
)
{
return *(volatile uint64_t *)((uintptr_t)base + byteOffset);
}
/* Functions for storing native endian values. */
__DARWIN_OS_INLINE
void
_OSWriteInt16(
volatile void * base,
uintptr_t byteOffset,
uint16_t data
)
{
*(volatile uint16_t *)((uintptr_t)base + byteOffset) = data;
}
__DARWIN_OS_INLINE
void
_OSWriteInt32(
volatile void * base,
uintptr_t byteOffset,
uint32_t data
)
{
*(volatile uint32_t *)((uintptr_t)base + byteOffset) = data;
}
__DARWIN_OS_INLINE
void
_OSWriteInt64(
volatile void * base,
uintptr_t byteOffset,
uint64_t data
)
{
*(volatile uint64_t *)((uintptr_t)base + byteOffset) = data;
}
#if defined(__BIG_ENDIAN__)
/* Functions for loading big endian to host endianess. */
#define OSReadBigInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
#define OSReadBigInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
#define OSReadBigInt64(base, byteOffset) _OSReadInt64(base, byteOffset)
/* Functions for storing host endianess to big endian. */
#define OSWriteBigInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
#define OSWriteBigInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
#define OSWriteBigInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)
/* Functions for loading little endian to host endianess. */
#define OSReadLittleInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
#define OSReadLittleInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
#define OSReadLittleInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)
/* Functions for storing host endianess to little endian. */
#define OSWriteLittleInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
#define OSWriteLittleInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
#define OSWriteLittleInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)
/* Host endianess to big endian byte swapping macros for constants. */
#define OSSwapHostToBigConstInt16(x) ((uint16_t)(x))
#define OSSwapHostToBigConstInt32(x) ((uint32_t)(x))
#define OSSwapHostToBigConstInt64(x) ((uint64_t)(x))
/* Generic host endianess to big endian byte swapping functions. */
#define OSSwapHostToBigInt16(x) ((uint16_t)(x))
#define OSSwapHostToBigInt32(x) ((uint32_t)(x))
#define OSSwapHostToBigInt64(x) ((uint64_t)(x))
/* Host endianess to little endian byte swapping macros for constants. */
#define OSSwapHostToLittleConstInt16(x) OSSwapConstInt16(x)
#define OSSwapHostToLittleConstInt32(x) OSSwapConstInt32(x)
#define OSSwapHostToLittleConstInt64(x) OSSwapConstInt64(x)
/* Generic host endianess to little endian byte swapping functions. */
#define OSSwapHostToLittleInt16(x) OSSwapInt16(x)
#define OSSwapHostToLittleInt32(x) OSSwapInt32(x)
#define OSSwapHostToLittleInt64(x) OSSwapInt64(x)
/* Big endian to host endianess byte swapping macros for constants. */
#define OSSwapBigToHostConstInt16(x) ((uint16_t)(x))
#define OSSwapBigToHostConstInt32(x) ((uint32_t)(x))
#define OSSwapBigToHostConstInt64(x) ((uint64_t)(x))
/* Generic big endian to host endianess byte swapping functions. */
#define OSSwapBigToHostInt16(x) ((uint16_t)(x))
#define OSSwapBigToHostInt32(x) ((uint32_t)(x))
#define OSSwapBigToHostInt64(x) ((uint64_t)(x))
/* Little endian to host endianess byte swapping macros for constants. */
#define OSSwapLittleToHostConstInt16(x) OSSwapConstInt16(x)
#define OSSwapLittleToHostConstInt32(x) OSSwapConstInt32(x)
#define OSSwapLittleToHostConstInt64(x) OSSwapConstInt64(x)
/* Generic little endian to host endianess byte swapping functions. */
#define OSSwapLittleToHostInt16(x) OSSwapInt16(x)
#define OSSwapLittleToHostInt32(x) OSSwapInt32(x)
#define OSSwapLittleToHostInt64(x) OSSwapInt64(x)
#elif defined(__LITTLE_ENDIAN__)
/* Functions for loading big endian to host endianess. */
#define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
#define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
#define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)
/* Functions for storing host endianess to big endian. */
#define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
#define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
#define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)
/* Functions for loading little endian to host endianess. */
#define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
#define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
#define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset)
/* Functions for storing host endianess to little endian. */
#define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
#define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
#define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)
/* Host endianess to big endian byte swapping macros for constants. */
#define OSSwapHostToBigConstInt16(x) OSSwapConstInt16(x)
#define OSSwapHostToBigConstInt32(x) OSSwapConstInt32(x)
#define OSSwapHostToBigConstInt64(x) OSSwapConstInt64(x)
/* Generic host endianess to big endian byte swapping functions. */
#define OSSwapHostToBigInt16(x) OSSwapInt16(x)
#define OSSwapHostToBigInt32(x) OSSwapInt32(x)
#define OSSwapHostToBigInt64(x) OSSwapInt64(x)
/* Host endianess to little endian byte swapping macros for constants. */
#define OSSwapHostToLittleConstInt16(x) ((uint16_t)(x))
#define OSSwapHostToLittleConstInt32(x) ((uint32_t)(x))
#define OSSwapHostToLittleConstInt64(x) ((uint64_t)(x))
/* Generic host endianess to little endian byte swapping functions. */
#define OSSwapHostToLittleInt16(x) ((uint16_t)(x))
#define OSSwapHostToLittleInt32(x) ((uint32_t)(x))
#define OSSwapHostToLittleInt64(x) ((uint64_t)(x))
/* Big endian to host endianess byte swapping macros for constants. */
#define OSSwapBigToHostConstInt16(x) OSSwapConstInt16(x)
#define OSSwapBigToHostConstInt32(x) OSSwapConstInt32(x)
#define OSSwapBigToHostConstInt64(x) OSSwapConstInt64(x)
/* Generic big endian to host endianess byte swapping functions. */
#define OSSwapBigToHostInt16(x) OSSwapInt16(x)
#define OSSwapBigToHostInt32(x) OSSwapInt32(x)
#define OSSwapBigToHostInt64(x) OSSwapInt64(x)
/* Little endian to host endianess byte swapping macros for constants. */
#define OSSwapLittleToHostConstInt16(x) ((uint16_t)(x))
#define OSSwapLittleToHostConstInt32(x) ((uint32_t)(x))
#define OSSwapLittleToHostConstInt64(x) ((uint64_t)(x))
/* Generic little endian to host endianess byte swapping functions. */
#define OSSwapLittleToHostInt16(x) ((uint16_t)(x))
#define OSSwapLittleToHostInt32(x) ((uint32_t)(x))
#define OSSwapLittleToHostInt64(x) ((uint64_t)(x))
#else
#error Unknown endianess.
#endif
#endif /* ! _OS_OSBYTEORDER_H */

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

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2006 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@
*/
#ifndef _OS__OSBYTEORDER_H
#define _OS__OSBYTEORDER_H
/*
* This header is normally included from <libkern/OSByteOrder.h>. However,
* <sys/_endian.h> also includes this in the case of little-endian
* architectures, so that we can map OSByteOrder routines to the hton* and ntoh*
* macros. This results in the asymmetry below; we only include
* <libkern/arch/_OSByteOrder.h> for little-endian architectures.
*/
#include <sys/_types.h>
/* Macros for swapping constant values in the preprocessing stage. */
#define __DARWIN_OSSwapConstInt16(x) \
((__uint16_t)((((__uint16_t)(x) & 0xff00U) >> 8) | \
(((__uint16_t)(x) & 0x00ffU) << 8)))
#define __DARWIN_OSSwapConstInt32(x) \
((__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) | \
(((__uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
(((__uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
(((__uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
(((__uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
(((__uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
(((__uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
(((__uint64_t)(x) & 0x00000000000000ffULL) << 56)))
#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) \
((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
#define __DARWIN_OSSwapInt32(x) \
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt32(x) : _OSSwapInt32(x))
#define __DARWIN_OSSwapInt64(x) \
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
#else /* ! __GNUC__ */
#if defined(__i386__) || defined(__x86_64__)
__DARWIN_OS_INLINE
uint16_t
_OSSwapInt16(
uint16_t data
)
{
return __DARWIN_OSSwapConstInt16(data);
}
__DARWIN_OS_INLINE
uint32_t
_OSSwapInt32(
uint32_t data
)
{
return __DARWIN_OSSwapConstInt32(data);
}
__DARWIN_OS_INLINE
uint64_t
_OSSwapInt64(
uint64_t data
)
{
return __DARWIN_OSSwapConstInt64(data);
}
#endif
#define __DARWIN_OSSwapInt16(x) _OSSwapInt16(x)
#define __DARWIN_OSSwapInt32(x) _OSSwapInt32(x)
#define __DARWIN_OSSwapInt64(x) _OSSwapInt64(x)
#endif /* __GNUC__ */
#endif /* ! _OS__OSBYTEORDER_H */

View File

@@ -0,0 +1,216 @@
/*
* Copyright (c) 1999-2007 Apple Inc. All rights reserved.
*/
#ifndef _OS_OSBYTEORDERARM_H
#define _OS_OSBYTEORDERARM_H
#include <stdint.h>
#include <arm/arch.h> /* for _ARM_ARCH_6 */
/* Generic byte swapping functions. */
__DARWIN_OS_INLINE
uint16_t
_OSSwapInt16(
uint16_t _data
)
{
/* Reduces to 'rev16' with clang */
return (uint16_t)(_data << 8 | _data >> 8);
}
__DARWIN_OS_INLINE
uint32_t
_OSSwapInt32(
uint32_t _data
)
{
#if defined(__llvm__)
_data = __builtin_bswap32(_data);
#else
/* This actually generates the best code */
_data = (((_data ^ (_data >> 16 | (_data << 16))) & 0xFF00FFFF) >> 8) ^ (_data >> 8 | _data << 24);
#endif
return _data;
}
__DARWIN_OS_INLINE
uint64_t
_OSSwapInt64(
uint64_t _data
)
{
#if defined(__llvm__)
return __builtin_bswap64(_data);
#else
union {
uint64_t _ull;
uint32_t _ul[2];
} _u;
/* This actually generates the best code */
_u._ul[0] = (uint32_t)(_data >> 32);
_u._ul[1] = (uint32_t)(_data & 0xffffffff);
_u._ul[0] = _OSSwapInt32(_u._ul[0]);
_u._ul[1] = _OSSwapInt32(_u._ul[1]);
return _u._ull;
#endif
}
/* Functions for byte reversed loads. */
struct _OSUnalignedU16 {
volatile uint16_t __val;
} __attribute__((__packed__));
struct _OSUnalignedU32 {
volatile uint32_t __val;
} __attribute__((__packed__));
struct _OSUnalignedU64 {
volatile uint64_t __val;
} __attribute__((__packed__));
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
uint16_t
_OSReadSwapInt16(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val);
}
#else
__DARWIN_OS_INLINE
uint16_t
OSReadSwapInt16(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
uint32_t
_OSReadSwapInt32(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val);
}
#else
__DARWIN_OS_INLINE
uint32_t
OSReadSwapInt32(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
uint64_t
_OSReadSwapInt64(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val);
}
#else
__DARWIN_OS_INLINE
uint64_t
OSReadSwapInt64(
const volatile void * _base,
uintptr_t _offset
)
{
return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val);
}
#endif
/* Functions for byte reversed stores. */
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
void
_OSWriteSwapInt16(
volatile void * _base,
uintptr_t _offset,
uint16_t _data
)
{
((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt16(_data);
}
#else
__DARWIN_OS_INLINE
void
OSWriteSwapInt16(
volatile void * _base,
uintptr_t _offset,
uint16_t _data
)
{
((struct _OSUnalignedU16 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt16(_data);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
void
_OSWriteSwapInt32(
volatile void * _base,
uintptr_t _offset,
uint32_t _data
)
{
((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt32(_data);
}
#else
__DARWIN_OS_INLINE
void
OSWriteSwapInt32(
volatile void * _base,
uintptr_t _offset,
uint32_t _data
)
{
((struct _OSUnalignedU32 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt32(_data);
}
#endif
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
__DARWIN_OS_INLINE
void
_OSWriteSwapInt64(
volatile void * _base,
uintptr_t _offset,
uint64_t _data
)
{
((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt64(_data);
}
#else
__DARWIN_OS_INLINE
void
OSWriteSwapInt64(
volatile void * _base,
uintptr_t _offset,
uint64_t _data
)
{
((struct _OSUnalignedU64 *)((uintptr_t)_base + _offset))->__val = _OSSwapInt64(_data);
}
#endif
#endif /* ! _OS_OSBYTEORDERARM_H */

View File

@@ -0,0 +1,167 @@
/*
* Copyright (c) 2000, 2004-2007, 2009 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@
*/
/* $NetBSD: limits.h,v 1.8 1996/10/21 05:10:50 jtc Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)limits.h 8.2 (Berkeley) 1/4/94
*/
#ifndef _LIMITS_H_
#define _LIMITS_H_
#include <sys/cdefs.h>
#include <machine/limits.h>
#include <sys/syslimits.h>
#if __DARWIN_C_LEVEL > __DARWIN_C_ANSI
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 25
#define _POSIX_LINK_MAX 8
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 8
#define _POSIX_OPEN_MAX 20
#define _POSIX_PATH_MAX 256
#define _POSIX_PIPE_BUF 512
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_TZNAME_MAX 6
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_EQUIV_CLASS_MAX 2
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX 255
#endif /* __DARWIN_C_LEVEL > __DARWIN_C_ANSI */
#if __DARWIN_C_LEVEL >= 199309L
#define _POSIX_AIO_LISTIO_MAX 2
#define _POSIX_AIO_MAX 1
#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_MQ_OPEN_MAX 8
#define _POSIX_MQ_PRIO_MAX 32
#define _POSIX_RTSIG_MAX 8
#define _POSIX_SEM_NSEMS_MAX 256
#define _POSIX_SEM_VALUE_MAX 32767
#define _POSIX_SIGQUEUE_MAX 32
#define _POSIX_TIMER_MAX 32
#define _POSIX_CLOCKRES_MIN 20000000
#endif /* __DARWIN_C_LEVEL >= 199309L */
#if __DARWIN_C_LEVEL >= 199506L
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
#define _POSIX_THREAD_KEYS_MAX 128
#define _POSIX_THREAD_THREADS_MAX 64
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
#define PTHREAD_KEYS_MAX 512
#if defined(__arm__) || defined(__arm64__)
#define PTHREAD_STACK_MIN 16384
#else
#define PTHREAD_STACK_MIN 8192
#endif
#endif /* __DARWIN_C_LEVEL >= 199506L */
#if __DARWIN_C_LEVEL >= 200112
#define _POSIX_HOST_NAME_MAX 255
#define _POSIX_LOGIN_NAME_MAX 9
#define _POSIX_SS_REPL_MAX 4
#define _POSIX_SYMLINK_MAX 255
#define _POSIX_SYMLOOP_MAX 8
#define _POSIX_TRACE_EVENT_NAME_MAX 30
#define _POSIX_TRACE_NAME_MAX 8
#define _POSIX_TRACE_SYS_MAX 8
#define _POSIX_TRACE_USER_EVENT_MAX 32
#define _POSIX_TTY_NAME_MAX 9
#define _POSIX2_CHARCLASS_NAME_MAX 14
#define _POSIX2_COLL_WEIGHTS_MAX 2
#define _POSIX_RE_DUP_MAX _POSIX2_RE_DUP_MAX
#endif /* __DARWIN_C_LEVEL >= 200112 */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
#define OFF_MIN LLONG_MIN /* min value for an off_t */
#define OFF_MAX LLONG_MAX /* max value for an off_t */
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */
/* Actually for XSI Visible */
#if __DARWIN_C_LEVEL > __DARWIN_C_ANSI
/* Removed in Issue 6 */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
#define PASS_MAX 128
#endif
#define NL_ARGMAX 9
#define NL_LANGMAX 14
#define NL_MSGMAX 32767
#define NL_NMAX 1
#define NL_SETMAX 255
#define NL_TEXTMAX 2048
#define _XOPEN_IOV_MAX 16
#define IOV_MAX 1024
#define _XOPEN_NAME_MAX 255
#define _XOPEN_PATH_MAX 1024
#endif /* __DARWIN_C_LEVEL > __DARWIN_C_ANSI */
/* NZERO to be defined here. TBD. See also sys/param.h */
#endif /* !_LIMITS_H_ */

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)locale.h 8.1 (Berkeley) 6/2/93
* $FreeBSD: /repoman/r/ncvs/src/include/locale.h,v 1.7 2002/10/09 09:19:27 tjr Exp $
*/
#ifndef _LOCALE_H_
#define _LOCALE_H_
#include <_locale.h>
#define LC_ALL 0
#define LC_COLLATE 1
#define LC_CTYPE 2
#define LC_MONETARY 3
#define LC_NUMERIC 4
#define LC_TIME 5
#define LC_MESSAGES 6
#define _LC_LAST 7 /* marks end */
__BEGIN_DECLS
char *setlocale(int, const char *);
__END_DECLS
#endif /* _LOCALE_H_ */

View File

@@ -0,0 +1,272 @@
/*
* Copyright (c) 1999-2008 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 _MACH_O_DYLD_H_
#define _MACH_O_DYLD_H_
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <mach-o/loader.h>
#include <Availability.h>
#if __cplusplus
extern "C" {
#endif
#ifdef __DRIVERKIT_19_0
#define DYLD_DRIVERKIT_UNAVAILABLE __API_UNAVAILABLE(driverkit)
#else
#define DYLD_DRIVERKIT_UNAVAILABLE
#endif
/*
* The following functions allow you to iterate through all loaded images.
* This is not a thread safe operation. Another thread can add or remove
* an image during the iteration.
*
* Many uses of these routines can be replace by a call to dladdr() which
* will return the mach_header and name of an image, given an address in
* the image. dladdr() is thread safe.
*/
extern uint32_t _dyld_image_count(void) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern const struct mach_header* _dyld_get_image_header(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern intptr_t _dyld_get_image_vmaddr_slide(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern const char* _dyld_get_image_name(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* The following functions allow you to install callbacks which will be called
* by dyld whenever an image is loaded or unloaded. During a call to _dyld_register_func_for_add_image()
* the callback func is called for every existing image. Later, it is called as each new image
* is loaded and bound (but initializers not yet run). The callback registered with
* _dyld_register_func_for_remove_image() is called after any terminators in an image are run
* and before the image is un-memory-mapped.
*/
extern void _dyld_register_func_for_add_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern void _dyld_register_func_for_remove_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* NSVersionOfRunTimeLibrary() returns the current_version number of the currently dylib
* specifed by the libraryName. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
* "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if no such library is loaded.
*/
extern int32_t NSVersionOfRunTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* NSVersionOfLinkTimeLibrary() returns the current_version number that the main executable was linked
* against at build time. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
* "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if the main executable did not link
* against the specified library.
*/
extern int32_t NSVersionOfLinkTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* _NSGetExecutablePath() copies the path of the main executable into the buffer. The bufsize parameter
* should initially be the size of the buffer. The function returns 0 if the path was successfully copied,
* and *bufsize is left unchanged. It returns -1 if the buffer is not large enough, and *bufsize is set
* to the size required.
*
* Note that _NSGetExecutablePath will return "a path" to the executable not a "real path" to the executable.
* That is the path may be a symbolic link and not the real file. With deep directories the total bufsize
* needed could be more than MAXPATHLEN.
*/
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize) __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
/*
* Registers a function to be called when the current thread terminates.
* Called by c++ compiler to implement destructors on thread_local object variables.
*/
extern void _tlv_atexit(void (*termFunc)(void* objAddr), void* objAddr) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
/*
* Never called. On-disk thread local variables contain a pointer to this. Once
* the thread local is prepared, the pointer changes to a real handler such as tlv_get_addr.
*/
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>.
* dlopen/dlsym/dlclose have been available since Mac OS X 10.3 and work with
* dylibs and bundles.
*
* NSAddImage -> dlopen
* NSLookupSymbolInImage -> dlsym
* NSCreateObjectFileImageFromFile -> dlopen
* NSDestroyObjectFileImage -> dlclose
* NSLinkModule -> not needed when dlopen used
* NSUnLinkModule -> not needed when dlclose used
* NSLookupSymbolInModule -> dlsym
* _dyld_image_containing_address -> dladdr
* NSLinkEditError -> dlerror
*
*/
#ifndef ENUM_DYLD_BOOL
#define ENUM_DYLD_BOOL
#undef FALSE
#undef TRUE
enum DYLD_BOOL { FALSE, TRUE };
#endif /* ENUM_DYLD_BOOL */
/* Object file image API */
typedef enum {
NSObjectFileImageFailure, /* for this a message is printed on stderr */
NSObjectFileImageSuccess,
NSObjectFileImageInappropriateFile,
NSObjectFileImageArch,
NSObjectFileImageFormat, /* for this a message is printed on stderr */
NSObjectFileImageAccess
} NSObjectFileImageReturnCode;
typedef struct __NSObjectFileImage* NSObjectFileImage;
/* NSObjectFileImage can only be used with MH_BUNDLE files */
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile(const char* pathName, NSObjectFileImage *objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromMemory(const void *address, size_t size, NSObjectFileImage *objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSDestroyObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlclose()");
extern uint32_t NSSymbolDefinitionCountInObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSSymbolDefinitionNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern uint32_t NSSymbolReferenceCountInObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSSymbolReferenceNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal, bool *tentative_definition) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSIsSymbolDefinedInObjectFileImage(NSObjectFileImage objectFileImage, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void* NSGetSectionDataInObjectFileImage(NSObjectFileImage objectFileImage, const char* segmentName, const char* sectionName, size_t *size) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "getsectiondata()");
typedef struct __NSModule* NSModule;
extern const char* NSNameOfModule(NSModule m) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSLibraryNameForModule(NSModule m) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern NSModule NSLinkModule(NSObjectFileImage objectFileImage, const char* moduleName, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
#define NSLINKMODULE_OPTION_NONE 0x0
#define NSLINKMODULE_OPTION_BINDNOW 0x1
#define NSLINKMODULE_OPTION_PRIVATE 0x2
#define NSLINKMODULE_OPTION_RETURN_ON_ERROR 0x4
#define NSLINKMODULE_OPTION_DONT_CALL_MOD_INIT_ROUTINES 0x8
#define NSLINKMODULE_OPTION_TRAILING_PHYS_NAME 0x10
extern bool NSUnLinkModule(NSModule module, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
#define NSUNLINKMODULE_OPTION_NONE 0x0
#define NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED 0x1
#define NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES 0x2
/* symbol API */
typedef struct __NSSymbol* NSSymbol;
extern bool NSIsSymbolNameDefined(const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern bool NSIsSymbolNameDefinedWithHint(const char* symbolName, const char* libraryNameHint) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern bool NSIsSymbolNameDefinedInImage(const struct mach_header* image, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupAndBindSymbol(const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupAndBindSymbolWithHint(const char* symbolName, const char* libraryNameHint) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupSymbolInModule(NSModule module, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern NSSymbol NSLookupSymbolInImage(const struct mach_header* image, const char* symbolName, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY 0x2
#define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4
extern const char* NSNameOfSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern void * NSAddressOfSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern NSModule NSModuleForSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dladdr()");
/* error handling API */
typedef enum {
NSLinkEditFileAccessError,
NSLinkEditFileFormatError,
NSLinkEditMachResourceError,
NSLinkEditUnixResourceError,
NSLinkEditOtherError,
NSLinkEditWarningError,
NSLinkEditMultiplyDefinedError,
NSLinkEditUndefinedError
} NSLinkEditErrors;
/*
* For the NSLinkEditErrors value NSLinkEditOtherError these are the values
* passed to the link edit error handler as the errorNumber (what would be an
* errno value for NSLinkEditUnixResourceError or a kern_return_t value for
* NSLinkEditMachResourceError).
*/
typedef enum {
NSOtherErrorRelocation,
NSOtherErrorLazyBind,
NSOtherErrorIndrLoop,
NSOtherErrorLazyInit,
NSOtherErrorInvalidArgs
} NSOtherErrorNumbers;
extern void NSLinkEditError(NSLinkEditErrors *c, int *errorNumber, const char** fileName, const char** errorString) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlerror()");
typedef struct {
void (*undefined)(const char* symbolName);
NSModule (*multiple)(NSSymbol s, NSModule oldModule, NSModule newModule);
void (*linkEdit)(NSLinkEditErrors errorClass, int errorNumber,
const char* fileName, const char* errorString);
} NSLinkEditErrorHandlers;
extern void NSInstallLinkEditErrorHandlers(const NSLinkEditErrorHandlers *handlers) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSAddLibrary(const char* pathName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlopen()");
extern bool NSAddLibraryWithSearching(const char* pathName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlopen()");
extern const struct mach_header* NSAddImage(const char* image_name, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
#define NSADDIMAGE_OPTION_NONE 0x0
#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1
#define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2
#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4
#define NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME 0x8
extern bool _dyld_present(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "always true");
extern bool _dyld_launched_prebound(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "moot");
extern bool _dyld_all_twolevel_modules_prebound(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "moot");
extern bool _dyld_bind_fully_image_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen(RTLD_NOW)");
extern bool _dyld_image_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "dladdr()");
extern void _dyld_lookup_and_bind(const char* symbol_name, void **address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void _dyld_lookup_and_bind_with_hint(const char* symbol_name, const char* library_name_hint, void** address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void _dyld_lookup_and_bind_fully(const char* symbol_name, void** address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern const struct mach_header* _dyld_get_image_header_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "dladdr()");
#if __cplusplus
}
#endif
#endif /* _MACH_O_DYLD_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,645 @@
/*
* Copyright (c) 2004-2007 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@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_ARM__STRUCTS_H_
#define _MACH_ARM__STRUCTS_H_
#include <sys/cdefs.h> /* __DARWIN_UNIX03 */
#include <machine/types.h> /* __uint32_t */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_EXCEPTION_STATE struct __darwin_arm_exception_state
_STRUCT_ARM_EXCEPTION_STATE
{
__uint32_t __exception; /* number of arm exception taken */
__uint32_t __fsr; /* Fault status */
__uint32_t __far; /* Virtual Fault Address */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_EXCEPTION_STATE struct arm_exception_state
_STRUCT_ARM_EXCEPTION_STATE
{
__uint32_t exception; /* number of arm exception taken */
__uint32_t fsr; /* Fault status */
__uint32_t far; /* Virtual Fault Address */
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_EXCEPTION_STATE64 struct __darwin_arm_exception_state64
_STRUCT_ARM_EXCEPTION_STATE64
{
__uint64_t __far; /* Virtual Fault Address */
__uint32_t __esr; /* Exception syndrome */
__uint32_t __exception; /* number of arm exception taken */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_EXCEPTION_STATE64 struct arm_exception_state64
_STRUCT_ARM_EXCEPTION_STATE64
{
__uint64_t far; /* Virtual Fault Address */
__uint32_t esr; /* Exception syndrome */
__uint32_t exception; /* number of arm exception taken */
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_THREAD_STATE struct __darwin_arm_thread_state
_STRUCT_ARM_THREAD_STATE
{
__uint32_t __r[13]; /* General purpose register r0-r12 */
__uint32_t __sp; /* Stack pointer r13 */
__uint32_t __lr; /* Link register r14 */
__uint32_t __pc; /* Program counter r15 */
__uint32_t __cpsr; /* Current program status register */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_THREAD_STATE struct arm_thread_state
_STRUCT_ARM_THREAD_STATE
{
__uint32_t r[13]; /* General purpose register r0-r12 */
__uint32_t sp; /* Stack pointer r13 */
__uint32_t lr; /* Link register r14 */
__uint32_t pc; /* Program counter r15 */
__uint32_t cpsr; /* Current program status register */
};
#endif /* __DARWIN_UNIX03 */
/*
* By default, the pointer fields in the arm_thread_state64_t structure are
* opaque on the arm64e architecture and require the use of accessor macros.
* This mode can also be enabled on the arm64 architecture by building with
* -D__DARWIN_OPAQUE_ARM_THREAD_STATE64=1.
*/
#if defined(__arm64__) && defined(__LP64__)
#if __has_feature(ptrauth_calls)
#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 1
#define __DARWIN_PTRAUTH_ARM_THREAD_STATE64 1
#endif /* __has_feature(ptrauth_calls) */
#ifndef __DARWIN_OPAQUE_ARM_THREAD_STATE64
#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0
#endif
#else /* defined(__arm64__) && defined(__LP64__) */
#undef __DARWIN_OPAQUE_ARM_THREAD_STATE64
#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0
#endif /* defined(__arm64__) && defined(__LP64__) */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_THREAD_STATE64 struct __darwin_arm_thread_state64
#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t __x[29]; /* General purpose registers x0-x28 */
void* __opaque_fp; /* Frame pointer x29 */
void* __opaque_lr; /* Link register x30 */
void* __opaque_sp; /* Stack pointer x31 */
void* __opaque_pc; /* Program counter */
__uint32_t __cpsr; /* Current program status register */
__uint32_t __opaque_flags; /* Flags describing structure format */
};
#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t __x[29]; /* General purpose registers x0-x28 */
__uint64_t __fp; /* Frame pointer x29 */
__uint64_t __lr; /* Link register x30 */
__uint64_t __sp; /* Stack pointer x31 */
__uint64_t __pc; /* Program counter */
__uint32_t __cpsr; /* Current program status register */
__uint32_t __pad; /* Same size for 32-bit or 64-bit clients */
};
#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64
#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t x[29]; /* General purpose registers x0-x28 */
void* __opaque_fp; /* Frame pointer x29 */
void* __opaque_lr; /* Link register x30 */
void* __opaque_sp; /* Stack pointer x31 */
void* __opaque_pc; /* Program counter */
__uint32_t cpsr; /* Current program status register */
__uint32_t __opaque_flags; /* Flags describing structure format */
};
#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t x[29]; /* General purpose registers x0-x28 */
__uint64_t fp; /* Frame pointer x29 */
__uint64_t lr; /* Link register x30 */
__uint64_t sp; /* Stack pointer x31 */
__uint64_t pc; /* Program counter */
__uint32_t cpsr; /* Current program status register */
__uint32_t __pad; /* Same size for 32-bit or 64-bit clients */
};
#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__)
/* Accessor macros for arm_thread_state64_t pointer fields */
#if __has_feature(ptrauth_calls) && defined(__LP64__)
#include <ptrauth.h>
#if !__DARWIN_OPAQUE_ARM_THREAD_STATE64 || !__DARWIN_PTRAUTH_ARM_THREAD_STATE64
#error "Invalid configuration"
#endif
#define __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH 0x1
#define __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR 0x2
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_data(__tsp->__opaque_pc, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("pc")) : __tsp->__opaque_pc); })
/* Return pc field of arm_thread_state64_t as a function pointer. May return
* NULL if a valid function pointer cannot be constructed, the caller should
* fall back to the __darwin_arm_thread_state64_get_pc() macro in that case. */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_function(__tsp->__opaque_pc, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("pc")) : NULL); })
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
__typeof__(fptr) __f = (fptr); __tsp->__opaque_pc = \
(__f ? (!(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("pc")) : ptrauth_auth_data(__f, \
ptrauth_key_function_pointer, 0)) : __f); })
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \
ptrauth_auth_data(__tsp->__opaque_lr, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("lr")) : __tsp->__opaque_lr); })
/* Return lr field of arm_thread_state64_t as a function pointer. May return
* NULL if a valid function pointer cannot be constructed, the caller should
* fall back to the __darwin_arm_thread_state64_get_lr() macro in that case. */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \
ptrauth_auth_function(__tsp->__opaque_lr, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("lr")) : NULL); })
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
__typeof__(fptr) __f = (fptr); __tsp->__opaque_lr = \
(__f ? (!(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? (__tsp->__opaque_flags \
&= ~__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR , \
ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("lr"))) : ptrauth_auth_data(__f, \
ptrauth_key_function_pointer, 0)) : __f); })
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_sp && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_data(__tsp->__opaque_sp, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("sp")) : __tsp->__opaque_sp); })
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_sp = \
(__p && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_sign_unauthenticated(__p, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("sp")) : __p); })
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_fp && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_data(__tsp->__opaque_fp, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("fp")) : __tsp->__opaque_fp); })
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_fp = \
(__p && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_sign_unauthenticated(__p, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("fp")) : __p); })
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
__tsp->__opaque_pc = ((__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_pc : \
ptrauth_strip(__tsp->__opaque_pc, ptrauth_key_process_independent_code)); \
__tsp->__opaque_lr = ((__tsp->__opaque_flags & \
(__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? __tsp->__opaque_lr : \
ptrauth_strip(__tsp->__opaque_lr, ptrauth_key_process_independent_code)); \
__tsp->__opaque_sp = ((__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_sp : \
ptrauth_strip(__tsp->__opaque_sp, ptrauth_key_process_independent_data)); \
__tsp->__opaque_fp = ((__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_fp : \
ptrauth_strip(__tsp->__opaque_fp, ptrauth_key_process_independent_data)); \
__tsp->__opaque_flags |= \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH; })
#else /* __has_feature(ptrauth_calls) && defined(__LP64__) */
#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
#ifndef __LP64__
#error "Invalid configuration"
#endif
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
((uintptr_t)((ts).__opaque_pc))
/* Return pc field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
((ts).__opaque_pc)
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
((ts).__opaque_pc = (fptr))
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
((uintptr_t)((ts).__opaque_lr))
/* Return lr field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
((ts).__opaque_lr)
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
((ts).__opaque_lr = (fptr))
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
((uintptr_t)((ts).__opaque_sp))
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
((ts).__opaque_sp = (void*)(uintptr_t)(ptr))
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
((uintptr_t)((ts).__opaque_fp))
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
((ts).__opaque_fp = (void*)(uintptr_t)(ptr))
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
(void)(ts)
#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#if __DARWIN_UNIX03
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
((ts).__pc)
/* Return pc field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
((void*)(uintptr_t)((ts).__pc))
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
((ts).__pc = (uintptr_t)(fptr))
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
((ts).__lr)
/* Return lr field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
((void*)(uintptr_t)((ts).__lr))
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
((ts).__lr = (uintptr_t)(fptr))
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
((ts).__sp)
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
((ts).__sp = (uintptr_t)(ptr))
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
((ts).__fp)
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
((ts).__fp = (uintptr_t)(ptr))
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
(void)(ts)
#else /* __DARWIN_UNIX03 */
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
((ts).pc)
/* Return pc field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
((void*)(uintptr_t)((ts).pc))
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
((ts).pc = (uintptr_t)(fptr))
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
((ts).lr)
/* Return lr field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
((void*)(uintptr_t)((ts).lr))
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
((ts).lr = (uintptr_t)(fptr))
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
((ts).sp)
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
((ts).sp = (uintptr_t)(ptr))
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
((ts).fp)
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
((ts).fp = (uintptr_t)(ptr))
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
(void)(ts)
#endif /* __DARWIN_UNIX03 */
#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#endif /* __has_feature(ptrauth_calls) && defined(__LP64__) */
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state
_STRUCT_ARM_VFP_STATE
{
__uint32_t __r[64];
__uint32_t __fpscr;
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_VFP_STATE struct arm_vfp_state
_STRUCT_ARM_VFP_STATE
{
__uint32_t r[64];
__uint32_t fpscr;
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64
#define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state
#if defined(__arm64__)
_STRUCT_ARM_NEON_STATE64
{
__uint128_t __v[32];
__uint32_t __fpsr;
__uint32_t __fpcr;
};
_STRUCT_ARM_NEON_STATE
{
__uint128_t __v[16];
__uint32_t __fpsr;
__uint32_t __fpcr;
};
#elif defined(__arm__)
/*
* No 128-bit intrinsic for ARM; leave it opaque for now.
*/
_STRUCT_ARM_NEON_STATE64
{
char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
_STRUCT_ARM_NEON_STATE
{
char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
#else
#error Unknown architecture.
#endif
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64
#define _STRUCT_ARM_NEON_STATE struct arm_neon_state
#if defined(__arm64__)
_STRUCT_ARM_NEON_STATE64
{
__uint128_t q[32];
uint32_t fpsr;
uint32_t fpcr;
};
_STRUCT_ARM_NEON_STATE
{
__uint128_t q[16];
uint32_t fpsr;
uint32_t fpcr;
};
#elif defined(__arm__)
/*
* No 128-bit intrinsic for ARM; leave it opaque for now.
*/
_STRUCT_ARM_NEON_STATE64
{
char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
_STRUCT_ARM_NEON_STATE
{
char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
#else
#error Unknown architecture.
#endif
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_AMX_STATE_V1 struct __darwin_arm_amx_state_v1
_STRUCT_ARM_AMX_STATE_V1
{
__uint8_t __x[8][64]; /* 8 64-byte registers */
__uint8_t __y[8][64]; /* 8 64-byte registers */
__uint8_t __z[64][64]; /* 64 64-byte registers in an M-by-N matrix */
__uint64_t __amx_state_t_el1; /* AMX_STATE_T_EL1 value */
} __attribute__((aligned(64)));
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_AMX_STATE_V1 struct arm_amx_state_v1
_STRUCT_ARM_AMX_STATE_V1
{
__uint8_t x[8][64]; /* 8 64-byte registers */
__uint8_t y[8][64]; /* 8 64-byte registers */
__uint8_t z[64][64]; /* 64 64-byte registers in an M-by-N matrix */
__uint64_t amx_state_t_el1; /* AMX_STATE_T_EL1 value. */
} __attribute__((aligned(64)));
#endif /* __DARWIN_UNIX03 */
#define _STRUCT_ARM_PAGEIN_STATE struct __arm_pagein_state
_STRUCT_ARM_PAGEIN_STATE
{
int __pagein_error;
};
/*
* Debug State
*/
#if defined(__arm__)
/* Old-fashioned debug state is only for ARM */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state
_STRUCT_ARM_DEBUG_STATE
{
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state
_STRUCT_ARM_DEBUG_STATE
{
__uint32_t bvr[16];
__uint32_t bcr[16];
__uint32_t wvr[16];
__uint32_t wcr[16];
};
#endif /* __DARWIN_UNIX03 */
#elif defined(__arm64__)
/* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_LEGACY_DEBUG_STATE struct __arm_legacy_debug_state
_STRUCT_ARM_LEGACY_DEBUG_STATE
{
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
};
#else /* __DARWIN_UNIX03 */
#define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
_STRUCT_ARM_LEGACY_DEBUG_STATE
{
__uint32_t bvr[16];
__uint32_t bcr[16];
__uint32_t wvr[16];
__uint32_t wcr[16];
};
#endif /* __DARWIN_UNIX03 */
#else
#error unknown architecture
#endif
#if __DARWIN_UNIX03
#define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32
_STRUCT_ARM_DEBUG_STATE32
{
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
__uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64
_STRUCT_ARM_DEBUG_STATE64
{
__uint64_t __bvr[16];
__uint64_t __bcr[16];
__uint64_t __wvr[16];
__uint64_t __wcr[16];
__uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32
_STRUCT_ARM_DEBUG_STATE32
{
__uint32_t bvr[16];
__uint32_t bcr[16];
__uint32_t wvr[16];
__uint32_t wcr[16];
__uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64
_STRUCT_ARM_DEBUG_STATE64
{
__uint64_t bvr[16];
__uint64_t bcr[16];
__uint64_t wvr[16];
__uint64_t wcr[16];
__uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64
_STRUCT_ARM_CPMU_STATE64
{
__uint64_t __ctrs[16];
};
#else /* __DARWIN_UNIX03 */
#define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64
_STRUCT_ARM_CPMU_STATE64
{
__uint64_t ctrs[16];
};
#endif /* !__DARWIN_UNIX03 */
#endif /* _MACH_ARM__STRUCTS_H_ */

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2000-2007 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@
*/
/*
* @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.
*/
/*
*/
/*
* File: boolean.h
*
* Boolean type, for ARM.
*/
#ifndef _MACH_ARM_BOOLEAN_H_
#define _MACH_ARM_BOOLEAN_H_
typedef int boolean_t;
#endif /* _MACH_ARM_BOOLEAN_H_ */

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2007 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 _MACH_ARM_EXCEPTION_H_
#define _MACH_ARM_EXCEPTION_H_
#define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */
#define EXC_MASK_MACHINE 0
#define EXCEPTION_CODE_MAX 2 /* code and subcode */
/*
* Trap numbers as defined by the hardware exception vectors.
*/
/*
* EXC_BAD_INSTRUCTION
*/
#define EXC_ARM_UNDEFINED 1 /* Undefined */
/*
* EXC_ARITHMETIC
*/
#define EXC_ARM_FP_UNDEFINED 0 /* Undefined Floating Point Exception */
#define EXC_ARM_FP_IO 1 /* Invalid Floating Point Operation */
#define EXC_ARM_FP_DZ 2 /* Floating Point Divide by Zero */
#define EXC_ARM_FP_OF 3 /* Floating Point Overflow */
#define EXC_ARM_FP_UF 4 /* Floating Point Underflow */
#define EXC_ARM_FP_IX 5 /* Inexact Floating Point Result */
#define EXC_ARM_FP_ID 6 /* Floating Point Denormal Input */
/*
* EXC_BAD_ACCESS
* Note: do not conflict with kern_return_t values returned by vm_fault
*/
#define EXC_ARM_DA_ALIGN 0x101 /* Alignment Fault */
#define EXC_ARM_DA_DEBUG 0x102 /* Debug (watch/break) Fault */
#define EXC_ARM_SP_ALIGN 0x103 /* SP Alignment Fault */
#define EXC_ARM_SWP 0x104 /* SWP instruction */
#define EXC_ARM_PAC_FAIL 0x105 /* PAC authentication failure */
/*
* EXC_BREAKPOINT
*/
#define EXC_ARM_BREAKPOINT 1 /* breakpoint trap */
#endif /* _MACH_ARM_EXCEPTION_H_ */

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2000-2007 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@
*/
/*
* @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.
*/
/*
*/
/*
* File: kern_return.h
* Author: Avadis Tevanian, Jr., Michael Wayne Young
* Date: 1985
*
* Machine-dependent kernel return definitions.
*/
#ifndef _MACH_ARM_KERN_RETURN_H_
#define _MACH_ARM_KERN_RETURN_H_
#ifndef ASSEMBLER
typedef int kern_return_t;
#endif /* ASSEMBLER */
#endif /* _MACH_ARM_KERN_RETURN_H_ */

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2007-2018 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 _MACH_ARM_PROCESSOR_INFO_H_
#define _MACH_ARM_PROCESSOR_INFO_H_
#define PROCESSOR_CPU_STAT 0x10000003 /* Low-level CPU statistics */
#define PROCESSOR_CPU_STAT64 0x10000004 /* Low-level CPU statistics, in full 64-bit */
#include <stdint.h> /* uint32_t, uint64_t */
struct processor_cpu_stat {
uint32_t irq_ex_cnt;
uint32_t ipi_cnt;
uint32_t timer_cnt;
uint32_t undef_ex_cnt;
uint32_t unaligned_cnt;
uint32_t vfp_cnt;
uint32_t vfp_shortv_cnt;
uint32_t data_ex_cnt;
uint32_t instr_ex_cnt;
};
typedef struct processor_cpu_stat processor_cpu_stat_data_t;
typedef struct processor_cpu_stat *processor_cpu_stat_t;
#define PROCESSOR_CPU_STAT_COUNT ((mach_msg_type_number_t) \
(sizeof(processor_cpu_stat_data_t) / sizeof(natural_t)))
struct processor_cpu_stat64 {
uint64_t irq_ex_cnt;
uint64_t ipi_cnt;
uint64_t timer_cnt;
uint64_t undef_ex_cnt;
uint64_t unaligned_cnt;
uint64_t vfp_cnt;
uint64_t vfp_shortv_cnt;
uint64_t data_ex_cnt;
uint64_t instr_ex_cnt;
uint64_t pmi_cnt;
} __attribute__((packed, aligned(4)));
typedef struct processor_cpu_stat64 processor_cpu_stat64_data_t;
typedef struct processor_cpu_stat64 *processor_cpu_stat64_t;
#define PROCESSOR_CPU_STAT64_COUNT ((mach_msg_type_number_t) \
(sizeof(processor_cpu_stat64_data_t) / sizeof(integer_t)))
#endif /* _MACH_ARM_PROCESSOR_INFO_H_ */

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