Path: blob/main/contrib/llvm-project/clang/lib/Headers/__clang_hip_stdlib.h
35233 views
/*===---- __clang_hip_stdlib.h - Device-side HIP math support --------------===1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===-----------------------------------------------------------------------===7*/8#ifndef __CLANG_HIP_STDLIB_H__910#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__)11#error "This file is for HIP and OpenMP AMDGCN device compilation only."12#endif1314#if !defined(__cplusplus)1516#include <limits.h>1718#ifdef __OPENMP_AMDGCN__19#define __DEVICE__ static inline __attribute__((always_inline, nothrow))20#else21#define __DEVICE__ static __device__ inline __attribute__((always_inline))22#endif2324__DEVICE__25int abs(int __x) {26int __sgn = __x >> (sizeof(int) * CHAR_BIT - 1);27return (__x ^ __sgn) - __sgn;28}29__DEVICE__30long labs(long __x) {31long __sgn = __x >> (sizeof(long) * CHAR_BIT - 1);32return (__x ^ __sgn) - __sgn;33}34__DEVICE__35long long llabs(long long __x) {36long long __sgn = __x >> (sizeof(long long) * CHAR_BIT - 1);37return (__x ^ __sgn) - __sgn;38}3940#endif // !defined(__cplusplus)4142#endif // #define __CLANG_HIP_STDLIB_H__434445