1 //===-- divti3_test.c - Test __divti3 -------------------------------------===//
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 __divti3 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
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
);
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
);
44 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
51 if (test__divti3(0, 1, 0))
53 if (test__divti3(0, -1, 0))
56 if (test__divti3(2, 1, 2))
58 if (test__divti3(2, -1, -2))
60 if (test__divti3(-2, 1, -2))
62 if (test__divti3(-2, -1, 2))
65 if (test__divti3(make_ti(0x8000000000000000LL
, 0), 1, make_ti(0x8000000000000000LL
, 0)))
67 if (test__divti3(make_ti(0x8000000000000000LL
, 0), -1, make_ti(0x8000000000000000LL
, 0)))
69 if (test__divti3(make_ti(0x8000000000000000LL
, 0), -2, make_ti(0x4000000000000000LL
, 0)))
71 if (test__divti3(make_ti(0x8000000000000000LL
, 0), 2, make_ti(0xC000000000000000LL
, 0)))