1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_udivmodsi4
3 //===-- udivmodsi4_test.c - Test __udivmodsi4 -----------------------------===//
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
11 // This file tests __udivmodsi4 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
20 extern COMPILER_RT_ABI su_int
__udivmodsi4(su_int a
, su_int b
, su_int
* rem
);
22 int test__udivmodsi4(su_int a
, su_int b
,
23 su_int expected_result
, su_int expected_rem
)
26 su_int result
= __udivmodsi4(a
, b
, &rem
);
27 if (result
!= expected_result
) {
28 printf("error in __udivmodsi4: %u / %u = %u, expected %u\n",
29 a
, b
, result
, expected_result
);
32 if (rem
!= expected_rem
) {
33 printf("error in __udivmodsi4: %u mod %u = %u, expected %u\n",
34 a
, b
, rem
, expected_rem
);
44 if (test__udivmodsi4(0, 1, 0, 0))
47 if (test__udivmodsi4(2, 1, 2, 0))
50 if (test__udivmodsi4(19, 5, 3, 4))
53 if (test__udivmodsi4(0x80000000, 8, 0x10000000, 0))
56 if (test__udivmodsi4(0x80000003, 8, 0x10000000, 3))