diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2013-01-25 00:54:12 +0400 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2013-01-25 00:54:12 +0400 |
commit | 7539009d5b3ee1b2ddb76400917a9876a3cfe184 (patch) | |
tree | bc0b379f0473e9d4d2a8dd90521b7e0f0151b8f2 | |
parent | ca7b277c120e4622c816b8a6d922d64ccf050bd0 (diff) |
Do not redefine math functions for floats if compiler complies with C99 or POSIX.1-2001
This is useful for gcc which does not define sqrtf/powf/... functions with preprocessor and therefore always used sqrt/pow/...
Float functions are generally 20-50% faster than their equivalents for double type.
-rw-r--r-- | source/blender/blenlib/BLI_math_base.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 69d6478e0e2..15b8eb184d0 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -80,6 +80,9 @@ #define MAXFLOAT ((float)3.40282347e+38) #endif +/* do not redefine functions from C99 or POSIX.1-2001 */ +#if !(defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L) + #ifndef sqrtf #define sqrtf(a) ((float)sqrt(a)) #endif @@ -129,6 +132,8 @@ #define hypotf(a, b) ((float)hypot(a, b)) #endif +#endif + #ifdef WIN32 # ifndef FREE_WINDOWS # define isnan(n) _isnan(n) |