authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-06 21:48:10+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-05-07 11:47:23+02:00
log4ab7b459dfea45d1dbdfe301eeb840eaa796a4e7
treea819728e67d238a91a09f4e3a579a469be05f2af
parent94b504c9e41c84825708701a2bf7a3cc7bdca375

Avoid endless recursion in __extendhfsf2

On some platforms the conversion ended up creating a dangerous recursive loop that ate all the stack. The conversion to f16 is also pointless since we're operating on the raw bits anyway.

1 files changed, 4 insertions(+), 4 deletions(-)

std/special/compiler_rt/extendXfYf2.zig+4-4
......@@ -3,20 +3,20 @@ const builtin = @import("builtin");
33const is_test = builtin.is_test;
44
55pub extern fn __extenddftf2(a: f64) f128 {
6 return extendXfYf2(f128, f64, a);
6 return extendXfYf2(f128, f64, @bitCast(u64, a));
77}
88
99pub extern fn __extendsftf2(a: f32) f128 {
10 return extendXfYf2(f128, f32, a);
10 return extendXfYf2(f128, f32, @bitCast(u32, a));
1111}
1212
1313pub extern fn __extendhfsf2(a: u16) f32 {
14 return extendXfYf2(f32, f16, @bitCast(f16, a));
14 return extendXfYf2(f32, f16, a);
1515}
1616
1717const CHAR_BIT = 8;
1818
19inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
19inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
2020 const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
2121 const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
2222 const srcSigBits = std.math.floatMantissaBits(src_t);