@@ -171,7 +171,6 @@ internal extension TGMath {
171
171
}
172
172
173
173
% for T in [ 'Float', 'Double', 'CGFloat', 'Float80 '] :
174
- % Module = 'CoreGraphics' if T == 'CGFloat' else 'Darwin'
175
174
176
175
% if T == 'Float80 ':
177
176
#if (arch(i386) || arch(x86_64)) && !os(Windows)
@@ -181,6 +180,8 @@ internal extension TGMath {
181
180
% end
182
181
183
182
extension ${ T} : TGMath {
183
+ #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
184
+ % Module = 'CoreGraphics' if T == 'CGFloat' else 'Darwin'
184
185
% for f in unary:
185
186
static func _${ f} ( _ x: ${ T} ) - > ${ T} { return ${ Module} . ${ f} ( x) }
186
187
% end
@@ -189,13 +190,39 @@ extension ${T}: TGMath {
189
190
% end
190
191
static func _remquo( _ x: ${ T} , _ y: ${ T} ) -> ( ${ T} , Int) { return ${ Module} . remquo ( x, y) }
191
192
static func _fma( _ x: ${ T} , _ y: ${ T} , _ z: ${ T} ) -> ${ T} { return ${ Module} . fma ( x, y, z) }
192
- #if !os(Windows)
193
193
static func _lgamma( _ x: ${ T} ) -> ( ${ T} , Int) { return ${ Module} . lgamma ( x) }
194
- #endif
195
194
static func _modf( _ x: ${ T} ) -> ( ${ T} , ${ T} ) { return ${ Module} . modf ( x) }
196
195
static func _scalbn( _ x: ${ T} , _ n: Int) -> ${ T} { return ${ Module} . scalbn ( x, n) }
197
196
static func _frexp( _ x: ${ T} ) -> ( ${ T} , Int) { return ${ Module} . frexp ( x) }
198
197
static func _ilogb( _ x: ${ T} ) -> Int { return ${ Module} . ilogb ( x) }
198
+ #elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
199
+ % for f in unary:
200
+ static func _${ f} ( _ x: ${ T} ) - > ${ T} { return Glibc . ${ f} ( x) }
201
+ % end
202
+ % for f in binary:
203
+ static func _${ f} ( _ x: ${ T} , _ y: ${ T} ) - > ${ T} { return Glibc . ${ f} ( x, y) }
204
+ % end
205
+ static func _remquo( _ x: ${ T} , _ y: ${ T} ) -> ( ${ T} , Int) { return Glibc . remquo ( x, y) }
206
+ static func _fma( _ x: ${ T} , _ y: ${ T} , _ z: ${ T} ) -> ${ T} { return Glibc . fma ( x, y, z) }
207
+ static func _lgamma( _ x: ${ T} ) -> ( ${ T} , Int) { return Glibc . lgamma ( x) }
208
+ static func _modf( _ x: ${ T} ) -> ( ${ T} , ${ T} ) { return Glibc . modf ( x) }
209
+ static func _scalbn( _ x: ${ T} , _ n: Int) -> ${ T} { return Glibc . scalbn ( x, n) }
210
+ static func _frexp( _ x: ${ T} ) -> ( ${ T} , Int) { return Glibc . frexp ( x) }
211
+ static func _ilogb( _ x: ${ T} ) -> Int { return Glibc . ilogb ( x) }
212
+ #elseif os(Windows)
213
+ % for f in unary:
214
+ static func _${ f} ( _ x: ${ T} ) - > ${ T} { return MSVCRT . ${ f} ( x) }
215
+ % end
216
+ % for f in binary:
217
+ static func _${ f} ( _ x: ${ T} , _ y: ${ T} ) - > ${ T} { return MSVCRT . ${ f} ( x, y) }
218
+ % end
219
+ static func _remquo( _ x: ${ T} , _ y: ${ T} ) -> ( ${ T} , Int) { return MSVCRT . remquo ( x, y) }
220
+ static func _fma( _ x: ${ T} , _ y: ${ T} , _ z: ${ T} ) -> ${ T} { return MSVCRT . fma ( x, y, z) }
221
+ static func _modf( _ x: ${ T} ) -> ( ${ T} , ${ T} ) { return MSVCRT . modf ( x) }
222
+ static func _scalbn( _ x: ${ T} , _ n: Int) -> ${ T} { return MSVCRT . scalbn ( x, n) }
223
+ static func _frexp( _ x: ${ T} ) -> ( ${ T} , Int) { return MSVCRT . frexp ( x) }
224
+ static func _ilogb( _ x: ${ T} ) -> Int { return MSVCRT . ilogb ( x) }
225
+ #endif
199
226
}
200
227
201
228
MathTests . test ( " ${T} " ) {
0 commit comments