Skip to content

Commit 62eab29

Browse files
authored
Merge pull request swiftlang#32669 from varungandhi-apple/vg-use-os-checks-in-stdlib
[Gardening] Use os(..) checks instead of canImport(Darwin) in CTypes.swift
2 parents f989aa2 + cacfb01 commit 62eab29

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

stdlib/public/Differentiation/TgmathDerivatives.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
import Swift
1616

17-
#if canImport(Darwin)
17+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
1818
import Darwin.C.tgmath
19-
#elseif canImport(Glibc)
19+
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
2020
import Glibc
2121
#elseif os(Windows)
2222
import MSVCRT

stdlib/public/Platform/MachError.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if canImport(Darwin)
13+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
1414
/// Enumeration describing Mach error codes.
1515
@objc
1616
public enum MachErrorCode : Int32 {
@@ -202,4 +202,4 @@ public enum MachErrorCode : Int32 {
202202
/// The requested property cannot be changed at this time.
203203
case policyStatic = 51
204204
}
205-
#endif // canImport(Darwin)
205+
#endif // os(macOS) || os(iOS) || os(tvOS) || os(watchOS)

stdlib/public/Platform/POSIXError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if canImport(Darwin)
13+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
1414

1515
/// Enumeration describing POSIX error codes.
1616
@objc

stdlib/public/Platform/Platform.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SwiftOverlayShims
1717
import ucrt
1818
#endif
1919

20-
#if canImport(Darwin)
20+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
2121
//===----------------------------------------------------------------------===//
2222
// MacTypes.h
2323
//===----------------------------------------------------------------------===//
@@ -103,7 +103,7 @@ public var errno : Int32 {
103103
// stdio.h
104104
//===----------------------------------------------------------------------===//
105105

106-
#if canImport(Darwin) || os(FreeBSD) || os(PS4)
106+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(FreeBSD) || os(PS4)
107107
public var stdin : UnsafeMutablePointer<FILE> {
108108
get {
109109
return __stdinp
@@ -248,7 +248,7 @@ public var S_IFBLK: mode_t { return mode_t(0o060000) }
248248
public var S_IFREG: mode_t { return mode_t(0o100000) }
249249
public var S_IFLNK: mode_t { return mode_t(0o120000) }
250250
public var S_IFSOCK: mode_t { return mode_t(0o140000) }
251-
#if canImport(Darwin)
251+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
252252
public var S_IFWHT: mode_t { return mode_t(0o160000) }
253253
#endif
254254

@@ -271,7 +271,7 @@ public var S_ISUID: mode_t { return mode_t(0o004000) }
271271
public var S_ISGID: mode_t { return mode_t(0o002000) }
272272
public var S_ISVTX: mode_t { return mode_t(0o001000) }
273273

274-
#if canImport(Darwin)
274+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
275275
public var S_ISTXT: mode_t { return S_ISVTX }
276276
public var S_IREAD: mode_t { return S_IRUSR }
277277
public var S_IWRITE: mode_t { return S_IWUSR }
@@ -315,7 +315,7 @@ public func ioctl(
315315
// unistd.h
316316
//===----------------------------------------------------------------------===//
317317

318-
#if canImport(Darwin)
318+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
319319
@available(*, unavailable, message: "Please use threads or posix_spawn*()")
320320
public func fork() -> Int32 {
321321
fatalError("unavailable function can't be called")
@@ -331,7 +331,7 @@ public func vfork() -> Int32 {
331331
// signal.h
332332
//===----------------------------------------------------------------------===//
333333

334-
#if canImport(Darwin)
334+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
335335
public var SIG_DFL: sig_t? { return nil }
336336
public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) }
337337
public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) }
@@ -395,10 +395,10 @@ public typealias Semaphore = UnsafeMutablePointer<sem_t>
395395

396396
/// The value returned by `sem_open()` in the case of failure.
397397
public var SEM_FAILED: Semaphore? {
398-
#if canImport(Darwin)
399-
// The value is ABI. Value verified to be correct for macOS, iOS, watchOS, tvOS.
398+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
399+
// The value is ABI. Value verified to be correct for OS X, iOS, watchOS, tvOS.
400400
return Semaphore(bitPattern: -1)
401-
#elseif canImport(Glibc)
401+
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI)
402402
// The value is ABI. Value verified to be correct on Glibc.
403403
return Semaphore(bitPattern: 0)
404404
#else
@@ -429,7 +429,7 @@ public func sem_open(
429429
//===----------------------------------------------------------------------===//
430430

431431
// Some platforms don't have `extern char** environ` imported from C.
432-
#if canImport(Darwin) || os(FreeBSD) || os(OpenBSD) || os(PS4)
432+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(FreeBSD) || os(OpenBSD) || os(PS4)
433433
public var environ: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?> {
434434
return _swift_stdlib_getEnviron()
435435
}

stdlib/public/Platform/TiocConstants.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Tty ioctl request constants, needed only on Darwin and FreeBSD.
1414

1515
// Constants available on all platforms, also available on Linux.
16-
#if canImport(Darwin) || os(FreeBSD) || os(Haiku)
16+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(FreeBSD) || os(Haiku)
1717

1818
/// Set exclusive use of tty.
1919
public var TIOCEXCL: UInt { return 0x2000740d }
@@ -115,7 +115,7 @@ public var TIOCGLTC: UInt { return 0x40067474 }
115115

116116

117117
// Darwin only constants, also available on Linux.
118-
#if canImport(Darwin)
118+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
119119

120120
/// Get termios struct.
121121
public var TIOCGETA: UInt { return 0x40487413 }

stdlib/public/Platform/tgmath.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} {
234234

235235
% end
236236

237-
#if canImport(Darwin)
237+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
238238
// Unary intrinsic functions
239239
// Note these have a corresponding LLVM intrinsic
240240
% for T, ufunc in TypedUnaryIntrinsicFunctions():

stdlib/public/core/Availability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public func _stdlib_isOSVersionAtLeast(
2424
_ minor: Builtin.Word,
2525
_ patch: Builtin.Word
2626
) -> Builtin.Int1 {
27-
#if canImport(Darwin)
27+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
2828
if Int(major) == 9999 {
2929
return true._value
3030
}

stdlib/public/core/CTypes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public typealias CFloat = Float
6767
public typealias CDouble = Double
6868

6969
/// The C 'long double' type.
70-
#if canImport(Darwin)
70+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
7171
// On Darwin, long double is Float80 on x86, and Double otherwise.
7272
#if arch(x86_64) || arch(i386)
7373
public typealias CLongDouble = Float80
@@ -231,7 +231,7 @@ extension UInt {
231231
}
232232

233233
/// A wrapper around a C `va_list` pointer.
234-
#if arch(arm64) && !(canImport(Darwin) || os(Windows))
234+
#if arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows))
235235
@frozen
236236
public struct CVaListPointer {
237237
@usableFromInline // unsafe-performance

stdlib/public/core/UnicodeScalarProperties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ extension Unicode.Scalar.Properties {
590590
return _hasBinaryProperty(__swift_stdlib_UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED)
591591
}
592592

593-
#if canImport(Darwin)
593+
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
594594
// FIXME: These properties were introduced in ICU 57, but Ubuntu 16.04 comes
595595
// with ICU 55 so the values won't be correct there. Exclude them on
596596
// non-Darwin platforms for now; bundling ICU with the toolchain would resolve

stdlib/public/core/VarArgs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ internal let _countGPRegisters = 16
9191
@usableFromInline
9292
internal let _registerSaveWords = _countGPRegisters
9393

94-
#elseif arch(arm64) && !(canImport(Darwin) || os(Windows))
94+
#elseif arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows))
9595
// ARM Procedure Call Standard for aarch64. (IHI0055B)
9696
// The va_list type may refer to any parameter in a parameter list may be in one
9797
// of three memory locations depending on its type and position in the argument
@@ -419,7 +419,7 @@ extension Float80: CVarArg, _CVarArgAligned {
419419
}
420420
#endif
421421

422-
#if (arch(x86_64) && !os(Windows)) || arch(s390x) || (arch(arm64) && !(canImport(Darwin) || os(Windows)))
422+
#if (arch(x86_64) && !os(Windows)) || arch(s390x) || (arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows)))
423423

424424
/// An object that can manage the lifetime of storage backing a
425425
/// `CVaListPointer`.

0 commit comments

Comments
 (0)