Skip to content

Commit 324a1cf

Browse files
committed
Fix endianness issues in CFString
1 parent a7fb03c commit 324a1cf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

CoreFoundation/String.subproj/CFString.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ struct __CFConstStr {
165165
uint8_t _pad[4];
166166
} _base;
167167
uint8_t *_ptr;
168-
uint32_t _length;
168+
signed long _length;
169169
};
170170

171171
#if DEPLOYMENT_TARGET_LINUX
@@ -174,10 +174,17 @@ struct __CFConstStr {
174174
#define CONST_STRING_LITERAL_SECTION
175175
#endif
176176

177+
#if __BIG_ENDIAN__
178+
#define CFSTR(cStr) ({ \
179+
static struct __CFConstStr str CONST_STRING_LITERAL_SECTION = {{(uintptr_t)&__CFConstantStringClassReference, _CF_CONSTANT_OBJECT_STRONG_RC, 0, {0x00, 0x00, 0x07, 0xc8}, {0x00, 0x00, 0x00, 0x00}}, (uint8_t *)(cStr), sizeof(cStr) - 1}; \
180+
(CFStringRef)&str; \
181+
})
182+
#else
177183
#define CFSTR(cStr) ({ \
178184
static struct __CFConstStr str CONST_STRING_LITERAL_SECTION = {{(uintptr_t)&__CFConstantStringClassReference, _CF_CONSTANT_OBJECT_STRONG_RC, 0, {0xc8, 0x07, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00}}, (uint8_t *)(cStr), sizeof(cStr) - 1}; \
179185
(CFStringRef)&str; \
180186
})
187+
#endif
181188

182189
#else
183190

0 commit comments

Comments
 (0)