diff options
Diffstat (limited to 'source/blender/blenlib/BLI_utildefines.h')
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index ef6edda1118..f70befddc4d 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -34,6 +34,7 @@ /* avoid many includes for now */ #include "BLI_sys_types.h" +#include "BLI_compiler_compat.h" #ifndef NDEBUG /* for BLI_assert */ #include <stdio.h> @@ -211,8 +212,10 @@ } (void)0 -#define FTOCHAR(val) (char)(((val) <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * (val)) + 0.5f))) -#define FTOUSHORT(val) ((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (unsigned short)(val * 65535.0f + 0.5f)) +#define FTOCHAR(val) ((CHECK_TYPE_INLINE(val, float)), \ + (char)(((val) <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * (val)) + 0.5f)))) +#define FTOUSHORT(val) ((CHECK_TYPE_INLINE(val, float)), \ + ((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (unsigned short)(val * 65535.0f + 0.5f))) #define USHORTTOUCHAR(val) ((unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8)) #define F3TOCHAR3(v2, v1) { \ (v1)[0] = FTOCHAR((v2[0])); \ @@ -260,9 +263,9 @@ *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (fac); \ } (void)0 #define VECMADD(v1, v2, v3, v4) { \ - *(v1) = *(v2) + *(v3) * (*(v4)); \ - *(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (*(v4 + 1)); \ - *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (*(v4 + 2)); \ + *(v1) = *(v2) + *(v3) * (*(v4)); \ + *(v1 + 1) = *(v2 + 1) + *(v3 + 1) * (*(v4 + 1)); \ + *(v1 + 2) = *(v2 + 2) + *(v3 + 2) * (*(v4 + 2)); \ } (void)0 #define VECSUBFAC(v1, v2, v3, fac) { \ *(v1) = *(v2) - *(v3) * (fac); \ @@ -384,16 +387,9 @@ #define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0) #define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0) - - /* useful for debugging */ #define AT __FILE__ ":" STRINGIFY(__LINE__) -/* so we can use __func__ everywhere */ -#if defined(_MSC_VER) -# define __func__ __FUNCTION__ -#endif - /* UNUSED macro, for function argument */ #ifdef __GNUC__ @@ -464,7 +460,7 @@ # define BLI_STATIC_ASSERT(a, msg) #endif -/* hints for branch pradiction, only use in code that runs a _lot_ where */ +/* hints for branch prediction, only use in code that runs a _lot_ where */ #ifdef __GNUC__ # define LIKELY(x) __builtin_expect(!!(x), 1) # define UNLIKELY(x) __builtin_expect(!!(x), 0) |