mirror of
https://github.com/darlinghq/darling.git
synced 2026-02-05 13:08:48 -06:00
Update availability headers, add headers for some frameworks
Headers added for CryptoTokenKit and LocalAuthentication They have been stripped of Apple's comments Licensing may still be an issue, please verify
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2015 by Apple Inc.. All rights reserved.
|
||||
* Copyright (c) 2007-2016 by Apple Inc.. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
@@ -131,39 +131,55 @@
|
||||
#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
|
||||
/* __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
|
||||
|
||||
#define __IPHONE_2_0 20000
|
||||
#define __IPHONE_2_1 20100
|
||||
#define __IPHONE_2_2 20200
|
||||
#define __IPHONE_3_0 30000
|
||||
#define __IPHONE_3_1 30100
|
||||
#define __IPHONE_3_2 30200
|
||||
#define __IPHONE_4_0 40000
|
||||
#define __IPHONE_4_1 40100
|
||||
#define __IPHONE_4_2 40200
|
||||
#define __IPHONE_4_3 40300
|
||||
#define __IPHONE_5_0 50000
|
||||
#define __IPHONE_5_1 50100
|
||||
#define __IPHONE_6_0 60000
|
||||
#define __IPHONE_6_1 60100
|
||||
#define __IPHONE_7_0 70000
|
||||
#define __IPHONE_7_1 70100
|
||||
#define __IPHONE_8_0 80000
|
||||
#define __IPHONE_8_1 80100
|
||||
#define __IPHONE_8_2 80200
|
||||
#define __IPHONE_8_3 80300
|
||||
#define __IPHONE_8_4 80400
|
||||
#define __IPHONE_9_0 90000
|
||||
#define __IPHONE_9_1 90100
|
||||
#define __IPHONE_9_2 90200
|
||||
#define __IPHONE_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
|
||||
/* __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
|
||||
|
||||
#define __TVOS_9_0 90000
|
||||
#define __TVOS_9_1 90100
|
||||
#define __TVOS_9_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 __WATCHOS_1_0 10000
|
||||
#define __WATCHOS_2_0 20000
|
||||
#define __WATCHOS_1_0 10000
|
||||
#define __WATCHOS_2_0 20000
|
||||
#define __WATCHOS_3_0 30000
|
||||
#define __WATCHOS_3_1 30100
|
||||
#define __WATCHOS_3_1_1 30101
|
||||
|
||||
#include <AvailabilityInternal.h>
|
||||
|
||||
@@ -192,6 +208,9 @@
|
||||
#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)
|
||||
@@ -221,7 +240,7 @@
|
||||
|
||||
|
||||
/* for use marking APIs available info for Mac OSX */
|
||||
#if defined(__has_feature)
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(availability)
|
||||
#define __OSX_UNAVAILABLE __OS_AVAILABILITY(macosx,unavailable)
|
||||
#define __OSX_AVAILABLE(_vers) __OS_AVAILABILITY(macosx,introduced=_vers)
|
||||
@@ -243,7 +262,7 @@
|
||||
|
||||
|
||||
/* for use marking APIs available info for iOS */
|
||||
#if defined(__has_feature)
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(availability)
|
||||
#define __IOS_UNAVAILABLE __OS_AVAILABILITY(ios,unavailable)
|
||||
#define __IOS_PROHIBITED __OS_AVAILABILITY(ios,unavailable)
|
||||
@@ -323,4 +342,72 @@
|
||||
#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
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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))
|
||||
*/
|
||||
#define __API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
|
||||
/*
|
||||
* 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_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1)(__VA_ARGS__)
|
||||
#define __API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1)(__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* 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_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
#endif /* __AVAILABILITY__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1
src/CryptoTokenKit/CryptTokenKit
Symbolic link
1
src/CryptoTokenKit/CryptTokenKit
Symbolic link
@@ -0,0 +1 @@
|
||||
Headers
|
||||
12
src/CryptoTokenKit/Headers/CryptoTokenKit.h
Normal file
12
src/CryptoTokenKit/Headers/CryptoTokenKit.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#import <CryptoTokenKit/TKError.h>
|
||||
#import <CryptoTokenKit/TKTLVRecord.h>
|
||||
|
||||
#import <CryptoTokenKit/TKToken.h>
|
||||
#import <CryptoTokenKit/TKTokenKeychainItem.h>
|
||||
#import <CryptoTokenKit/TKSmartCardToken.h>
|
||||
|
||||
#import <CryptoTokenKit/TKTokenWatcher.h>
|
||||
|
||||
#import <CryptoTokenKit/TKSmartCard.h>
|
||||
#import <CryptoTokenKit/TKSmartCardToken.h>
|
||||
#import <CryptoTokenKit/TKSmartCardATR.h>
|
||||
26
src/CryptoTokenKit/Headers/TKError.h
Normal file
26
src/CryptoTokenKit/Headers/TKError.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *const TKErrorDomain;
|
||||
|
||||
typedef NS_ENUM(NSInteger, TKErrorCode) {
|
||||
TKErrorCodeNotImplemented = -1,
|
||||
TKErrorCodeCommunicationError = -2,
|
||||
TKErrorCodeCorruptedData = -3,
|
||||
TKErrorCodeCanceledByUser = -4,
|
||||
TKErrorCodeAuthenticationFailed = -5,
|
||||
TKErrorCodeObjectNotFound = -6,
|
||||
TKErrorCodeTokenNotFound = -7,
|
||||
TKErrorCodeBadParameter = -8,
|
||||
TKErrorCodeAuthenticationNeeded = -9,
|
||||
|
||||
TKErrorAuthenticationFailed NS_ENUM_DEPRECATED(10_10, 10_11, 9_0, 9_0, "Use TKErrorCodeAuthenticationFailed")
|
||||
= TKErrorCodeAuthenticationFailed,
|
||||
TKErrorObjectNotFound NS_ENUM_DEPRECATED(10_10, 10_11, 9_0, 9_0, "Use TKErrorCodeObjectNotFound")
|
||||
= TKErrorCodeObjectNotFound,
|
||||
TKErrorTokenNotFound NS_ENUM_DEPRECATED(10_10, 10_11, 9_0, 9_0, "Use TKErrorCodeTokenNotFound")
|
||||
= TKErrorCodeTokenNotFound,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
263
src/CryptoTokenKit/Headers/TKSmartCard.h
Normal file
263
src/CryptoTokenKit/Headers/TKSmartCard.h
Normal file
@@ -0,0 +1,263 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CryptoTokenKit/TKSmartCardATR.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TKSmartCard;
|
||||
@class TKSmartCardSlot;
|
||||
@class TKSmartCardUserInteraction;
|
||||
|
||||
NS_CLASS_AVAILABLE(10_10, 9_0)
|
||||
@interface TKSmartCardSlotManager : NSObject
|
||||
|
||||
@property (class, nullable, readonly) TKSmartCardSlotManager *defaultManager;
|
||||
|
||||
@property (readonly) NSArray<NSString *> *slotNames;
|
||||
|
||||
- (void)getSlotWithName:(NSString *)name reply:(void(^)(TKSmartCardSlot *__nullable slot))reply;
|
||||
|
||||
@end
|
||||
|
||||
typedef NS_ENUM(NSInteger, TKSmartCardSlotState) {
|
||||
|
||||
TKSmartCardSlotStateMissing = 0,
|
||||
|
||||
|
||||
TKSmartCardSlotStateEmpty = 1,
|
||||
|
||||
|
||||
TKSmartCardSlotStateProbing = 2,
|
||||
|
||||
|
||||
TKSmartCardSlotStateMuteCard = 3,
|
||||
|
||||
|
||||
TKSmartCardSlotStateValidCard = 4,
|
||||
} NS_ENUM_AVAILABLE(10_10, 9_0);
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, TKSmartCardPINCharset) {
|
||||
|
||||
TKSmartCardPINCharsetNumeric = 0,
|
||||
|
||||
|
||||
TKSmartCardPINCharsetAlphanumeric = 1,
|
||||
|
||||
|
||||
TKSmartCardPINCharsetUpperAlphanumeric = 2,
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0);
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, TKSmartCardPINEncoding) {
|
||||
|
||||
TKSmartCardPINEncodingBinary = 0,
|
||||
|
||||
|
||||
TKSmartCardPINEncodingASCII = 1,
|
||||
|
||||
|
||||
TKSmartCardPINEncodingBCD = 2,
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0);
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger, TKSmartCardPINJustification) {
|
||||
|
||||
TKSmartCardPINJustificationLeft = 0,
|
||||
|
||||
|
||||
TKSmartCardPINJustificationRight = 1,
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0);
|
||||
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, TKSmartCardPINCompletion) {
|
||||
|
||||
TKSmartCardPINCompletionMaxLength = (1L << 0),
|
||||
|
||||
|
||||
TKSmartCardPINCompletionKey = (1L << 1),
|
||||
|
||||
|
||||
TKSmartCardPINCompletionTimeout = (1L << 2),
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0);
|
||||
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, TKSmartCardPINConfirmation) {
|
||||
|
||||
TKSmartCardPINConfirmationNone = 0,
|
||||
|
||||
|
||||
TKSmartCardPINConfirmationNew = (1L << 0),
|
||||
|
||||
|
||||
TKSmartCardPINConfirmationCurrent = (1L << 1),
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0);
|
||||
|
||||
|
||||
NS_CLASS_AVAILABLE(10_11, 9_0)
|
||||
@interface TKSmartCardPINFormat : NSObject
|
||||
|
||||
|
||||
@property TKSmartCardPINCharset charset;
|
||||
|
||||
@property TKSmartCardPINEncoding encoding;
|
||||
|
||||
|
||||
@property NSInteger minPINLength;
|
||||
|
||||
|
||||
@property NSInteger maxPINLength;
|
||||
|
||||
|
||||
@property NSInteger PINBlockByteLength;
|
||||
|
||||
@property TKSmartCardPINJustification PINJustification;
|
||||
|
||||
@property NSInteger PINBitOffset;
|
||||
|
||||
@property NSInteger PINLengthBitOffset;
|
||||
|
||||
@property NSInteger PINLengthBitSize;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
NS_CLASS_AVAILABLE(10_11, 9_0)
|
||||
@protocol TKSmartCardUserInteractionDelegate
|
||||
@optional
|
||||
|
||||
- (void)characterEnteredInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
- (void)correctionKeyPressedInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
- (void)validationKeyPressedInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
- (void)invalidCharacterEnteredInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
- (void)oldPINRequestedInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
- (void)newPINRequestedInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
- (void)newPINConfirmationRequestedInUserInteraction:(TKSmartCardUserInteraction *)interaction;
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_11, 9_0)
|
||||
@interface TKSmartCardUserInteraction : NSObject
|
||||
|
||||
@property (weak, nullable) id<TKSmartCardUserInteractionDelegate> delegate;
|
||||
|
||||
@property NSTimeInterval initialTimeout;
|
||||
|
||||
@property NSTimeInterval interactionTimeout;
|
||||
|
||||
- (void)runWithReply: (void(^)(BOOL success, NSError *__nullable error))reply;
|
||||
|
||||
- (BOOL)cancel;
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_11, 9_0)
|
||||
@interface TKSmartCardUserInteractionForPINOperation : TKSmartCardUserInteraction
|
||||
|
||||
@property TKSmartCardPINCompletion PINCompletion;
|
||||
|
||||
@property (nullable) NSArray<NSNumber *> *PINMessageIndices;
|
||||
|
||||
@property (null_resettable) NSLocale *locale;
|
||||
|
||||
@property UInt16 resultSW;
|
||||
|
||||
@property (nullable) NSData *resultData;
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_11, 9_0)
|
||||
@interface TKSmartCardUserInteractionForSecurePINVerification : TKSmartCardUserInteractionForPINOperation
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_11, 9_0)
|
||||
@interface TKSmartCardUserInteractionForSecurePINChange : TKSmartCardUserInteractionForPINOperation
|
||||
|
||||
@property TKSmartCardPINConfirmation PINConfirmation;
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_10, 9_0)
|
||||
@interface TKSmartCardSlot : NSObject
|
||||
|
||||
@property (readonly) TKSmartCardSlotState state;
|
||||
|
||||
@property (readonly, nullable) TKSmartCardATR *ATR;
|
||||
|
||||
@property (nonatomic, readonly) NSString *name;
|
||||
|
||||
@property (nonatomic, readonly) NSInteger maxInputLength;
|
||||
|
||||
@property (nonatomic, readonly) NSInteger maxOutputLength;
|
||||
|
||||
- (nullable TKSmartCard *)makeSmartCard;
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_10, 9_0)
|
||||
@interface TKSmartCard : NSObject
|
||||
|
||||
@property (nonatomic, readonly) TKSmartCardSlot *slot;
|
||||
|
||||
@property (readonly) BOOL valid;
|
||||
|
||||
@property TKSmartCardProtocol allowedProtocols;
|
||||
|
||||
@property (readonly) TKSmartCardProtocol currentProtocol;
|
||||
|
||||
@property BOOL sensitive;
|
||||
|
||||
@property (nullable) id context;
|
||||
|
||||
- (void)beginSessionWithReply:(void(^)(BOOL success, NSError *__nullable error))reply;
|
||||
|
||||
- (void)transmitRequest:(NSData *)request reply:(void(^)(NSData *__nullable response, NSError *__nullable error))reply;
|
||||
|
||||
|
||||
- (void)endSession;
|
||||
|
||||
- (nullable TKSmartCardUserInteractionForSecurePINVerification *)userInteractionForSecurePINVerificationWithPINFormat:(TKSmartCardPINFormat *)PINFormat
|
||||
APDU:(NSData *)APDU
|
||||
PINByteOffset:(NSInteger)PINByteOffset
|
||||
NS_AVAILABLE(10_11, 9_0);
|
||||
|
||||
- (nullable TKSmartCardUserInteractionForSecurePINChange *)userInteractionForSecurePINChangeWithPINFormat:(TKSmartCardPINFormat *)PINFormat
|
||||
APDU:(NSData *)APDU
|
||||
currentPINByteOffset:(NSInteger)currentPINByteOffset
|
||||
newPINByteOffset:(NSInteger)newPINByteOffset
|
||||
NS_AVAILABLE(10_11, 9_0);
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TKSmartCard (APDULevelTransmit)
|
||||
|
||||
@property UInt8 cla
|
||||
__OSX_AVAILABLE(10.10) __IOS_AVAILABLE(9.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
@property BOOL useExtendedLength
|
||||
__OSX_AVAILABLE(10.10) __IOS_AVAILABLE(9.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
@property BOOL useCommandChaining
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
- (void)sendIns:(UInt8)ins p1:(UInt8)p1 p2:(UInt8)p2 data:(nullable NSData *)requestData le:(nullable NSNumber *)le
|
||||
reply:(void(^)(NSData *__nullable replyData, UInt16 sw, NSError *__nullable error))reply
|
||||
__OSX_AVAILABLE(10.10) __IOS_AVAILABLE(9.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
- (BOOL)inSessionWithError:(NSError **)error executeBlock:(BOOL(^)(NSError **error))block
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
- (nullable NSData *)sendIns:(UInt8)ins p1:(UInt8)p1 p2:(UInt8)p2 data:(nullable NSData *)requestData
|
||||
le:(nullable NSNumber *)le sw:(UInt16 *)sw error:(NSError **)error
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
50
src/CryptoTokenKit/Headers/TKSmartCardATR.h
Normal file
50
src/CryptoTokenKit/Headers/TKSmartCardATR.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "TKTLVRecord.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, TKSmartCardProtocol) {
|
||||
TKSmartCardProtocolNone = 0,
|
||||
TKSmartCardProtocolT0 = (1L << 0),
|
||||
TKSmartCardProtocolT1 = (1L << 1),
|
||||
TKSmartCardProtocolT15 = (1L << 15),
|
||||
TKSmartCardProtocolAny = (1L << 16) - 1,
|
||||
} NS_ENUM_AVAILABLE(10_10, 9_0);
|
||||
|
||||
NS_CLASS_AVAILABLE(10_10, 9_0)
|
||||
@interface TKSmartCardATRInterfaceGroup : NSObject
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSNumber *TA;
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSNumber *TB;
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSNumber *TC;
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSNumber *protocol;
|
||||
|
||||
@end
|
||||
|
||||
NS_CLASS_AVAILABLE(10_10, 9_0)
|
||||
@interface TKSmartCardATR : NSObject
|
||||
|
||||
- (nullable instancetype)initWithBytes:(NSData *)bytes;
|
||||
|
||||
- (nullable instancetype)initWithSource:(int(^)())source;
|
||||
|
||||
@property (nonatomic, readonly) NSData *bytes;
|
||||
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *protocols;
|
||||
|
||||
- (nullable TKSmartCardATRInterfaceGroup *)interfaceGroupAtIndex:(NSInteger)index;
|
||||
|
||||
- (nullable TKSmartCardATRInterfaceGroup *)interfaceGroupForProtocol:(TKSmartCardProtocol)protocol;
|
||||
|
||||
@property (nonatomic, readonly) NSData *historicalBytes;
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSArray<TKCompactTLVRecord *> *historicalRecords
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
55
src/CryptoTokenKit/Headers/TKSmartCardToken.h
Normal file
55
src/CryptoTokenKit/Headers/TKSmartCardToken.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#import <CryptoTokenKit/TKToken.h>
|
||||
#import <CryptoTokenKit/TKSmartCard.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TKSmartCardTokenSession;
|
||||
@class TKSmartCardToken;
|
||||
@protocol TKSmartCardTokenDriverDelegate;
|
||||
@class TKSmartCardTokenDriver;
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenSmartCardPINAuthOperation : TKTokenAuthOperation
|
||||
|
||||
@property TKSmartCardPINFormat *PINFormat;
|
||||
|
||||
@property (nullable, copy) NSData *APDUTemplate;
|
||||
|
||||
@property NSInteger PINByteOffset;
|
||||
|
||||
@property (nullable) TKSmartCard *smartCard;
|
||||
|
||||
@property (nullable, copy) NSString *PIN;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKSmartCardTokenSession : TKTokenSession
|
||||
|
||||
@property (readonly) TKSmartCard *smartCard;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKSmartCardToken : TKToken
|
||||
|
||||
- (instancetype)initWithSmartCard:(TKSmartCard *)smartCard AID:(nullable NSData *)AID instanceID:(NSString *)instanceID tokenDriver:(TKSmartCardTokenDriver *)tokenDriver NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@property (readonly, nullable) NSData *AID;
|
||||
|
||||
- (instancetype)initWithTokenDriver:(TKTokenDriver *)tokenDriver instanceID:(NSString *)instanceID NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKSmartCardTokenDriver : TKTokenDriver
|
||||
|
||||
@end
|
||||
|
||||
@protocol TKSmartCardTokenDriverDelegate<TKTokenDriverDelegate>
|
||||
|
||||
- (nullable TKSmartCardToken *)tokenDriver:(TKSmartCardTokenDriver *)driver createTokenForSmartCard:(TKSmartCard *)smartCard AID:(nullable NSData *)AID error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
51
src/CryptoTokenKit/Headers/TKTLVRecord.h
Normal file
51
src/CryptoTokenKit/Headers/TKTLVRecord.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef UInt64 TKTLVTag
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTLVRecord : NSObject
|
||||
|
||||
@property (nonatomic, readonly) TKTLVTag tag;
|
||||
|
||||
@property (nonatomic, readonly) NSData *value;
|
||||
|
||||
@property (nonatomic, readonly) NSData *data;
|
||||
|
||||
+ (nullable instancetype)recordFromData:(NSData *)data;
|
||||
|
||||
+ (nullable NSArray<TKTLVRecord *> *)sequenceOfRecordsFromData:(NSData *)data;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKBERTLVRecord : TKTLVRecord
|
||||
|
||||
+ (NSData *)dataForTag:(TKTLVTag)tag;
|
||||
|
||||
- (instancetype)initWithTag:(TKTLVTag)tag value:(NSData *)value;
|
||||
|
||||
- (instancetype)initWithTag:(TKTLVTag)tag records:(NSArray<TKTLVRecord *> *)records;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKSimpleTLVRecord : TKTLVRecord
|
||||
|
||||
- (instancetype)initWithTag:(UInt8)tag value:(NSData *)value;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKCompactTLVRecord : TKTLVRecord
|
||||
|
||||
- (instancetype)initWithTag:(UInt8)tag value:(NSData *)value;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
141
src/CryptoTokenKit/Headers/TKToken.h
Normal file
141
src/CryptoTokenKit/Headers/TKToken.h
Normal file
@@ -0,0 +1,141 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Security/Security.h>
|
||||
|
||||
#import <CryptoTokenKit/TKSmartCard.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol TKTokenSessionDelegate;
|
||||
@class TKTokenSession;
|
||||
@class TKTokenKeyAlgorithm;
|
||||
@class TKTokenKeyExchangeParameters;
|
||||
@protocol TKTokenDelegate;
|
||||
@class TKToken;
|
||||
@protocol TKTokenDriverDelegate;
|
||||
@class TKTokenDriver;
|
||||
@class TKTokenKeychainContents;
|
||||
@class TKTokenAuthOperation;
|
||||
|
||||
typedef id TKTokenObjectID
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
typedef NS_ENUM(NSInteger, TKTokenOperation) {
|
||||
TKTokenOperationNone = 0,
|
||||
|
||||
TKTokenOperationReadData = 1,
|
||||
|
||||
TKTokenOperationSignData = 2,
|
||||
|
||||
TKTokenOperationDecryptData = 3,
|
||||
|
||||
TKTokenOperationPerformKeyExchange = 4,
|
||||
} __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
typedef id TKTokenOperationConstraint
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE;
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenKeyAlgorithm : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
- (BOOL)isAlgorithm:(SecKeyAlgorithm)algorithm;
|
||||
|
||||
- (BOOL)supportsAlgorithm:(SecKeyAlgorithm)algorithm;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenKeyExchangeParameters : NSObject
|
||||
|
||||
@property (readonly) NSInteger requestedSize;
|
||||
|
||||
@property (readonly, nullable, copy) NSData *sharedInfo;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenSession : NSObject
|
||||
|
||||
- (instancetype)initWithToken:(TKToken *)token NS_DESIGNATED_INITIALIZER;
|
||||
@property (readonly) TKToken *token;
|
||||
@property (weak, nullable) id<TKTokenSessionDelegate> delegate;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@protocol TKTokenSessionDelegate<NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
- (nullable TKTokenAuthOperation *)tokenSession:(TKTokenSession *)session beginAuthForOperation:(TKTokenOperation)operation constraint:(TKTokenOperationConstraint)constraint error:(NSError **)error;
|
||||
|
||||
- (BOOL)tokenSession:(TKTokenSession *)session supportsOperation:(TKTokenOperation)operation usingKey:(TKTokenObjectID)keyObjectID algorithm:(TKTokenKeyAlgorithm *)algorithm;
|
||||
|
||||
- (nullable NSData *)tokenSession:(TKTokenSession *)session signData:(NSData *)dataToSign usingKey:(TKTokenObjectID)keyObjectID algorithm:(TKTokenKeyAlgorithm *)algorithm error:(NSError **)error;
|
||||
|
||||
- (nullable NSData *)tokenSession:(TKTokenSession *)session decryptData:(NSData *)ciphertext usingKey:(TKTokenObjectID)keyObjectID algorithm:(TKTokenKeyAlgorithm *)algorithm error:(NSError **)error;
|
||||
|
||||
- (nullable NSData *)tokenSession:(TKTokenSession *)session performKeyExchangeWithPublicKey:(NSData *)otherPartyPublicKeyData usingKey:(TKTokenObjectID)objectID algorithm:(TKTokenKeyAlgorithm *)algorithm parameters:(TKTokenKeyExchangeParameters *)parameters error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKToken : NSObject
|
||||
|
||||
- (instancetype)initWithTokenDriver:(TKTokenDriver *)tokenDriver instanceID:(NSString *)instanceID NS_DESIGNATED_INITIALIZER;
|
||||
@property (readonly) TKTokenDriver *tokenDriver;
|
||||
@property (weak, nullable) id<TKTokenDelegate> delegate;
|
||||
|
||||
@property (nullable, readonly) TKTokenKeychainContents *keychainContents;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@protocol TKTokenDelegate<NSObject>
|
||||
|
||||
@required
|
||||
|
||||
- (nullable TKTokenSession *)token:(TKToken *)token createSessionWithError:(NSError **)error;
|
||||
|
||||
@optional
|
||||
|
||||
- (void)token:(TKToken *)token terminateSession:(TKTokenSession *)session;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenDriver : NSObject
|
||||
|
||||
@property (weak, nullable) id<TKTokenDriverDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@protocol TKTokenDriverDelegate<NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)tokenDriver:(TKTokenDriver *)driver terminateToken:(TKToken *)token;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenAuthOperation : NSObject<NSSecureCoding>
|
||||
|
||||
- (BOOL)finishWithError:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenPasswordAuthOperation : TKTokenAuthOperation
|
||||
|
||||
@property (nullable, copy) NSString *password;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
77
src/CryptoTokenKit/Headers/TKTokenKeychainItem.h
Normal file
77
src/CryptoTokenKit/Headers/TKTokenKeychainItem.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <CryptoTokenKit/TKToken.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TKTokenKeychainItem;
|
||||
@class TKTokenKeychainCertificate;
|
||||
@class TKTokenKeychainKey;
|
||||
@class TKTokenKeychainState;
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenKeychainItem : NSObject
|
||||
|
||||
- (instancetype)initWithObjectID:(TKTokenObjectID)objectID NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@property (readonly, copy) TKTokenObjectID objectID;
|
||||
|
||||
@property (nullable, copy) NSString *label;
|
||||
|
||||
@property (nullable, copy) NSDictionary<NSNumber *, TKTokenOperationConstraint> *constraints;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenKeychainCertificate : TKTokenKeychainItem
|
||||
|
||||
- (nullable instancetype)initWithCertificate:(SecCertificateRef)certificateRef objectID:(TKTokenObjectID)objectID NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjectID:(TKTokenObjectID)objectID NS_UNAVAILABLE;
|
||||
|
||||
@property (copy, readonly) NSData *data;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenKeychainKey : TKTokenKeychainItem
|
||||
|
||||
- (nullable instancetype)initWithCertificate:(nullable SecCertificateRef)certificateRef objectID:(TKTokenObjectID)objectID NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithObjectID:(TKTokenObjectID)objectID NS_UNAVAILABLE;
|
||||
|
||||
@property (copy) NSString *keyType;
|
||||
|
||||
@property (copy, nullable) NSData *applicationTag;
|
||||
|
||||
@property NSInteger keySizeInBits;
|
||||
|
||||
@property (copy, nullable) NSData *publicKeyData;
|
||||
|
||||
@property (copy, nullable) NSData *publicKeyHash;
|
||||
|
||||
@property BOOL canDecrypt;
|
||||
|
||||
@property BOOL canSign;
|
||||
|
||||
@property BOOL canPerformKeyExchange;
|
||||
|
||||
@property (getter=isSuitableForLogin) BOOL suitableForLogin;
|
||||
|
||||
@end
|
||||
|
||||
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
|
||||
@interface TKTokenKeychainContents : NSObject
|
||||
|
||||
- (void)fillWithItems:(NSArray<TKTokenKeychainItem *> *)items;
|
||||
|
||||
@property (readonly, copy) NSArray<TKTokenKeychainItem *> *items;
|
||||
|
||||
- (nullable TKTokenKeychainKey *)keyForObjectID:(TKTokenObjectID)objectID error:(NSError **)error;
|
||||
|
||||
- (nullable TKTokenKeychainCertificate *)certificateForObjectID:(TKTokenObjectID)objectID error:(NSError **)error;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
17
src/CryptoTokenKit/Headers/TKTokenWatcher.h
Normal file
17
src/CryptoTokenKit/Headers/TKTokenWatcher.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TKTokenWatcher : NSObject
|
||||
|
||||
@property (readonly) NSArray<NSString *> *tokenIDs;
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
- (instancetype)initWithInsertionHandler:(void(^)(NSString* tokenID)) insertionHandler;
|
||||
|
||||
- (void)addRemovalHandler:(void(^)(NSString* tokenID)) removalHandler forTokenID:(NSString*) tokenID;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -33,7 +33,7 @@ set(IOKit_SRCS
|
||||
)
|
||||
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/darling")
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
add_library(IOKit SHARED ${IOKit_SRCS})
|
||||
|
||||
1
src/IOKit/os
Symbolic link
1
src/IOKit/os
Symbolic link
@@ -0,0 +1 @@
|
||||
../libc/os
|
||||
4
src/LocalAuthentication/Headers/LACFSupport.h
Normal file
4
src/LocalAuthentication/Headers/LACFSupport.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef LocalAuthentication_LACFSupport_h
|
||||
#define LocalAuthentication_LACFSupport_h
|
||||
|
||||
#endif
|
||||
82
src/LocalAuthentication/Headers/LAContext.h
Normal file
82
src/LocalAuthentication/Headers/LAContext.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <LocalAuthentication/LAPublicDefines.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, LAPolicy)
|
||||
{
|
||||
LAPolicyDeviceOwnerAuthenticationWithBiometrics NS_ENUM_AVAILABLE(10_12, 8_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0) = kLAPolicyDeviceOwnerAuthenticationWithBiometrics,
|
||||
|
||||
LAPolicyDeviceOwnerAuthentication NS_ENUM_AVAILABLE(10_11, 9_0) = kLAPolicyDeviceOwnerAuthentication
|
||||
|
||||
} NS_ENUM_AVAILABLE(10_10, 8_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
|
||||
|
||||
extern const NSTimeInterval LATouchIDAuthenticationMaximumAllowableReuseDuration NS_AVAILABLE(10_12, 9_0) __WATCHOS_UNAVAILABLE __TVOS_UNAVAILABLE;
|
||||
|
||||
NS_CLASS_AVAILABLE(10_10, 8_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0)
|
||||
@interface LAContext : NSObject
|
||||
|
||||
- (BOOL)canEvaluatePolicy:(LAPolicy)policy error:(NSError * __autoreleasing *)error __attribute__((swift_error(none)));
|
||||
|
||||
- (void)evaluatePolicy:(LAPolicy)policy
|
||||
localizedReason:(NSString *)localizedReason
|
||||
reply:(void(^)(BOOL success, NSError * __nullable error))reply;
|
||||
|
||||
- (void)invalidate NS_AVAILABLE(10_11, 9_0);
|
||||
|
||||
typedef NS_ENUM(NSInteger, LACredentialType)
|
||||
{
|
||||
LACredentialTypeApplicationPassword __TVOS_UNAVAILABLE = 0,
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
|
||||
|
||||
|
||||
- (BOOL)setCredential:(nullable NSData *)credential
|
||||
type:(LACredentialType)type NS_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3.0) __TVOS_UNAVAILABLE;
|
||||
|
||||
|
||||
- (BOOL)isCredentialSet:(LACredentialType)type NS_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3.0) __TVOS_UNAVAILABLE;
|
||||
|
||||
typedef NS_ENUM(NSInteger, LAAccessControlOperation)
|
||||
{
|
||||
|
||||
LAAccessControlOperationCreateItem,
|
||||
|
||||
|
||||
LAAccessControlOperationUseItem,
|
||||
|
||||
|
||||
LAAccessControlOperationCreateKey,
|
||||
|
||||
|
||||
LAAccessControlOperationUseKeySign,
|
||||
|
||||
|
||||
LAAccessControlOperationUseKeyDecrypt NS_ENUM_AVAILABLE(10_12, 10_0),
|
||||
|
||||
|
||||
LAAccessControlOperationUseKeyKeyExchange NS_ENUM_AVAILABLE(10_12, 10_0),
|
||||
} NS_ENUM_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
|
||||
|
||||
|
||||
- (void)evaluateAccessControl:(SecAccessControlRef)accessControl
|
||||
operation:(LAAccessControlOperation)operation
|
||||
localizedReason:(NSString *)localizedReason
|
||||
reply:(void(^)(BOOL success, NSError * __nullable error))reply
|
||||
NS_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3.0) __TVOS_UNAVAILABLE;
|
||||
|
||||
|
||||
@property (nonatomic, nullable, copy) NSString *localizedFallbackTitle;
|
||||
|
||||
|
||||
@property (nonatomic, nullable, copy) NSString *localizedCancelTitle NS_AVAILABLE(10_12, 10_0);
|
||||
|
||||
|
||||
@property (nonatomic, nullable) NSNumber *maxBiometryFailures NS_DEPRECATED_IOS(8_3, 9_0) __WATCHOS_UNAVAILABLE __TVOS_UNAVAILABLE;
|
||||
|
||||
@property (nonatomic, nullable, readonly) NSData *evaluatedPolicyDomainState NS_AVAILABLE(10_11, 9_0) __WATCHOS_UNAVAILABLE __TVOS_UNAVAILABLE;
|
||||
|
||||
@property (nonatomic) NSTimeInterval touchIDAuthenticationAllowableReuseDuration NS_AVAILABLE(10_12, 9_0) __WATCHOS_UNAVAILABLE __TVOS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
28
src/LocalAuthentication/Headers/LAError.h
Normal file
28
src/LocalAuthentication/Headers/LAError.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <LocalAuthentication/LAPublicDefines.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, LAError)
|
||||
{
|
||||
LAErrorAuthenticationFailed = kLAErrorAuthenticationFailed,
|
||||
|
||||
LAErrorUserCancel = kLAErrorUserCancel,
|
||||
|
||||
LAErrorUserFallback = kLAErrorUserFallback,
|
||||
|
||||
LAErrorSystemCancel = kLAErrorSystemCancel,
|
||||
|
||||
LAErrorPasscodeNotSet = kLAErrorPasscodeNotSet,
|
||||
|
||||
LAErrorTouchIDNotAvailable = kLAErrorTouchIDNotAvailable,
|
||||
|
||||
LAErrorTouchIDNotEnrolled = kLAErrorTouchIDNotEnrolled,
|
||||
|
||||
LAErrorTouchIDLockout NS_ENUM_AVAILABLE(10_11, 9_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0) = kLAErrorTouchIDLockout,
|
||||
|
||||
LAErrorAppCancel NS_ENUM_AVAILABLE(10_11, 9_0) = kLAErrorAppCancel,
|
||||
|
||||
LAErrorInvalidContext NS_ENUM_AVAILABLE(10_11, 9_0) = kLAErrorInvalidContext
|
||||
} NS_ENUM_AVAILABLE(10_10, 8_0) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
|
||||
|
||||
extern NSString *const __nonnull LAErrorDomain
|
||||
NS_AVAILABLE(10_10, 8_3) __WATCHOS_AVAILABLE(3.0) __TVOS_AVAILABLE(10.0);
|
||||
14
src/LocalAuthentication/Headers/LAPrivateDefines.h
Normal file
14
src/LocalAuthentication/Headers/LAPrivateDefines.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef LocalAuthentication_LAPrivateDefines_h
|
||||
#define LocalAuthentication_LAPrivateDefines_h
|
||||
|
||||
#include <LocalAuthentication/LAPublicDefines.h>
|
||||
|
||||
/* These aren't actual values, just made-up ones */
|
||||
|
||||
#define kLAErrorParameter -2134234
|
||||
#define kLAErrorNotInteractive -598423
|
||||
#define kTKErrorCodeBadParameter -659833
|
||||
|
||||
typedef void* LAFunctionCopyExternalizedContext;
|
||||
|
||||
#endif
|
||||
27
src/LocalAuthentication/Headers/LAPublicDefines.h
Normal file
27
src/LocalAuthentication/Headers/LAPublicDefines.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef LocalAuthentication_LAPublicDefines_h
|
||||
#define LocalAuthentication_LAPublicDefines_h
|
||||
|
||||
#define kLAPolicyDeviceOwnerAuthenticationWithBiometrics 1
|
||||
#define kLAPolicyDeviceOwnerAuthentication 2
|
||||
|
||||
#define kLAOptionUserFallback 1
|
||||
#define kLAOptionAuthenticationReason 2
|
||||
|
||||
#define kLACredentialTypePasscode -1
|
||||
#define kLACredentialTypePassphrase -2
|
||||
#define kLACredentialCTKPIN -3
|
||||
|
||||
#define kLAErrorAuthenticationFailed -1
|
||||
#define kLAErrorUserCancel -2
|
||||
#define kLAErrorUserFallback -3
|
||||
#define kLAErrorSystemCancel -4
|
||||
#define kLAErrorPasscodeNotSet -5
|
||||
#define kLAErrorTouchIDNotAvailable -6
|
||||
#define kLAErrorTouchIDNotEnrolled -7
|
||||
#define kLAErrorTouchIDLockout -8
|
||||
#define kLAErrorAppCancel -9
|
||||
#define kLAErrorInvalidContext -10
|
||||
|
||||
#define kLAErrorDomain "com.apple.LocalAuthentication"
|
||||
|
||||
#endif
|
||||
2
src/LocalAuthentication/Headers/LocalAuthentication.h
Normal file
2
src/LocalAuthentication/Headers/LocalAuthentication.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#import <LocalAuthentication/LAContext.h>
|
||||
#import <LocalAuthentication/LAError.h>
|
||||
1
src/LocalAuthentication/LocalAuthentication
Symbolic link
1
src/LocalAuthentication/LocalAuthentication
Symbolic link
@@ -0,0 +1 @@
|
||||
Headers
|
||||
2
src/external/corefoundation
vendored
2
src/external/corefoundation
vendored
Submodule src/external/corefoundation updated: 5596ef3d33...39fe28e693
2
src/external/security
vendored
2
src/external/security
vendored
Submodule src/external/security updated: ed219b46da...9a6e079f1c
573
src/libc/os/activity.h
Normal file
573
src/libc/os/activity.h
Normal file
@@ -0,0 +1,573 @@
|
||||
/*
|
||||
* Copyright (c) 2013-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 __OS_ACTIVITY_H__
|
||||
#define __OS_ACTIVITY_H__
|
||||
|
||||
#include <os/base.h>
|
||||
|
||||
#include <os/object.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <mach-o/loader.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if ((defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) \
|
||||
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0) \
|
||||
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0) \
|
||||
|| (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12))
|
||||
#define OS_ACTIVITY_OBJECT_API 1
|
||||
#else
|
||||
#if OS_ACTIVITY_OBJECT_API
|
||||
#error Please change your minimum OS requirements because OS_ACTIVITY_OBJECT_API is not available
|
||||
#endif // OS_ACTIVITY_OBJECT_API
|
||||
#define OS_ACTIVITY_OBJECT_API 0
|
||||
#endif
|
||||
|
||||
extern struct mach_header __dso_handle;
|
||||
|
||||
#define OS_LOG_STRING(_var, _str) \
|
||||
_Static_assert(__builtin_constant_p(_str), "formatters/labels/descriptions must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) static const char _var[] __asm(OS_STRINGIFY(OS_CONCAT(LOSACTIVITY_, __COUNTER__))) = _str
|
||||
|
||||
/*!
|
||||
* @typedef os_breadcrumb_t
|
||||
* An opaque value for the breadcrumb ID.
|
||||
*/
|
||||
__API_DEPRECATED("No longer supported", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
typedef uint32_t os_breadcrumb_t;
|
||||
|
||||
#define OS_ACTIVITY_NULL 0
|
||||
|
||||
/*!
|
||||
* @enum os_activity_flag_t
|
||||
*
|
||||
* @discussion
|
||||
* Support flags for os_activity_create or os_activity_start.
|
||||
*
|
||||
* @constant OS_ACTIVITY_FLAG_DEFAULT
|
||||
* Use the default flags.
|
||||
*
|
||||
* @constant OS_ACTIVITY_FLAG_DETACHED
|
||||
* Detach the newly created activity from the provided activity (if any). If passed in conjunction
|
||||
* with an exiting activity, the activity will only note what activity "created" the new one, but
|
||||
* will make the new activity a top level activity. This allows users to see what activity triggered
|
||||
* work without actually relating the activities.
|
||||
*
|
||||
* @constant OS_ACTIVITY_FLAG_IF_NONE_PRESENT
|
||||
* Will only create a new activity if none present. If an activity ID is already present, a new object
|
||||
* will be returned with the same activity ID underneath.
|
||||
*/
|
||||
OS_ENUM(os_activity_flag, uint32_t,
|
||||
OS_ACTIVITY_FLAG_DEFAULT = 0,
|
||||
OS_ACTIVITY_FLAG_DETACHED = 0x1,
|
||||
OS_ACTIVITY_FLAG_IF_NONE_PRESENT = 0x2
|
||||
);
|
||||
|
||||
#if OS_ACTIVITY_OBJECT_API
|
||||
|
||||
#define OS_ACTIVITY_NULL NULL
|
||||
|
||||
/*!
|
||||
* @typedef os_activity_t
|
||||
* An opaque activity object.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
#if OS_OBJECT_USE_OBJC
|
||||
OS_OBJECT_DECL(os_activity);
|
||||
#else
|
||||
typedef struct os_activity_s *os_activity_t;
|
||||
#endif /* OS_OBJECT_USE_OBJC */
|
||||
|
||||
/*!
|
||||
* @const OS_ACTIVITY_NONE
|
||||
*
|
||||
* @discussion
|
||||
* Create activity with no current traits, this is the equivalent of a
|
||||
* detached activity.
|
||||
*/
|
||||
#define OS_ACTIVITY_NONE OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_none)
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT
|
||||
const struct os_activity_s _os_activity_none;
|
||||
|
||||
/*!
|
||||
* @const OS_ACTIVITY_CURRENT
|
||||
*
|
||||
* @discussion
|
||||
* Create activity and links to the current activity if one is present.
|
||||
* If no activity is present it is treated as if it is detached.
|
||||
*/
|
||||
#define OS_ACTIVITY_CURRENT OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_current)
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT
|
||||
const struct os_activity_s _os_activity_current;
|
||||
|
||||
#else // !OS_ACTIVITY_OBJECT_API
|
||||
|
||||
#define OS_ACTIVITY_NULL 0
|
||||
|
||||
/*!
|
||||
* @typedef os_activity_t
|
||||
* An opaque activity identifier.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
typedef uint64_t os_activity_t;
|
||||
|
||||
#endif // OS_ACTIVITY_OBJECT_API
|
||||
|
||||
/*!
|
||||
* @typedef os_activity_id_t
|
||||
* An value representing the activity ID assigned to an newly created activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
typedef uint64_t os_activity_id_t;
|
||||
|
||||
#if !defined(__TRACE_BUILDING_TRACE__)
|
||||
/*!
|
||||
* @typedef os_activity_scope_state_t
|
||||
* Structure that is populated by os_activity_scope_enter and restored using
|
||||
* os_activity_scope_leave.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
typedef struct os_activity_scope_state_s {
|
||||
uint64_t opaque[2];
|
||||
} *os_activity_scope_state_t;
|
||||
#else
|
||||
typedef struct os_activity_scope_state_s *os_activity_scope_state_t;
|
||||
#endif
|
||||
|
||||
#pragma mark - Internal support functions
|
||||
|
||||
#if OS_ACTIVITY_OBJECT_API
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT_NEEDS_RELEASE OS_NOT_TAIL_CALLED OS_OBJECT_RETURNS_RETAINED
|
||||
os_activity_t
|
||||
_os_activity_create(void *dso, const char *description, os_activity_t activity, os_activity_flag_t flags);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function _os_activity_label_useraction
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for use by os_activity_label_useraction. Do not use directly.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_label_useraction(void *dso, const char *name);
|
||||
|
||||
/*!
|
||||
* @function _os_activity_initiate
|
||||
*
|
||||
* @abstract
|
||||
* Do not use directly because your description will not be preserved.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_initiate(void *dso, const char *description, os_activity_flag_t flags, os_block_t activity_block OS_NOESCAPE);
|
||||
|
||||
/*!
|
||||
* @function _os_activity_initiate_f
|
||||
*
|
||||
* @abstract
|
||||
* Do not use directly because your description will not be preserved.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_initiate_f(void *dso, const char *description, os_activity_flag_t flags, void *context, os_function_t function);
|
||||
|
||||
#pragma mark - Internal deprecated function support
|
||||
|
||||
/*!
|
||||
* @function _os_activity_set_breadcrumb
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for setting breadcrumb. Do not use directly.
|
||||
*/
|
||||
__API_DEPRECATED_WITH_REPLACEMENT("os_activity_label_useraction", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_set_breadcrumb(void *dso, const char *name);
|
||||
|
||||
/*!
|
||||
* @function _os_activity_start
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for activity start, do not use directly will not preserve
|
||||
* description.
|
||||
*/
|
||||
__API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NOT_TAIL_CALLED
|
||||
os_activity_t
|
||||
_os_activity_start(void *dso, const char *description, os_activity_flag_t flags);
|
||||
|
||||
#pragma mark - activity related
|
||||
|
||||
/*!
|
||||
* @function os_activity_initiate
|
||||
*
|
||||
* @abstract
|
||||
* Synchronously initiates an activity using provided block.
|
||||
*
|
||||
* @discussion
|
||||
* Synchronously initiates an activity using the provided block and creates
|
||||
* a tracing buffer as appropriate. All new activities are created as a
|
||||
* subactivity of an existing activity on the current thread.
|
||||
*
|
||||
* os_activity_initiate("indexing database", OS_ACTIVITY_FLAG_DEFAULT, ^(void) {
|
||||
* // either do work directly or issue work asynchronously
|
||||
* });
|
||||
*
|
||||
* @param description
|
||||
* A constant string describing the activity, e.g., "performClick" or
|
||||
* "menuSelection".
|
||||
*
|
||||
* @param flags
|
||||
* Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
|
||||
*
|
||||
* @param activity_block
|
||||
* The block to execute a given activity
|
||||
*/
|
||||
#define os_activity_initiate(description, flags, activity_block) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
_os_activity_initiate(&__dso_handle, __description, flags, activity_block); \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_activity_initiate_f
|
||||
*
|
||||
* @abstract
|
||||
* Synchronously initiates an activity using the provided function.
|
||||
*
|
||||
* @discussion
|
||||
* Synchronously initiates an activity using the provided function and creates
|
||||
* a tracing buffer as appropriate. All new activities are created as a
|
||||
* subactivity of an existing activity on the current thread.
|
||||
*
|
||||
* os_activity_initiate_f("indexing database", OS_ACTIVITY_FLAG_DEFAULT, context, function);
|
||||
*
|
||||
* @param description
|
||||
* A constant string describing the activity, e.g., "performClick" or
|
||||
* "menuSelection".
|
||||
*
|
||||
* @param flags
|
||||
* Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
|
||||
*
|
||||
* @param context
|
||||
* An optional context that will be supplied to the activity function.
|
||||
*
|
||||
* @param activity_func
|
||||
* The function to execute for the new activity.
|
||||
*/
|
||||
#define os_activity_initiate_f(description, flags, context, function) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
_os_activity_initiate_f(&__dso_handle, __description, flags, context, function); \
|
||||
})
|
||||
|
||||
#if OS_ACTIVITY_OBJECT_API
|
||||
/*!
|
||||
* @function os_activity_create
|
||||
*
|
||||
* @abstract
|
||||
* Creates an os_activity_t object which can be passed to os_activity_apply function.
|
||||
*
|
||||
* @discussion
|
||||
* Creates an os_activity_t object which can be passed to os_activity_apply function.
|
||||
*
|
||||
* @param description
|
||||
* Pass a description for the activity. The description must be a constant string
|
||||
* within the calling executable or library.
|
||||
*
|
||||
* @param parent_activity
|
||||
* Depending on flags will link the newly created activity to the value passed or
|
||||
* note where the activity was created. Possible activities include: OS_ACTIVITY_NONE,
|
||||
* OS_ACTIVITY_CURRENT or any existing os_activity_t object created using os_activity_create.
|
||||
*
|
||||
* @param flags
|
||||
* A valid os_activity_flag_t which will determine behavior of the newly created activity.
|
||||
*
|
||||
* @result
|
||||
* Returns an os_activity_t object which can be used with os_activity_apply.
|
||||
*/
|
||||
#define os_activity_create(description, parent_activity, flags) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
os_activity_t __activity = _os_activity_create(&__dso_handle, __description, parent_activity, flags); \
|
||||
__activity; \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_activity_apply
|
||||
*
|
||||
* @abstract
|
||||
* Execute a block using a given activity object.
|
||||
*
|
||||
* @discussion
|
||||
* Execute a block using a given activity object.
|
||||
*
|
||||
* @param activity
|
||||
* There are global objects available which include: OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT
|
||||
* or an existing os_activity_t object.
|
||||
*
|
||||
* @param block
|
||||
* Pass the block to be executed within the context of the given activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
|
||||
|
||||
/*!
|
||||
* @function os_activity_apply_f
|
||||
*
|
||||
* @abstract
|
||||
* Execute a given function with a provided activity.
|
||||
*
|
||||
* @discussion
|
||||
* Execute a given function with a provided activity.
|
||||
*
|
||||
* @param activity
|
||||
* There are global objects available which include: OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT
|
||||
* or an existing os_activity_t object.
|
||||
*
|
||||
* @param context
|
||||
* Context to pass to the function which may be NULL.
|
||||
*
|
||||
* @param function
|
||||
* Pass the function to be executed within the context of the given activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_apply_f(os_activity_t activity, void *context, os_function_t function);
|
||||
|
||||
/*!
|
||||
* @function os_activity_scope_enter
|
||||
*
|
||||
* @abstract
|
||||
* Will change the current execution context to use the provided activity.
|
||||
*
|
||||
* @discussion
|
||||
* Will change the current execution context to use the provided activity. An activity
|
||||
* can be created and then applied to the current scope by doing:
|
||||
*
|
||||
* struct os_activity_scope_state_s state;
|
||||
* os_activity_t activity = os_activity_create("my new activity", 0);
|
||||
* os_activity_scope_enter(activity, &state);
|
||||
* ... do some work ...
|
||||
* os_activity_scope_leave(&state);
|
||||
*
|
||||
* To auto-cleanup state call:
|
||||
*
|
||||
* os_activity_scope(activity);
|
||||
*
|
||||
* @param activity
|
||||
* Pass a valid activity created with os_activity_create or any global object.
|
||||
*
|
||||
* @param state
|
||||
* A stack-based struct os_activity_scope_state_s to store the state.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state);
|
||||
|
||||
/*!
|
||||
* @function os_activity_scope_leave
|
||||
*
|
||||
* @abstract
|
||||
* Will pop state up to the state provided.
|
||||
*
|
||||
* @discussion
|
||||
* Will leave scope using the state provided. If state is not present an error will be
|
||||
* generated.
|
||||
*
|
||||
* @param state
|
||||
* Must be a valid value filled by os_activity_scope_enter call.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_scope_leave(os_activity_scope_state_t state);
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define _os_activity_scope(var, activity) \
|
||||
struct os_activity_scope_state_s var __attribute__((__cleanup__(os_activity_scope_leave))); \
|
||||
os_activity_scope_enter(activity, &var)
|
||||
#define os_activity_scope(activity) _os_activity_scope(OS_CONCAT(scope, __COUNTER__), activity)
|
||||
#endif
|
||||
|
||||
#endif // OS_ACTIVITY_OBJECT_API
|
||||
|
||||
/*!
|
||||
* @function os_activity_start
|
||||
*
|
||||
* @abstract
|
||||
* Starts a new activity immediately within the current context.
|
||||
*
|
||||
* @discussion
|
||||
* Starts a new activity immediately within the current context. Deprecated please use new
|
||||
* os_activity_create and os_activity_apply.
|
||||
*
|
||||
* os_activity_t activity = os_activity_start("indexing database", OS_ACTIVITY_FLAG_DEFAULT);
|
||||
* < do some work >
|
||||
* os_activity_end(activity);
|
||||
*
|
||||
* @param description
|
||||
* A constant string describing the activity, e.g., "performClick" or
|
||||
* "menuSelection".
|
||||
*
|
||||
* @param flags
|
||||
* Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
|
||||
*
|
||||
* @result
|
||||
* Returns a valid os_activity_id_t or 0 on failure.
|
||||
*/
|
||||
#define os_activity_start(description, flags) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
os_activity_t _aid = _os_activity_start(&__dso_handle, __description, flags); \
|
||||
_aid; \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_activity_end
|
||||
*
|
||||
* @abstract
|
||||
* Ends the specified activity on the current thread.
|
||||
*
|
||||
* @discussion
|
||||
* Ends the specified activity on the current thread. Does not signify anything
|
||||
* other than the originator has received control back from the activity. Work
|
||||
* could still be in flight related to the activity.
|
||||
*
|
||||
* @param activity
|
||||
* An os_activity_t returned from os_activity_start.
|
||||
*/
|
||||
__API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_end(os_activity_t activity);
|
||||
|
||||
/*!
|
||||
* @function os_activity_get_active
|
||||
*
|
||||
* @abstract
|
||||
* Returns the stack of nested activities associated with the current thread.
|
||||
*
|
||||
* @discussion
|
||||
* Activities have a sense of nesting and therefore there could be more than
|
||||
* one activity involved on the current thread. This should be used by
|
||||
* diagnostic tools only for making additional decisions about a situation.
|
||||
*
|
||||
* @param entries
|
||||
* Pass a buffer of sufficient size to hold the the number of os_activity_id_t
|
||||
* being requested.
|
||||
*
|
||||
* @param count
|
||||
* Pointer to the requested number of activity identifiers.
|
||||
* On output will be filled with the number of activities that are available.
|
||||
*
|
||||
* @result
|
||||
* Number of activity identifiers written to 'entries'
|
||||
*/
|
||||
__API_DEPRECATED("No longer supported", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
unsigned int
|
||||
os_activity_get_active(os_activity_id_t *entries, unsigned int *count);
|
||||
|
||||
/*!
|
||||
* @function os_activity_get_identifier
|
||||
*
|
||||
* @abstract
|
||||
* Returns the current activity ID and will fill the parent_id if present.
|
||||
*
|
||||
* @discussion
|
||||
* Returns the current activity ID and will fill the parent_id if present.
|
||||
*
|
||||
* @param parent_id
|
||||
* If non-null will set the parent activity ID.
|
||||
*
|
||||
* @result
|
||||
* The identifier for the provided activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NONNULL1 OS_WARN_RESULT
|
||||
os_activity_id_t
|
||||
os_activity_get_identifier(os_activity_t activity, os_activity_id_t *parent_id);
|
||||
|
||||
/*!
|
||||
* @function os_activity_label_useraction
|
||||
*
|
||||
* @abstract
|
||||
* Label an activity that is auto-generated by AppKit/UIKit with a name that is useful
|
||||
* for debugging macro-level user actions.
|
||||
*
|
||||
* @discussion
|
||||
* Label an activity that is auto-generated by AppKit/UIKit with a name that is useful
|
||||
* for debugging macro-level user actions. The API should be called early within the scope
|
||||
* of the IBAction and before any sub-activities are created. The name provided will
|
||||
* be shown in tools in additon to the underlying AppKit/UIKit provided name. This API
|
||||
* can only be called once and only on the activity created by AppKit/UIKit. These actions
|
||||
* help determine workflow of the user in order to reproduce problems that occur.
|
||||
* For example, a control press and/or menu item selection can be labeled:
|
||||
*
|
||||
* os_activity_label_useraction("New mail message");
|
||||
* os_activity_label_useraction("Empty trash");
|
||||
*
|
||||
* Where the underlying AppKit/UIKit name will be "gesture:" or "menuSelect:".
|
||||
*
|
||||
* @param name
|
||||
* A constant string that describes the the action.
|
||||
*/
|
||||
#define os_activity_label_useraction(label) __extension__({ \
|
||||
OS_LOG_STRING(__label, label); \
|
||||
_os_activity_label_useraction(&__dso_handle, __label); \
|
||||
})
|
||||
|
||||
#pragma mark - application breadcrumbs
|
||||
|
||||
/*!
|
||||
* @function os_activity_set_breadcrumb
|
||||
*
|
||||
* @abstract
|
||||
* This flags the current activity as a "breadcrumb", i.e., an interesting event.
|
||||
*
|
||||
* @discussion
|
||||
* Not all activities are interesting events at the macro-level. Some activities
|
||||
* can be flagged as a breadcrumb for evalutating cross activity interactions.
|
||||
* This can only be called once per activity, other requests will be ignored.
|
||||
*
|
||||
* @param name
|
||||
* A constant string that describes the breadcrumb.
|
||||
*/
|
||||
#define os_activity_set_breadcrumb(name) __extension__({ \
|
||||
OS_LOG_STRING(__name, name); \
|
||||
_os_activity_set_breadcrumb(&__dso_handle, __name); \
|
||||
})
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // __OS_ACTIVITY_H__
|
||||
81
src/libc/os/availability.h
Normal file
81
src/libc/os/availability.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_AVAILABILITY__
|
||||
#define __OS_AVAILABILITY__
|
||||
|
||||
#include <AvailabilityInternal.h>
|
||||
|
||||
/*
|
||||
Macros for defining which versions/platform a given symbol can be used.
|
||||
|
||||
@see http://clang.llvm.org/docs/AttributeReference.html#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))
|
||||
*/
|
||||
|
||||
#define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* 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_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1)(__VA_ARGS__)
|
||||
#define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1)(__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
#endif /* __OS_AVAILABILITY__ */
|
||||
@@ -1,51 +1,240 @@
|
||||
/* Copyright (c) 2012 Apple Inc. All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2008-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
|
||||
* @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_LICENSE_HEADER_END@
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_BASE_H__
|
||||
#define __OS_BASE_H__
|
||||
#ifndef __OS_BASE__
|
||||
#define __OS_BASE__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#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
|
||||
|
||||
#undef OS_INLINE // <sys/_types/_os_inline.h>
|
||||
#if __GNUC__
|
||||
#define os_fastpath(x) ((__typeof__(x))(uintptr_t)__builtin_expect((uintptr_t)(x), ~0l))
|
||||
#define os_slowpath(x) ((__typeof__(x))(uintptr_t)__builtin_expect((uintptr_t)(x), 0l))
|
||||
#define os_constant(x) __builtin_constant_p((x))
|
||||
#define os_hardware_trap() __asm__ __volatile__ (""); __builtin_trap()
|
||||
#define OS_NORETURN __attribute__((__noreturn__))
|
||||
#define OS_NOTHROW __attribute__((__nothrow__))
|
||||
#define OS_NONNULL1 __attribute__((__nonnull__(1)))
|
||||
#define OS_NONNULL2 __attribute__((__nonnull__(2)))
|
||||
#define OS_NONNULL3 __attribute__((__nonnull__(3)))
|
||||
#define OS_NONNULL4 __attribute__((__nonnull__(4)))
|
||||
#define OS_NONNULL5 __attribute__((__nonnull__(5)))
|
||||
#define OS_NONNULL6 __attribute__((__nonnull__(6)))
|
||||
#define OS_NONNULL7 __attribute__((__nonnull__(7)))
|
||||
#define OS_NONNULL8 __attribute__((__nonnull__(8)))
|
||||
#define OS_NONNULL9 __attribute__((__nonnull__(9)))
|
||||
#define OS_NONNULL10 __attribute__((__nonnull__(10)))
|
||||
#define OS_NONNULL11 __attribute__((__nonnull__(11)))
|
||||
#define OS_NONNULL12 __attribute__((__nonnull__(12)))
|
||||
#define OS_NONNULL13 __attribute__((__nonnull__(13)))
|
||||
#define OS_NONNULL14 __attribute__((__nonnull__(14)))
|
||||
#define OS_NONNULL15 __attribute__((__nonnull__(15)))
|
||||
#define OS_NONNULL_ALL __attribute__((__nonnull__))
|
||||
#define OS_SENTINEL __attribute__((__sentinel__))
|
||||
#define OS_PURE __attribute__((__pure__))
|
||||
#define OS_CONST __attribute__((__const__))
|
||||
#define OS_WARN_RESULT __attribute__((__warn_unused_result__))
|
||||
#define OS_MALLOC __attribute__((__malloc__))
|
||||
#define OS_USED __attribute__((__used__))
|
||||
#define OS_UNUSED __attribute__((__unused__))
|
||||
#define OS_COLD __attribute__((__cold__))
|
||||
#define OS_WEAK __attribute__((__weak__))
|
||||
#define OS_WEAK_IMPORT __attribute__((__weak_import__))
|
||||
#define OS_NOINLINE __attribute__((__noinline__))
|
||||
#define OS_ALWAYS_INLINE __attribute__((__always_inline__))
|
||||
#define OS_TRANSPARENT_UNION __attribute__((__transparent_union__))
|
||||
#define OS_ALIGNED(n) __attribute__((__aligned__((n))))
|
||||
#define OS_FORMAT_PRINTF(x,y) __attribute__((__format__(printf,x,y)))
|
||||
#define OS_EXPORT extern __attribute__((__visibility__("default")))
|
||||
#define OS_INLINE static __inline__
|
||||
#define OS_EXPECT(x, v) __builtin_expect((x), (v))
|
||||
#else
|
||||
#define OS_NORETURN
|
||||
#define OS_NOTHROW
|
||||
#define OS_NONNULL1
|
||||
#define OS_NONNULL2
|
||||
#define OS_NONNULL3
|
||||
#define OS_NONNULL4
|
||||
#define OS_NONNULL5
|
||||
#define OS_NONNULL6
|
||||
#define OS_NONNULL7
|
||||
#define OS_NONNULL8
|
||||
#define OS_NONNULL9
|
||||
#define OS_NONNULL10
|
||||
#define OS_NONNULL11
|
||||
#define OS_NONNULL12
|
||||
#define OS_NONNULL13
|
||||
#define OS_NONNULL14
|
||||
#define OS_NONNULL15
|
||||
#define OS_NONNULL_ALL
|
||||
#define OS_SENTINEL
|
||||
#define OS_PURE
|
||||
#define OS_CONST
|
||||
#define OS_WARN_RESULT
|
||||
#define OS_MALLOC
|
||||
#define OS_USED
|
||||
#define OS_UNUSED
|
||||
#define OS_COLD
|
||||
#define OS_WEAK
|
||||
#define OS_WEAK_IMPORT
|
||||
#define OS_NOINLINE
|
||||
#define OS_ALWAYS_INLINE
|
||||
#define OS_TRANSPARENT_UNION
|
||||
#define OS_ALIGNED(n)
|
||||
#define OS_FORMAT_PRINTF(x,y)
|
||||
#define OS_EXPORT extern
|
||||
#define OS_INLINE static inline
|
||||
#define OS_EXPECT(x, v) (x)
|
||||
#endif
|
||||
|
||||
#define __OS_COMPILETIME_ASSERT__(e) __extension__({ \
|
||||
char __compile_time_assert__[(e) ? 1 : -1]; \
|
||||
(void)__compile_time_assert__; \
|
||||
})
|
||||
#if __has_attribute(noescape)
|
||||
#define OS_NOESCAPE __attribute__((__noescape__))
|
||||
#else
|
||||
#define OS_NOESCAPE
|
||||
#endif
|
||||
|
||||
#define __OS_CONST __attribute__((__const__))
|
||||
#define __OS_PRINTFLIKE(x,y) __attribute__((__format__(printf,x,y)))
|
||||
#else /* __GNUC__ */
|
||||
#define os_fastpath(x) (x)
|
||||
#define os_slowpath(x) (x)
|
||||
#define os_constant(x) ((long)0)
|
||||
#define os_hardware_trap() abort()
|
||||
#if __has_feature(assume_nonnull)
|
||||
#define OS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
|
||||
#define OS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
|
||||
#else
|
||||
#define OS_ASSUME_NONNULL_BEGIN
|
||||
#define OS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
|
||||
#define __OS_COMPILETIME_ASSERT__(e) (e)
|
||||
#if __has_builtin(__builtin_assume)
|
||||
#define OS_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
|
||||
#else
|
||||
#define OS_COMPILER_CAN_ASSUME(expr) ((void)(expr))
|
||||
#endif
|
||||
|
||||
#define __OS_CONST
|
||||
#define __OS_PRINTFLIKE(x,y)
|
||||
#endif /* __GNUC__ */
|
||||
#if __has_extension(attribute_overloadable)
|
||||
#define OS_OVERLOADABLE __attribute__((__overloadable__))
|
||||
#else
|
||||
#define OS_OVERLOADABLE
|
||||
#endif
|
||||
|
||||
#endif /* __OS_BASE_H__ */
|
||||
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
|
||||
#define OS_ENUM(_name, _type, ...) \
|
||||
typedef enum : _type { __VA_ARGS__ } _name##_t
|
||||
#else
|
||||
#define OS_ENUM(_name, _type, ...) \
|
||||
enum { __VA_ARGS__ }; typedef _type _name##_t
|
||||
#endif
|
||||
|
||||
#if __has_feature(attribute_availability_swift)
|
||||
// equivalent to __SWIFT_UNAVAILABLE from Availability.h
|
||||
#define OS_SWIFT_UNAVAILABLE(_msg) \
|
||||
__attribute__((__availability__(swift, unavailable, message=_msg)))
|
||||
#else
|
||||
#define OS_SWIFT_UNAVAILABLE(_msg)
|
||||
#endif
|
||||
|
||||
#if __has_attribute(swift_private)
|
||||
# define OS_REFINED_FOR_SWIFT __attribute__((__swift_private__))
|
||||
#else
|
||||
# define OS_REFINED_FOR_SWIFT
|
||||
#endif
|
||||
|
||||
#if __has_attribute(swift_name)
|
||||
# define OS_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
|
||||
#else
|
||||
# define OS_SWIFT_NAME(_name)
|
||||
#endif
|
||||
|
||||
#define __OS_STRINGIFY(s) #s
|
||||
#define OS_STRINGIFY(s) __OS_STRINGIFY(s)
|
||||
#define __OS_CONCAT(x, y) x ## y
|
||||
#define OS_CONCAT(x, y) __OS_CONCAT(x, y)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define os_prevent_tail_call_optimization() __asm__("")
|
||||
#define os_is_compile_time_constant(expr) __builtin_constant_p(expr)
|
||||
#define os_compiler_barrier() __asm__ __volatile__("" ::: "memory")
|
||||
#else
|
||||
#define os_prevent_tail_call_optimization() do { } while (0)
|
||||
#define os_is_compile_time_constant(expr) 0
|
||||
#define os_compiler_barrier() do { } while (0)
|
||||
#endif
|
||||
|
||||
#if __has_attribute(not_tail_called)
|
||||
#define OS_NOT_TAIL_CALLED __attribute__((__not_tail_called__))
|
||||
#else
|
||||
#define OS_NOT_TAIL_CALLED
|
||||
#endif
|
||||
|
||||
typedef void (*os_function_t)(void *_Nullable);
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
/*!
|
||||
* @typedef os_block_t
|
||||
*
|
||||
* @abstract
|
||||
* Generic type for a block taking no arguments and returning no 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>
|
||||
* os_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 (^os_block_t)(void);
|
||||
#endif
|
||||
|
||||
#endif // __OS_BASE__
|
||||
|
||||
Reference in New Issue
Block a user