blob: c523367455a926f985cab5d89df9c5f77496f18d [file] [log] [blame]
Daniel Dunbarfd089992009-06-26 16:47:03 +00001//===-- divsi3_test.c - Test __divsi3 -------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant5b791f62010-11-16 22:13:33 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Daniel Dunbarfd089992009-06-26 16:47:03 +00007//
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
Derek Schuffeb0ebc32015-04-24 15:45:57 +000019COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
Daniel Dunbarfd089992009-06-26 16:47:03 +000020
21int 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
30int 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}