@@ -171,7 +171,6 @@ internal extension TGMath {
171171}
172172
173173% for T in [ 'Float', 'Double', 'CGFloat', 'Float80 '] :
174- % Module = 'CoreGraphics' if T == 'CGFloat' else 'Darwin'
175174
176175% if T == 'Float80 ':
177176#if (arch(i386) || arch(x86_64)) && !os(Windows)
@@ -181,6 +180,8 @@ internal extension TGMath {
181180% end
182181
183182extension ${ T} : TGMath {
183+ #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
184+ % Module = 'CoreGraphics' if T == 'CGFloat' else 'Darwin'
184185% for f in unary:
185186 static func _${ f} ( _ x: ${ T} ) - > ${ T} { return ${ Module} . ${ f} ( x) }
186187% end
@@ -189,13 +190,39 @@ extension ${T}: TGMath {
189190% end
190191 static func _remquo( _ x: ${ T} , _ y: ${ T} ) -> ( ${ T} , Int) { return ${ Module} . remquo ( x, y) }
191192 static func _fma( _ x: ${ T} , _ y: ${ T} , _ z: ${ T} ) -> ${ T} { return ${ Module} . fma ( x, y, z) }
192- #if !os(Windows)
193193 static func _lgamma( _ x: ${ T} ) -> ( ${ T} , Int) { return ${ Module} . lgamma ( x) }
194- #endif
195194 static func _modf( _ x: ${ T} ) -> ( ${ T} , ${ T} ) { return ${ Module} . modf ( x) }
196195 static func _scalbn( _ x: ${ T} , _ n: Int) -> ${ T} { return ${ Module} . scalbn ( x, n) }
197196 static func _frexp( _ x: ${ T} ) -> ( ${ T} , Int) { return ${ Module} . frexp ( x) }
198197 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
199226}
200227
201228MathTests . test ( " ${T} " ) {
0 commit comments