Skip to content

Commit 512e412

Browse files
authored
Merge pull request #3058 from millenomi/pr-monterey-merge
The Monterey Merge
2 parents 8834372 + 6634ee3 commit 512e412

File tree

95 files changed

+4101
-1401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+4101
-1401
lines changed

CoreFoundation/AppServices.subproj/CFUserNotification.c

+9
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ static void _CFUserNotificationMachPortCallBack(CFMachPortRef port, void *m, CFI
299299
}
300300

301301
SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags) {
302+
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
302303
CHECK_FOR_FORK();
303304
SInt32 retval = ERR_SUCCESS;
304305
mach_msg_timeout_t msgtime = (timeout > 0.0 && 1000.0 * timeout < INT_MAX) ? (mach_msg_timeout_t)(1000.0 * timeout) : 0;
@@ -343,11 +344,15 @@ SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification,
343344
}
344345

345346
CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx) {
347+
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
346348
CHECK_FOR_FORK();
347349
CFStringRef retval = NULL;
348350
CFTypeRef value = NULL;
349351
if (userNotification && userNotification->_responseDictionary) {
350352
value = CFDictionaryGetValue(userNotification->_responseDictionary, key);
353+
if (value == NULL) {
354+
return NULL;
355+
}
351356
if (CFGetTypeID(value) == CFStringGetTypeID()) {
352357
if (0 == idx) retval = (CFStringRef)value;
353358
} else if (CFGetTypeID(value) == CFArrayGetTypeID()) {
@@ -358,11 +363,13 @@ CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotific
358363
}
359364

360365
CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification) {
366+
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
361367
CHECK_FOR_FORK();
362368
return userNotification ? userNotification->_responseDictionary : NULL;
363369
}
364370

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

375382
SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification) {
383+
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
376384
CHECK_FOR_FORK();
377385
SInt32 retval = ERR_SUCCESS;
378386
if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
@@ -383,6 +391,7 @@ SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification) {
383391
}
384392

385393
CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order) {
394+
CF_ASSERT_TYPE_OR_NULL(_kCFRuntimeIDCFUserNotification, userNotification);
386395
CHECK_FOR_FORK();
387396
CFRunLoopSourceRef source = NULL;
388397
if (userNotification && callout && !userNotification->_machPort && MACH_PORT_NULL != userNotification->_replyPort) {

CoreFoundation/Base.subproj/CFAvailability.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@
135135
#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)))
136136

137137
#if __CF_ENUM_FIXED_IS_AVAILABLE
138-
#define __CF_NAMED_ENUM(_type, _name) int __CF_ENUM_ ## _name; enum __CF_ENUM_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
138+
#define __CF_NAMED_ENUM(_type, _name) enum __CF_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
139139
#define __CF_ANON_ENUM(_type) enum __CF_ENUM_ATTRIBUTES : _type
140-
#define CF_CLOSED_ENUM(_type, _name) int __CF_ENUM_ ## _name; enum __CF_CLOSED_ENUM_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
140+
#define CF_CLOSED_ENUM(_type, _name) enum __CF_CLOSED_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
141141
#if (__cplusplus)
142142
#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _type
143143
#else
144-
#define CF_OPTIONS(_type, _name) int __CF_OPTIONS_ ## _name; enum __CF_OPTIONS_ATTRIBUTES _name : _type; typedef enum _name _name; enum _name : _type
144+
#define CF_OPTIONS(_type, _name) enum __CF_OPTIONS_ATTRIBUTES _name : _type _name; enum _name : _type
145145
#endif
146146
#else
147147
#define __CF_NAMED_ENUM(_type, _name) _type _name; enum

CoreFoundation/Base.subproj/CFBase.c

+20-19
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct __CFAllocator {
5959
};
6060

6161
CF_INLINE uintptr_t __CFISAForCFAllocator(void) {
62-
return __CFRuntimeObjCClassTable[_kCFRuntimeIDCFAllocator];
62+
return _GetCFRuntimeObjcClassAtIndex(_kCFRuntimeIDCFAllocator);
6363
}
6464

6565
CF_INLINE CFAllocatorRetainCallBack __CFAllocatorGetRetainFunction(const CFAllocatorContext *context) {
@@ -478,7 +478,7 @@ void CFAllocatorSetDefault(CFAllocatorRef allocator) {
478478
}
479479
#endif
480480
#if TARGET_OS_MAC
481-
if (allocator && allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
481+
if (allocator && _CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
482482
return; // require allocator to this function to be an allocator
483483
}
484484
#endif
@@ -505,7 +505,7 @@ static CFAllocatorRef __CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorC
505505
CFAllocatorAllocateCallBack allocateFunc;
506506
void *retainedInfo;
507507
#if TARGET_OS_MAC
508-
if (allocator && kCFAllocatorUseContext != allocator && allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
508+
if (allocator && kCFAllocatorUseContext != allocator && _CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
509509
return NULL; // require allocator to this function to be an allocator
510510
}
511511
#endif
@@ -588,15 +588,15 @@ void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags
588588
}
589589

590590
#if defined(DEBUG) && TARGET_OS_MAC
591-
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
591+
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
592592
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
593593
}
594594
#else
595595
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
596596
#endif
597597
if (0 == size) return NULL;
598598
#if TARGET_OS_MAC
599-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
599+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
600600
return malloc_zone_malloc((malloc_zone_t *)allocator, size);
601601
}
602602
#endif
@@ -619,15 +619,15 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
619619
}
620620

621621
#if defined(DEBUG) && TARGET_OS_MAC
622-
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
622+
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
623623
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
624624
}
625625
#else
626626
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
627627
#endif
628628
if (NULL == ptr && 0 < newsize) {
629629
#if TARGET_OS_MAC
630-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
630+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
631631
return malloc_zone_malloc((malloc_zone_t *)allocator, newsize);
632632
}
633633
#endif
@@ -640,7 +640,7 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
640640
}
641641
if (NULL != ptr && 0 == newsize) {
642642
#if TARGET_OS_MAC
643-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
643+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
644644
#if defined(DEBUG)
645645
size_t size = malloc_size(ptr);
646646
if (size) memset(ptr, 0xCC, size);
@@ -657,7 +657,7 @@ void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize
657657
}
658658
if (NULL == ptr && 0 == newsize) return NULL;
659659
#if TARGET_OS_MAC
660-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
660+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
661661
return malloc_zone_realloc((malloc_zone_t *)allocator, ptr, newsize);
662662
}
663663
#endif
@@ -675,14 +675,14 @@ void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr) {
675675
}
676676

