ots_cmpe.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Software floating-point emulation: comparison.
  2. Copyright (C) 1997-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include "local-soft-fp.h"
  16. static long
  17. internal_compare (long al, long ah, long bl, long bh)
  18. {
  19. FP_DECL_EX;
  20. FP_DECL_Q(A); FP_DECL_Q(B);
  21. long r;
  22. AXP_UNPACK_RAW_Q(A, a);
  23. AXP_UNPACK_RAW_Q(B, b);
  24. FP_CMP_Q (r, A, B, 2, 2);
  25. FP_HANDLE_EXCEPTIONS;
  26. return r;
  27. }
  28. long
  29. _OtsLssX (long al, long ah, long bl, long bh)
  30. {
  31. long r = internal_compare (al, ah, bl, bh);
  32. if (r == 2)
  33. return -1;
  34. else
  35. return r < 0;
  36. }
  37. long
  38. _OtsLeqX (long al, long ah, long bl, long bh)
  39. {
  40. long r = internal_compare (al, ah, bl, bh);
  41. if (r == 2)
  42. return -1;
  43. else
  44. return r <= 0;
  45. }
  46. long
  47. _OtsGtrX (long al, long ah, long bl, long bh)
  48. {
  49. long r = internal_compare (al, ah, bl, bh);
  50. if (r == 2)
  51. return -1;
  52. else
  53. return r > 0;
  54. }
  55. long
  56. _OtsGeqX (long al, long ah, long bl, long bh)
  57. {
  58. long r = internal_compare (al, ah, bl, bh);
  59. if (r == 2)
  60. return -1;
  61. else
  62. return r >= 0;
  63. }