diff options
author | marha <marha@users.sourceforge.net> | 2010-04-12 09:53:17 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-04-12 09:53:17 +0000 |
commit | 29b86f9852b2b7ecc31cdfee56679537e40bc6e2 (patch) | |
tree | 1e6ec8ccf2dbf773260a1953b8e13c49f9b7c5f5 /mesalib/src/mesa/main/bitset.h | |
parent | 529236591df7366479a6fac30b387667678fd1ba (diff) | |
download | vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.tar.gz vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.tar.bz2 vcxsrv-29b86f9852b2b7ecc31cdfee56679537e40bc6e2.zip |
svn merge -r524:HEAD "^/branches/released" .
Diffstat (limited to 'mesalib/src/mesa/main/bitset.h')
-rw-r--r-- | mesalib/src/mesa/main/bitset.h | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/mesalib/src/mesa/main/bitset.h b/mesalib/src/mesa/main/bitset.h index 8bd4526cb..9f48b3cce 100644 --- a/mesalib/src/mesa/main/bitset.h +++ b/mesalib/src/mesa/main/bitset.h @@ -27,7 +27,12 @@ * \brief Bitset of arbitrary size definitions. * \author Michal Krol */ - + +#ifndef BITSET_H +#define BITSET_H + +#include "imports.h" + /**************************************************************************** * generic bitset implementation */ @@ -42,10 +47,10 @@ /* bitset operations */ -#define BITSET_COPY(x, y) _mesa_memcpy( (x), (y), sizeof (x) ) -#define BITSET_EQUAL(x, y) (_mesa_memcmp( (x), (y), sizeof (x) ) == 0) -#define BITSET_ZERO(x) _mesa_memset( (x), 0, sizeof (x) ) -#define BITSET_ONES(x) _mesa_memset( (x), 0xff, sizeof (x) ) +#define BITSET_COPY(x, y) memcpy( (x), (y), sizeof (x) ) +#define BITSET_EQUAL(x, y) (memcmp( (x), (y), sizeof (x) ) == 0) +#define BITSET_ZERO(x) memset( (x), 0, sizeof (x) ) +#define BITSET_ONES(x) memset( (x), 0xff, sizeof (x) ) #define BITSET_BITWORD(b) ((b) / BITSET_WORDBITS) #define BITSET_BIT(b) (1 << ((b) % BITSET_WORDBITS)) @@ -74,6 +79,23 @@ ((x)[BITSET_BITWORD(b)] &= ~BITSET_RANGE(b, e)) : \ (assert (!"BITSET_CLEAR_RANGE: bit range crosses word boundary"), 0)) +/* Get first bit set in a bitset. + */ +static INLINE int +__bitset_ffs(const BITSET_WORD *x, int n) +{ + int i; + + for (i = 0; i < n; i++) { + if (x[i]) + return _mesa_ffs(x[i]) + BITSET_WORDBITS * i; + } + + return 0; +} + +#define BITSET_FFS(x) __bitset_ffs(x, Elements(x)) + /**************************************************************************** * 64-bit bitset implementation */ @@ -120,3 +142,4 @@ ((x)[BITSET64_BITWORD(b)] &= ~BITSET64_RANGE(b, e)) : \ (assert (!"BITSET64_CLEAR_RANGE: bit range crosses word boundary"), 0)) +#endif |