Changes in uspace/lib/softfloat/comparison.c [c0c38c7c:2416085] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/softfloat/comparison.c
rc0c38c7c r2416085 34 34 */ 35 35 36 #include "sftypes.h" 36 37 #include "comparison.h" 37 38 #include "common.h" … … 438 439 } 439 440 440 #ifdef float32_t441 442 int __gtsf2(float32_t a, float32_t b)443 {444 float32_u ua;445 ua.val = a;446 447 float32_u ub;448 ub.val = b;449 450 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {451 // TODO: sigNaNs452 return -1;453 }454 455 if (is_float32_gt(ua.data, ub.data))456 return 1;457 458 return 0;459 }460 461 int __gesf2(float32_t a, float32_t b)462 {463 float32_u ua;464 ua.val = a;465 466 float32_u ub;467 ub.val = b;468 469 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {470 // TODO: sigNaNs471 return -1;472 }473 474 if (is_float32_eq(ua.data, ub.data))475 return 0;476 477 if (is_float32_gt(ua.data, ub.data))478 return 1;479 480 return -1;481 }482 483 int __ltsf2(float32_t a, float32_t b)484 {485 float32_u ua;486 ua.val = a;487 488 float32_u ub;489 ub.val = b;490 491 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {492 // TODO: sigNaNs493 return 1;494 }495 496 if (is_float32_lt(ua.data, ub.data))497 return -1;498 499 return 0;500 }501 502 int __lesf2(float32_t a, float32_t b)503 {504 float32_u ua;505 ua.val = a;506 507 float32_u ub;508 ub.val = b;509 510 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {511 // TODO: sigNaNs512 return 1;513 }514 515 if (is_float32_eq(ua.data, ub.data))516 return 0;517 518 if (is_float32_lt(ua.data, ub.data))519 return -1;520 521 return 1;522 }523 524 int __eqsf2(float32_t a, float32_t b)525 {526 float32_u ua;527 ua.val = a;528 529 float32_u ub;530 ub.val = b;531 532 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {533 // TODO: sigNaNs534 return 1;535 }536 537 return is_float32_eq(ua.data, ub.data) - 1;538 }539 540 int __nesf2(float32_t a, float32_t b)541 {542 /* Strange, but according to GCC documentation */543 return __eqsf2(a, b);544 }545 546 int __cmpsf2(float32_t a, float32_t b)547 {548 float32_u ua;549 ua.val = a;550 551 float32_u ub;552 ub.val = b;553 554 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {555 /* No special constant for unordered - maybe signaled? */556 return 1;557 }558 559 if (is_float32_eq(ua.data, ub.data))560 return 0;561 562 if (is_float32_lt(ua.data, ub.data))563 return -1;564 565 return 1;566 }567 568 int __unordsf2(float32_t a, float32_t b)569 {570 float32_u ua;571 ua.val = a;572 573 float32_u ub;574 ub.val = b;575 576 return ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data)));577 }578 579 int __aeabi_fcmpgt(float32_t a, float32_t b)580 {581 float32_u ua;582 ua.val = a;583 584 float32_u ub;585 ub.val = b;586 587 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {588 // TODO: sigNaNs589 return -1;590 }591 592 if (is_float32_gt(ua.data, ub.data))593 return 1;594 595 return 0;596 }597 598 int __aeabi_fcmplt(float32_t a, float32_t b)599 {600 float32_u ua;601 ua.val = a;602 603 float32_u ub;604 ub.val = b;605 606 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {607 // TODO: sigNaNs608 return 1;609 }610 611 if (is_float32_lt(ua.data, ub.data))612 return -1;613 614 return 0;615 }616 617 int __aeabi_fcmpge(float32_t a, float32_t b)618 {619 float32_u ua;620 ua.val = a;621 622 float32_u ub;623 ub.val = b;624 625 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {626 // TODO: sigNaNs627 return -1;628 }629 630 if (is_float32_eq(ua.data, ub.data))631 return 0;632 633 if (is_float32_gt(ua.data, ub.data))634 return 1;635 636 return -1;637 }638 639 int __aeabi_fcmpeq(float32_t a, float32_t b)640 {641 float32_u ua;642 ua.val = a;643 644 float32_u ub;645 ub.val = b;646 647 if ((is_float32_nan(ua.data)) || (is_float32_nan(ub.data))) {648 // TODO: sigNaNs649 return 1;650 }651 652 return is_float32_eq(ua.data, ub.data) - 1;653 }654 655 #endif656 657 #ifdef float64_t658 659 int __gtdf2(float64_t a, float64_t b)660 {661 float64_u ua;662 ua.val = a;663 664 float64_u ub;665 ub.val = b;666 667 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {668 // TODO: sigNaNs669 return -1;670 }671 672 if (is_float64_gt(ua.data, ub.data))673 return 1;674 675 return 0;676 }677 678 int __gedf2(float64_t a, float64_t b)679 {680 float64_u ua;681 ua.val = a;682 683 float64_u ub;684 ub.val = b;685 686 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {687 // TODO: sigNaNs688 return -1;689 }690 691 if (is_float64_eq(ua.data, ub.data))692 return 0;693 694 if (is_float64_gt(ua.data, ub.data))695 return 1;696 697 return -1;698 }699 700 int __ltdf2(float64_t a, float64_t b)701 {702 float64_u ua;703 ua.val = a;704 705 float64_u ub;706 ub.val = b;707 708 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {709 // TODO: sigNaNs710 return 1;711 }712 713 if (is_float64_lt(ua.data, ub.data))714 return -1;715 716 return 0;717 }718 719 int __ledf2(float64_t a, float64_t b)720 {721 float64_u ua;722 ua.val = a;723 724 float64_u ub;725 ub.val = b;726 727 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {728 // TODO: sigNaNs729 return 1;730 }731 732 if (is_float64_eq(ua.data, ub.data))733 return 0;734 735 if (is_float64_lt(ua.data, ub.data))736 return -1;737 738 return 1;739 }740 741 int __eqdf2(float64_t a, float64_t b)742 {743 float64_u ua;744 ua.val = a;745 746 float64_u ub;747 ub.val = b;748 749 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {750 // TODO: sigNaNs751 return 1;752 }753 754 return is_float64_eq(ua.data, ub.data) - 1;755 }756 757 int __nedf2(float64_t a, float64_t b)758 {759 /* Strange, but according to GCC documentation */760 return __eqdf2(a, b);761 }762 763 int __cmpdf2(float64_t a, float64_t b)764 {765 float64_u ua;766 ua.val = a;767 768 float64_u ub;769 ub.val = b;770 771 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {772 /* No special constant for unordered - maybe signaled? */773 return 1;774 }775 776 if (is_float64_eq(ua.data, ub.data))777 return 0;778 779 if (is_float64_lt(ua.data, ub.data))780 return -1;781 782 return 1;783 }784 785 int __unorddf2(float64_t a, float64_t b)786 {787 float64_u ua;788 ua.val = a;789 790 float64_u ub;791 ub.val = b;792 793 return ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data)));794 }795 796 int __aeabi_dcmplt(float64_t a, float64_t b)797 {798 float64_u ua;799 ua.val = a;800 801 float64_u ub;802 ub.val = b;803 804 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {805 // TODO: sigNaNs806 return 1;807 }808 809 if (is_float64_lt(ua.data, ub.data))810 return -1;811 812 return 0;813 }814 815 int __aeabi_dcmpeq(float64_t a, float64_t b)816 {817 float64_u ua;818 ua.val = a;819 820 float64_u ub;821 ub.val = b;822 823 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {824 // TODO: sigNaNs825 return 1;826 }827 828 return is_float64_eq(ua.data, ub.data) - 1;829 }830 831 int __aeabi_dcmpgt(float64_t a, float64_t b)832 {833 float64_u ua;834 ua.val = a;835 836 float64_u ub;837 ub.val = b;838 839 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {840 // TODO: sigNaNs841 return -1;842 }843 844 if (is_float64_gt(ua.data, ub.data))845 return 1;846 847 return 0;848 }849 850 int __aeabi_dcmpge(float64_t a, float64_t b)851 {852 float64_u ua;853 ua.val = a;854 855 float64_u ub;856 ub.val = b;857 858 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {859 // TODO: sigNaNs860 return -1;861 }862 863 if (is_float64_eq(ua.data, ub.data))864 return 0;865 866 if (is_float64_gt(ua.data, ub.data))867 return 1;868 869 return -1;870 }871 872 int __aeabi_dcmple(float64_t a, float64_t b)873 {874 float64_u ua;875 ua.val = a;876 877 float64_u ub;878 ub.val = b;879 880 if ((is_float64_nan(ua.data)) || (is_float64_nan(ub.data))) {881 // TODO: sigNaNs882 return 1;883 }884 885 if (is_float64_eq(ua.data, ub.data))886 return 0;887 888 if (is_float64_lt(ua.data, ub.data))889 return -1;890 891 return 1;892 }893 894 #endif895 896 #ifdef float128_t897 898 int __gttf2(float128_t a, float128_t b)899 {900 float128_u ua;901 ua.val = a;902 903 float128_u ub;904 ub.val = b;905 906 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data))) {907 // TODO: sigNaNs908 return -1;909 }910 911 if (is_float128_gt(ua.data, ub.data))912 return 1;913 914 return 0;915 }916 917 int __getf2(float128_t a, float128_t b)918 {919 float128_u ua;920 ua.val = a;921 922 float128_u ub;923 ub.val = b;924 925 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data))) {926 // TODO: sigNaNs927 return -1;928 }929 930 if (is_float128_eq(ua.data, ub.data))931 return 0;932 933 if (is_float128_gt(ua.data, ub.data))934 return 1;935 936 return -1;937 }938 939 int __lttf2(float128_t a, float128_t b)940 {941 float128_u ua;942 ua.val = a;943 944 float128_u ub;945 ub.val = b;946 947 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data))) {948 // TODO: sigNaNs949 return 1;950 }951 952 if (is_float128_lt(ua.data, ub.data))953 return -1;954 955 return 0;956 }957 958 int __letf2(float128_t a, float128_t b)959 {960 float128_u ua;961 ua.val = a;962 963 float128_u ub;964 ub.val = b;965 966 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data))) {967 // TODO: sigNaNs968 return 1;969 }970 971 if (is_float128_eq(ua.data, ub.data))972 return 0;973 974 if (is_float128_lt(ua.data, ub.data))975 return -1;976 977 return 1;978 }979 980 int __eqtf2(float128_t a, float128_t b)981 {982 float128_u ua;983 ua.val = a;984 985 float128_u ub;986 ub.val = b;987 988 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data))) {989 // TODO: sigNaNs990 return 1;991 }992 993 return is_float128_eq(ua.data, ub.data) - 1;994 }995 996 int __netf2(float128_t a, float128_t b)997 {998 /* Strange, but according to GCC documentation */999 return __eqtf2(a, b);1000 }1001 1002 int __cmptf2(float128_t a, float128_t b)1003 {1004 float128_u ua;1005 ua.val = a;1006 1007 float128_u ub;1008 ub.val = b;1009 1010 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data))) {1011 /* No special constant for unordered - maybe signaled? */1012 return 1;1013 }1014 1015 if (is_float128_eq(ua.data, ub.data))1016 return 0;1017 1018 if (is_float128_lt(ua.data, ub.data))1019 return -1;1020 1021 return 1;1022 }1023 1024 int __unordtf2(float128_t a, float128_t b)1025 {1026 float128_u ua;1027 ua.val = a;1028 1029 float128_u ub;1030 ub.val = b;1031 1032 return ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)));1033 }1034 1035 int _Qp_cmp(float128_t *a, float128_t *b)1036 {1037 float128_u ua;1038 ua.val = *a;1039 1040 float128_u ub;1041 ub.val = *b;1042 1043 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1044 return 3;1045 1046 if (is_float128_eq(ua.data, ub.data))1047 return 0;1048 1049 if (is_float128_lt(ua.data, ub.data))1050 return 1;1051 1052 return 2;1053 }1054 1055 int _Qp_cmpe(float128_t *a, float128_t *b)1056 {1057 /* Strange, but according to SPARC Compliance Definition */1058 return _Qp_cmp(a, b);1059 }1060 1061 int _Qp_fgt(float128_t *a, float128_t *b)1062 {1063 float128_u ua;1064 ua.val = *a;1065 1066 float128_u ub;1067 ub.val = *b;1068 1069 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1070 return 0;1071 1072 return is_float128_gt(ua.data, ub.data);1073 }1074 1075 int _Qp_fge(float128_t *a, float128_t *b)1076 {1077 float128_u ua;1078 ua.val = *a;1079 1080 float128_u ub;1081 ub.val = *b;1082 1083 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1084 return 0;1085 1086 return is_float128_eq(ua.data, ub.data) ||1087 is_float128_gt(ua.data, ub.data);1088 }1089 1090 int _Qp_flt(float128_t *a, float128_t *b)1091 {1092 float128_u ua;1093 ua.val = *a;1094 1095 float128_u ub;1096 ub.val = *b;1097 1098 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1099 return 0;1100 1101 return is_float128_lt(ua.data, ub.data);1102 }1103 1104 int _Qp_fle(float128_t *a, float128_t *b)1105 {1106 float128_u ua;1107 ua.val = *a;1108 1109 float128_u ub;1110 ub.val = *b;1111 1112 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1113 return 0;1114 1115 return is_float128_eq(ua.data, ub.data) ||1116 is_float128_lt(ua.data, ub.data);1117 }1118 1119 int _Qp_feq(float128_t *a, float128_t *b)1120 {1121 float128_u ua;1122 ua.val = *a;1123 1124 float128_u ub;1125 ub.val = *b;1126 1127 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1128 return 0;1129 1130 return is_float128_eq(ua.data, ub.data);1131 }1132 1133 int _Qp_fne(float128_t *a, float128_t *b)1134 {1135 float128_u ua;1136 ua.val = *a;1137 1138 float128_u ub;1139 ub.val = *b;1140 1141 if ((is_float128_nan(ua.data)) || (is_float128_nan(ub.data)))1142 return 0;1143 1144 return !is_float128_eq(ua.data, ub.data);1145 }1146 1147 #endif1148 1149 441 /** @} 1150 442 */
Note:
See TracChangeset
for help on using the changeset viewer.