Skip to content

Commit 60b7bd2

Browse files
authored
Revert "Import CoreFoundation sources from High Sierra"
1 parent 5d04589 commit 60b7bd2

File tree

170 files changed

+4778
-6517
lines changed

Some content is hidden

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

170 files changed

+4778
-6517
lines changed

CoreFoundation/AppServices.subproj/CFNotificationCenter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFNotificationCenter.h
2-
Copyright (c) 1998-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 1998-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

CoreFoundation/AppServices.subproj/CFUserNotification.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFUserNotification.c
2-
Copyright (c) 2000-2017, Apple Inc. All rights reserved.
2+
Copyright (c) 2000-2016, Apple Inc. All rights reserved.
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

CoreFoundation/AppServices.subproj/CFUserNotification.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFUserNotification.h
2-
Copyright (c) 2000-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 2000-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -170,7 +170,7 @@ CF_EXPORT
170170
const CFStringRef kCFUserNotificationTextFieldValuesKey;
171171

172172
CF_EXPORT
173-
const CFStringRef kCFUserNotificationPopUpSelectionKey API_AVAILABLE(macos(10.3)) API_UNAVAILABLE(ios, watchos, tvos);
173+
const CFStringRef kCFUserNotificationPopUpSelectionKey CF_AVAILABLE(10_3, NA);
174174

175175
#if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
176176
CF_EXPORT

CoreFoundation/Base.subproj/CFAvailability.h

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFAvailability.h
2-
Copyright (c) 2013-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 2013-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -10,23 +10,23 @@
1010
#if !defined(__COREFOUNDATION_CFAVAILABILITY__)
1111
#define __COREFOUNDATION_CFAVAILABILITY__ 1
1212

13-
#if __has_include(<CoreFoundation/TargetConditionals.h>)
13+
#if DEPLOYMENT_RUNTIME_SWIFT
1414
#include <CoreFoundation/TargetConditionals.h>
15-
#elif __has_include(<TargetConditionals.h>)
16-
#include <TargetConditionals.h>
1715
#else
18-
#error Missing header TargetConditionals.h
16+
#include <TargetConditionals.h>
1917
#endif
2018

21-
#if __has_include(<Availability.h>) && __has_include(<os/Availability.h>) && __has_include(<AvailabilityMacros.h>)
19+
#if DEPLOYMENT_RUNTIME_SWIFT
20+
#define API_AVAILABLE(...)
21+
#define API_DEPRECATED(...)
22+
#else
23+
#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32)
2224
#include <Availability.h>
2325
#include <os/availability.h>
26+
2427
// Even if unused, these must remain here for compatibility, because projects rely on them being included.
2528
#include <AvailabilityMacros.h>
26-
#else
27-
#define API_AVAILABLE(...)
28-
#define API_DEPRECATED(...)
29-
#define API_UNAVAILABLE(...)
29+
#endif
3030
#endif
3131

3232
#ifndef __has_feature
@@ -112,22 +112,14 @@
112112
#endif
113113

