1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_absvdi2
3 //===-- absvdi2_test.c - Test __absvdi2 -----------------------------------===//
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
11 // This file tests __absvdi2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
19 // Returns: absolute value
21 // Effects: aborts if abs(x) < 0
23 COMPILER_RT_ABI di_int
__absvdi2(di_int a
);
25 int test__absvdi2(di_int a
)
27 di_int x
= __absvdi2(a
);
31 if (x
!= expected
|| expected
< 0)
32 printf("error in __absvdi2(0x%llX) = %lld, expected positive %lld\n",
39 // if (test__absvdi2(0x8000000000000000LL)) // should abort
41 if (test__absvdi2(0x0000000000000000LL
))
43 if (test__absvdi2(0x0000000000000001LL
))
45 if (test__absvdi2(0x0000000000000002LL
))
47 if (test__absvdi2(0x7FFFFFFFFFFFFFFELL
))
49 if (test__absvdi2(0x7FFFFFFFFFFFFFFFLL
))
51 if (test__absvdi2(0x8000000000000001LL
))
53 if (test__absvdi2(0x8000000000000002LL
))
55 if (test__absvdi2(0xFFFFFFFFFFFFFFFELL
))
57 if (test__absvdi2(0xFFFFFFFFFFFFFFFFLL
))
61 for (i
= 0; i
< 10000; ++i
)
62 if (test__absvdi2(((di_int
)rand() << 32) | rand()))