Skip to content

Commit 06f29bd

Browse files
committed
Adopt CFSTR() on non-Mac.
1 parent 7e09607 commit 06f29bd

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

CoreFoundation/Base.subproj/CFInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ CF_PRIVATE Boolean __CFProcessIsRestricted(void);
421421

422422
CF_EXPORT void * __CFConstantStringClassReferencePtr;
423423

424-
#if DEPLOYMENT_RUNTIME_SWIFT
424+
#if DEPLOYMENT_RUNTIME_SWIFT && TARGET_OS_MAC
425425

426426
#if DEPLOYMENT_TARGET_LINUX
427427
#define CONST_STRING_SECTION __attribute__((section(".cfstr.data")))

CoreFoundation/String.subproj/CFString.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,16 @@ since it is the default choice with Mac OS X developer tools.
152152
#endif
153153

154154
#if DEPLOYMENT_RUNTIME_SWIFT
155+
#if TARGET_OS_MAC
156+
#define _CF_CONSTANT_STRING_SWIFT_CLASS $s15SwiftFoundation19_NSCFConstantStringCN
157+
#else
158+
#define _CF_CONSTANT_STRING_SWIFT_CLASS $s10Foundation19_NSCFConstantStringCN
159+
#endif
155160

156-
#if TARGET_OS_MAC
157-
#define _CF_CONSTANT_STRING_SWIFT_CLASS $s15SwiftFoundation19_NSCFConstantStringCN
158-
#else
159-
#define _CF_CONSTANT_STRING_SWIFT_CLASS $s10Foundation19_NSCFConstantStringCN
161+
CF_EXPORT void *_CF_CONSTANT_STRING_SWIFT_CLASS[];
160162
#endif
161163

162-
CF_EXPORT void *_CF_CONSTANT_STRING_SWIFT_CLASS[];
164+
#if DEPLOYMENT_RUNTIME_SWIFT && TARGET_OS_MAC
163165

164166
struct __CFConstStr {
165167
struct {
@@ -175,20 +177,14 @@ struct __CFConstStr {
175177
#endif // defined(__LP64__) || defined(__LLP64__)
176178
};
177179

178-
#if TARGET_OS_LINUX
179-
#define CONST_STRING_LITERAL_SECTION __attribute__((section(".cfstrlit.data")))
180-
#else
181-
#define CONST_STRING_LITERAL_SECTION
182-
#endif // TARGET_OS_LINUX
183-
184180
#if __BIG_ENDIAN__
185181
#define CFSTR(cStr) ({ \
186-
static struct __CFConstStr str CONST_STRING_LITERAL_SECTION = {{(uintptr_t)&_CF_CONSTANT_STRING_SWIFT_CLASS, _CF_CONSTANT_OBJECT_STRONG_RC, 0x00000000C8070000}, (uint8_t *)(cStr), sizeof(cStr) - 1}; \
182+
static struct __CFConstStr str = {{(uintptr_t)&_CF_CONSTANT_STRING_SWIFT_CLASS, _CF_CONSTANT_OBJECT_STRONG_RC, 0x00000000C8070000}, (uint8_t *)(cStr), sizeof(cStr) - 1}; \
187183
(CFStringRef)&str; \
188184
})
189185
#else // Little endian:
190186
#define CFSTR(cStr) ({ \
191-
static struct __CFConstStr str CONST_STRING_LITERAL_SECTION = {{(uintptr_t)&_CF_CONSTANT_STRING_SWIFT_CLASS, _CF_CONSTANT_OBJECT_STRONG_RC, 0x07C8}, (uint8_t *)(cStr), sizeof(cStr) - 1}; \
187+
static struct __CFConstStr str = {{(uintptr_t)&_CF_CONSTANT_STRING_SWIFT_CLASS, _CF_CONSTANT_OBJECT_STRONG_RC, 0x07C8}, (uint8_t *)(cStr), sizeof(cStr) - 1}; \
192188
(CFStringRef)&str; \
193189
})
194190
#endif // __BIG_ENDIAN__

0 commit comments

Comments
 (0)