zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

getf2.zig (1375B) - 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_ppc_abi) {
     10         @export(&__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility });
     11         @export(&__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility });
     12     } else if (common.want_sparc_abi) {
     13         // These exports are handled in cmptf2.zig because gt and ge on sparc
     14         // are based on calling _Qp_cmp.
     15     }
     16     @export(&__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility });
     17     @export(&__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility });
     18 }
     19 
     20 /// "These functions return a value greater than or equal to zero if neither
     21 /// argument is NaN, and a is greater than or equal to b."
     22 fn __getf2(a: f128, b: f128) callconv(.c) i32 {
     23     return @intFromEnum(comparef.cmpf2(f128, comparef.GE, a, b));
     24 }
     25 
     26 /// "These functions return a value greater than zero if neither argument is NaN,
     27 /// and a is strictly greater than b."
     28 fn __gttf2(a: f128, b: f128) callconv(.c) i32 {
     29     return __getf2(a, b);
     30 }