master
 1///! The quoted behavior definitions are from
 2///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
 3const common = @import("./common.zig");
 4const comparef = @import("./comparef.zig");
 5
 6pub const panic = common.panic;
 7
 8comptime {
 9    if (common.want_aeabi) {
10        @export(&__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility });
11        @export(&__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility });
12    } else {
13        @export(&__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility });
14        @export(&__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility });
15    }
16}
17
18/// "These functions return a value greater than or equal to zero if neither
19/// argument is NaN, and a is greater than or equal to b."
20pub fn __gesf2(a: f32, b: f32) callconv(.c) i32 {
21    return @intFromEnum(comparef.cmpf2(f32, comparef.GE, a, b));
22}
23
24/// "These functions return a value greater than zero if neither argument is NaN,
25/// and a is strictly greater than b."
26pub fn __gtsf2(a: f32, b: f32) callconv(.c) i32 {
27    return __gesf2(a, b);
28}
29
30fn __aeabi_fcmpge(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
31    return @intFromBool(comparef.cmpf2(f32, comparef.GE, a, b) != .Less);
32}
33
34fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
35    return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater);
36}