1 //===-- umodsi3_test.c - Test __umodsi3 -----------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file tests __umodsi3 for the compiler_rt library. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "int_lib.h" 15 #include <stdio.h> 16 17 // Returns: a % b 18 19 COMPILER_RT_ABI su_int __umodsi3(su_int a, su_int b); 20 21 int test__umodsi3(su_int a, su_int b, su_int expected_r) 22 { 23 su_int r = __umodsi3(a, b); 24 if (r != expected_r) 25 printf("error in __umodsi3: %X %% %X = %X, expected %X\n", 26 a, b, r, expected_r); 27 return r != expected_r; 28 } 29 30 su_int tests[][4] = 31 { 32 {0x00000000, 0x00000001, 0x00000000}, 33 {0x00000000, 0x00000002, 0x00000000}, 34 {0x00000000, 0x00000003, 0x00000000}, 35 {0x00000000, 0x00000010, 0x00000000}, 36 {0x00000000, 0x078644FA, 0x00000000}, 37 {0x00000000, 0x0747AE14, 0x00000000}, 38 {0x00000000, 0x7FFFFFFF, 0x00000000}, 39 {0x00000000, 0x80000000, 0x00000000}, 40 {0x00000000, 0xFFFFFFFD, 0x00000000}, 41 {0x00000000, 0xFFFFFFFE, 0x00000000}, 42 {0x00000000, 0xFFFFFFFF, 0x00000000}, 43 {0x00000001, 0x00000001, 0x00000000}, 44 {0x00000001, 0x00000002, 0x00000001}, 45 {0x00000001, 0x00000003, 0x00000001}, 46 {0x00000001, 0x00000010, 0x00000001}, 47 {0x00000001, 0x078644FA, 0x00000001}, 48 {0x00000001, 0x0747AE14, 0x00000001}, 49 {0x00000001, 0x7FFFFFFF, 0x00000001}, 50 {0x00000001, 0x80000000, 0x00000001}, 51 {0x00000001, 0xFFFFFFFD, 0x00000001}, 52 {0x00000001, 0xFFFFFFFE, 0x00000001}, 53 {0x00000001, 0xFFFFFFFF, 0x00000001}, 54 {0x00000002, 0x00000001, 0x00000000}, 55 {0x00000002, 0x00000002, 0x00000000}, 56 {0x00000002, 0x00000003, 0x00000002}, 57 {0x00000002, 0x00000010, 0x00000002}, 58 {0x00000002, 0x078644FA, 0x00000002}, 59 {0x00000002, 0x0747AE14, 0x00000002}, 60 {0x00000002, 0x7FFFFFFF, 0x00000002}, 61 {0x00000002, 0x80000000, 0x00000002}, 62 {0x00000002, 0xFFFFFFFD, 0x00000002}, 63 {0x00000002, 0xFFFFFFFE, 0x00000002}, 64 {0x00000002, 0xFFFFFFFF, 0x00000002}, 65 {0x00000003, 0x00000001, 0x00000000}, 66 {0x00000003, 0x00000002, 0x00000001}, 67 {0x00000003, 0x00000003, 0x00000000}, 68 {0x00000003, 0x00000010, 0x00000003}, 69 {0x00000003, 0x078644FA, 0x00000003}, 70 {0x00000003, 0x0747AE14, 0x00000003}, 71 {0x00000003, 0x7FFFFFFF, 0x00000003}, 72 {0x00000003, 0x80000000, 0x00000003}, 73 {0x00000003, 0xFFFFFFFD, 0x00000003}, 74 {0x00000003, 0xFFFFFFFE, 0x00000003}, 75 {0x00000003, 0xFFFFFFFF, 0x00000003}, 76 {0x00000010, 0x00000001, 0x00000000}, 77 {0x00000010, 0x00000002, 0x00000000}, 78 {0x00000010, 0x00000003, 0x00000001}, 79 {0x00000010, 0x00000010, 0x00000000}, 80 {0x00000010, 0x078644FA, 0x00000010}, 81 {0x00000010, 0x0747AE14, 0x00000010}, 82 {0x00000010, 0x7FFFFFFF, 0x00000010}, 83 {0x00000010, 0x80000000, 0x00000010}, 84 {0x00000010, 0xFFFFFFFD, 0x00000010}, 85 {0x00000010, 0xFFFFFFFE, 0x00000010}, 86 {0x00000010, 0xFFFFFFFF, 0x00000010}, 87 {0x078644FA, 0x00000001, 0x00000000}, 88 {0x078644FA, 0x00000002, 0x00000000}, 89 {0x078644FA, 0x00000003, 0x00000000}, 90 {0x078644FA, 0x00000010, 0x0000000A}, 91 {0x078644FA, 0x078644FA, 0x00000000}, 92 {0x078644FA, 0x0747AE14, 0x003E96E6}, 93 {0x078644FA, 0x7FFFFFFF, 0x078644FA}, 94 {0x078644FA, 0x80000000, 0x078644FA}, 95 {0x078644FA, 0xFFFFFFFD, 0x078644FA}, 96 {0x078644FA, 0xFFFFFFFE, 0x078644FA}, 97 {0x078644FA, 0xFFFFFFFF, 0x078644FA}, 98 {0x0747AE14, 0x00000001, 0x00000000}, 99 {0x0747AE14, 0x00000002, 0x00000000}, 100 {0x0747AE14, 0x00000003, 0x00000002}, 101 {0x0747AE14, 0x00000010, 0x00000004}, 102 {0x0747AE14, 0x078644FA, 0x0747AE14}, 103 {0x0747AE14, 0x0747AE14, 0x00000000}, 104 {0x0747AE14, 0x7FFFFFFF, 0x0747AE14}, 105 {0x0747AE14, 0x80000000, 0x0747AE14}, 106 {0x0747AE14, 0xFFFFFFFD, 0x0747AE14}, 107 {0x0747AE14, 0xFFFFFFFE, 0x0747AE14}, 108 {0x0747AE14, 0xFFFFFFFF, 0x0747AE14}, 109 {0x7FFFFFFF, 0x00000001, 0x00000000}, 110 {0x7FFFFFFF, 0x00000002, 0x00000001}, 111 {0x7FFFFFFF, 0x00000003, 0x00000001}, 112 {0x7FFFFFFF, 0x00000010, 0x0000000F}, 113 {0x7FFFFFFF, 0x078644FA, 0x00156B65}, 114 {0x7FFFFFFF, 0x0747AE14, 0x043D70AB}, 115 {0x7FFFFFFF, 0x7FFFFFFF, 0x00000000}, 116 {0x7FFFFFFF, 0x80000000, 0x7FFFFFFF}, 117 {0x7FFFFFFF, 0xFFFFFFFD, 0x7FFFFFFF}, 118 {0x7FFFFFFF, 0xFFFFFFFE, 0x7FFFFFFF}, 119 {0x7FFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF}, 120 {0x80000000, 0x00000001, 0x00000000}, 121 {0x80000000, 0x00000002, 0x00000000}, 122 {0x80000000, 0x00000003, 0x00000002}, 123 {0x80000000, 0x00000010, 0x00000000}, 124 {0x80000000, 0x078644FA, 0x00156B66}, 125 {0x80000000, 0x0747AE14, 0x043D70AC}, 126 {0x80000000, 0x7FFFFFFF, 0x00000001}, 127 {0x80000000, 0x80000000, 0x00000000}, 128 {0x80000000, 0xFFFFFFFD, 0x80000000}, 129 {0x80000000, 0xFFFFFFFE, 0x80000000}, 130 {0x80000000, 0xFFFFFFFF, 0x80000000}, 131 {0xFFFFFFFD, 0x00000001, 0x00000000}, 132 {0xFFFFFFFD, 0x00000002, 0x00000001}, 133 {0xFFFFFFFD, 0x00000003, 0x00000001}, 134 {0xFFFFFFFD, 0x00000010, 0x0000000D}, 135 {0xFFFFFFFD, 0x078644FA, 0x002AD6C9}, 136 {0xFFFFFFFD, 0x0747AE14, 0x01333341}, 137 {0xFFFFFFFD, 0x7FFFFFFF, 0x7FFFFFFE}, 138 {0xFFFFFFFD, 0x80000000, 0x7FFFFFFD}, 139 {0xFFFFFFFD, 0xFFFFFFFD, 0x00000000}, 140 {0xFFFFFFFD, 0xFFFFFFFE, 0xFFFFFFFD}, 141 {0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFD}, 142 {0xFFFFFFFE, 0x00000001, 0x00000000}, 143 {0xFFFFFFFE, 0x00000002, 0x00000000}, 144 {0xFFFFFFFE, 0x00000003, 0x00000002}, 145 {0xFFFFFFFE, 0x00000010, 0x0000000E}, 146 {0xFFFFFFFE, 0x078644FA, 0x002AD6CA}, 147 {0xFFFFFFFE, 0x0747AE14, 0x01333342}, 148 {0xFFFFFFFE, 0x7FFFFFFF, 0x00000000}, 149 {0xFFFFFFFE, 0x80000000, 0x7FFFFFFE}, 150 {0xFFFFFFFE, 0xFFFFFFFD, 0x00000001}, 151 {0xFFFFFFFE, 0xFFFFFFFE, 0x00000000}, 152 {0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFE}, 153 {0xFFFFFFFF, 0x00000001, 0x00000000}, 154 {0xFFFFFFFF, 0x00000002, 0x00000001}, 155 {0xFFFFFFFF, 0x00000003, 0x00000000}, 156 {0xFFFFFFFF, 0x00000010, 0x0000000F}, 157 {0xFFFFFFFF, 0x078644FA, 0x002AD6CB}, 158 {0xFFFFFFFF, 0x0747AE14, 0x01333343}, 159 {0xFFFFFFFF, 0x7FFFFFFF, 0x00000001}, 160 {0xFFFFFFFF, 0x80000000, 0x7FFFFFFF}, 161 {0xFFFFFFFF, 0xFFFFFFFD, 0x00000002}, 162 {0xFFFFFFFF, 0xFFFFFFFE, 0x00000001}, 163 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000} 164 }; 165 166 int main() 167 { 168 const unsigned N = sizeof(tests) / sizeof(tests[0]); 169 unsigned i; 170 for (i = 0; i < N; ++i) 171 if (test__umodsi3(tests[i][0], tests[i][1], tests[i][2])) 172 return 1; 173 174 return 0; 175 } 176