mirror of
https://github.com/ziglang/zig.git
synced 2026-01-26 01:05:22 +00:00
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.
This commit is contained in:
parent
94b504c9e4
commit
4ab7b459df
@ -3,20 +3,20 @@ const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
pub extern fn __extenddftf2(a: f64) f128 {
|
||||
return extendXfYf2(f128, f64, a);
|
||||
return extendXfYf2(f128, f64, @bitCast(u64, a));
|
||||
}
|
||||
|
||||
pub extern fn __extendsftf2(a: f32) f128 {
|
||||
return extendXfYf2(f128, f32, a);
|
||||
return extendXfYf2(f128, f32, @bitCast(u32, a));
|
||||
}
|
||||
|
||||
pub extern fn __extendhfsf2(a: u16) f32 {
|
||||
return extendXfYf2(f32, f16, @bitCast(f16, a));
|
||||
return extendXfYf2(f32, f16, a);
|
||||
}
|
||||
|
||||
const CHAR_BIT = 8;
|
||||
|
||||
inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
|
||||
inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
|
||||
const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
|
||||
const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
|
||||
const srcSigBits = std.math.floatMantissaBits(src_t);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user