authorgravatar for hi@mihaelm.commihael <hi@mihaelm.com> 2026-03-10 00:40:23+01:00
committergravatar for hi@mihaelm.commihael <hi@mihaelm.com> 2026-03-10 00:42:32+01:00
log4a0be5613b865c345e2b9daade65ee6fbb139e39
tree928f71423ba27bc9b231967f96a88353cc27fe04
parent159568a05a222681f54a27310ac15c3043563f95
signaturebadge-check Signed by SSH key SHA256:aoFoShdYLdrqMichqKXSSieTKUfACUIDJHsKc4V2tQg

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".

1 files changed, 46 insertions(+), 45 deletions(-)

lib/c/math.zig+46-45
......@@ -14,20 +14,20 @@ comptime {
1414 symbol(&isnanl, "isnanl");
1515 symbol(&isnanl, "__isnanl");
1616
17 symbol(&math.floatTrueMin(f64), "__DENORM");
18 symbol(&math.inf(f64), "__INF");
1719 symbol(&math.nan(f64), "__QNAN");
1820 symbol(&math.snan(f64), "__SNAN");
19 symbol(&math.inf(f64), "__INF");
20 symbol(&math.floatTrueMin(f64), "__DENORM");
2121
22 symbol(&math.floatTrueMin(f32), "__DENORMF");
23 symbol(&math.inf(f32), "__INFF");
2224 symbol(&math.nan(f32), "__QNANF");
2325 symbol(&math.snan(f32), "__SNANF");
24 symbol(&math.inf(f32), "__INFF");
25 symbol(&math.floatTrueMin(f32), "__DENORMF");
2626
27 symbol(&math.floatTrueMin(c_longdouble), "__DENORML");
28 symbol(&math.inf(c_longdouble), "__INFL");
2729 symbol(&math.nan(c_longdouble), "__QNANL");
2830 symbol(&math.snan(c_longdouble), "__SNANL");
29 symbol(&math.inf(c_longdouble), "__INFL");
30 symbol(&math.floatTrueMin(c_longdouble), "__DENORML");
3131 }
3232
3333 if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
......@@ -41,8 +41,9 @@ comptime {
4141
4242 if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
4343 symbol(&acos, "acos");
44 symbol(&atanf, "atanf");
44 symbol(&acosf, "acosf");
4545 symbol(&atan, "atan");
46 symbol(&atanf, "atanf");
4647 symbol(&atanl, "atanl");
4748 symbol(&cbrt, "cbrt");
4849 symbol(&cbrtf, "cbrtf");
......@@ -53,14 +54,14 @@ comptime {
5354 symbol(&pow, "pow");
5455 symbol(&pow10, "pow10");
5556 symbol(&pow10f, "pow10f");
56 symbol(&acosf, "acosf");
5757 }
5858
5959 if (builtin.target.isMuslLibC()) {
60 symbol(&copysignf, "copysignf");
6160 symbol(&copysign, "copysign");
61 symbol(&copysignf, "copysignf");
6262 symbol(&rint, "rint");
6363 }
64
6465 symbol(&copysignl, "copysignl");
6566}
6667
......@@ -68,14 +69,18 @@ fn acos(x: f64) callconv(.c) f64 {
6869 return math.acos(x);
6970}
7071
71fn atanf(x: f32) callconv(.c) f32 {
72 return math.atan(x);
72fn acosf(x: f32) callconv(.c) f32 {
73 return std.math.acos(x);
7374}
7475
7576fn atan(x: f64) callconv(.c) f64 {
7677 return math.atan(x);
7778}
7879
80fn atanf(x: f32) callconv(.c) f32 {
81 return math.atan(x);
82}
83
7984fn atanl(x: c_longdouble) callconv(.c) c_longdouble {
8085 return switch (@typeInfo(@TypeOf(x)).float.bits) {
8186 16 => math.atan(@as(f16, @floatCast(x))),
......@@ -87,39 +92,19 @@ fn atanl(x: c_longdouble) callconv(.c) c_longdouble {
8792 };
8893}
8994
90fn acosf(x: f32) callconv(.c) f32 {
91 return std.math.acos(x);
92}
93
94fn isnan(x: f64) callconv(.c) c_int {
95 return if (math.isNan(x)) 1 else 0;
96}
97
98fn isnanf(x: f32) callconv(.c) c_int {
99 return if (math.isNan(x)) 1 else 0;
100}
101
102fn isnanl(x: c_longdouble) callconv(.c) c_int {
103 return if (math.isNan(x)) 1 else 0;
104}
105
106fn nan(_: [*:0]const c_char) callconv(.c) f64 {
107 return math.nan(f64);
108}
109
110fn nanf(_: [*:0]const c_char) callconv(.c) f32 {
111 return math.nan(f32);
95fn cbrt(x: f64) callconv(.c) f64 {
96 return math.cbrt(x);
11297}
11398
114fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble {
115 return math.nan(c_longdouble);
99fn cbrtf(x: f32) callconv(.c) f32 {
100 return math.cbrt(x);
116101}
117102
118fn copysignf(x: f32, y: f32) callconv(.c) f32 {
103fn copysign(x: f64, y: f64) callconv(.c) f64 {
119104 return math.copysign(x, y);
120105}
121106
122fn copysign(x: f64, y: f64) callconv(.c) f64 {
107fn copysignf(x: f32, y: f32) callconv(.c) f32 {
123108 return math.copysign(x, y);
124109}
125110
......@@ -135,14 +120,6 @@ fn coshf(x: f32) callconv(.c) f32 {
135120 return math.cosh(x);
136121}
137122
138fn cbrt(x: f64) callconv(.c) f64 {
139 return math.cbrt(x);
140}
141
142fn cbrtf(x: f32) callconv(.c) f32 {
143 return math.cbrt(x);
144}
145
146123fn exp10(x: f64) callconv(.c) f64 {
147124 return math.pow(f64, 10.0, x);
148125}
......@@ -163,6 +140,30 @@ fn hypotl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
163140 return math.hypot(x, y);
164141}
165142
143fn isnan(x: f64) callconv(.c) c_int {
144 return if (math.isNan(x)) 1 else 0;
145}
146
147fn isnanf(x: f32) callconv(.c) c_int {
148 return if (math.isNan(x)) 1 else 0;
149}
150
151fn isnanl(x: c_longdouble) callconv(.c) c_int {
152 return if (math.isNan(x)) 1 else 0;
153}
154
155fn nan(_: [*:0]const c_char) callconv(.c) f64 {
156 return math.nan(f64);
157}
158
159fn nanf(_: [*:0]const c_char) callconv(.c) f32 {
160 return math.nan(f32);
161}
162
163fn nanl(_: [*:0]const c_char) callconv(.c) c_longdouble {
164 return math.nan(c_longdouble);
165}
166
166167fn pow(x: f64, y: f64) callconv(.c) f64 {
167168 return math.pow(f64, x, y);
168169}