1 //===-- divmodsi4_test.c - Test __divmodsi4 -------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __divmodsi4 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
19 extern si_int
__divmodsi4(si_int a
, si_int b
, si_int
* rem
);
22 int test__divmodsi4(si_int a
, si_int b
,
23 si_int expected_result
, si_int expected_rem
)
26 si_int result
= __divmodsi4(a
, b
, &rem
);
27 if (result
!= expected_result
) {
28 printf("error in __divmodsi4: %d / %d = %d, expected %d\n",
29 a
, b
, result
, expected_result
);
32 if (rem
!= expected_rem
) {
33 printf("error in __divmodsi4: %d mod %d = %d, expected %d\n",
34 a
, b
, rem
, expected_rem
);
44 if (test__divmodsi4(0, 1, 0, 0))
46 if (test__divmodsi4(0, -1, 0, 0))
49 if (test__divmodsi4(2, 1, 2, 0))
51 if (test__divmodsi4(2, -1, -2, 0))
53 if (test__divmodsi4(-2, 1, -2, 0))
55 if (test__divmodsi4(-2, -1, 2, 0))
58 if (test__divmodsi4(7, 5, 1, 2))
60 if (test__divmodsi4(-7, 5, -1, -2))
62 if (test__divmodsi4(19, 5, 3, 4))
64 if (test__divmodsi4(19, -5, -3, 4))
67 if (test__divmodsi4(0x80000000, 8, 0xf0000000, 0))
69 if (test__divmodsi4(0x80000007, 8, 0xf0000001, -1))