From bf90fedc884ce6b31a499a22cfed2733425c1390 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 23 Oct 2020 14:29:30 -0700 Subject: [PATCH] SystemInternals: make `Mocking` build on Windows Fix some of the type errors and add missing imports. --- Sources/SystemInternals/Mocking.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/SystemInternals/Mocking.swift b/Sources/SystemInternals/Mocking.swift index 343372d..aa4bdbb 100644 --- a/Sources/SystemInternals/Mocking.swift +++ b/Sources/SystemInternals/Mocking.swift @@ -87,6 +87,9 @@ public class MockingDriver { import Darwin #elseif os(Linux) || os(FreeBSD) || os(Android) import Glibc +#elseif os(Windows) +import ucrt +import WinSDK #else #error("Unsupported Platform") #endif @@ -95,14 +98,14 @@ import Glibc #if os(Windows) internal typealias TLSKey = DWORD internal func makeTLSKey() -> TLSKey { - var raw: DWORD = FlsAlloc(nil) + let raw: DWORD = FlsAlloc(nil) if raw == FLS_OUT_OF_INDEXES { fatalError("Unable to create key") } return raw } internal func setTLS(_ key: TLSKey, _ p: UnsafeMutableRawPointer?) { - guard 0 != FlsSetValue(key, p) else { + guard FlsSetValue(key, p) else { fatalError("Unable to set TLS") } }