Merge pull request #264 from hpux735/arm-fixes

Foundation fixes for 32-bit systems and more
diff --git a/CoreFoundation/Base.subproj/CFBase.h b/CoreFoundation/Base.subproj/CFBase.h
index 1ee6706..d647d63 100644
--- a/CoreFoundation/Base.subproj/CFBase.h
+++ b/CoreFoundation/Base.subproj/CFBase.h
@@ -61,6 +61,10 @@
 #define __HAS_DISPATCH__ 1
 #endif
 #endif
+#if DEPLOYMENT_TARGET_LINUX && DEPLOYMENT_RUNTIME_SWIFT && DEPLOYMENT_ENABLE_LIBDISPATCH
+#define __HAS_DISPATCH__ 1
+#endif
+
 // Some compilers provide the capability to test if certain features are available. This macro provides a compatibility path for other compilers.
 #ifndef __has_feature
 #define __has_feature(x) 0
diff --git a/Foundation.xcodeproj/project.pbxproj b/Foundation.xcodeproj/project.pbxproj
index dd3b3a2..6b129d5 100755
--- a/Foundation.xcodeproj/project.pbxproj
+++ b/Foundation.xcodeproj/project.pbxproj
@@ -275,7 +275,6 @@
 		EADE0B4E1BD09E0800C49C64 /* NSAffineTransform.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B4D1BD09E0800C49C64 /* NSAffineTransform.swift */; };
 		EADE0B501BD09E3100C49C64 /* NSAttributedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B4F1BD09E3100C49C64 /* NSAttributedString.swift */; };
 		EADE0B521BD09F2F00C49C64 /* NSByteCountFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B511BD09F2F00C49C64 /* NSByteCountFormatter.swift */; };
-		EADE0B911BD15DFF00C49C64 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = EADE0B531BD15DFF00C49C64 /* Info.plist */; };
 		EADE0B921BD15DFF00C49C64 /* NSCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B541BD15DFF00C49C64 /* NSCache.swift */; };
 		EADE0B931BD15DFF00C49C64 /* NSComparisonPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B551BD15DFF00C49C64 /* NSComparisonPredicate.swift */; };
 		EADE0B941BD15DFF00C49C64 /* NSCompoundPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EADE0B561BD15DFF00C49C64 /* NSCompoundPredicate.swift */; };
