Define a backup log2f if the compiler doesn't have it

This commit is contained in:
Chris Robinson 2017-06-29 10:11:31 -07:00
parent aefa11b6ad
commit a69d608a1e
4 changed files with 11 additions and 3 deletions

View File

@ -1213,9 +1213,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void* UNUSED(reserved))
pthread_setspecific(gJVMThreadKey, env);
return JNI_VERSION_1_4;
}
/* Android doesn't have log2f, really? */
#define log2f(x) (logf(x) / logf(2.0f))
#endif

View File

@ -505,6 +505,7 @@ CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
CHECK_SYMBOL_EXISTS(lrintf math.h HAVE_LRINTF)
CHECK_SYMBOL_EXISTS(modff math.h HAVE_MODFF)
CHECK_SYMBOL_EXISTS(log2f math.h HAVE_LOG2F)
IF(NOT HAVE_C99_VLA)
CHECK_SYMBOL_EXISTS(alloca malloc.h HAVE_ALLOCA)
IF(NOT HAVE_ALLOCA)

View File

@ -22,6 +22,13 @@ static const union msvc_inf_hack {
#define HUGE_VALF (msvc_inf_union.f)
#endif
#ifndef HAVE_LOG2F
static inline float log2f(float f)
{
return logf(f) / logf(2.0f);
}
#endif
#define DEG2RAD(x) ((float)(x) * (F_PI/180.0f))
#define RAD2DEG(x) ((float)(x) * (180.0f/F_PI))

View File

@ -80,6 +80,9 @@
/* Define if we have the modff function */
#cmakedefine HAVE_MODFF
/* Define if we have the log2f function */
#cmakedefine HAVE_LOG2F
/* Define if we have the strtof function */
#cmakedefine HAVE_STRTOF