114114
// Enums and Options
115-
#if __has_attribute(enum_extensibility)
116-
#define __CF_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open)))
117-
#define __CF_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open)))
118-
#else
119-
#define __CF_ENUM_ATTRIBUTES
120-
#define __CF_OPTIONS_ATTRIBUTES
121-
#endif
122-
123115
#define __CF_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME
124116
#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
125-
#define __CF_NAMED_ENUM(_type, _name) enum __CF_ENUM_ATTRIBUTES _name : _type _name; enum _name : _type
126-
#define __CF_ANON_ENUM(_type) enum __CF_ENUM_ATTRIBUTES : _type
117+
#define __CF_NAMED_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
118+
#define __CF_ANON_ENUM(_type) enum : _type
127119
#if (__cplusplus)
128-
#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _type
120+
#define CF_OPTIONS(_type, _name) _type _name; enum : _type
129121
#else
130-
#define CF_OPTIONS(_type, _name) enum __CF_OPTIONS_ATTRIBUTES _name : _type _name; enum _name : _type
122+
#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
131123
#endif
132124
#else
133125
#define __CF_NAMED_ENUM(_type, _name) _type _name; enum
@@ -164,40 +156,11 @@ CF_ENUM(CFIndex) {
164156
#if DEPLOYMENT_RUNTIME_SWIFT
165157
#define CF_STRING_ENUM
166158
#define CF_EXTENSIBLE_STRING_ENUM
167-
168-
#define CF_TYPED_ENUM
169-
#define CF_TYPED_EXTENSIBLE_ENUM
170159
#else
171160
#define CF_STRING_ENUM _CF_TYPED_ENUM
172161
#define CF_EXTENSIBLE_STRING_ENUM _CF_TYPED_EXTENSIBLE_ENUM
173-
174-
#define CF_TYPED_ENUM _CF_TYPED_ENUM
175-
#define CF_TYPED_EXTENSIBLE_ENUM _CF_TYPED_EXTENSIBLE_ENUM
176-
#endif
177-
178-
#define __CF_ERROR_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME
179-
#if ((__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))) && __has_attribute(ns_error_domain)
180-
#define __CF_NAMED_ERROR_ENUM(_domain, _name) enum __attribute__((ns_error_domain(_domain))) _name : CFIndex _name; enum _name : CFIndex
181-
#define __CF_ANON_ERROR_ENUM(_domain) enum __attribute__((ns_error_domain(_domain))) : CFIndex
182-
#else
183-
#define __CF_NAMED_ERROR_ENUM(_domain, _name) __CF_NAMED_ENUM(CFIndex, _name)
184-
#define __CF_ANON_ERROR_ENUM(_domain) __CF_ANON_ENUM(CFIndex)
185162
#endif
186163

187-
/* CF_ERROR_ENUM supports the use of one or two arguments. The first argument is always the domain specifier for the enum. The second argument is an optional name of the typedef for the macro. When specifying a name for of the typedef, you must precede the macro with 'typedef' like so:
188-
189-
typedef CF_ERROR_ENUM(kCFSomeErrorDomain, SomeErrorCodes) {
190-
...
191-
};
192-
193-
If you do not specify a typedef name, do not use 'typedef', like so:
194-
195-
CF_ERROR_ENUM(kCFSomeErrorDomain) {
196-
...
197-
};
198-
*/
199-
#define CF_ERROR_ENUM(...) __CF_ERROR_ENUM_GET_MACRO(__VA_ARGS__, __CF_NAMED_ERROR_ENUM, __CF_ANON_ERROR_ENUM)(__VA_ARGS__)
200-
201164
// Extension availability macros
202165
#define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg)
203166
#define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg)

CoreFoundation/Base.subproj/CFBase.c

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFBase.c
2-
Copyright (c) 1998-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 1998-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -533,7 +533,12 @@ static CFAllocatorRef __CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorC
533533
if (__CFOASafe) __CFSetLastAllocationEventName(memory, "CFAllocator");
534534
}
535535
memset(memory, 0, sizeof(CFRuntimeBase));
536-
__CFRuntimeSetRC(memory, 1);
536+
#if __LP64__
537+
memory->_base._rc = 1;
538+
#else
539+
memory->_base._cfinfo[CF_RC_BITS] = 1;
540+
#endif
541+
memory->_base._cfinfo[CF_INFO_BITS] = 0;
537542
_CFAllocatorSetInstanceTypeIDAndIsa(memory);
538543
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI
539544
memory->size = __CFAllocatorCustomSize;
@@ -753,41 +758,6 @@ void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context
753758
// -------- -------- -------- -------- -------- -------- -------- --------
754759

755760

756-
757-
static void __CFReallocationFailed(void *ptr, CFStringRef reason, void (^reallocationFailureHandler)(void *original, _Bool *outRecovered)) {
758-
_Bool recovered = false;
759-
if (reallocationFailureHandler) {
760-
reallocationFailureHandler(ptr, &recovered);
761-
}
762-
763-
if (!recovered) {
764-
CRSetCrashLogMessage("Failed to grow buffer");
765-
HALT;
766-
}
767-
}
768-
769-
770-
void *__CFSafelyReallocate(void *destination, size_t newCapacity, void (^reallocationFailureHandler)(void *original, _Bool *outRecovered)) {
771-
void *const reallocated = realloc(destination, newCapacity);
772-
if (__builtin_expect(reallocated == NULL, false)) {
773-
__CFReallocationFailed(destination, CFSTR("realloc"), reallocationFailureHandler);
774-
}
775-
return reallocated;
776-
}
777-
778-
779-
void *__CFSafelyReallocateWithAllocator(CFAllocatorRef allocator, void *destination, size_t newCapacity, CFOptionFlags options, void (^reallocationFailureHandler)(void *original, _Bool *outRecovered)) {
780-
void *reallocated = CFAllocatorReallocate(allocator, destination, newCapacity, options);
781-
// NOTE: important difference in behavior between realloc vs CFAllocateReallocate NULL+0 -> NULL for allocators!
782-
if (__builtin_expect(reallocated == NULL, false) && !(destination == NULL && newCapacity == 0)) {
783-
__CFReallocationFailed(destination, CFSTR("realloc"), reallocationFailureHandler);
784-
}
785-
return reallocated;
786-
}
787-
788-
789-
790-
791761
CFRange __CFRangeMake(CFIndex loc, CFIndex len) {
792762
CFRange range;
793763
range.location = loc;

CoreFoundation/Base.subproj/CFBase.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFBase.h
2-
Copyright (c) 1998-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 1998-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -66,10 +66,6 @@
6666
#if defined(__GNUC__) || TARGET_OS_WIN32
6767
#include <stdint.h>
6868
#include <stdbool.h>
69-
#endif
70-
71-
#if __BLOCKS__ && ((TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
72-
#include <Block.h>
7369
#endif
7470

7571
#if ((TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) && !DEPLOYMENT_RUNTIME_SWIFT
@@ -139,9 +135,11 @@
139135
#endif
140136
#endif
141137
#else
142-
143-
#define CF_EXPORT extern
144-
138+
#if defined(__cplusplus)
139+
#define CF_EXPORT extern "C"
140+
#else
141+
#define CF_EXPORT extern
142+
#endif
145143
#endif
146144

147145
CF_EXTERN_C_BEGIN
@@ -656,7 +654,7 @@ void CFRelease(CFTypeRef cf);
656654
#if DEPLOYMENT_RUNTIME_SWIFT
657655
#else
658656
CF_EXPORT
659-
CFTypeRef CFAutorelease(CFTypeRef CF_RELEASES_ARGUMENT arg) API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0));
657+
CFTypeRef CFAutorelease(CFTypeRef CF_RELEASES_ARGUMENT arg) CF_AVAILABLE(10_9, 7_0);
660658

