\r
inline s32 s32_min(s32 a, s32 b)\r
{\r
- const s32 mask = (a - b) >> 31;\r
- return (a & mask) | (b & ~mask);\r
+ return min_(a, b);\r
}\r
\r
inline s32 s32_max(s32 a, s32 b)\r
{\r
- const s32 mask = (a - b) >> 31;\r
- return (b & mask) | (a & ~mask);\r
+ return max_(a, b);\r
}\r
\r
inline s32 s32_clamp (s32 value, s32 low, s32 high)\r
{\r
- return s32_min(s32_max(value,low), high);\r
+ return clamp(value, low, high);\r
}\r
\r
/*\r
#endif\r
#endif\r
\r
- //! conditional set based on mask and arithmetic shift\r
- REALINLINE u32 if_c_a_else_b ( const s32 condition, const u32 a, const u32 b )\r
- {\r
- return ( ( -condition >> 31 ) & ( a ^ b ) ) ^ b;\r
- }\r
-\r
- //! conditional set based on mask and arithmetic shift\r
- REALINLINE u16 if_c_a_else_b ( const s16 condition, const u16 a, const u16 b )\r
- {\r
- return ( ( -condition >> 15 ) & ( a ^ b ) ) ^ b;\r
- }\r
-\r
- //! conditional set based on mask and arithmetic shift\r
- REALINLINE u32 if_c_a_else_0 ( const s32 condition, const u32 a )\r
- {\r
- return ( -condition >> 31 ) & a;\r
- }\r
-\r
- /*\r
- if (condition) state |= m; else state &= ~m;\r
- */\r
- REALINLINE void setbit_cond ( u32 &state, s32 condition, u32 mask )\r
- {\r
- // 0, or any positive to mask\r
- //s32 conmask = -condition >> 31;\r
- state ^= ( ( -condition >> 31 ) ^ state ) & mask;\r
- }\r
\r
// NOTE: This is not as exact as the c99/c++11 round function, especially at high numbers starting with 8388609\r
// (only low number which seems to go wrong is 0.49999997 which is rounded to 1)\r