Skip to content

Commit 66d42da

Browse files
committed
In response to review comments
1 parent aea9106 commit 66d42da

File tree

15 files changed

+24
-28
lines changed

15 files changed

+24
-28
lines changed

CoreFoundation/Base.subproj/CFBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ CF_EXPORT double kCFCoreFoundationVersionNumber;
449449
#endif
450450

451451
#ifdef __ANDROID__
452-
typedef uint16_t _swift_rc_type;
452+
typedef uint16_t _CFSwiftRCCount;
453453
#else
454-
typedef uint32_t _swift_rc_type;
454+
typedef uint32_t _CFSwiftRCCount;
455455
#endif
456456

457457
#if __LLP64__

CoreFoundation/Base.subproj/CFInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ extern void __CFGenericValidateType_(CFTypeRef cf, CFTypeID type, const char *fu
216216
#define __CFBitfield64GetValue(V, N1, N2) (((V) & __CFBitfield64Mask(N1, N2)) >> (N2))
217217
#define __CFBitfield64SetValue(V, N1, N2, X) ((V) = ((V) & ~__CFBitfield64Mask(N1, N2)) | ((((uint64_t)X) << (N2)) & __CFBitfield64Mask(N1, N2)))
218218

219-
#if __LP64__ || defined(__ANDROID__)
219+
#if __LP64__ || DEPLOYMENT_TARGET_ANDROID
220220
typedef uint64_t __CFInfoType;
221221
#define __CFInfoMask(N1, N2) __CFBitfield64Mask(N1, N2)
222222
#else

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ CF_EXPORT CFStringRef CFCopyFullUserName(void) {
297297
uid_t euid;
298298
__CFGetUGIDs(&euid, NULL);
299299
struct passwd *upwd = getpwuid(euid ? euid : getuid());
300-
#ifdef __ANDROID__
300+
#if DEPLOYMENT_TARGET_ANDROID
301301
#define pw_gecos pw_name
302302
#endif
303303
if (upwd && upwd->pw_gecos) {

CoreFoundation/Base.subproj/CFRuntime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ CFTypeRef _CFRuntimeCreateInstance(CFAllocatorRef allocator, CFTypeID typeID, CF
384384
CFRuntimeClass *cls = __CFRuntimeClassTable[typeID];
385385
size_t align = (cls->version & _kCFRuntimeRequiresAlignment) ? cls->requiredAlignment : 16;
386386

387+
#if DEPLOYMENT_TARGET_ANDROID
388+
CFRuntimeBase *memory = (CFRuntimeBase *)swift_allocObject(isa, size+4, align - 1);
389+
#else
387390
CFRuntimeBase *memory = (CFRuntimeBase *)swift_allocObject(isa, size, align - 1);
391+
#endif
388392

389393
// Zero the rest of the memory, starting at cfinfo
390394
memset(&memory->_cfinfoa, 0, size - (sizeof(memory->_cfisa) + sizeof(memory->_swift_strong_rc) + sizeof(memory->_swift_weak_rc)));

CoreFoundation/Base.subproj/CFRuntime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ CF_EXPORT void _CFRuntimeUnregisterClassWithTypeID(CFTypeID typeID);
193193
typedef struct __CFRuntimeBase {
194194
// This matches the isa and retain count storage in Swift
195195
uintptr_t _cfisa;
196-
_swift_rc_type _swift_strong_rc;
197-
_swift_rc_type _swift_weak_rc;
196+
_CFSwiftRCCount _swift_strong_rc;
197+
_CFSwiftRCCount _swift_weak_rc;
198198
// This is for CF's use, and must match _NSCFType layout
199199
_Atomic(uint64_t) _cfinfoa;
200200
} CFRuntimeBase;

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((n
403403
static inline int _direntNameLength(struct dirent *entry) {
404404
#ifdef _D_EXACT_NAMLEN // defined on Linux
405405
return _D_EXACT_NAMLEN(entry);
406-
#elseif defined(__ANDROID__)
406+
#elseif DEPLOYMENT_TARGET_ANDROID
407407
return strlen(entry->d_name);
408408
#else
409409
return entry->d_namlen;

CoreFoundation/PlugIn.subproj/CFBundle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ static CFBundleRef _CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL,
714714

715715
bundle->_url = newURL;
716716

717-
#if !DEPLOYMENT_RUNTIME_OBJC && !DEPLOYMENT_TARGET_WINDOWS && !defined(__ANDROID__)
717+
#if !DEPLOYMENT_RUNTIME_OBJC && !DEPLOYMENT_TARGET_WINDOWS && !DEPLOYMENT_TARGET_ANDROID
718718
bundle->_isFHSInstalledBundle = _CFBundleURLIsForFHSInstalledBundle(newURL);
719719
#endif
720720

CoreFoundation/PlugIn.subproj/CFBundle_Main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static CFBundleRef _CFBundleGetMainBundleAlreadyLocked(void) {
7979
CFStringRef str = NULL;
8080
CFURLRef executableURL = NULL, bundleURL = NULL;
8181
_initedMainBundle = true;
82-
#ifdef __ANDROID__
82+
#if DEPLOYMENT_TARGET_ANDROID
8383
const char *bundlePath = getenv("CFFIXED_USER_HOME") ?: getenv("TMPDIR") ?: "/data/local/tmp";
8484
CFStringRef bundleRef = CFStringCreateWithFileSystemRepresentation(kCFAllocatorNull, bundlePath);
8585
bundleURL = CFRetain(CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, bundleRef,

CoreFoundation/Preferences.subproj/CFPreferences.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static CFURLRef _CFPreferencesURLForStandardDomainWithSafetyLevel(CFStringRef do
440440
CFURLRef theURL = NULL;
441441
CFAllocatorRef prefAlloc = __CFPreferencesAllocator();
442442
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_WINDOWS
443-
#ifdef __ANDROID__
443+
#if DEPLOYMENT_TARGET_ANDROID
444444
CFURLRef prefDir = CFBundleCopyBundleURL(CFBundleGetMainBundle());
445445
#else
446446
CFURLRef prefDir = _preferencesDirectoryForUserHostSafetyLevel(userName, hostName, safeLevel);

CoreFoundation/String.subproj/CFString.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ since it is the default choice with Mac OS X developer tools.
155155
struct __CFConstStr {
156156
struct {
157157
uintptr_t _cfisa;
158-
_swift_rc_type _swift_strong_rc;
159-
_swift_rc_type _swift_weak_rc;
158+
_CFSwiftRCCount _swift_strong_rc;
159+
_CFSwiftRCCount _swift_weak_rc;
160160
uint64_t _cfinfoa;
161161
} _base;
162162
uint8_t *_ptr;

CoreFoundation/URL.subproj/CFURL.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include <unistd.h>
2626
#include <sys/stat.h>
2727
#include <sys/types.h>
28-
#if __has_include(<sys/syslog.h>)
29-
#include <sys/syslog.h>
30-
#elif __has_include(<syslog.h>)
28+
#if __has_include(<syslog.h>)
3129
#include <syslog.h>
30+
#else
31+
#include <sys/syslog.h>
3232
#endif
3333
#include <CoreFoundation/CFURLPriv.h>
3434
#endif

Foundation/NSCFArray.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import CoreFoundation
1212

1313
internal final class _NSCFArray : NSMutableArray {
1414
deinit {
15-
#if !os(Android)
1615
_CFDeinit(self)
17-
#endif
1816
_CFZeroUnsafeIvars(&_storage)
1917
}
2018

Foundation/NSCFString.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ internal final class _NSCFConstantString : _NSCFString {
6161
internal var _ptr : UnsafePointer<UInt8> {
6262
// FIXME: Split expression as a work-around for slow type
6363
// checking (tracked by SR-5322).
64-
let offTemp1 = MemoryLayout<OpaquePointer>.size + MemoryLayout<_swift_rc_type>.size
65-
let offTemp2 = MemoryLayout<_swift_rc_type>.size + MemoryLayout<_CFInfo>.size
64+
let offTemp1 = MemoryLayout<OpaquePointer>.size + MemoryLayout<_CFSwiftRCCount>.size
65+
let offTemp2 = MemoryLayout<_CFSwiftRCCount>.size + MemoryLayout<_CFInfo>.size
6666
let offset = offTemp1 + offTemp2
6767
let ptr = Unmanaged.passUnretained(self).toOpaque()
6868
return ptr.load(fromByteOffset: offset, as: UnsafePointer<UInt8>.self)
@@ -71,8 +71,8 @@ internal final class _NSCFConstantString : _NSCFString {
7171
private var _lenOffset : Int {
7272
// FIXME: Split expression as a work-around for slow type
7373
// checking (tracked by SR-5322).
74-
let offTemp1 = MemoryLayout<OpaquePointer>.size + MemoryLayout<_swift_rc_type>.size
75-
let offTemp2 = MemoryLayout<_swift_rc_type>.size + MemoryLayout<_CFInfo>.size
74+
let offTemp1 = MemoryLayout<OpaquePointer>.size + MemoryLayout<_CFSwiftRCCount>.size
75+
let offTemp2 = MemoryLayout<_CFSwiftRCCount>.size + MemoryLayout<_CFInfo>.size
7676
return offTemp1 + offTemp2 + MemoryLayout<UnsafePointer<UInt8>>.size
7777
}
7878

Foundation/NSString.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,6 @@ extension NSString {
630630
}
631631

632632
public var boolValue: Bool {
633-
#if os(Android)
634-
return (try? NSRegularExpression(pattern: "^[-+]?0*[tTyY123456789]"))?
635-
.firstMatch(in: _swiftObject, range: NSMakeRange(0, length)) != nil
636-
#endif
637633
let scanner = Scanner(string: _swiftObject)
638634
// skip initial whitespace if present
639635
let _ = scanner.scanCharactersFromSet(.whitespaces)

TestFoundation/TestFileManager.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ class TestFileManager : XCTestCase {
228228
}
229229

230230
func test_fileSystemAttributes() {
231-
#if os(Android)
232-
XCTFail("File system attributes not available on Android")
233-
#else
231+
#if !os(Android)
234232
let fm = FileManager.default
235233
let path = NSTemporaryDirectory()
236234

0 commit comments

Comments
 (0)