Files
swift-mirror/stdlib/public/core/BuiltinMath.swift.gyb
practicalswift 1cd4d4e9c9 [gardening] Fix violations of non-controversial PEP8 rules
Fixes:
* multiple statements on one line (colon) (E701)
* missing whitespace around arithmetic operator (E226)
* missing whitespace around operator (E225)
* closing bracket does not match visual indentation (E124)
* blank line contains whitespace (W293)
* continuation line missing indentation or outdented (E122)
* continuation line over-indented for hanging indent (E126)
* missing expected blank line (E301)
* trailing whitespace (W291)
* unexpected spaces around keyword / parameter equals (E251)
* whitespace after '(', '[' or '{' (E201)
* whitespace before ')', ']' or '}' (E202)
* whitespace before ',' or ':' (E203)
2016-01-23 09:23:33 +01:00

77 lines
2.0 KiB
Swift

//===--- BuiltinMath.swift.gyb --------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
%{
# Don't need 64-bit (Double/CDouble) overlays. The ordinary C imports work fine.
# FIXME: need 80-bit (Float80/long double) versions when long double is imported
overlayFloatBits = [32] # 80
allFloatBits = [32, 64] # 80
def floatName(bits):
if bits == 32:
return 'Float'
if bits == 64:
return 'Double'
if bits == 80:
return 'Float80'
def cFloatName(bits):
if bits == 32:
return 'CFloat'
if bits == 64:
return 'CDouble'
if bits == 80:
return 'CLongDouble'
def cFuncSuffix(bits):
if bits == 32:
return 'f'
if bits == 64:
return ''
if bits == 80:
return 'l'
# Each of the following lists is ordered to match math.h
# These functions have a corresponding LLVM intrinsic
# Note, keep this up to date with Darwin/tgmath.swift.gyb
UnaryIntrinsicFunctions = [
'cos', 'sin',
'exp', 'exp2',
'log', 'log10', 'log2',
'fabs',
'ceil', 'floor', 'nearbyint', 'rint', 'round', 'trunc',
]
def TypedUnaryIntrinsicFunctions():
for ufunc in UnaryIntrinsicFunctions:
for bits in allFloatBits:
yield floatName(bits), cFloatName(bits), bits, ufunc
}%
// Unary intrinsic functions
// Note these have a corresponding LLVM intrinsic
% for T, CT, bits, ufunc in TypedUnaryIntrinsicFunctions():
@_transparent
@warn_unused_result
public func _${ufunc}(x: ${T}) -> ${T} {
return ${T}(_bits: Builtin.int_${ufunc}_FPIEEE${bits}(x._value))
}
% end
// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End: