| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 1 | //===-- umodti3_test.c - Test __umodti3 -----------------------------------===// | 
|  | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
| Howard Hinnant | 5b791f6 | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open | 
|  | 6 | // Source Licenses. See LICENSE.TXT for details. | 
| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 7 | // | 
|  | 8 | //===----------------------------------------------------------------------===// | 
|  | 9 | // | 
|  | 10 | // This file tests __umodti3 for the compiler_rt library. | 
|  | 11 | // | 
|  | 12 | //===----------------------------------------------------------------------===// | 
|  | 13 |  | 
| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 14 | #include "int_lib.h" | 
|  | 15 | #include <stdio.h> | 
|  | 16 |  | 
| Joerg Sonnenberger | 1474312 | 2014-03-18 21:35:30 +0000 | [diff] [blame] | 17 | #ifdef CRT_HAS_128BIT | 
|  | 18 |  | 
| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 19 | // Returns: a % b | 
|  | 20 |  | 
|  | 21 | tu_int __umodti3(tu_int a, tu_int b); | 
|  | 22 |  | 
|  | 23 | int test__umodti3(tu_int a, tu_int b, tu_int expected_r) | 
|  | 24 | { | 
|  | 25 | tu_int r = __umodti3(a, b); | 
|  | 26 | if (r != expected_r) | 
|  | 27 | { | 
|  | 28 | utwords at; | 
|  | 29 | at.all = a; | 
|  | 30 | utwords bt; | 
|  | 31 | bt.all = b; | 
|  | 32 | utwords rt; | 
|  | 33 | rt.all = r; | 
|  | 34 | utwords expected_rt; | 
|  | 35 | expected_rt.all = expected_r; | 
|  | 36 | printf("error in __umodti3: 0x%llX%.16llX %% 0x%llX%.16llX = " | 
|  | 37 | "0x%llX%.16llX, expected 0x%llX%.16llX\n", | 
| Daniel Dunbar | 6485720 | 2009-10-27 17:49:07 +0000 | [diff] [blame] | 38 | at.s.high, at.s.low, bt.s.high, bt.s.low, rt.s.high, rt.s.low, | 
|  | 39 | expected_rt.s.high, expected_rt.s.low); | 
| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 40 | } | 
|  | 41 | return r != expected_r; | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | #endif | 
|  | 45 |  | 
|  | 46 | int main() | 
|  | 47 | { | 
| Joerg Sonnenberger | 1474312 | 2014-03-18 21:35:30 +0000 | [diff] [blame] | 48 | #ifdef CRT_HAS_128BIT | 
| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 49 | if (test__umodti3(0, 1, 0)) | 
|  | 50 | return 1; | 
|  | 51 | if (test__umodti3(2, 1, 0)) | 
|  | 52 | return 1; | 
|  | 53 | if (test__umodti3(make_tu(0x8000000000000000uLL, 0), 1, 0x0uLL)) | 
|  | 54 | return 1; | 
|  | 55 | if (test__umodti3(make_tu(0x8000000000000000uLL, 0), 2, 0x0uLL)) | 
|  | 56 | return 1; | 
|  | 57 | if (test__umodti3(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL), | 
|  | 58 | 2, 0x1uLL)) | 
|  | 59 | return 1; | 
|  | 60 |  | 
| Joerg Sonnenberger | d9bcddd | 2011-05-29 21:43:29 +0000 | [diff] [blame] | 61 | #else | 
|  | 62 | printf("skipped\n"); | 
| Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 63 | #endif | 
|  | 64 | return 0; | 
|  | 65 | } |