blob: 9617b95ff1058a9aff80ccd715a47399d2a4e109 [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001//===-- negvdi2_test.c - Test __negvdi2 -----------------------------------===//
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 __negvdi2 for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "int_lib.h"
15#include <stdio.h>
16
17// Returns: -a
18
19// Effects: aborts if -a overflows
20
21di_int __negvdi2(di_int a);
22
23int test__negvdi2(di_int a)
24{
25 di_int x = __negvdi2(a);
26 di_int expected = -a;
27 if (x != expected)
28 printf("error in __negvdi2(0x%llX) = %lld, expected %lld\n",
29 a, x, expected);
30 return x != expected;
31}
32
33int main()
34{
35// if (test__negvdi2(0x8000000000000000LL)) // should abort
36// return 1;
37 if (test__negvdi2(0x0000000000000000LL))
38 return 1;
39 if (test__negvdi2(0x0000000000000001LL))
40 return 1;
41 if (test__negvdi2(0x0000000000000002LL))
42 return 1;
43 if (test__negvdi2(0x7FFFFFFFFFFFFFFELL))
44 return 1;
45 if (test__negvdi2(0x7FFFFFFFFFFFFFFFLL))
46 return 1;
47 if (test__negvdi2(0x8000000000000001LL))
48 return 1;
49 if (test__negvdi2(0x8000000000000002LL))
50 return 1;
51 if (test__negvdi2(0xFFFFFFFFFFFFFFFELL))
52 return 1;
53 if (test__negvdi2(0xFFFFFFFFFFFFFFFFLL))
54 return 1;
55
56 return 0;
57}