mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* Fixes issue addressed Float80 data type. Float80 is disabled for Intel architectures (i.e. Android Simulator). * More precise condition check.
72 lines
3.3 KiB
Swift
72 lines
3.3 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
@_exported import SwiftGlibc // Clang module
|
|
|
|
public let MAP_FAILED: UnsafeMutableRawPointer! = UnsafeMutableRawPointer(bitPattern: -1)
|
|
|
|
// Constants defined by <math.h>
|
|
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.")
|
|
public let M_PI = Double.pi
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.")
|
|
public let M_PI_2 = Double.pi / 2
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.")
|
|
public let M_PI_4 = Double.pi / 4
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.")
|
|
public let M_SQRT2 = 2.squareRoot()
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.")
|
|
public let M_SQRT1_2 = 0.5.squareRoot()
|
|
|
|
// Constants defined by <float.h>
|
|
@available(swift, deprecated: 3.0, message: "Please use 'T.radix' to get the radix of a FloatingPoint type 'T'.")
|
|
public let FLT_RADIX = Double.radix
|
|
|
|
%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL'), ('Float80', 'LDBL')]:
|
|
% if type == "Float80":
|
|
#if !os(Android) && (arch(i386) || arch(x86_64))
|
|
% end
|
|
// Where does the 1 come from? C counts the usually-implicit leading
|
|
// significand bit, but Swift does not. Neither is really right or wrong.
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.significandBitCount + 1'.")
|
|
public let ${prefix}_MANT_DIG = ${type}.significandBitCount + 1
|
|
|
|
// Where does the 1 come from? C models floating-point numbers as having a
|
|
// significand in [0.5, 1), but Swift (following IEEE 754) considers the
|
|
// significand to be in [1, 2). This rationale applies to ${prefix}_MIN_EXP
|
|
// as well.
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude.exponent + 1'.")
|
|
public let ${prefix}_MAX_EXP = ${type}.greatestFiniteMagnitude.exponent + 1
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude.exponent + 1'.")
|
|
public let ${prefix}_MIN_EXP = ${type}.leastNormalMagnitude.exponent + 1
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.")
|
|
public let ${prefix}_MAX = ${type}.greatestFiniteMagnitude
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.ulpOfOne' or '.ulpOfOne'.")
|
|
public let ${prefix}_EPSILON = ${type}.ulpOfOne
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.")
|
|
public let ${prefix}_MIN = ${type}.leastNormalMagnitude
|
|
|
|
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.")
|
|
public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude
|
|
|
|
% if type == "Float80":
|
|
#endif
|
|
% end
|
|
%end
|