Home | History | Annotate | Download | only in Unit
      1 //===-- negvdi2_test.c - Test __negvdi2 -----------------------------------===//
      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 __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 
     21 di_int __negvdi2(di_int a);
     22 
     23 int 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 
     33 int 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 }
     58