Skip to content

Commit

Permalink
Merge pull request #3058 from millenomi/pr-monterey-merge
Browse files Browse the repository at this point in the history
The Monterey Merge
  • Loading branch information
millenomi committed Sep 10, 2021
2 parents 8834372 + 6634ee3 commit 512e412
Show file tree
Hide file tree
Showing 95 changed files with 4,101 additions and 1,401 deletions.
9 changes: 9 additions & 0 deletions CoreFoundation/AppServices.subproj/CFUserNotification.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ static void _CFUserNotificationMachPortCallBack(CFMachPortRef port, void *m, CFI
}

SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags) {
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
CHECK_FOR_FORK();
SInt32 retval = ERR_SUCCESS;
mach_msg_timeout_t msgtime = (timeout > 0.0 && 1000.0 * timeout < INT_MAX) ? (mach_msg_timeout_t)(1000.0 * timeout) : 0;
Expand Down Expand Up @@ -343,11 +344,15 @@ SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification,
}

CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx) {
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
CHECK_FOR_FORK();
CFStringRef retval = NULL;
CFTypeRef value = NULL;
if (userNotification && userNotification->_responseDictionary) {
value = CFDictionaryGetValue(userNotification->_responseDictionary, key);
if (value == NULL) {
return NULL;
}
if (CFGetTypeID(value) == CFStringGetTypeID()) {
if (0 == idx) retval = (CFStringRef)value;
} else if (CFGetTypeID(value) == CFArrayGetTypeID()) {
Expand All @@ -358,11 +363,13 @@ CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotific
}

CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification) {
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
CHECK_FOR_FORK();
return userNotification ? userNotification->_responseDictionary : NULL;
}

SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary) {
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
CHECK_FOR_FORK();
SInt32 retval = ERR_SUCCESS;
if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
Expand All @@ -373,6 +380,7 @@ SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeIn
}

SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification) {
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
CHECK_FOR_FORK();
SInt32 retval = ERR_SUCCESS;
if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
Expand All @@ -383,6 +391,7 @@ SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification) {
}

CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order) {
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
CHECK_FOR_FORK();
CFRunLoopSourceRef source = NULL;
if (userNotification && callout && !userNotification->_machPort && MACH_PORT_NULL != userNotification->_replyPort) {
Expand Down
6 changes: 3 additions & 3 deletions CoreFoundation/Base.subproj/CFAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@
#define __CF_ENUM_FIXED_IS_AVAILABLE (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && (__has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum)))

#if __CF_ENUM_FIXED_IS_AVAILABLE
#define __CF_NAMED_ENUM(_type, _name) int __CF_ENUM_ ## _name; enum __CF_ENUM_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
#define __CF_NAMED_ENUM(_type, _name) enum __CF_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
#define __CF_ANON_ENUM(_type) enum __CF_ENUM_ATTRIBUTES : _type
#define CF_CLOSED_ENUM(_type, _name) int __CF_ENUM_ ## _name; enum __CF_CLOSED_ENUM_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
#define CF_CLOSED_ENUM(_type, _name) enum __CF_CLOSED_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
#if (__cplusplus)
#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _type
#else
#define CF_OPTIONS(_type, _name) int __CF_OPTIONS_ ## _name; enum __CF_OPTIONS_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
#define CF_OPTIONS(_type, _name) enum __CF_OPTIONS_ATTRIBUTES _name : _type _name; enum _name : _type
#endif
#else
#define __CF_NAMED_ENUM(_type, _name) _type _name; enum
Expand Down
39 changes: 20 additions & 19 deletions CoreFoundation/Base.subproj/CFBase.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct __CFAllocator {
};

CF_INLINE uintptr_t __CFISAForCFAllocator(void) {
return __CFRuntimeObjCClassTable[_kCFRuntimeIDCFAllocator];
return _GetCFRuntimeObjcClassAtIndex(_kCFRuntimeIDCFAllocator);
}

CF_INLINE CFAllocatorRetainCallBack __CFAllocatorGetRetainFunction(const CFAllocatorContext *context) {
Expand Down Expand Up @@ -478,7 +478,7 @@ void CFAllocatorSetDefault(CFAllocatorRef allocator) {
}
#endif
#if TARGET_OS_MAC
if (allocator && allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (allocator && _CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return; // require allocator to this function to be an allocator
}
#endif
Expand All @@ -505,7 +505,7 @@ static CFAllocatorRef __CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorC
CFAllocatorAllocateCallBack allocateFunc;
void *retainedInfo;
#if TARGET_OS_MAC
if (allocator && kCFAllocatorUseContext != allocator && allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (allocator && kCFAllocatorUseContext != allocator && _CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return NULL; // require allocator to this function to be an allocator
}
#endif
Expand Down Expand Up @@ -588,15 +588,15 @@ void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags
}

#if defined(DEBUG) && TARGET_OS_MAC
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
}
#else
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
#endif
if (0 == size) return NULL;
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return malloc_zone_malloc((malloc_zone_t *)allocator, size);
}
#endif
Expand All @@ -619,15 +619,15 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
}

#if defined(DEBUG) && TARGET_OS_MAC
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
}
#else
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
#endif
if (NULL == ptr && 0 < newsize) {
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return malloc_zone_malloc((malloc_zone_t *)allocator, newsize);
}
#endif
Expand All @@ -640,7 +640,7 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
}
if (NULL != ptr && 0 == newsize) {
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
#if defined(DEBUG)
size_t size = malloc_size(ptr);
if (size) memset(ptr, 0xCC, size);
Expand All @@ -657,7 +657,7 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
}
if (NULL == ptr && 0 == newsize) return NULL;
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return malloc_zone_realloc((malloc_zone_t *)allocator, ptr, newsize);
}
#endif
Expand All @@ -675,14 +675,14 @@ void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr) {
}

