Skip to content

Commit cc64f68

Browse files
committed
Unvail the Darwin.abs function to avoid collisions with Swift.abs
Also marks M_PI etc obsoleted instead of merely deprecated (which they have been since Swift 3.0).
1 parent 6ea773e commit cc64f68

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

stdlib/public/Platform/Darwin.swift.gyb

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@
1515
public let MAP_FAILED: UnsafeMutableRawPointer! = UnsafeMutableRawPointer(bitPattern: -1)
1616

1717
// Constants defined by <math.h>
18-
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.")
18+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.")
1919
public let M_PI = Double.pi
2020

21-
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.")
21+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.")
2222
public let M_PI_2 = Double.pi / 2
2323

24-
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.")
24+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.")
2525
public let M_PI_4 = Double.pi / 4
2626

27-
@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.")
28-
public let M_SQRT2 = 2.squareRoot()
27+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use 'sqrt(2)'.")
28+
public let M_SQRT2 = sqrt(2)
2929

30-
@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.")
31-
public let M_SQRT1_2 = 0.5.squareRoot()
30+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use 'sqrt(0.5)'.")
31+
public let M_SQRT1_2 = sqrt(0.5)
3232

3333
// Constants defined by <float.h>
34-
@available(swift, deprecated: 3.0, message: "Please use 'T.radix' to get the radix of a FloatingPoint type 'T'.")
34+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use 'T.radix' to get the radix of a FloatingPoint type 'T'.")
3535
public let FLT_RADIX = Double.radix
3636

3737
%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL'), ('Float80', 'LDBL')]:
@@ -40,29 +40,29 @@ public let FLT_RADIX = Double.radix
4040
% end
4141
// Where does the 1 come from? C counts the usually-implicit leading
4242
// significand bit, but Swift does not. Neither is really right or wrong.
43-
@available(swift, deprecated: 3.0, message: "Please use '${type}.significandBitCount + 1'.")
43+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.significandBitCount + 1'.")
4444
public let ${prefix}_MANT_DIG = ${type}.significandBitCount + 1
4545

4646
// Where does the 1 come from? C models floating-point numbers as having a
4747
// significand in [0.5, 1), but Swift (following IEEE 754) considers the
4848
// significand to be in [1, 2). This rationale applies to ${prefix}_MIN_EXP
4949
// as well.
50-
@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude.exponent + 1'.")
50+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.greatestFiniteMagnitude.exponent + 1'.")
5151
public let ${prefix}_MAX_EXP = ${type}.greatestFiniteMagnitude.exponent + 1
5252

53-
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude.exponent + 1'.")
53+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.leastNormalMagnitude.exponent + 1'.")
5454
public let ${prefix}_MIN_EXP = ${type}.leastNormalMagnitude.exponent + 1
5555

56-
@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.")
56+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.")
5757
public let ${prefix}_MAX = ${type}.greatestFiniteMagnitude
5858

59-
@available(swift, deprecated: 3.0, message: "Please use '${type}.ulpOfOne' or '.ulpOfOne'.")
59+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.ulpOfOne' or '.ulpOfOne'.")
6060
public let ${prefix}_EPSILON = ${type}.ulpOfOne
6161

62-
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.")
62+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.")
6363
public let ${prefix}_MIN = ${type}.leastNormalMagnitude
6464

65-
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.")
65+
@available(swift, deprecated: 3.0, obsoleted: 5.1, message: "Use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.")
6666
public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude
6767

6868
% if type == "Float80":
@@ -79,3 +79,7 @@ extension extern_proc {
7979
set { self.p_un.__p_starttime = newValue }
8080
}
8181
}
82+
83+
// Hide Darwin.abs to avoid conflicts with Swift.abs
84+
@available(*, unavailable, message: "Use 'Swift.abs( )'.")
85+
public func abs(_ x: Int32) -> Int32 { fatalError() }

0 commit comments

Comments
 (0)