1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
#ifdef __cplusplus
inline void memset32(void *ptr, uint32 value, int count) { uint32 *p = (uint32 *)ptr; for ( int i=0; i < count; i++ ) *p++ = value; }
template<class T> int16 __PAIR__( int8 high, T low) { return ((( int16)high) << sizeof(high)*8) | uint8(low); } template<class T> int32 __PAIR__( int16 high, T low) { return ((( int32)high) << sizeof(high)*8) | uint16(low); } template<class T> int64 __PAIR__( int32 high, T low) { return ((( int64)high) << sizeof(high)*8) | uint32(low); } template<class T> uint16 __PAIR__(uint8 high, T low) { return (((uint16)high) << sizeof(high)*8) | uint8(low); } template<class T> uint32 __PAIR__(uint16 high, T low) { return (((uint32)high) << sizeof(high)*8) | uint16(low); } template<class T> uint64 __PAIR__(uint32 high, T low) { return (((uint64)high) << sizeof(high)*8) | uint32(low); }
template<class T> T __ROL__(T value, uint count) { const uint nbits = sizeof(T) * 8; count %= nbits;
T high = value >> (nbits - count); value <<= count; value |= high; return value; }
template<class T> T __ROR__(T value, uint count) { const uint nbits = sizeof(T) * 8; count %= nbits;
T low = value << (nbits - count); value >>= count; value |= low; return value; }
template<class T> int8 __MKCSHL__(T value, uint count) { const uint nbits = sizeof(T) * 8; count %= nbits;
return (value >> (nbits-count)) & 1; }
template<class T> int8 __MKCSHR__(T value, uint count) { return (value >> (count-1)) & 1; }
template<class T> int8 __SETS__(T x) { if ( sizeof(T) == 1 ) return int8(x) < 0; if ( sizeof(T) == 2 ) return int16(x) < 0; if ( sizeof(T) == 4 ) return int32(x) < 0; return int64(x) < 0; }
template<class T, class U> int8 __OFSUB__(T x, U y) { if ( sizeof(T) < sizeof(U) ) { U x2 = x; int8 sx = __SETS__(x2); return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y)); } else { T y2 = y; int8 sx = __SETS__(x); return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2)); } }
template<class T, class U> int8 __OFADD__(T x, U y) { if ( sizeof(T) < sizeof(U) ) { U x2 = x; int8 sx = __SETS__(x2); return ((1 ^ sx) ^ __SETS__(y)) & (sx ^ __SETS__(x2+y)); } else { T y2 = y; int8 sx = __SETS__(x); return ((1 ^ sx) ^ __SETS__(y2)) & (sx ^ __SETS__(x+y2)); } }
template<class T, class U> int8 __CFSUB__(T x, U y) { int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); if ( size == 1 ) return uint8(x) < uint8(y); if ( size == 2 ) return uint16(x) < uint16(y); if ( size == 4 ) return uint32(x) < uint32(y); return uint64(x) < uint64(y); }
template<class T, class U> int8 __CFADD__(T x, U y) { int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); if ( size == 1 ) return uint8(x) > uint8(x+y); if ( size == 2 ) return uint16(x) > uint16(x+y); if ( size == 4 ) return uint32(x) > uint32(x+y); return uint64(x) > uint64(x+y); }
#else
#define __PAIR__(high, low) (((uint64)(high)<<sizeof(high)*8) | low)
#define __ROL__(x, y) __rotl__(x, y) #define __ROR__(x, y) __rotr__(x, y) #define __CFSHL__(x, y) invalid_operation #define __CFSHR__(x, y) invalid_operation #define __CFADD__(x, y) invalid_operation #define __CFSUB__(x, y) invalid_operation #define __OFADD__(x, y) invalid_operation #define __OFSUB__(x, y) invalid_operation #endif
#define __RCL__(x, y) invalid_operation #define __RCR__(x, y) invalid_operation #define __MKCRCL__(x, y) invalid_operation #define __MKCRCR__(x, y) invalid_operation #define __SETP__(x, y) invalid_operation
#define _UNKNOWN char
#ifdef _MSC_VER #define snprintf _snprintf #define vsnprintf _vsnprintf #endif
|