diff --git a/Sources/Core/Debug.h b/Sources/Core/Debug.h index 33461606d..16af52473 100644 --- a/Sources/Core/Debug.h +++ b/Sources/Core/Debug.h @@ -132,15 +132,18 @@ namespace spades { #ifdef __GNUC__ #define DEPRECATED(func) func __attribute__((deprecated)) +#define PURE __attribute__((pure)) #define LIKELY(cond) __builtin_expect(!!(cond), true) #define UNLIKELY(cond) __builtin_expect(!!(cond), false) #elif defined(_MSC_VER) #define DEPRECATED(func) __declspec(deprecated) func #define LIKELY(cond) (cond) #define UNLIKELY(cond) (cond) +#define PURE #else #pragma message("WARNING: You need to implement DEPRECATED for this compiler") #define DEPRECATED(func) func +#define PURE #pragma message("WARNING: You need to implement LIKELY/UNLIKELY for this compiler") #define LIKELY(cond) (cond) #define UNLIKELY(cond) (cond) diff --git a/Sources/Draw/SWFeatureLevel.h b/Sources/Draw/SWFeatureLevel.h index 7899ceec8..54b92bddb 100644 --- a/Sources/Draw/SWFeatureLevel.h +++ b/Sources/Draw/SWFeatureLevel.h @@ -115,9 +115,9 @@ namespace spades { return tmp; } #else - static inline float fastDiv(float a, float b) { return a / b; } - static inline float fastRcp(float b) { return 1.f / b; } - static inline float fastRSqrt(float b) { return 1.f / sqrtf(b); } + static inline PURE float fastDiv(float a, float b) { return a / b; } + static inline PURE float fastRcp(float b) { return 1.f / b; } + static inline PURE float fastRSqrt(float b) { return 1.f / sqrtf(b); } #endif static inline float fastSqrt(float s) { if (s == 0.f) diff --git a/Sources/Draw/SWUtils.h b/Sources/Draw/SWUtils.h index b047f7455..966ec839a 100644 --- a/Sources/Draw/SWUtils.h +++ b/Sources/Draw/SWUtils.h @@ -65,12 +65,12 @@ namespace spades { } } - static inline int ToFixed8(float v) { + static inline PURE int ToFixed8(float v) { int i = static_cast(v * 255.f + .5f); return std::max(std::min(i, 255), 0); } - static inline int ToFixedFactor8(float v) { + static inline PURE int ToFixedFactor8(float v) { int i = static_cast(v * 256.f + .5f); return std::max(std::min(i, 256), 0); }