diff --git a/lib/c/math.zig b/lib/c/math.zig index 281b898ac2..501df810d6 100644 --- a/lib/c/math.zig +++ b/lib/c/math.zig @@ -14,20 +14,20 @@ comptime { symbol(&isnanl, "isnanl"); symbol(&isnanl, "__isnanl"); + symbol(&math.floatTrueMin(f64), "__DENORM"); + symbol(&math.inf(f64), "__INF"); symbol(&math.nan(f64), "__QNAN"); symbol(&math.snan(f64), "__SNAN"); - symbol(&math.inf(f64), "__INF"); - symbol(&math.floatTrueMin(f64), "__DENORM"); + symbol(&math.floatTrueMin(f32), "__DENORMF"); + symbol(&math.inf(f32), "__INFF"); symbol(&math.nan(f32), "__QNANF"); symbol(&math.snan(f32), "__SNANF"); - symbol(&math.inf(f32), "__INFF"); - symbol(&math.floatTrueMin(f32), "__DENORMF"); + symbol(&math.floatTrueMin(c_longdouble), "__DENORML"); + symbol(&math.inf(c_longdouble), "__INFL"); symbol(&math.nan(c_longdouble), "__QNANL"); symbol(&math.snan(c_longdouble), "__SNANL"); - symbol(&math.inf(c_longdouble), "__INFL"); - symbol(&math.floatTrueMin(c_longdouble), "__DENORML"); } if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { @@ -41,8 +41,9 @@ comptime { if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { symbol(&acos, "acos"); - symbol(&atanf, "atanf"); + symbol(&acosf, "acosf"); symbol(&atan, "atan"); + symbol(&atanf, "atanf"); symbol(&atanl, "atanl"); symbol(&cbrt, "cbrt"); symbol(&cbrtf, "cbrtf"); @@ -53,14 +54,14 @@ comptime { symbol(&pow, "pow"); symbol(&pow10, "pow10"); symbol(&pow10f, "pow10f"); - symbol(&acosf, "acosf"); } if (builtin.target.isMuslLibC()) { - symbol(©signf, "copysignf"); symbol(©sign, "copysign"); + symbol(©signf, "copysignf"); symbol(&rint, "rint"); } + symbol(©signl, "copysignl"); } @@ -68,14 +69,18 @@ fn acos(x: f64) callconv(.c) f64 { return math.acos(x); } -fn atanf(x: f32) callconv(.c) f32 { - return math.atan(x); +fn acosf(x: f32) callconv(.c) f32 { + return std.math.acos(x); } fn atan(x: f64) callconv(.c) f64 { return math.atan(x); } +fn atanf(x: f32) callconv(.c) f32 { + return math.atan(x); +} + fn atanl(x: c_longdouble) callconv(.c) c_longdouble { return switch (@typeInfo(@TypeOf(x)).float.bits) { 16 => math.atan(@as(f16, @floatCast(x))), @@ -87,8 +92,52 @@ fn atanl(x: c_longdouble) callconv(.c) c_longdouble { }; } -fn acosf(x: f32) callconv(.c) f32 { - return std.math.acos(x); +fn cbrt(x: f64) callconv(.c) f64 { + return math.cbrt(x); +} + +fn cbrtf(x: f32) callconv(.c) f32 { + return math.cbrt(x); +} + +fn copysign(x: f64, y: f64) callconv(.c) f64 { + return math.copysign(x, y); +} + +fn copysignf(x: f32, y: f32) callconv(.c) f32 { + return math.copysign(x, y); +} + +fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { + return math.copysign(x, y); +} + +fn cosh(x: f64) callconv(.c) f64 { + return math.cosh(x); +} + +fn coshf(x: f32) callconv(.c) f32 { + return math.cosh(x); +} + +fn exp10(x: f64) callconv(.c) f64 { + return math.pow(f64, 10.0, x); +} + +fn exp10f(x: f32) callconv(.c) f32 { + return math.pow(f32, 10.0, x); +} + +fn hypot(x: f64, y: f64) callconv(.c) f64 { + return math.hypot(x, y); +} + +fn hypotf(x: f32, y: f32) callconv(.c) f32 { + return math.hypot(x, y); +} + +fn hypotl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { + return math.hypot(x, y); } fn isnan(x: f64) callconv(.c) c_int { @@ -115,54 +164,6 @@ fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble { return math.nan(c_longdouble); } -fn copysignf(x: f32, y: f32) callconv(.c) f32 { - return math.copysign(x, y); -} - -fn copysign(x: f64, y: f64) callconv(.c) f64 { - return math.copysign(x, y); -} - -fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { - return math.copysign(x, y); -} - -fn cosh(x: f64) callconv(.c) f64 { - return math.cosh(x); -} - -fn coshf(x: f32) callconv(.c) f32 { - return math.cosh(x); -} - -fn cbrt(x: f64) callconv(.c) f64 { - return math.cbrt(x); -} - -fn cbrtf(x: f32) callconv(.c) f32 { - return math.cbrt(x); -} - -fn exp10(x: f64) callconv(.c) f64 { - return math.pow(f64, 10.0, x); -} - -fn exp10f(x: f32) callconv(.c) f32 { - return math.pow(f32, 10.0, x); -} - -fn hypot(x: f64, y: f64) callconv(.c) f64 { - return math.hypot(x, y); -} - -fn hypotf(x: f32, y: f32) callconv(.c) f32 { - return math.hypot(x, y); -} - -fn hypotl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { - return math.hypot(x, y); -} - fn pow(x: f64, y: f64) callconv(.c) f64 { return math.pow(f64, x, y); }