Skip to content

Commit 5e15ebc

Browse files
authored
Merge pull request #1702 from alblue/swift-4.2-branch
2 parents 0a26113 + e56ddfb commit 5e15ebc

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

CoreFoundation/Base.subproj/CFInternal.h

+11
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@
8282
#define _CF_RELEASES_ARGUMENT_OBJ
8383
#endif
8484

85+
#if DEPLOYMENT_TARGET_WINDOWS
86+
// No C99 support
87+
#define _CF_RESTRICT
88+
#else
89+
#if defined(__cplusplus)
90+
#define _CF_RESTRICT __restrict__
91+
#else
92+
#define _CF_RESTRICT restrict
93+
#endif
94+
#endif
95+
8596
CF_EXTERN_C_BEGIN
8697

8798
#include <CoreFoundation/CFBase.h>

CoreFoundation/Base.subproj/CFPlatform.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ void _CFThreadSpecificSet(_CFThreadSpecificKey key, CFTypeRef _Nullable value) {
13371337
}
13381338
}
13391339

1340-
_CFThreadRef _CFThreadCreate(const _CFThreadAttributes attrs, void *_Nullable (* _Nonnull startfn)(void *_Nullable), void *restrict _Nullable context) {
1340+
_CFThreadRef _CFThreadCreate(const _CFThreadAttributes attrs, void *_Nullable (* _Nonnull startfn)(void *_Nullable), void *_CF_RESTRICT _Nullable context) {
13411341
pthread_t thread;
13421342
pthread_create(&thread, &attrs, startfn, context);
13431343
return thread;

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

+4
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ CF_EXPORT _CFThreadSpecificKey _CFThreadSpecificKeyCreate(void);
315315
typedef pthread_attr_t _CFThreadAttributes;
316316
typedef pthread_t _CFThreadRef;
317317

318+
#if defined(__cplusplus)
319+
CF_EXPORT _CFThreadRef _CFThreadCreate(const _CFThreadAttributes attrs, void *_Nullable (* _Nonnull startfn)(void *_Nullable), void *__restrict__ _Nullable context);
320+
#else
318321
CF_EXPORT _CFThreadRef _CFThreadCreate(const _CFThreadAttributes attrs, void *_Nullable (* _Nonnull startfn)(void *_Nullable), void *restrict _Nullable context);
322+
#endif
319323

320324
CF_CROSS_PLATFORM_EXPORT int _CFThreadSetName(pthread_t thread, const char *_Nonnull name);
321325
CF_CROSS_PLATFORM_EXPORT int _CFThreadGetName(char *_Nonnull buf, int length);

CoreFoundation/Collections.subproj/CFStorage.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#endif
3838

3939
#if DEPLOYMENT_TARGET_WINDOWS
40-
// No C99 support
41-
#define restrict
4240

4341
// Replace bzero
4442
#define bzero(dst, size) ZeroMemory(dst, size)
@@ -244,7 +242,7 @@ static inline void __CFStorageSetChild(CFStorageNode *parentNode, CFIndex childI
244242
*((void **)&parentNode->info.notLeaf.child[childIndex]) = newChild;
245243
}
246244

247-
static inline void __CFStorageGetChildren(const CFStorageNode *parent, CFStorageNode ** restrict resultArray, bool shouldRetain, bool shouldFreeze) {
245+
static inline void __CFStorageGetChildren(const CFStorageNode *parent, CFStorageNode ** _CF_RESTRICT resultArray, bool shouldRetain, bool shouldFreeze) {
248246
ASSERT(! parent->isLeaf);
249247
CFIndex i;
250248
for (i=0; i < 3; i++) {
@@ -272,7 +270,7 @@ CF_INLINE void __CFStorageSetCache(CFStorageRef storage, CFStorageNode *node, CF
272270
/* Gets the location for the specified absolute loc from the cached info.
273271
Returns NULL if the location is not in the cache.
274272
*/
275-
CF_INLINE uint8_t *__CFStorageGetFromCache(CFStorageRef storage, CFIndex loc, CFRange * restrict validConsecutiveValueRange, bool requireUnfrozenNode) {
273+
CF_INLINE uint8_t *__CFStorageGetFromCache(CFStorageRef storage, CFIndex loc, CFRange * _CF_RESTRICT validConsecutiveValueRange, bool requireUnfrozenNode) {
276274
CFStorageNode * const cachedNode = storage->cacheNode; /* It's important we read from this field no more than once, for thread safety with other concurrent reads; that is why the field is marked volatile. */
277275
if (! cachedNode) return NULL; /* No cache */
278276

@@ -307,7 +305,7 @@ CF_INLINE uint8_t *__CFStorageGetFromCache(CFStorageRef storage, CFIndex loc, CF
307305
relativeByteNum (not optional, for performance reasons) returns the relative byte number of the specified byte in the child.
308306
Don't call with leaf nodes!
309307
*/
310-
CF_INLINE CFStorageNode *__CFStorageFindChild(const CFStorageNode * restrict node, CFIndex byteNum, bool forInsertionOrDeletion, CFIndex * restrict childNum, CFIndex * restrict relativeByteNum) {
308+
CF_INLINE CFStorageNode *__CFStorageFindChild(const CFStorageNode * _CF_RESTRICT node, CFIndex byteNum, bool forInsertionOrDeletion, CFIndex * _CF_RESTRICT childNum, CFIndex * _CF_RESTRICT relativeByteNum) {
311309
if (forInsertionOrDeletion) byteNum--; /* If for insertion, we do <= checks, not <, so this accomplishes the same thing */
312310
CFStorageNode *result;
313311
result = node->info.notLeaf.child[0];

CoreFoundation/Parsing.subproj/CFXMLInterface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ typedef void* _CFXMLEntityPtr;
137137
typedef void* _CFXMLDTDPtr;
138138
typedef void* _CFXMLDTDNodePtr;
139139

140-
_CFXMLNodePtr _CFXMLNewNode(_CFXMLNamespacePtr _Nullable namespace, const char* name);
140+
_CFXMLNodePtr _CFXMLNewNode(_CFXMLNamespacePtr _Nullable name_space, const char* name);
141141
_CFXMLNodePtr _CFXMLCopyNode(_CFXMLNodePtr node, bool recursive);
142142

143143
_CFXMLDocPtr _CFXMLNewDoc(const unsigned char* version);

Foundation/NSCFString.swift

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ internal class _NSCFString : NSMutableString {
5757
}
5858
}
5959

60+
@usableFromInline
6061
internal final class _NSCFConstantString : _NSCFString {
6162
internal var _ptr : UnsafePointer<UInt8> {
6263
// FIXME: Split expression as a work-around for slow type

0 commit comments

Comments
 (0)