Bug 924392 - part 1 - don't use JS_BITS_PER_WORD for bit arrays; r=Waldo

This commit is contained in:
Nathan Froyd 2013-10-08 10:04:06 -04:00
parent 92d4df75b8
commit 0c94056933

View File

@ -14,6 +14,8 @@
#include "mozilla/Compiler.h"
#include "mozilla/GuardObjects.h"
#include <limits.h>
#ifdef USE_ZLIB
#include <zlib.h>
#endif
@ -204,16 +206,18 @@ UnsignedPtrDiff(const void *bigger, const void *smaller)
/* A bit array is an array of bits represented by an array of words (size_t). */
static const size_t BitArrayElementBits = sizeof(size_t) * CHAR_BIT;
static inline unsigned
NumWordsForBitArrayOfLength(size_t length)
{
return (length + (JS_BITS_PER_WORD - 1)) / JS_BITS_PER_WORD;
return (length + (BitArrayElementBits - 1)) / BitArrayElementBits;
}
static inline unsigned
BitArrayIndexToWordIndex(size_t length, size_t bitIndex)
{
unsigned wordIndex = bitIndex / JS_BITS_PER_WORD;
unsigned wordIndex = bitIndex / BitArrayElementBits;
JS_ASSERT(wordIndex < length);
return wordIndex;
}
@ -221,7 +225,7 @@ BitArrayIndexToWordIndex(size_t length, size_t bitIndex)
static inline size_t
BitArrayIndexToWordMask(size_t i)
{
return size_t(1) << (i % JS_BITS_PER_WORD);
return size_t(1) << (i % BitArrayElementBits);
}
static inline bool