@@ -79,7 +79,7 @@ OtherFunctions = [
79
79
'jn', 'yn'
80
80
]
81
81
82
- # These functions are imported correctly as - is.
82
+ # These functions are imported correctly as - is.
83
83
OkayFunctions = [ 'j0 ', 'j1 ', 'y0 ', 'y1 ']
84
84
85
85
# These functions are not supported for various reasons.
@@ -129,6 +129,7 @@ public func ${ufunc}(x: ${T}) -> ${T} {
129
129
130
130
% end
131
131
132
+ #if os(OSX) || os(iOS) || os(tvOS) || os(watchOS)
132
133
// Unary intrinsic functions
133
134
// Note these have a corresponding LLVM intrinsic
134
135
% for T, ufunc in TypedUnaryIntrinsicFunctions ( ) :
@@ -139,6 +140,22 @@ public func ${ufunc}(x: ${T}) -> ${T} {
139
140
}
140
141
141
142
% end
143
+ #else
144
+ // FIXME: As of now, we cannot declare 64-bit (Double/CDouble) overlays here.
145
+ // Since CoreFoundation also exports libc functions, they will conflict with
146
+ // Swift overlays when building Foundation. For now, just like normal
147
+ // UnaryFunctions, we define overlays only for OverlayFloatTypes.
148
+ % for ufunc in UnaryIntrinsicFunctions:
149
+ % for T, CT, f in OverlayFloatTypes ( ) :
150
+ @_transparent
151
+ @warn_unused_result
152
+ public func ${ ufunc } ( x: ${ T} ) - > ${ T} {
153
+ return ${ T} ( ${ ufunc} ${ f} ( ${ CT} ( x) ) )
154
+ }
155
+
156
+ % end
157
+ % end
158
+ #endif
142
159
143
160
// Binary functions
144
161
@@ -153,11 +170,9 @@ public func ${bfunc}(lhs: ${T}, _ rhs: ${T}) -> ${T} {
153
170
154
171
// Other functions
155
172
156
- % # These are AllFloatTypes not OverlayFloatTypes because of the Int return .
157
- % for T, CT, f in AllFloatTypes( ) :
158
- % if f == '':
159
- % f = 'd'
160
- % end
173
+ % # These would be AllFloatTypes not OverlayFloatTypes because of the Int return .
174
+ % # ... except we need special treatment for Double .
175
+ % for T, CT, f in OverlayFloatTypes ( ) :
161
176
@_transparent
162
177
@warn_unused_result
163
178
public func fpclassify( x: ${ T} ) -> Int {
@@ -166,6 +181,16 @@ public func fpclassify(x: ${T}) -> Int {
166
181
167
182
% end
168
183
184
+ @_transparent
185
+ @warn_unused_result
186
+ public func fpclassify( x: Double ) -> Int {
187
+ #if os(Linux)
188
+ return Int ( __fpclassify ( CDouble ( x) ) )
189
+ #else
190
+ return Int ( __fpclassifyd ( CDouble ( x) ) )
191
+ #endif
192
+ }
193
+
169
194
% # These are AllFloatTypes not OverlayFloatTypes because we need to cover
170
195
% # them all because C's declarations are compiler builtins.
171
196
% for T, CT, f in AllFloatTypes( ) :
@@ -257,6 +282,16 @@ public func scalbn(x: ${T}, _ n: Int) -> ${T} {
257
282
258
283
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return .
259
284
% for T, CT, f in AllFloatTypes( ) :
285
+ #if os(Linux) || os(FreeBSD)
286
+ @_transparent
287
+ @warn_unused_result
288
+ public func lgamma( x: ${ T} ) -> ( ${ T} , Int) {
289
+ var sign = CInt ( 0 )
290
+ let value = lgamma ${ f} _r( ${ CT} ( x) , & sign)
291
+ return ( ${ T} ( value) , Int ( sign) )
292
+ }
293
+ #else
294
+ % # On Darwin platform,
260
295
% # The real lgamma_r is not imported because it hides behind macro _REENTRANT.
261
296
@warn_unused_result
262
297
@_silgen_name ( " _swift_Darwin_lgamma${f}_r " )
@@ -273,6 +308,7 @@ public func lgamma(x: ${T}) -> (${T}, Int) {
273
308
}
274
309
return ( ${ T} ( value) , Int ( sign) )
275
310
}
311
+ #endif
276
312
277
313
% end
278
314
0 commit comments