diff options
author | Chris Robinson <[email protected]> | 2017-06-29 10:11:31 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-06-29 10:11:31 -0700 |
commit | a69d608a1ec38e6afd903224e86c0bf29b8d0623 (patch) | |
tree | 449efe96be44689d54c0b1fb228bb181cbbac9c5 | |
parent | aefa11b6adf3bdd0e82d2c2f125d2bd62288e246 (diff) |
Define a backup log2f if the compiler doesn't have it
-rw-r--r-- | Alc/ALc.c | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | common/math_defs.h | 7 | ||||
-rw-r--r-- | config.h.in | 3 |
4 files changed, 11 insertions, 3 deletions
@@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bba3c27..523e288d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/common/math_defs.h b/common/math_defs.h index 1b394976..cbe9091f 100644 --- a/common/math_defs.h +++ b/common/math_defs.h @@ -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)) diff --git a/config.h.in b/config.h.in index a71b54fb..56a78448 100644 --- a/config.h.in +++ b/config.h.in @@ -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 |