mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Keep calm: remember that the standard library has many more public exports than the average target, and that this contains ALL of them at once. I also deliberately tried to tag nearly every top-level decl, even if that was just to explicitly mark things @internal, to make sure I didn't miss something. This does export more than we might want to, mostly for protocol conformance reasons, along with our simple-but-limiting typealias rule. I tried to also mark things private where possible, but it's really going to be up to the standard library owners to get this right. This is also only validated against top-level access control; I haven't fully tested against member-level access control yet, and none of our semantic restrictions are in place. Along the way I also noticed bits of stdlib cruft; to keep this patch understandable, I didn't change any of them. Swift SVN r19145
76 lines
2.2 KiB
Swift
76 lines
2.2 KiB
Swift
%# -*- mode: swift -*-
|
|
|
|
%# Ignore the following admonition; it applies to the resulting .swift file only
|
|
//// Automatically Generated From BuiltinMath.swift.gyb. Do Not Edit Directly
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 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', 'sqrt',
|
|
'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 @public
|
|
func _${ufunc}(x: ${T}) -> ${T} {
|
|
return ${T}(Builtin.int_${ufunc}_FPIEEE${bits}(x.value))
|
|
}
|
|
|
|
% end
|
|
|