1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_modsi3
3 /* ===-- modsi3_test.c - Test __modsi3 -------------------------------------===
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 __modsi3 for the compiler_rt library.
13 * ===----------------------------------------------------------------------===
21 COMPILER_RT_ABI si_int
__modsi3(si_int a
, si_int b
);
23 int test__modsi3(si_int a
, si_int b
, si_int expected
) {
24 si_int x
= __modsi3(a
, b
);
26 fprintf(stderr
, "error in __modsi3: %d %% %d = %d, expected %d\n",
32 if (test__modsi3(0, 1, 0))
34 if (test__modsi3(0, -1, 0))
37 if (test__modsi3(5, 3, 2))
39 if (test__modsi3(5, -3, 2))
41 if (test__modsi3(-5, 3, -2))
43 if (test__modsi3(-5, -3, -2))
46 if (test__modsi3(0x80000000, 1, 0x0))
48 if (test__modsi3(0x80000000, 2, 0x0))
50 if (test__modsi3(0x80000000, -2, 0x0))
52 if (test__modsi3(0x80000000, 3, -2))
54 if (test__modsi3(0x80000000, -3, -2))