Skip to content

Commit e0e512c

Browse files
committed
WIP/Foundation: port to Windows
Unformalised changes to port Foundation to Windows
1 parent 50b7086 commit e0e512c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+448
-192
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
7676
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
7777
set(deployment_target -DDEPLOYMENT_TARGET_FREEBSD)
7878
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
79-
set(deployment_target -DDEPLOYMENT_TARGET_WINDOWS)
79+
set(deployment_target -DDEPLOYMENT_TARGET_WINDOWS -D_AMD64_)
8080
endif()
8181

8282
add_swift_library(Foundation

CoreFoundation/Base.subproj/CFPriv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ CF_EXPORT void _CFRuntimeSetCFMPresent(void *a);
5757
CF_EXPORT const char *_CFProcessPath(void);
5858
CF_EXPORT const char **_CFGetProcessPath(void);
5959
CF_EXPORT const char **_CFGetProgname(void);
60+
61+
#if !TARGET_OS_WIN32
6062
CF_EXPORT void _CFGetUGIDs(uid_t *euid, gid_t *egid);
6163
CF_EXPORT uid_t _CFGetEUID(void);
6264
CF_EXPORT uid_t _CFGetEGID(void);
65+
#endif
6366

6467

6568
#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX))

Foundation/AffineTransform.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import Darwin
1212
#elseif os(Linux) || CYGWIN
1313
import Glibc
14+
#elseif os(Windows)
15+
import MSVCRT
1416
#endif
1517

1618
private let ε: CGFloat = CGFloat(2.22045e-16)

Foundation/ByteCountFormatter.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10+
#if os(Windows)
11+
import MSVCRT
12+
#endif
1013

1114
extension ByteCountFormatter {
1215
public struct Units : OptionSet {

Foundation/CGFloat.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10+
#if os(Windows)
11+
import MSVCRT
12+
#endif
13+
1014
@_fixed_layout
1115
public struct CGFloat {
1216
#if arch(i386) || arch(arm)
@@ -863,11 +867,13 @@ public func scalbn(_ x: CGFloat, _ n: Int) -> CGFloat {
863867
return CGFloat(scalbn(x.native, n))
864868
}
865869

870+
#if !os(Windows)
866871
@_transparent
867872
public func lgamma(_ x: CGFloat) -> (CGFloat, Int) {
868873
let (value, sign) = lgamma(x.native)
869874
return (CGFloat(value), sign)
870875
}
876+
#endif
871877

872878
@_transparent
873879
public func remquo(_ x: CGFloat, _ y: CGFloat) -> (CGFloat, Int) {

Foundation/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public final class _DataStorage {
187187
var buffer = UnsafeMutableRawBufferPointer.allocate(byteCount: range.count, alignment: MemoryLayout<UInt>.alignment)
188188
defer { buffer.deallocate() }
189189

190-
let sliceRange = NSRange(location: range.lowerBound - _offset, length: range.count)
190+
_ = NSRange(location: range.lowerBound - _offset, length: range.count)
191191
var enumerated = 0
192192
d.enumerateBytes { (ptr, byteRange, stop) in
193193
if byteRange.upperBound - _offset < range.lowerBound {

Foundation/DateFormatter.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ open class DateFormatter : Formatter {
1414
private var __cfObject: CFType?
1515
private var _cfObject: CFType {
1616
guard let obj = __cfObject else {
17-
#if os(macOS) || os(iOS)
18-
let dateStyle = CFDateFormatterStyle(rawValue: CFIndex(self.dateStyle.rawValue))!
19-
let timeStyle = CFDateFormatterStyle(rawValue: CFIndex(self.timeStyle.rawValue))!
20-
#else
21-
let dateStyle = CFDateFormatterStyle(self.dateStyle.rawValue)
22-
let timeStyle = CFDateFormatterStyle(self.timeStyle.rawValue)
23-
#endif
24-
17+
let dateStyle = CFDateFormatterStyle(rawValue: CFIndex(self.dateStyle.rawValue))!
18+
let timeStyle = CFDateFormatterStyle(rawValue: CFIndex(self.timeStyle.rawValue))!
19+
2520
let obj = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale._cfObject, dateStyle, timeStyle)!
2621
_setFormatterAttributes(obj)
2722
if let dateFormat = _dateFormat {

0 commit comments

Comments
 (0)