661659
CF_EXPORT
662660
CFIndex CFGetRetainCount(CFTypeRef cf);

CoreFoundation/Base.subproj/CFByteOrder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFByteOrder.h
2-
Copyright (c) 1995-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 1995-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

CoreFoundation/Base.subproj/CFFileUtilities.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* CFFileUtilities.c
2-
Copyright (c) 1999-2017, Apple Inc. and the Swift project authors
2+
Copyright (c) 1999-2016, Apple Inc. and the Swift project authors
33
4-
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
4+
Portions Copyright (c) 2014-2016 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
See http://swift.org/LICENSE.txt for license information
77
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -594,10 +594,6 @@ CF_PRIVATE SInt32 _CFGetFileProperties(CFAllocatorRef alloc, CFURLRef pathURL, B
594594
return _CFGetPathProperties(alloc, path, exists, posixMode, size, modTime, ownerID, dirContents);
595595
}
596596

597-
CF_PRIVATE bool _CFURLExists(CFURLRef url) {
598-
Boolean exists;
599-
return url && (0 == _CFGetFileProperties(kCFAllocatorSystemDefault, url, &exists, NULL, NULL, NULL, NULL, NULL)) && exists;
600-
}
601597

602598
#if DEPLOYMENT_TARGET_WINDOWS
603599
#define WINDOWS_PATH_SEMANTICS
@@ -1096,22 +1092,15 @@ CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean appendSla
10961092
for (CFIndex i = 0; i < CFArrayGetCount(stuffToPrefix); i++) {
10971093
CFStringRef onePrefix = CFArrayGetValueAtIndex(stuffToPrefix, i);
10981094
// Note: CFStringGetBytes does not null-terminate - we will do that below
1099-
CFIndex usedBufLen = 0;
1100-
startAt += CFStringGetBytes(onePrefix, CFRangeMake(0, CFStringGetLength(onePrefix)), CFStringFileSystemEncoding(), 0, false, (UInt8 *)fullPathToFile + startAt, sizeof(fullPathToFile) - startAt, &usedBufLen);
1101-
if (startAt > 0) { // Add a / if the string did not have one
1102-
// In some cases, startAt and usedBufLen differ (e.g. the num of bytes returned is less than the number written to the buffer).
1103-
if (startAt < usedBufLen) {
1104-
if (fullPathToFile[usedBufLen - 1] != (char)_CFGetSlash()) {
1105-
fullPathToFile[usedBufLen] = (char)_CFGetSlash();
1106-
startAt += (usedBufLen - startAt) + 1;
1107-
}
1108-
} else {
1109-
if (fullPathToFile[startAt - 1] != (char)_CFGetSlash()) {
1110-
fullPathToFile[startAt++] = (char)_CFGetSlash();
1111-
}
1095+
startAt += CFStringGetBytes(onePrefix, CFRangeMake(0, CFStringGetLength(onePrefix)), CFStringFileSystemEncoding(), 0, false, (UInt8 *)fullPathToFile + startAt, sizeof(fullPathToFile) - startAt, NULL);
1096+
if (startAt > 0) {
1097+
// Add a / if the string did not have one
1098+
if (fullPathToFile[startAt - 1] != (char)_CFGetSlash()) {
1099+
fullPathToFile[startAt++] = (char)_CFGetSlash();
11121100
}
11131101
}
11141102
}
1103+
11151104
fullPathToFile[startAt] = 0;
11161105
}
11171106

@@ -1178,7 +1167,6 @@ CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean appendSla
11781167
#endif
11791168
}
11801169

1181-
11821170
#if DEPLOYMENT_RUNTIME_SWIFT
11831171

11841172
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -1357,4 +1345,3 @@ CF_PRIVATE CFArrayRef _CFCreateCFArrayByTokenizingString(const char *values, cha
13571345
}
13581346

13591347
#endif
1360-

0 commit comments

Comments
 (0)