Skip to content

Commit 1b8a72d

Browse files
committed
gcc/clang attribute pure usage in few places.
1 parent 2fca03c commit 1b8a72d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Sources/Core/Debug.h

+3
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,18 @@ namespace spades {
132132

133133
#ifdef __GNUC__
134134
#define DEPRECATED(func) func __attribute__((deprecated))
135+
#define PURE __attribute__((pure))
135136
#define LIKELY(cond) __builtin_expect(!!(cond), true)
136137
#define UNLIKELY(cond) __builtin_expect(!!(cond), false)
137138
#elif defined(_MSC_VER)
138139
#define DEPRECATED(func) __declspec(deprecated) func
139140
#define LIKELY(cond) (cond)
140141
#define UNLIKELY(cond) (cond)
142+
#define PURE
141143
#else
142144
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
143145
#define DEPRECATED(func) func
146+
#define PURE
144147
#pragma message("WARNING: You need to implement LIKELY/UNLIKELY for this compiler")
145148
#define LIKELY(cond) (cond)
146149
#define UNLIKELY(cond) (cond)

Sources/Draw/SWFeatureLevel.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ namespace spades {
115115
return tmp;
116116
}
117117
#else
118-
static inline float fastDiv(float a, float b) { return a / b; }
119-
static inline float fastRcp(float b) { return 1.f / b; }
120-
static inline float fastRSqrt(float b) { return 1.f / sqrtf(b); }
118+
static inline PURE float fastDiv(float a, float b) { return a / b; }
119+
static inline PURE float fastRcp(float b) { return 1.f / b; }
120+
static inline PURE float fastRSqrt(float b) { return 1.f / sqrtf(b); }
121121
#endif
122122
static inline float fastSqrt(float s) {
123123
if (s == 0.f)

Sources/Draw/SWUtils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ namespace spades {
6565
}
6666
}
6767

68-
static inline int ToFixed8(float v) {
68+
static inline PURE int ToFixed8(float v) {
6969
int i = static_cast<int>(v * 255.f + .5f);
7070
return std::max(std::min(i, 255), 0);
7171
}
7272

73-
static inline int ToFixedFactor8(float v) {
73+
static inline PURE int ToFixedFactor8(float v) {
7474
int i = static_cast<int>(v * 256.f + .5f);
7575
return std::max(std::min(i, 256), 0);
7676
}

0 commit comments

Comments
 (0)