tsan: deflake tests
[blocksruntime.git] / test / Unit / udivmodsi4_test.c
blobd734cd1fdf719cd3c448b02fdcd7023f6231384f
1 //===-- udivmodsi4_test.c - Test __udivmodsi4 -----------------------------===//
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 __udivmodsi4 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
14 #include "int_lib.h"
15 #include <stdio.h>
17 // Returns: a / b
19 extern su_int __udivmodsi4(su_int a, su_int b, su_int* rem);
21 int test__udivmodsi4(su_int a, su_int b,
22 su_int expected_result, su_int expected_rem)
24 su_int rem;
25 su_int result = __udivmodsi4(a, b, &rem);
26 if (result != expected_result) {
27 printf("error in __udivmodsi4: %u / %u = %u, expected %u\n",
28 a, b, result, expected_result);
29 return 1;
31 if (rem != expected_rem) {
32 printf("error in __udivmodsi4: %u mod %u = %u, expected %u\n",
33 a, b, rem, expected_rem);
34 return 1;
37 return 0;
41 int main()
43 if (test__udivmodsi4(0, 1, 0, 0))
44 return 1;
46 if (test__udivmodsi4(2, 1, 2, 0))
47 return 1;
49 if (test__udivmodsi4(19, 5, 3, 4))
50 return 1;
52 if (test__udivmodsi4(0x80000000, 8, 0x10000000, 0))
53 return 1;
55 if (test__udivmodsi4(0x80000003, 8, 0x10000000, 3))
56 return 1;
58 return 0;