1 /*===---- __clang_hip_stdlib.h - Device-side HIP math support --------------===
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===-----------------------------------------------------------------------===
9 #ifndef __CLANG_HIP_STDLIB_H__
11 #if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__)
12 #error "This file is for HIP and OpenMP AMDGCN device compilation only."
15 #if !defined(__cplusplus)
19 #ifdef __OPENMP_AMDGCN__
20 #define __DEVICE__ static inline __attribute__((always_inline, nothrow))
22 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
27 int __sgn
= __x
>> (sizeof(int) * CHAR_BIT
- 1);
28 return (__x
^ __sgn
) - __sgn
;
32 long __sgn
= __x
>> (sizeof(long) * CHAR_BIT
- 1);
33 return (__x
^ __sgn
) - __sgn
;
36 long long llabs(long long __x
) {
37 long long __sgn
= __x
>> (sizeof(long long) * CHAR_BIT
- 1);
38 return (__x
^ __sgn
) - __sgn
;
41 #endif // !defined(__cplusplus)
43 #endif // #define __CLANG_HIP_STDLIB_H__