| ... | ... | @@ -116,13 +116,9 @@ fn atanf(x: f32) callconv(.c) f32 { |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | fn atanl(x: c_longdouble) callconv(.c) c_longdouble { |
| 119 | | return switch (@typeInfo(@TypeOf(x)).float.bits) { |
| 120 | | 16 => math.atan(@as(f16, @floatCast(x))), |
| 121 | | 32 => math.atan(@as(f32, @floatCast(x))), |
| 122 | | 64 => math.atan(@as(f64, @floatCast(x))), |
| 123 | | 80 => math.atan(@as(f80, @floatCast(x))), |
| 124 | | 128 => math.atan(@as(f128, @floatCast(x))), |
| 125 | | else => unreachable, |
| 119 | return switch (@typeInfo(c_longdouble).float.bits) { |
| 120 | 64 => std.c.atan(x), |
| 121 | else => math.atan(x), |
| 126 | 122 | }; |
| 127 | 123 | } |
| 128 | 124 | |
| ... | ... | @@ -143,7 +139,10 @@ fn copysignf(x: f32, y: f32) callconv(.c) f32 { |
| 143 | 139 | } |
| 144 | 140 | |
| 145 | 141 | fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { |
| 146 | | return math.copysign(x, y); |
| 142 | return switch (@typeInfo(c_longdouble).float.bits) { |
| 143 | 64 => std.c.copysign(x, y), |
| 144 | else => math.copysign(x, y), |
| 145 | }; |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | 148 | fn cosh(x: f64) callconv(.c) f64 { |
| ... | ... | @@ -183,15 +182,18 @@ fn fdimf(x: f32, y: f32) callconv(.c) f32 { |
| 183 | 182 | } |
| 184 | 183 | |
| 185 | 184 | fn fdiml(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { |
| 186 | | return fdimGeneric(c_longdouble, x, y); |
| 185 | return switch (@typeInfo(c_longdouble).float.bits) { |
| 186 | 64 => std.c.fdim(x, y), |
| 187 | else => fdimGeneric(c_longdouble, x, y), |
| 188 | }; |
| 187 | 189 | } |
| 188 | 190 | |
| 189 | 191 | fn finite(x: f64) callconv(.c) c_int { |
| 190 | | return if (math.isFinite(x)) 1 else 0; |
| 192 | return @intFromBool(math.isFinite(x)); |
| 191 | 193 | } |
| 192 | 194 | |
| 193 | 195 | fn finitef(x: f32) callconv(.c) c_int { |
| 194 | | return if (math.isFinite(x)) 1 else 0; |
| 196 | return @intFromBool(math.isFinite(x)); |
| 195 | 197 | } |
| 196 | 198 | |
| 197 | 199 | fn frexpGeneric(comptime T: type, x: T, e: *c_int) T { |
| ... | ... | @@ -222,7 +224,10 @@ fn frexpf(x: f32, e: *c_int) callconv(.c) f32 { |
| 222 | 224 | } |
| 223 | 225 | |
| 224 | 226 | fn frexpl(x: c_longdouble, e: *c_int) callconv(.c) c_longdouble { |
| 225 | | return frexpGeneric(c_longdouble, x, e); |
| 227 | return switch (@typeInfo(c_longdouble).float.bits) { |
| 228 | 64 => std.c.frexp(x, e), |
| 229 | else => frexpGeneric(c_longdouble, x, e), |
| 230 | }; |
| 226 | 231 | } |
| 227 | 232 | |
| 228 | 233 | fn hypot(x: f64, y: f64) callconv(.c) f64 { |
| ... | ... | @@ -234,19 +239,22 @@ fn hypotf(x: f32, y: f32) callconv(.c) f32 { |
| 234 | 239 | } |
| 235 | 240 | |
| 236 | 241 | fn hypotl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { |
| 237 | | return math.hypot(x, y); |
| 242 | return switch (@typeInfo(c_longdouble).float.bits) { |
| 243 | 64 => std.c.hypot(x, y), |
| 244 | else => math.hypot(x, y), |
| 245 | }; |
| 238 | 246 | } |
| 239 | 247 | |
| 240 | 248 | fn isnan(x: f64) callconv(.c) c_int { |
| 241 | | return if (math.isNan(x)) 1 else 0; |
| 249 | return @intFromBool(math.isNan(x)); |
| 242 | 250 | } |
| 243 | 251 | |
| 244 | 252 | fn isnanf(x: f32) callconv(.c) c_int { |
| 245 | | return if (math.isNan(x)) 1 else 0; |
| 253 | return @intFromBool(math.isNan(x)); |
| 246 | 254 | } |
| 247 | 255 | |
| 248 | 256 | fn isnanl(x: c_longdouble) callconv(.c) c_int { |
| 249 | | return if (math.isNan(x)) 1 else 0; |
| 257 | return @intFromBool(math.isNan(x)); |
| 250 | 258 | } |
| 251 | 259 | |
| 252 | 260 | fn lrint(x: f64) callconv(.c) c_long { |
| ... | ... | @@ -290,7 +298,10 @@ fn modff(x: f32, iptr: *f32) callconv(.c) f32 { |
| 290 | 298 | } |
| 291 | 299 | |
| 292 | 300 | fn modfl(x: c_longdouble, iptr: *c_longdouble) callconv(.c) c_longdouble { |
| 293 | | return modfGeneric(c_longdouble, x, iptr); |
| 301 | return switch (@typeInfo(c_longdouble).float.bits) { |
| 302 | 64 => std.c.modf(x, iptr), |
| 303 | else => modfGeneric(c_longdouble, x, iptr), |
| 304 | }; |
| 294 | 305 | } |
| 295 | 306 | |
| 296 | 307 | fn testModf(comptime T: type) !void { |