diff --git a/lib/libc/gen/isnan.c b/lib/libc/gen/isnan.c index e17d915e0ad3..ea84c7ebe403 100644 --- a/lib/libc/gen/isnan.c +++ b/lib/libc/gen/isnan.c @@ -43,6 +43,13 @@ */ #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(__isnanf, isnanf); diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h index a8f45544c475..6ce45cbb5280 100644 --- a/lib/msun/src/math.h +++ b/lib/msun/src/math.h @@ -214,6 +214,12 @@ __inline_isnanl(__const long double __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 * isinf() as functions taking double. C99, and the subsequent POSIX revisions diff --git a/lib/msun/src/s_isnan.c b/lib/msun/src/s_isnan.c index 249c00615748..ea3c8db67da6 100644 --- a/lib/msun/src/s_isnan.c +++ b/lib/msun/src/s_isnan.c @@ -45,6 +45,12 @@ isnan(double d) } #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 __isnanf(float f) {