Remove building with NOCRYPTO option
[minix3.git] / sys / external / bsd / compiler_rt / dist / test / Unit / divti3_test.c
blob7c8e2970fa6e535173f7d5b9c9dbdfd8071fc3d4
1 //===-- divti3_test.c - Test __divti3 -------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file tests __divti3 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
14 #if __x86_64
16 #include "int_lib.h"
17 #include <stdio.h>
19 // Returns: a / b
21 ti_int __divti3(ti_int a, ti_int b);
23 int test__divti3(ti_int a, ti_int b, ti_int expected)
25 ti_int x = __divti3(a, b);
26 if (x != expected)
28 twords at;
29 at.all = a;
30 twords bt;
31 bt.all = b;
32 twords xt;
33 xt.all = x;
34 twords expectedt;
35 expectedt.all = expected;
36 printf("error in __divti3: 0x%llX%.16llX / 0x%llX%.16llX = "
37 "0x%llX%.16llX, expected 0x%llX%.16llX\n",
38 at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
39 expectedt.s.high, expectedt.s.low);
41 return x != expected;
44 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
46 #endif
48 int main()
50 #if __x86_64
51 if (test__divti3(0, 1, 0))
52 return 1;
53 if (test__divti3(0, -1, 0))
54 return 1;
56 if (test__divti3(2, 1, 2))
57 return 1;
58 if (test__divti3(2, -1, -2))
59 return 1;
60 if (test__divti3(-2, 1, -2))
61 return 1;
62 if (test__divti3(-2, -1, 2))
63 return 1;
65 if (test__divti3(make_ti(0x8000000000000000LL, 0), 1, make_ti(0x8000000000000000LL, 0)))
66 return 1;
67 if (test__divti3(make_ti(0x8000000000000000LL, 0), -1, make_ti(0x8000000000000000LL, 0)))
68 return 1;
69 if (test__divti3(make_ti(0x8000000000000000LL, 0), -2, make_ti(0x4000000000000000LL, 0)))
70 return 1;
71 if (test__divti3(make_ti(0x8000000000000000LL, 0), 2, make_ti(0xC000000000000000LL, 0)))
72 return 1;
74 #else
75 printf("skipped\n");
76 #endif
77 return 0;