677677
#if defined(DEBUG) && TARGET_OS_MAC
678-
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
678+
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
679679
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
680680
}
681681
#else
682682
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
683683
#endif
684684
#if TARGET_OS_MAC
685-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
685+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
686686
#if defined(DEBUG)
687687
size_t size = malloc_size(ptr);
688688
if (size) memset(ptr, 0xCC, size);
@@ -704,15 +704,15 @@ CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex siz
704704
allocator = __CFGetDefaultAllocator();
705705
}
706706

707-
#if defined(DEBUG) && TARGET_OS_MAC
708-
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
707+
#if TARGET_OS_MAC
708+
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
709709
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
710710
}
711711
#else
712712
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
713713
#endif
714714
#if TARGET_OS_MAC
715-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
715+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
716716
return malloc_good_size(size);
717717
}
718718
#endif
@@ -729,16 +729,16 @@ void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context
729729
allocator = __CFGetDefaultAllocator();
730730
}
731731

732-
#if defined(DEBUG) && TARGET_OS_MAC
733-
if (allocator->_base._cfisa == __CFISAForCFAllocator()) {
732+
#if TARGET_OS_MAC
733+
if (_CFTypeGetClass(allocator) == __CFISAForCFAllocator()) {
734734
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
735735
}
736736
#else
737737
__CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator);
738738
#endif
739739
CFAssert1(0 == context->version, __kCFLogAssertion, "%s(): context version not initialized to 0", __PRETTY_FUNCTION__);
740740
#if TARGET_OS_MAC
741-
if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t *
741+
if (_CFTypeGetClass(allocator) != __CFISAForCFAllocator()) { // malloc_zone_t *
742742
return;
743743
}
744744
#endif
@@ -808,7 +808,7 @@ struct __CFNull {
808808

809809
DECLARE_STATIC_CLASS_REF(NSNull);
810810

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

855855

856-
extern void __HALT() {
856+
extern void __HALT(void);
857+
void __HALT() {
857858
__builtin_trap();
858859
}
859860

CoreFoundation/Base.subproj/CFBase.h

+22
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
#if !defined(__COREFOUNDATION_CFBASE__)
1111
#define __COREFOUNDATION_CFBASE__ 1
1212

13+
#if __has_include(<CoreFoundation/TargetConditionals.h>)
1314
#include <CoreFoundation/TargetConditionals.h>
15+
#else
16+
#include <TargetConditionals.h>
17+
#endif
18+
1419
#include <CoreFoundation/CFAvailability.h>
1520

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

702+
#if __has_include(<ptrauth.h>)
703+
#include <ptrauth.h>
704+
#endif
705+
706+
#ifndef __ptrauth_objc_isa_pointer
707+
#define __ptrauth_objc_isa_pointer
708+
#endif
709+
710+
#define ISA_PTRAUTH_DISCRIMINATOR 0x6AE1
711+
#if defined(__ptrauth_objc_isa_uintptr)
712+
#define __ptrauth_cf_objc_isa_pointer __ptrauth_objc_isa_uintptr
713+
#elif defined(__arm64e__) && defined(__PTRAUTH_INTRINSICS__) && __has_feature(ptrauth_objc_isa)
714+
#define __ptrauth_cf_objc_isa_pointer __ptrauth_restricted_intptr(ptrauth_key_objc_isa_pointer, 1, ISA_PTRAUTH_DISCRIMINATOR)
715+
#else
716+
#define __ptrauth_cf_objc_isa_pointer
717+
#endif
718+
697719
CF_EXTERN_C_END
698720

699721
#endif /* ! __COREFOUNDATION_CFBASE__ */

CoreFoundation/Base.subproj/CFFileUtilities.c

+7
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc,
371371
}
372372
}
373373

374+
#if TARGET_OS_MAC
375+
struct dirent buffer;
376+
#endif
374377
struct dirent *dp;
375378
int err;
376379

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

393+
#if TARGET_OS_MAC
394+
while((0 == readdir_r(dirp, &buffer, &dp)) && dp) {
395+
#else
390396
while((dp = readdir(dirp))) {
397+
#endif
391398
CFURLRef fileURL;
392399
unsigned namelen = strlen(dp->d_name);
393400

0 commit comments

Comments
 (0)