zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 4a0be5613b865c345e2b9daade65ee6fbb139e39 (tree)
parent 159568a05a222681f54a27310ac15c3043563f95
Author: mihael <hi@mihaelm.com>
Date:   Tue, 10 Mar 2026 00:40:23 +0100

Alphabetically sort functions in `libzigc/math`

The functions were sorted alphabetically for easier navigation, and less
confusion where to add a new one. The sorting of comptime exports was
done within the visual "blocks".

Diffstat:
Mlib/c/math.zig | 91++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 46 insertions(+), 45 deletions(-)

diff --git 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(&copysignf, "copysignf"); symbol(&copysign, "copysign"); + symbol(&copysignf, "copysignf"); symbol(&rint, "rint"); } + symbol(&copysignl, "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,39 +92,19 @@ fn atanl(x: c_longdouble) callconv(.c) c_longdouble { }; } -fn acosf(x: f32) callconv(.c) f32 { - return std.math.acos(x); -} - -fn isnan(x: f64) callconv(.c) c_int { - return if (math.isNan(x)) 1 else 0; -} - -fn isnanf(x: f32) callconv(.c) c_int { - return if (math.isNan(x)) 1 else 0; -} - -fn isnanl(x: c_longdouble) callconv(.c) c_int { - return if (math.isNan(x)) 1 else 0; -} - -fn nan(_: [*:0]const c_char) callconv(.c) f64 { - return math.nan(f64); -} - -fn nanf(_: [*:0]const c_char) callconv(.c) f32 { - return math.nan(f32); +fn cbrt(x: f64) callconv(.c) f64 { + return math.cbrt(x); } -fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble { - return math.nan(c_longdouble); +fn cbrtf(x: f32) callconv(.c) f32 { + return math.cbrt(x); } -fn copysignf(x: f32, y: f32) callconv(.c) f32 { +fn copysign(x: f64, y: f64) callconv(.c) f64 { return math.copysign(x, y); } -fn copysign(x: f64, y: f64) callconv(.c) f64 { +fn copysignf(x: f32, y: f32) callconv(.c) f32 { return math.copysign(x, y); } @@ -135,14 +120,6 @@ 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); } @@ -163,6 +140,30 @@ 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 { + return if (math.isNan(x)) 1 else 0; +} + +fn isnanf(x: f32) callconv(.c) c_int { + return if (math.isNan(x)) 1 else 0; +} + +fn isnanl(x: c_longdouble) callconv(.c) c_int { + return if (math.isNan(x)) 1 else 0; +} + +fn nan(_: [*:0]const c_char) callconv(.c) f64 { + return math.nan(f64); +} + +fn nanf(_: [*:0]const c_char) callconv(.c) f32 { + return math.nan(f32); +} + +fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble { + return math.nan(c_longdouble); +} + fn pow(x: f64, y: f64) callconv(.c) f64 { return math.pow(f64, x, y); }