Skip to content

Commit

Permalink
fix getFloat on other other targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexicon226 committed Jan 14, 2025
1 parent f33fde9 commit 77a20c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ubsan_rt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ const Value = extern struct {
};
}

fn getFloat(value: Value) c_longdouble {
fn getFloat(value: Value) f128 {
assert(value.td.kind == .float);
const size = value.td.info.float;
const max_inline_size = @bitSizeOf(ValueHandle);
if (size <= max_inline_size) {
return @bitCast(@intFromPtr(value.handle));
return @as(switch (@sizeOf(usize)) {
32 => f32,
64 => f64,
else => @compileError("unsupported target"),
}, @bitCast(@intFromPtr(value.handle)));
}
return @floatCast(switch (size) {
64 => @as(*const f64, @alignCast(@ptrCast(value.handle))).*,
Expand Down

0 comments on commit 77a20c1

Please sign in to comment.