gcc/clang attribute pure usage in few places.
This commit is contained in:
parent
2fca03cf7f
commit
1b8a72deae
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -65,12 +65,12 @@ namespace spades {
|
||||
}
|
||||
}
|
||||
|
||||
static inline int ToFixed8(float v) {
|
||||
static inline PURE int ToFixed8(float v) {
|
||||
int i = static_cast<int>(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<int>(v * 256.f + .5f);
|
||||
return std::max(std::min(i, 256), 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user