37 #include "platform_config.h" 40 #define _STR(m_x) #m_x 41 #define _MKSTR(m_x) _STR(m_x) 45 #define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_PATCH)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION) 47 #define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION) 48 #endif // VERSION_PATCH 49 #define VERSION_FULL_NAME _MKSTR(VERSION_NAME)" v" VERSION_MKSTRING 52 #ifndef _ALWAYS_INLINE_ 54 #if defined(__GNUC__) && (__GNUC__ >= 4 ) 55 # define _ALWAYS_INLINE_ __attribute__((always_inline)) inline 56 #elif defined(__llvm__) 57 # define _ALWAYS_INLINE_ __attribute__((always_inline)) inline 58 #elif defined(_MSC_VER) 59 # define _ALWAYS_INLINE_ __forceinline 61 # define _ALWAYS_INLINE_ inline 66 #ifndef _FORCE_INLINE_ 70 #define _FORCE_INLINE_ inline 74 #define _FORCE_INLINE_ _ALWAYS_INLINE_ 80 #ifndef DEFAULT_ALIGNMENT 81 #define DEFAULT_ALIGNMENT 1 87 T *_nullptr() { T*t=NULL;
return t; }
89 #define OFFSET_OF(st, m) \ 90 ((size_t) ( (char *)&(_nullptr<st>()->m) - (char *)0 )) 104 # undef min // override standard definition 105 # undef max // override standard definition 106 # undef ERROR // override (really stupid) wingdi.h standard definition 107 # undef DELETE // override (another really stupid) winnt.h standard definition 108 # undef MessageBox // override winuser.h standard definition 109 # undef MIN // override standard definition 110 # undef MAX // override standard definition 111 # undef CLAMP // override standard definition 116 #include "error_macros.h" 117 #include "error_list.h" 119 #include "int_types.h" 124 #define ABS(m_v) ((m_v<0)?(-(m_v)):(m_v)) 128 #define SGN(m_v) ((m_v<0)?(-1.0):(+1.0)) 132 #define MIN(m_a,m_b) (((m_a)<(m_b))?(m_a):(m_b)) 136 #define MAX(m_a,m_b) (((m_a)>(m_b))?(m_a):(m_b)) 140 #define CLAMP(m_a,m_min,m_max) (((m_a)<(m_min))?(m_min):(((m_a)>(m_max))?m_max:m_a)) 146 #define SWAP(m_x,m_y) __swap_tmpl(m_x,m_y) 148 inline void __swap_tmpl(T &x, T &y ) {
157 #define HEX2CHR( m_hex ) ( (m_hex>='0' && m_hex<='9')?(m_hex-'0'):\ 158 ((m_hex>='A' && m_hex<='F')?(10+m_hex-'A'):\ 159 ((m_hex>='a' && m_hex<='f')?(10+m_hex-'a'):0))) 163 #if defined(__llvm__) && defined(__has_builtin) 164 #define _llvm_has_builtin(x) __has_builtin(x) 166 #define _llvm_has_builtin(x) 0 169 #if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_mul_overflow) 170 # define _mul_overflow __builtin_mul_overflow 173 #if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_add_overflow) 174 # define _add_overflow __builtin_add_overflow 183 static _FORCE_INLINE_
unsigned int nearest_power_of_2(
unsigned int x) {
196 static _FORCE_INLINE_ T nearest_power_of_2_templated(T x) {
201 for (
size_t i = 0; i <
sizeof(T); i++)
209 static inline unsigned int nearest_shift(
unsigned int p_number) {
211 for (
int i=30;i>=0;i--) {
221 static inline int get_shift_from_power_of_2(
unsigned int p_pixel ) {
225 for (
unsigned int i=0;i<32;i++) {
227 if (p_pixel==(
unsigned int)(1<<i))
235 static inline uint16_t BSWAP16(uint16_t x) {
236 return (x>>8)|(x<<8);
239 static inline uint32_t BSWAP32(uint32_t x) {
240 return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24));
244 static inline uint64_t BSWAP64(uint64_t x) {
245 x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
246 x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
247 x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
259 inline bool operator()(
const T& p_a,
const T& p_b)
const {
return (p_a<p_b); }
265 void _global_unlock();
273 #define GLOBAL_LOCK_FUNCTION _GlobalLock _global_lock_; 276 #define SAFE_CAST static_cast 280 #define SAFE_CAST dynamic_cast 286 #define __STRX(m_index) #m_index 287 #define __STR(m_index) __STRX(m_index) Definition: typedefs.h:267
Definition: typedefs.h:257