1 // REQUIRES: arm-target-arch || armv6m-target-arch
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
8 // Based on udivmodsi4_test.c
10 extern du_int
__aeabi_uidivmod(su_int a
, su_int b
);
12 int test__aeabi_uidivmod(su_int a
, su_int b
,
13 su_int expected_result
, su_int expected_rem
)
15 du_int ret
= __aeabi_uidivmod(a
, b
);
16 su_int rem
= ret
>> 32;
17 si_int result
= ret
& 0xFFFFFFFF;
19 if (result
!= expected_result
) {
20 printf("error in __aeabi_uidivmod: %u / %u = %u, expected %u\n",
21 a
, b
, result
, expected_result
);
24 if (rem
!= expected_rem
) {
25 printf("error in __aeabi_uidivmod: %u mod %u = %u, expected %u\n",
26 a
, b
, rem
, expected_rem
);
38 if (test__aeabi_uidivmod(0, 1, 0, 0))
41 if (test__aeabi_uidivmod(2, 1, 2, 0))
44 if (test__aeabi_uidivmod(19, 5, 3, 4))
47 if (test__aeabi_uidivmod(0x80000000, 8, 0x10000000, 0))
50 if (test__aeabi_uidivmod(0x80000003, 8, 0x10000000, 3))