@@ -141,23 +141,23 @@ public func snprintf(ptr: UnsafeMutablePointer<Int8>, _ len: Int, _ format: Unsa
141141// fcntl.h
142142//===----------------------------------------------------------------------===//
143143
144- #if ! os(Windows) || CYGWIN
144+ #if os(Windows)
145145@_silgen_name ( " _swift_Platform_open " )
146146func _swift_Platform_open(
147147 _ path: UnsafePointer < CChar > ,
148148 _ oflag: Int32 ,
149- _ mode: mode_t
149+ _ mode: Int32
150150) -> Int32
151151#else
152152@_silgen_name ( " _swift_Platform_open " )
153153func _swift_Platform_open(
154154 _ path: UnsafePointer < CChar > ,
155155 _ oflag: Int32 ,
156- _ mode: Int32
156+ _ mode: mode_t
157157) -> Int32
158158#endif
159159
160- #if !os(Windows) || CYGWIN
160+ #if !os(Windows)
161161@_silgen_name ( " _swift_Platform_openat " )
162162func _swift_Platform_openat(
163163 _ fd: Int32 ,
@@ -174,7 +174,15 @@ public func open(
174174 return _swift_Platform_open ( path, oflag, 0 )
175175}
176176
177- #if !os(Windows) || CYGWIN
177+ #if os(Windows)
178+ public func open(
179+ _ path: UnsafePointer < CChar > ,
180+ _ oflag: Int32 ,
181+ _ mode: Int32
182+ ) -> Int32 {
183+ return _swift_Platform_open ( path, oflag, mode)
184+ }
185+ #else
178186public func open(
179187 _ path: UnsafePointer < CChar > ,
180188 _ oflag: Int32 ,
@@ -199,17 +207,9 @@ public func openat(
199207) -> Int32 {
200208 return _swift_Platform_openat ( fd, path, oflag, mode)
201209}
202- #else
203- public func open(
204- _ path: UnsafePointer < CChar > ,
205- _ oflag: Int32 ,
206- _ mode: Int32
207- ) -> Int32 {
208- return _swift_Platform_open ( path, oflag, mode)
209- }
210210#endif
211211
212- #if !os(Windows) || CYGWIN
212+ #if !os(Windows)
213213@_silgen_name ( " _swift_Platform_fcntl " )
214214internal func _swift_Platform_fcntl(
215215 _ fd: Int32 ,
@@ -248,7 +248,18 @@ public func fcntl(
248248}
249249#endif
250250
251- #if !os(Windows) || CYGWIN
251+ #if os(Windows)
252+ public var S_IFMT : Int32 { return Int32 ( 0xf000 ) }
253+
254+ public var S_IFREG : Int32 { return Int32 ( 0x8000 ) }
255+ public var S_IFDIR : Int32 { return Int32 ( 0x4000 ) }
256+ public var S_IFCHR : Int32 { return Int32 ( 0x2000 ) }
257+ public var S_IFIFO : Int32 { return Int32 ( 0x1000 ) }
258+
259+ public var S_IREAD : Int32 { return Int32 ( 0x0100 ) }
260+ public var S_IWRITE : Int32 { return Int32 ( 0x0080 ) }
261+ public var S_IEXEC : Int32 { return Int32 ( 0x0040 ) }
262+ #else
252263public var S_IFMT : mode_t { return mode_t ( 0o170000 ) }
253264public var S_IFIFO : mode_t { return mode_t ( 0o010000 ) }
254265public var S_IFCHR : mode_t { return mode_t ( 0o020000 ) }
@@ -286,24 +297,13 @@ public var S_IREAD: mode_t { return S_IRUSR }
286297public var S_IWRITE : mode_t { return S_IWUSR }
287298public var S_IEXEC : mode_t { return S_IXUSR }
288299#endif
289- #else
290- public var S_IFMT : Int32 { return Int32 ( 0xf000 ) }
291-
292- public var S_IFREG : Int32 { return Int32 ( 0x8000 ) }
293- public var S_IFDIR : Int32 { return Int32 ( 0x4000 ) }
294- public var S_IFCHR : Int32 { return Int32 ( 0x2000 ) }
295- public var S_IFIFO : Int32 { return Int32 ( 0x1000 ) }
296-
297- public var S_IREAD : Int32 { return Int32 ( 0x0100 ) }
298- public var S_IWRITE : Int32 { return Int32 ( 0x0080 ) }
299- public var S_IEXEC : Int32 { return Int32 ( 0x0040 ) }
300300#endif
301301
302302//===----------------------------------------------------------------------===//
303303// ioctl.h
304304//===----------------------------------------------------------------------===//
305305
306- #if !os(Windows) || CYGWIN
306+ #if !os(Windows)
307307@_silgen_name ( " _swift_Platform_ioctl " )
308308internal func _swift_Platform_ioctl(
309309 _ fd: CInt ,
@@ -380,8 +380,7 @@ public var SIG_ERR: sighandler_t {
380380public var SIG_HOLD : sighandler_t {
381381 return unsafeBitCast ( 2 , to: sighandler_t. self)
382382}
383- #elseif os(Windows)
384- #if CYGWIN
383+ #elseif os(Cygwin)
385384public typealias sighandler_t = _sig_func_ptr
386385
387386public var SIG_DFL : sighandler_t ? { return nil }
@@ -394,15 +393,14 @@ public var SIG_ERR: sighandler_t {
394393public var SIG_HOLD : sighandler_t {
395394 return unsafeBitCast ( 2 , to: sighandler_t. self)
396395}
397- #else
396+ #elseif os(Windows)
398397public var SIG_DFL : _crt_signal_t ? { return nil }
399398public var SIG_IGN : _crt_signal_t {
400399 return unsafeBitCast ( 1 , to: _crt_signal_t. self)
401400}
402401public var SIG_ERR : _crt_signal_t {
403402 return unsafeBitCast ( - 1 , to: _crt_signal_t. self)
404403}
405- #endif
406404#else
407405internal var _ignore = _UnsupportedPlatformError ( )
408406#endif
@@ -411,13 +409,13 @@ internal var _ignore = _UnsupportedPlatformError()
411409// semaphore.h
412410//===----------------------------------------------------------------------===//
413411
414- #if !os(Windows) || CYGWIN
412+ #if !os(Windows)
415413/// The value returned by `sem_open()` in the case of failure.
416414public var SEM_FAILED : UnsafeMutablePointer < sem_t > ? {
417415#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
418416 // The value is ABI. Value verified to be correct for OS X, iOS, watchOS, tvOS.
419417 return UnsafeMutablePointer < sem_t > ( bitPattern: - 1 )
420- #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || CYGWIN
418+ #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin)
421419 // The value is ABI. Value verified to be correct on Glibc.
422420 return UnsafeMutablePointer < sem_t > ( bitPattern: 0 )
423421#else
0 commit comments