Remove building with NOCRYPTO option
[minix3.git] / sys / external / bsd / compiler_rt / dist / test / Unit / modsi3_test.c
blob52ec9a0ae36b3b359fa7c42b7bd2d64217cef0e4
1 /* ===-- modsi3_test.c - Test __modsi3 -------------------------------------===
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 __modsi3 for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
15 #include "int_lib.h"
16 #include <stdio.h>
18 /* Returns: a % b */
20 si_int __modsi3(si_int a, si_int b);
22 int test__modsi3(si_int a, si_int b, si_int expected) {
23 si_int x = __modsi3(a, b);
24 if (x != expected)
25 fprintf(stderr, "error in __modsi3: %d %% %d = %d, expected %d\n",
26 a, b, x, expected);
27 return x != expected;
30 int main() {
31 if (test__modsi3(0, 1, 0))
32 return 1;
33 if (test__modsi3(0, -1, 0))
34 return 1;
36 if (test__modsi3(5, 3, 2))
37 return 1;
38 if (test__modsi3(5, -3, 2))
39 return 1;
40 if (test__modsi3(-5, 3, -2))
41 return 1;
42 if (test__modsi3(-5, -3, -2))
43 return 1;
45 if (test__modsi3(0x80000000, 1, 0x0))
46 return 1;
47 if (test__modsi3(0x80000000, 2, 0x0))
48 return 1;
49 if (test__modsi3(0x80000000, -2, 0x0))
50 return 1;
51 if (test__modsi3(0x80000000, 3, -2))
52 return 1;
53 if (test__modsi3(0x80000000, -3, -2))
54 return 1;
56 return 0;