mirror of
https://github.com/ziglang/zig.git
synced 2025-12-29 01:23:17 +00:00
This is a partial revert of 0d533433e21621177fb291e2a4901bee11834501, which regressed this behavior. The idea here is to avoid aliases, which happens when the same function is exported with multiple names. The problem with aliases is that weak aliases don't seem to work, causing symbol collisions when multiple of the same symbol are provided, despite the desired behavior that weak symbols are overridden. In this case we export redundant functions with different names. Thanks to -ffunction-sections, the unused functions will be garbage-collected at link time. This leaves us with the best of both worlds: Zig's compiler-rt will provide both sets of symbols, and it will be binary-compatible with different compilers that expect different names, while still resulting in binaries without garbage.
26 lines
778 B
Zig
26 lines
778 B
Zig
const common = @import("./common.zig");
|
|
const extendf = @import("./extendf.zig").extendf;
|
|
|
|
pub const panic = common.panic;
|
|
|
|
comptime {
|
|
if (common.gnu_f16_abi) {
|
|
@export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage });
|
|
} else if (common.want_aeabi) {
|
|
@export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage });
|
|
}
|
|
@export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage });
|
|
}
|
|
|
|
pub fn __extendhfsf2(a: common.F16T) callconv(.C) f32 {
|
|
return extendf(f32, f16, @bitCast(u16, a));
|
|
}
|
|
|
|
fn __gnu_h2f_ieee(a: common.F16T) callconv(.C) f32 {
|
|
return extendf(f32, f16, @bitCast(u16, a));
|
|
}
|
|
|
|
fn __aeabi_h2f(a: u16) callconv(.AAPCS) f32 {
|
|
return extendf(f32, f16, @bitCast(u16, a));
|
|
}
|