Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA
Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from <built-in>:1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 MFC after: 1 week
This commit is contained in:
parent
25cf531ecd
commit
f68ff1ac1c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354255
@ -43,6 +43,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PIC
|
#ifdef PIC
|
||||||
|
/*
|
||||||
|
* Because math.h defines __isnan and __isnanf as aliases for compatibility with
|
||||||
|
* glibc and CUDA, we have to undefine them here to avoid redefinition errors.
|
||||||
|
*/
|
||||||
|
#undef __isnan
|
||||||
|
#undef __isnanf
|
||||||
|
|
||||||
__weak_reference(__isnan, isnan);
|
__weak_reference(__isnan, isnan);
|
||||||
__weak_reference(__isnanf, isnanf);
|
__weak_reference(__isnanf, isnanf);
|
||||||
|
|
||||||
|
@ -214,6 +214,12 @@ __inline_isnanl(__const long double __x)
|
|||||||
return (__x != __x);
|
return (__x != __x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the following aliases, for compatibility with glibc and CUDA.
|
||||||
|
*/
|
||||||
|
#define __isnan __inline_isnan
|
||||||
|
#define __isnanf __inline_isnanf
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and
|
* Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and
|
||||||
* isinf() as functions taking double. C99, and the subsequent POSIX revisions
|
* isinf() as functions taking double. C99, and the subsequent POSIX revisions
|
||||||
|
@ -45,6 +45,12 @@ isnan(double d)
|
|||||||
}
|
}
|
||||||
#endif /* !PIC */
|
#endif /* !PIC */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Because math.h defines __isnanf as an alias for compatibility with glibc and
|
||||||
|
* CUDA, we have to undefine it here to avoid redefinition errors.
|
||||||
|
*/
|
||||||
|
#undef __isnanf
|
||||||
|
|
||||||
int
|
int
|
||||||
__isnanf(float f)
|
__isnanf(float f)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user