| author | |
| committer | |
| log | bea4ea5ff89ca1e9c517b3c4b00934931d280c57 |
| tree | eef503841dbba65fe92a43d2102897cb89aa31ed |
| parent | 0177cb57c03d0e10b4d0ef6a11ebf16de3dfd2b5 |
| parent | f564a7733cb20395a399caea21aac6fa54af50b3 |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31775
Reviewed-by: Andrew Kelley <andrew@ziglang.org>22 files changed, 36 insertions(+), 57 deletions(-)
lib/c/math.zig+28-17| ... | ... | @@ -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 { |
lib/compiler_rt/cos.zig-2| ... | ... | @@ -173,8 +173,6 @@ pub fn cosq(x: f128) callconv(.c) f128 { |
| 173 | 173 | |
| 174 | 174 | pub fn cosl(x: c_longdouble) callconv(.c) c_longdouble { |
| 175 | 175 | switch (@typeInfo(c_longdouble).float.bits) { |
| 176 | 16 => return cosh(x), | |
| 177 | 32 => return cosf(x), | |
| 178 | 176 | 64 => return cos(x), |
| 179 | 177 | 80 => return cosx(x), |
| 180 | 178 | 128 => return cosq(x), |
lib/compiler_rt/exp.zig-2| ... | ... | @@ -198,8 +198,6 @@ const expq = @import("exp_f128.zig").exp; |
| 198 | 198 | |
| 199 | 199 | pub fn expl(x: c_longdouble) callconv(.c) c_longdouble { |
| 200 | 200 | switch (@typeInfo(c_longdouble).float.bits) { |
| 201 | 16 => return __exph(x), | |
| 202 | 32 => return expf(x), | |
| 203 | 201 | 64 => return exp(x), |
| 204 | 202 | 80 => return __expx(x), |
| 205 | 203 | 128 => return expq(x), |
lib/compiler_rt/exp2.zig-2| ... | ... | @@ -165,8 +165,6 @@ pub const exp2q = @import("exp_f128.zig").exp2; |
| 165 | 165 | |
| 166 | 166 | pub fn exp2l(x: c_longdouble) callconv(.c) c_longdouble { |
| 167 | 167 | switch (@typeInfo(c_longdouble).float.bits) { |
| 168 | 16 => return __exp2h(x), | |
| 169 | 32 => return exp2f(x), | |
| 170 | 168 | 64 => return exp2(x), |
| 171 | 169 | 80 => return __exp2x(x), |
| 172 | 170 | 128 => return exp2q(x), |
lib/compiler_rt/fabs.zig-2| ... | ... | @@ -38,8 +38,6 @@ pub fn fabsq(a: f128) callconv(.c) f128 { |
| 38 | 38 | |
| 39 | 39 | pub fn fabsl(x: c_longdouble) callconv(.c) c_longdouble { |
| 40 | 40 | switch (@typeInfo(c_longdouble).float.bits) { |
| 41 | 16 => return __fabsh(x), | |
| 42 | 32 => return fabsf(x), | |
| 43 | 41 | 64 => return fabs(x), |
| 44 | 42 | 80 => return __fabsx(x), |
| 45 | 43 | 128 => return fabsq(x), |
lib/compiler_rt/fma.zig-2| ... | ... | @@ -151,8 +151,6 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.c) f128 { |
| 151 | 151 | |
| 152 | 152 | pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.c) c_longdouble { |
| 153 | 153 | switch (@typeInfo(c_longdouble).float.bits) { |
| 154 | 16 => return __fmah(x, y, z), | |
| 155 | 32 => return fmaf(x, y, z), | |
| 156 | 154 | 64 => return fma(x, y, z), |
| 157 | 155 | 80 => return __fmax(x, y, z), |
| 158 | 156 | 128 => return fmaq(x, y, z), |
lib/compiler_rt/fmax.zig-2| ... | ... | @@ -39,8 +39,6 @@ pub fn fmaxq(x: f128, y: f128) callconv(.c) f128 { |
| 39 | 39 | |
| 40 | 40 | pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { |
| 41 | 41 | switch (@typeInfo(c_longdouble).float.bits) { |
| 42 | 16 => return __fmaxh(x, y), | |
| 43 | 32 => return fmaxf(x, y), | |
| 44 | 42 | 64 => return fmax(x, y), |
| 45 | 43 | 80 => return __fmaxx(x, y), |
| 46 | 44 | 128 => return fmaxq(x, y), |
lib/compiler_rt/fmin.zig-2| ... | ... | @@ -39,8 +39,6 @@ pub fn fminq(x: f128, y: f128) callconv(.c) f128 { |
| 39 | 39 | |
| 40 | 40 | pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble { |
| 41 | 41 | switch (@typeInfo(c_longdouble).float.bits) { |
| 42 | 16 => return __fminh(x, y), | |
| 43 | 32 => return fminf(x, y), | |
| 44 | 42 | 64 => return fmin(x, y), |
| 45 | 43 | 80 => return __fminx(x, y), |
| 46 | 44 | 128 => return fminq(x, y), |
lib/compiler_rt/fmod.zig-2| ... | ... | @@ -251,8 +251,6 @@ pub fn fmodq(a: f128, b: f128) callconv(.c) f128 { |
| 251 | 251 | |
| 252 | 252 | pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.c) c_longdouble { |
| 253 | 253 | switch (@typeInfo(c_longdouble).float.bits) { |
| 254 | 16 => return __fmodh(a, b), | |
| 255 | 32 => return fmodf(a, b), | |
| 256 | 254 | 64 => return fmod(a, b), |
| 257 | 255 | 80 => return __fmodx(a, b), |
| 258 | 256 | 128 => return fmodq(a, b), |
lib/compiler_rt/log.zig-2| ... | ... | @@ -443,8 +443,6 @@ pub fn logq(a: f128) callconv(.c) f128 { |
| 443 | 443 | |
| 444 | 444 | pub fn logl(x: c_longdouble) callconv(.c) c_longdouble { |
| 445 | 445 | switch (@typeInfo(c_longdouble).float.bits) { |
| 446 | 16 => return __logh(x), | |
| 447 | 32 => return logf(x), | |
| 448 | 446 | 64 => return log(x), |
| 449 | 447 | 80 => return __logx(x), |
| 450 | 448 | 128 => return logq(x), |
lib/compiler_rt/log10.zig-2| ... | ... | @@ -177,8 +177,6 @@ pub fn log10q(a: f128) callconv(.c) f128 { |
| 177 | 177 | |
| 178 | 178 | pub fn log10l(x: c_longdouble) callconv(.c) c_longdouble { |
| 179 | 179 | switch (@typeInfo(c_longdouble).float.bits) { |
| 180 | 16 => return __log10h(x), | |
| 181 | 32 => return log10f(x), | |
| 182 | 180 | 64 => return log10(x), |
| 183 | 181 | 80 => return __log10x(x), |
| 184 | 182 | 128 => return log10q(x), |
lib/compiler_rt/log2.zig-2| ... | ... | @@ -170,8 +170,6 @@ pub fn log2q(a: f128) callconv(.c) f128 { |
| 170 | 170 | |
| 171 | 171 | pub fn log2l(x: c_longdouble) callconv(.c) c_longdouble { |
| 172 | 172 | switch (@typeInfo(c_longdouble).float.bits) { |
| 173 | 16 => return __log2h(x), | |
| 174 | 32 => return log2f(x), | |
| 175 | 173 | 64 => return log2(x), |
| 176 | 174 | 80 => return __log2x(x), |
| 177 | 175 | 128 => return log2q(x), |
lib/compiler_rt/round.zig-2| ... | ... | @@ -142,8 +142,6 @@ pub fn roundq(x_: f128) callconv(.c) f128 { |
| 142 | 142 | |
| 143 | 143 | pub fn roundl(x: c_longdouble) callconv(.c) c_longdouble { |
| 144 | 144 | switch (@typeInfo(c_longdouble).float.bits) { |
| 145 | 16 => return __roundh(x), | |
| 146 | 32 => return roundf(x), | |
| 147 | 145 | 64 => return round(x), |
| 148 | 146 | 80 => return __roundx(x), |
| 149 | 147 | 128 => return roundq(x), |
lib/compiler_rt/sin.zig-2| ... | ... | @@ -189,8 +189,6 @@ pub fn sinq(x: f128) callconv(.c) f128 { |
| 189 | 189 | |
| 190 | 190 | pub fn sinl(x: c_longdouble) callconv(.c) c_longdouble { |
| 191 | 191 | switch (@typeInfo(c_longdouble).float.bits) { |
| 192 | 16 => return sinh(x), | |
| 193 | 32 => return sinf(x), | |
| 194 | 192 | 64 => return sin(x), |
| 195 | 193 | 80 => return sinx(x), |
| 196 | 194 | 128 => return sinq(x), |
lib/compiler_rt/sincos.zig-2| ... | ... | @@ -292,8 +292,6 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.c) void { |
| 292 | 292 | |
| 293 | 293 | pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.c) void { |
| 294 | 294 | switch (@typeInfo(c_longdouble).float.bits) { |
| 295 | 16 => return sincosh(x, r_sin, r_cos), | |
| 296 | 32 => return sincosf(x, r_sin, r_cos), | |
| 297 | 295 | 64 => return sincos(x, r_sin, r_cos), |
| 298 | 296 | 80 => return sincosx(x, r_sin, r_cos), |
| 299 | 297 | 128 => return sincosq(x, r_sin, r_cos), |
lib/compiler_rt/sqrt.zig-2| ... | ... | @@ -481,8 +481,6 @@ fn _Qp_sqrt(c: *f128, a: *f128) callconv(.c) void { |
| 481 | 481 | |
| 482 | 482 | pub fn sqrtl(x: c_longdouble) callconv(.c) c_longdouble { |
| 483 | 483 | switch (@typeInfo(c_longdouble).float.bits) { |
| 484 | 16 => return __sqrth(x), | |
| 485 | 32 => return sqrtf(x), | |
| 486 | 484 | 64 => return sqrt(x), |
| 487 | 485 | 80 => return __sqrtx(x), |
| 488 | 486 | 128 => return sqrtq(x), |
lib/compiler_rt/tan.zig-2| ... | ... | @@ -164,8 +164,6 @@ pub fn tanq(x: f128) callconv(.c) f128 { |
| 164 | 164 | |
| 165 | 165 | pub fn tanl(x: c_longdouble) callconv(.c) c_longdouble { |
| 166 | 166 | switch (@typeInfo(c_longdouble).float.bits) { |
| 167 | 16 => return tanh(x), | |
| 168 | 32 => return tanf(x), | |
| 169 | 167 | 64 => return tan(x), |
| 170 | 168 | 80 => return tanx(x), |
| 171 | 169 | 128 => return tanq(x), |
lib/compiler_rt/trunc.zig-2| ... | ... | @@ -99,8 +99,6 @@ pub fn truncq(x: f128) callconv(.c) f128 { |
| 99 | 99 | |
| 100 | 100 | pub fn truncl(x: c_longdouble) callconv(.c) c_longdouble { |
| 101 | 101 | switch (@typeInfo(c_longdouble).float.bits) { |
| 102 | 16 => return __trunch(x), | |
| 103 | 32 => return truncf(x), | |
| 104 | 102 | 64 => return trunc(x), |
| 105 | 103 | 80 => return __truncx(x), |
| 106 | 104 | 128 => return truncq(x), |
lib/std/Target.zig-2| ... | ... | @@ -3082,8 +3082,6 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 { |
| 3082 | 3082 | => @divExact(cTypeBitSize(t, c_type), 8), |
| 3083 | 3083 | |
| 3084 | 3084 | .longdouble => switch (cTypeBitSize(t, c_type)) { |
| 3085 | 16 => 2, | |
| 3086 | 32 => 4, | |
| 3087 | 3085 | 64 => 8, |
| 3088 | 3086 | 80 => @intCast(std.mem.alignForward(usize, 10, cTypeAlignment(t, .longdouble))), |
| 3089 | 3087 | 128 => 16, |
lib/std/c.zig+8| ... | ... | @@ -11102,6 +11102,14 @@ pub const ioctl = switch (native_os) { |
| 11102 | 11102 | else => private.ioctl, |
| 11103 | 11103 | }; |
| 11104 | 11104 | |
| 11105 | // Math | |
| 11106 | pub extern "c" fn atan(x: f64) callconv(.c) f64; | |
| 11107 | pub extern "c" fn copysign(x: f64, y: f64) callconv(.c) f64; | |
| 11108 | pub extern "c" fn fdim(x: f64, y: f64) callconv(.c) f64; | |
| 11109 | pub extern "c" fn frexp(x: f64, e: *c_int) callconv(.c) f64; | |
| 11110 | pub extern "c" fn hypot(x: f64, y: f64) callconv(.c) f64; | |
| 11111 | pub extern "c" fn modf(x: f64, iptr: *f64) callconv(.c) f64; | |
| 11112 | ||
| 11105 | 11113 | // OS-specific bits. These are protected from being used on the wrong OS by |
| 11106 | 11114 | // comptime assertions inside each OS-specific file. |
| 11107 | 11115 |
src/codegen/aarch64/Select.zig-2| ... | ... | @@ -12381,8 +12381,6 @@ pub const CallAbiIterator = struct { |
| 12381 | 12381 | .f128 => .quad, |
| 12382 | 12382 | .c_longdouble => switch (zcu.getTarget().cTypeBitSize(.longdouble)) { |
| 12383 | 12383 | else => unreachable, |
| 12384 | 16 => .half, | |
| 12385 | 32 => .single, | |
| 12386 | 12384 | 64 => .double, |
| 12387 | 12385 | 80 => null, |
| 12388 | 12386 | 128 => .quad, |
test/behavior/cast.zig-2| ... | ... | @@ -1838,8 +1838,6 @@ test "coerce between pointers of compatible differently-named floats" { |
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | const F = switch (@typeInfo(c_longdouble).float.bits) { |
| 1841 | 16 => f16, | |
| 1842 | 32 => f32, | |
| 1843 | 1841 | 64 => f64, |
| 1844 | 1842 | 80 => f80, |
| 1845 | 1843 | 128 => f128, |