]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/builtins/Unit/divsi3_test.c
New upstream version 1.20.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / builtins / Unit / divsi3_test.c
1 //===-- divsi3_test.c - Test __divsi3 -------------------------------------===//
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 __divsi3 for the compiler_rt library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "int_lib.h"
15 #include <stdio.h>
16
17 // Returns: a / b
18
19 COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
20
21 int test__divsi3(si_int a, si_int b, si_int expected)
22 {
23 si_int x = __divsi3(a, b);
24 if (x != expected)
25 printf("error in __divsi3: %d / %d = %d, expected %d\n",
26 a, b, x, expected);
27 return x != expected;
28 }
29
30 int main()
31 {
32 if (test__divsi3(0, 1, 0))
33 return 1;
34 if (test__divsi3(0, -1, 0))
35 return 1;
36
37 if (test__divsi3(2, 1, 2))
38 return 1;
39 if (test__divsi3(2, -1, -2))
40 return 1;
41 if (test__divsi3(-2, 1, -2))
42 return 1;
43 if (test__divsi3(-2, -1, 2))
44 return 1;
45
46 if (test__divsi3(0x80000000, 1, 0x80000000))
47 return 1;
48 if (test__divsi3(0x80000000, -1, 0x80000000))
49 return 1;
50 if (test__divsi3(0x80000000, -2, 0x40000000))
51 return 1;
52 if (test__divsi3(0x80000000, 2, 0xC0000000))
53 return 1;
54
55 return 0;
56 }