#if defined(DEBUG) && TARGET_OS_MAC
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
}
#else
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
#endif
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
#if defined(DEBUG)
size_t size = malloc_size(ptr);
if (size) memset(ptr, 0xCC, size);
Expand All @@ -704,15 +704,15 @@ CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex siz
allocator = __CFGetDefaultAllocator();
}

#if defined(DEBUG) && TARGET_OS_MAC
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
#if TARGET_OS_MAC
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
}
#else
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
#endif
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return malloc_good_size(size);
}
#endif
Expand All @@ -729,16 +729,16 @@ void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context
allocator = __CFGetDefaultAllocator();
}

#if defined(DEBUG) && TARGET_OS_MAC
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
#if TARGET_OS_MAC
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
}
#else
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
#endif
CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
#if TARGET_OS_MAC
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
return;
}
#endif
Expand Down Expand Up @@ -808,7 +808,7 @@ struct __CFNull {

DECLARE_STATIC_CLASS_REF(NSNull);

static struct __CFNull _CF_CONSTANT_OBJECT_BACKING __kCFNull = {
struct __CFNull _CF_CONSTANT_OBJECT_BACKING __kCFNull = {
INIT_CFRUNTIME_BASE_WITH_CLASS(NSNull, _kCFRuntimeIDCFNull)
};
const CFNullRef kCFNull = &__kCFNull;
Expand Down Expand Up @@ -853,7 +853,8 @@ void _CFRuntimeSetCFMPresent(void *addr) {
/* Keep this assembly at the bottom of the source file! */


extern void __HALT() {
extern void __HALT(void);
void __HALT() {
__builtin_trap();
}

Expand Down
22 changes: 22 additions & 0 deletions CoreFoundation/Base.subproj/CFBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
#if !defined(__COREFOUNDATION_CFBASE__)
#define __COREFOUNDATION_CFBASE__ 1

#if __has_include(<CoreFoundation/TargetConditionals.h>)
#include <CoreFoundation/TargetConditionals.h>
#else
#include <TargetConditionals.h>
#endif

#include <CoreFoundation/CFAvailability.h>

#if (defined(__CYGWIN32__) || defined(_WIN32)) && !defined(__WIN32__)
Expand Down Expand Up @@ -694,6 +699,23 @@ CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE;
#define _CF_CONSTANT_OBJECT_STRONG_RC ((uintptr_t)_CF_SWIFT_RC_PINNED_FLAG)
#endif

#if __has_include(<ptrauth.h>)
#include <ptrauth.h>
#endif

#ifndef __ptrauth_objc_isa_pointer
#define __ptrauth_objc_isa_pointer
#endif

#define ISA_PTRAUTH_DISCRIMINATOR 0x6AE1
#if defined(__ptrauth_objc_isa_uintptr)
#define __ptrauth_cf_objc_isa_pointer __ptrauth_objc_isa_uintptr
#elif defined(__arm64e__) && defined(__PTRAUTH_INTRINSICS__) && __has_feature(ptrauth_objc_isa)
#define __ptrauth_cf_objc_isa_pointer __ptrauth_restricted_intptr(ptrauth_key_objc_isa_pointer, 1, ISA_PTRAUTH_DISCRIMINATOR)
#else
#define __ptrauth_cf_objc_isa_pointer
#endif

CF_EXTERN_C_END

#endif /* ! __COREFOUNDATION_CFBASE__ */
Expand Down
7 changes: 7 additions & 0 deletions CoreFoundation/Base.subproj/CFFileUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc,
}
}

#if TARGET_OS_MAC
struct dirent buffer;
#endif
struct dirent *dp;
int err;

Expand All @@ -387,7 +390,11 @@ CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc,
}
files = CFArrayCreateMutable(alloc, 0, & kCFTypeArrayCallBacks);

#if TARGET_OS_MAC
while((0 == readdir_r(dirp, &buffer, &dp)) && dp) {
#else
while((dp = readdir(dirp))) {
#endif
CFURLRef fileURL;
unsigned namelen = strlen(dp->d_name);

Expand Down
Loading

0 comments on commit 512e412

Please sign in to comment.