(svn r8732) -Codechange/Fix(r8705): Turned the bit-handling macros into template functions. Fixes a problem with MSVC and 64-bit shifts.

This commit is contained in:
celestar
2007-02-14 11:53:39 +00:00
parent a374caf51d
commit bde06e75b4
3 changed files with 27 additions and 8 deletions

View File

@@ -62,11 +62,30 @@ static inline int64 BIGMULS(int32 a, int32 b) {
//#define IS_INSIDE_1D(x, base, size) ((x) >= (base) && (x) < (base) + (size))
#define IS_INSIDE_1D(x, base, size) ( (uint)((x) - (base)) < ((uint)(size)) )
template <typename T>
static inline bool HASBIT(T x, int y)
{
return (x & (((T)1) << y)) != 0;
}
template <typename T>
static inline T SETBIT(T& x, int y)
{
return x |= (((T)1) << y);
}
template <typename T>
static inline T CLRBIT(T& x, int y)
{
return x &= ~(((T)1) << y);
}
template <typename T>
static inline T TOGGLEBIT(T& x, int y)
{
return x ^= (((T)1) << y);
}
#define HASBIT(x,y) (((x) & (1 << (y))) != 0)
#define SETBIT(x,y) ((x) |= (1 << (y)))
#define CLRBIT(x,y) ((x) &= ~(1 << (y)))
#define TOGGLEBIT(x,y) ((x) ^= (1 << (y)))
// checking more bits. Maybe unneccessary, but easy to use
#define HASBITS(x,y) ((x) & (y))