blob: 59fd9d2ae15feda32ad5af4d6cd375c0b026a086 [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001//===-- addvsi3_test.c - Test __addvsi3 -----------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant9ad441f2010-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 Dunbarb3a69012009-06-26 16:47:03 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file tests __addvsi3 for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "int_lib.h"
15#include <stdio.h>
16
17// Returns: a + b
18
19// Effects: aborts if a + b overflows
20
21si_int __addvsi3(si_int a, si_int b);
22
23int test__addvsi3(si_int a, si_int b)
24{
25 si_int x = __addvsi3(a, b);
26 si_int expected = a + b;
27 if (x != expected)
28 printf("error in test__addvsi3(0x%X, 0x%X) = %d, expected %d\n",
29 a, b, x, expected);
30 return x != expected;
31}
32
33int main()
34{
35// test__addvsi3(0x80000000, -1); // should abort
36// test__addvsi3(-1, 0x80000000); // should abort
37// test__addvsi3(1, 0x7FFFFFFF); // should abort
38// test__addvsi3(0x7FFFFFFF, 1); // should abort
39
40 if (test__addvsi3(0x80000000, 1))
41 return 1;
42 if (test__addvsi3(1, 0x80000000))
43 return 1;
44 if (test__addvsi3(0x80000000, 0))
45 return 1;
46 if (test__addvsi3(0, 0x80000000))
47 return 1;
48 if (test__addvsi3(0x7FFFFFFF, -1))
49 return 1;
50 if (test__addvsi3(-1, 0x7FFFFFFF))
51 return 1;
52 if (test__addvsi3(0x7FFFFFFF, 0))
53 return 1;
54 if (test__addvsi3(0, 0x7FFFFFFF))
55 return 1;
56
57 return 0;
58}