gedf2.zig (1567B) - Raw
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 3 const common = @import("./common.zig"); 4 const comparef = @import("./comparef.zig"); 5 6 pub const panic = common.panic; 7 8 comptime { 9 if (common.want_aeabi) { 10 @export(&__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility }); 11 @export(&__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility }); 12 } else { 13 @export(&__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility }); 14 @export(&__gtdf2, .{ .name = "__gtdf2", .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." 20 pub fn __gedf2(a: f64, b: f64) callconv(.c) i32 { 21 return @intFromEnum(comparef.cmpf2(f64, 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." 26 pub fn __gtdf2(a: f64, b: f64) callconv(.c) i32 { 27 return __gedf2(a, b); 28 } 29 30 fn __aeabi_dcmpge(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 { 31 return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) != .Less); 32 } 33 34 fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 { 35 return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater); 36 }