@@ -1644,7 +1643,7 @@
 			isa = PBXProject;
 			attributes = {
 				LastSwiftUpdateCheck = 0720;
-				LastUpgradeCheck = 0710;
+				LastUpgradeCheck = 0730;
 				ORGANIZATIONNAME = Apple;
 				TargetAttributes = {
 					5B5D885C1BBC938800234F36 = {
@@ -1686,7 +1685,6 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				EADE0B911BD15DFF00C49C64 /* Info.plist in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2210,6 +2208,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				CODE_SIGN_IDENTITY = "-";
+				COMBINE_HIDPI_IMAGES = YES;
 				EXECUTABLE_PREFIX = lib;
 				GCC_PREFIX_HEADER = CoreFoundation/Base.subproj/CoreFoundation_Prefix.h;
 				HEADER_SEARCH_PATHS = /usr/include/libxml2;
@@ -2243,6 +2242,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				CODE_SIGN_IDENTITY = "-";
+				COMBINE_HIDPI_IMAGES = YES;
 				EXECUTABLE_PREFIX = lib;
 				GCC_PREFIX_HEADER = CoreFoundation/Base.subproj/CoreFoundation_Prefix.h;
 				HEADER_SEARCH_PATHS = /usr/include/libxml2;
diff --git a/Foundation.xcodeproj/xcshareddata/xcschemes/CoreFoundation.xcscheme b/Foundation.xcodeproj/xcshareddata/xcschemes/CoreFoundation.xcscheme
index 3091255..0748300 100644
--- a/Foundation.xcodeproj/xcshareddata/xcschemes/CoreFoundation.xcscheme
+++ b/Foundation.xcodeproj/xcshareddata/xcschemes/CoreFoundation.xcscheme
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0710"
+   LastUpgradeVersion = "0730"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
diff --git a/Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundation.xcscheme b/Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundation.xcscheme
index 9a6b344..55e412b 100644
--- a/Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundation.xcscheme
+++ b/Foundation.xcodeproj/xcshareddata/xcschemes/SwiftFoundation.xcscheme
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0710"
-   version = "1.8">
+   LastUpgradeVersion = "0730"
+   version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
       buildImplicitDependencies = "NO">
diff --git a/Foundation.xcodeproj/xcshareddata/xcschemes/TestFoundation.xcscheme b/Foundation.xcodeproj/xcshareddata/xcschemes/TestFoundation.xcscheme
index 3538943..f5c29c4 100644
--- a/Foundation.xcodeproj/xcshareddata/xcschemes/TestFoundation.xcscheme
+++ b/Foundation.xcodeproj/xcshareddata/xcschemes/TestFoundation.xcscheme
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0710"
-   version = "1.8">
+   LastUpgradeVersion = "0730"
+   version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
       buildImplicitDependencies = "NO">
diff --git a/Foundation.xcodeproj/xcshareddata/xcschemes/plutil.xcscheme b/Foundation.xcodeproj/xcshareddata/xcschemes/plutil.xcscheme
index 02ec5e6..7fbccf5 100644
--- a/Foundation.xcodeproj/xcshareddata/xcschemes/plutil.xcscheme
+++ b/Foundation.xcodeproj/xcshareddata/xcschemes/plutil.xcscheme
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0710"
+   LastUpgradeVersion = "0730"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
diff --git a/TestFoundation/TestNSURL.swift b/TestFoundation/TestNSURL.swift
index 8d7722f..d59a54a 100644
--- a/TestFoundation/TestNSURL.swift
+++ b/TestFoundation/TestNSURL.swift
@@ -259,7 +259,7 @@
         let cwd = NSFileManager.defaultManager().currentDirectoryPath
         let cwdURL = NSURL(fileURLWithPath: cwd, isDirectory: true)
         // 1 for path separator
-        gRelativeOffsetFromBaseCurrentWorkingDirectory = strlen(cwdURL.fileSystemRepresentation) + 1
+        gRelativeOffsetFromBaseCurrentWorkingDirectory = UInt(strlen(cwdURL.fileSystemRepresentation) + 1)
         
         return true
     }
@@ -301,8 +301,8 @@
         let fileSystemRep = url.fileSystemRepresentation
         let actualLength = strlen(fileSystemRep)
         // 1 for path separator
-        let expectedLength = strlen(TestNSURL.gFileDoesNotExistName) + TestNSURL.gRelativeOffsetFromBaseCurrentWorkingDirectory
-        XCTAssertTrue(actualLength == expectedLength, "fileSystemRepresentation was too short")
+        let expectedLength = UInt(strlen(TestNSURL.gFileDoesNotExistName)) + TestNSURL.gRelativeOffsetFromBaseCurrentWorkingDirectory
+        XCTAssertTrue(UInt(actualLength) == expectedLength, "fileSystemRepresentation was too short")
         XCTAssertTrue(strncmp(TestNSURL.gBaseCurrentWorkingDirectoryPath, fileSystemRep, Int(strlen(TestNSURL.gBaseCurrentWorkingDirectoryPath))) == 0, "fileSystemRepresentation of base path is wrong")
         let lengthOfRelativePath = Int(strlen(TestNSURL.gFileDoesNotExistName))
         let relativePath = fileSystemRep.advancedBy(Int(TestNSURL.gRelativeOffsetFromBaseCurrentWorkingDirectory))
@@ -354,9 +354,9 @@
         url = NSURL(fileURLWithPath: path, isDirectory: true)
         XCTAssertTrue(url.hasDirectoryPath, "expected URL with directory path: \(url)")
         let fileSystemRep = url.fileSystemRepresentation
-        let actualLength = strlen(fileSystemRep)
+        let actualLength = UInt(strlen(fileSystemRep))
         // 1 for path separator
-        let expectedLength = strlen(TestNSURL.gFileDoesNotExistName) + TestNSURL.gRelativeOffsetFromBaseCurrentWorkingDirectory
+        let expectedLength = UInt(strlen(TestNSURL.gFileDoesNotExistName)) + TestNSURL.gRelativeOffsetFromBaseCurrentWorkingDirectory
         XCTAssertTrue(actualLength == expectedLength, "fileSystemRepresentation was too short")
         XCTAssertTrue(strncmp(TestNSURL.gBaseCurrentWorkingDirectoryPath, fileSystemRep, Int(strlen(TestNSURL.gBaseCurrentWorkingDirectoryPath))) == 0, "fileSystemRepresentation of base path is wrong")
         let lengthOfRelativePath = Int(strlen(TestNSURL.gFileDoesNotExistName))
diff --git a/build.py b/build.py
index 11b2a7e..d713b08 100644
--- a/build.py
+++ b/build.py
@@ -60,6 +60,14 @@
 		'-L${XCTEST_BUILD_DIR}',
 		'-I/usr/include/libxml2'
 	]
+
+if "LIBDISPATCH_SOURCE_DIR" in Configuration.current.variables:
+        foundation.CFLAGS += " "+" ".join([
+                '-DDEPLOYMENT_ENABLE_LIBDISPATCH',
+                '-I'+Configuration.current.variables["LIBDISPATCH_SOURCE_DIR"],
+                '-I'+Configuration.current.variables["LIBDISPATCH_BUILD_DIR"]+'/tests'  # for include of dispatch/private.h in CF
+        ])
+
 foundation.SWIFTCFLAGS = " ".join(swift_cflags)
 
 foundation.LDFLAGS += '-lpthread -ldl -lm -lswiftCore -lxml2 '