1 // REQUIRES: arm-target-arch || armv6m-target-arch
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
8 // Based on divmodsi4_test.c
10 extern du_int
__aeabi_idivmod(si_int a
, si_int b
);
12 int test__aeabi_idivmod(si_int a
, si_int b
,
13 si_int expected_result
, si_int expected_rem
)
16 du_int ret
= __aeabi_idivmod(a
, b
);
18 si_int result
= ret
& 0xFFFFFFFF;
19 if (result
!= expected_result
) {
20 printf("error in __aeabi_idivmod: %d / %d = %d, expected %d\n",
21 a
, b
, result
, expected_result
);
24 if (rem
!= expected_rem
) {
25 printf("error in __aeabi_idivmod: %d mod %d = %d, expected %d\n",
26 a
, b
, rem
, expected_rem
);
38 if (test__aeabi_idivmod(0, 1, 0, 0))
40 if (test__aeabi_idivmod(0, -1, 0, 0))
43 if (test__aeabi_idivmod(2, 1, 2, 0))
45 if (test__aeabi_idivmod(2, -1, -2, 0))
47 if (test__aeabi_idivmod(-2, 1, -2, 0))
49 if (test__aeabi_idivmod(-2, -1, 2, 0))
52 if (test__aeabi_idivmod(7, 5, 1, 2))
54 if (test__aeabi_idivmod(-7, 5, -1, -2))
56 if (test__aeabi_idivmod(19, 5, 3, 4))
58 if (test__aeabi_idivmod(19, -5, -3, 4))
61 if (test__aeabi_idivmod(0x80000000, 8, 0xf0000000, 0))
63 if (test__aeabi_idivmod(0x80000007, 8, 0xf0000001, -1))