Bug 795511: Removed usages of PR_BIT and PR_BITMASK from the tree; r=ehsan
--- a/content/base/src/nsAttrAndChildArray.cpp
+++ b/content/base/src/nsAttrAndChildArray.cpp
@@ -748,17 +748,17 @@ nsAttrAndChildArray::GrowBy(uint32_t aGr
uint32_t minSize = size + aGrowSize;
if (minSize <= ATTRCHILD_ARRAY_LINEAR_THRESHOLD) {
do {
size += ATTRCHILD_ARRAY_GROWSIZE;
} while (size < minSize);
}
else {
- size = PR_BIT(PR_CeilingLog2(minSize));
+ size = 1u << PR_CeilingLog2(minSize);
}
bool needToInitialize = !mImpl;
Impl* newImpl = static_cast<Impl*>(PR_Realloc(mImpl, size * sizeof(void*)));
NS_ENSURE_TRUE(newImpl, false);
mImpl = newImpl;
--- a/content/base/src/nsObjectLoadingContent.h
+++ b/content/base/src/nsObjectLoadingContent.h
@@ -165,31 +165,31 @@ class nsObjectLoadingContent : public ns
* created
* @param aForceLoad If we should reload this content (and re-attempt the
* channel open) even if our parameters did not change
*/
nsresult LoadObject(bool aNotify,
bool aForceLoad = false);
enum Capabilities {
- eSupportImages = PR_BIT(0), // Images are supported (imgILoader)
- eSupportPlugins = PR_BIT(1), // Plugins are supported (nsIPluginHost)
- eSupportDocuments = PR_BIT(2), // Documents are supported
+ eSupportImages = 1u << 0, // Images are supported (imgILoader)
+ eSupportPlugins = 1u << 1, // Plugins are supported (nsIPluginHost)
+ eSupportDocuments = 1u << 2, // Documents are supported
// (nsIDocumentLoaderFactory)
// This flag always includes SVG
- eSupportSVG = PR_BIT(3), // SVG is supported (image/svg+xml)
- eSupportClassID = PR_BIT(4), // The classid attribute is supported
+ eSupportSVG = 1u << 3, // SVG is supported (image/svg+xml)
+ eSupportClassID = 1u << 4, // The classid attribute is supported
// Allows us to load a plugin if it matches a MIME type or file extension
// registered to a plugin without opening its specified URI first. Can
// result in launching plugins for URIs that return differing content
// types. Plugins without URIs may instantiate regardless.
// XXX(johns) this is our legacy behavior on <embed> tags, whereas object
// will always open a channel and check its MIME if a URI is present.
- eAllowPluginSkipChannel = PR_BIT(5)
+ eAllowPluginSkipChannel = 1u << 5
};
/**
* Returns the list of capabilities this content node supports. This is a
* bitmask consisting of flags from the Capabilities enum.
*
* The default implementation supports all types but not
* eSupportClassID or eAllowPluginSkipChannel
@@ -216,27 +216,27 @@ class nsObjectLoadingContent : public ns
bool aNullParent = true);
private:
// Object parameter changes returned by UpdateObjectParameters
enum ParameterUpdateFlags {
eParamNoChange = 0,
// Parameters that potentially affect the channel changed
// - mOriginalURI, mOriginalContentType
- eParamChannelChanged = PR_BIT(0),
+ eParamChannelChanged = 1u << 0,
// Parameters that affect displayed content changed
// - mURI, mContentType, mType, mBaseURI
- eParamStateChanged = PR_BIT(1),
+ eParamStateChanged = 1u << 1,
// The effective content type changed, independant of object type. This
// can happen when changing from Loading -> Final type, but doesn't
// necessarily happen when changing between object types. E.g., if a PDF
// handler was installed between the last load of this object and now, we
// might change from eType_Document -> eType_Plugin without changing
// ContentType
- eParamContentTypeChanged = PR_BIT(2)
+ eParamContentTypeChanged = 1u << 2
};
/**
* Loads fallback content with the specified FallbackType
*
* @param aType FallbackType value for type of fallback we're loading
* @param aNotify Send notifications and events. If false, caller is
* responsible for doing so
--- a/dom/base/ScreenOrientation.h
+++ b/dom/base/ScreenOrientation.h
@@ -11,17 +11,17 @@ namespace mozilla {
namespace dom {
// Make sure that any change here is also made in
// * mobile/android/base/GeckoScreenOrientationListener.java
// * embedding/android/GeckoScreenOrientationListener.java
typedef uint32_t ScreenOrientation;
static const ScreenOrientation eScreenOrientation_None = 0;
-static const ScreenOrientation eScreenOrientation_PortraitPrimary = PR_BIT(0);
-static const ScreenOrientation eScreenOrientation_PortraitSecondary = PR_BIT(1);
-static const ScreenOrientation eScreenOrientation_LandscapePrimary = PR_BIT(2);
-static const ScreenOrientation eScreenOrientation_LandscapeSecondary = PR_BIT(3);
+static const ScreenOrientation eScreenOrientation_PortraitPrimary = 1u << 0;
+static const ScreenOrientation eScreenOrientation_PortraitSecondary = 1u << 1;
+static const ScreenOrientation eScreenOrientation_LandscapePrimary = 1u << 2;
+static const ScreenOrientation eScreenOrientation_LandscapeSecondary = 1u << 3;
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ScreenOrientation_h
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -25,22 +25,22 @@ class Image;
#include "nsAutoPtr.h"
#include "nsTObserverArray.h"
#include "nsIRunnable.h"
#include "nscore.h"
#include "nsWeakReference.h"
#include "imgIDecoderObserver.h"
enum {
- stateRequestStarted = PR_BIT(0),
- stateHasSize = PR_BIT(1),
- stateDecodeStopped = PR_BIT(3),
- stateFrameStopped = PR_BIT(4),
- stateRequestStopped = PR_BIT(5),
- stateBlockingOnload = PR_BIT(6)
+ stateRequestStarted = 1u << 0,
+ stateHasSize = 1u << 1,
+ stateDecodeStopped = 1u << 3,
+ stateFrameStopped = 1u << 4,
+ stateRequestStopped = 1u << 5,
+ stateBlockingOnload = 1u << 6
};
class imgStatusTrackerObserver : public imgIDecoderObserver,
public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMGIDECODEROBSERVER
--- a/layout/tables/celldata.h
+++ b/layout/tables/celldata.h
@@ -158,17 +158,17 @@ enum BCBorderOwner
eCellOwner = 9,
eAjaCellOwner = 10 // cell to the top or to the left
};
typedef uint16_t BCPixelSize;
// These are the max sizes that are stored. If they are exceeded, then the max is stored and
// the actual value is computed when needed.
-#define MAX_BORDER_WIDTH nscoord(PR_BITMASK(sizeof(BCPixelSize) * 8))
+#define MAX_BORDER_WIDTH nscoord((1u << (sizeof(BCPixelSize) * 8)) - 1)
static inline nscoord
BC_BORDER_TOP_HALF_COORD(int32_t p2t, uint16_t px) { return (px - px / 2) * p2t; }
static inline nscoord
BC_BORDER_RIGHT_HALF_COORD(int32_t p2t, uint16_t px) { return ( px / 2) * p2t; }
static inline nscoord
BC_BORDER_BOTTOM_HALF_COORD(int32_t p2t, uint16_t px) { return ( px / 2) * p2t; }
static inline nscoord
--- a/rdf/base/src/nsRDFService.cpp
+++ b/rdf/base/src/nsRDFService.cpp
@@ -870,17 +870,17 @@ kLegalSchemeChars[] = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
static inline bool
IsLegalSchemeCharacter(const char aChar)
{
uint8_t mask = kLegalSchemeChars[aChar >> 3];
- uint8_t bit = PR_BIT(aChar & 0x7);
+ uint8_t bit = 1u << (aChar & 0x7);
return bool((mask & bit) != 0);
}
NS_IMETHODIMP
RDFServiceImpl::GetResource(const nsACString& aURI, nsIRDFResource** aResource)
{
// Sanity checks
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -125,17 +125,17 @@ void nsSupportsArray::GrowArrayBy(int32_
uint32_t newSize = sizeof(mArray[0]) * newCount;
if (newSize >= (uint32_t) kLinearThreshold)
{
// newCount includes enough space for at least kGrowArrayBy new slots.
// Select the next power-of-two size in bytes above that if newSize is
// not a power of two.
if (newSize & (newSize - 1))
- newSize = PR_BIT(PR_CeilingLog2(newSize));
+ newSize = 1u << PR_CeilingLog2(newSize);
newCount = newSize / sizeof(mArray[0]);
}
// XXX This would be far more efficient in many allocators if we used
// XXX PR_Realloc(), etc
nsISupports** oldArray = mArray;
mArray = new nsISupports*[newCount];
--- a/xpcom/glue/nsVoidArray.cpp
+++ b/xpcom/glue/nsVoidArray.cpp
@@ -251,17 +251,17 @@ bool nsVoidArray::GrowArrayBy(int32_t aG
if (GetArraySize() >= kMaxGrowArrayBy)
{
newCapacity = GetArraySize() + NS_MAX(kMaxGrowArrayBy,aGrowBy);
newSize = SIZEOF_IMPL(newCapacity);
}
else
{
PR_CEILING_LOG2(newSize, newSize);
- newCapacity = CAPACITYOF_IMPL(PR_BIT(newSize));
+ newCapacity = CAPACITYOF_IMPL(1u << newSize);
}
}
// frees old mImpl IF this succeeds
if (!SizeTo(newCapacity))
return false;
return true;
}
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -211,17 +211,17 @@ PL_DHashTableInit(PLDHashTable *table, c
table->ops = ops;
table->data = data;
if (capacity < PL_DHASH_MIN_SIZE)
capacity = PL_DHASH_MIN_SIZE;
PR_CEILING_LOG2(log2, capacity);
- capacity = PR_BIT(log2);
+ capacity = 1u << log2;
if (capacity >= PL_DHASH_SIZE_LIMIT)
return false;
table->hashShift = PL_DHASH_BITS - log2;
table->maxAlphaFrac = (uint8_t)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA);
table->minAlphaFrac = (uint8_t)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA);
table->entrySize = entrySize;
table->entryCount = table->removedCount = 0;
table->generation = 0;
@@ -401,17 +401,17 @@ SearchTable(PLDHashTable *table, const v
if (MATCH_ENTRY_KEYHASH(entry, keyHash) && matchEntry(table, entry, key)) {
METER(table->stats.hits++);
return entry;
}
/* Collision: double hash. */
sizeLog2 = PL_DHASH_BITS - table->hashShift;
hash2 = HASH2(keyHash, sizeLog2, hashShift);
- sizeMask = PR_BITMASK(sizeLog2);
+ sizeMask = (1u << sizeLog2) - 1;
/* Save the first removed entry pointer so PL_DHASH_ADD can recycle it. */
firstRemoved = NULL;
for (;;) {
if (NS_UNLIKELY(ENTRY_IS_REMOVED(entry))) {
if (!firstRemoved)
firstRemoved = entry;
@@ -472,17 +472,17 @@ FindFreeEntry(PLDHashTable *table, PLDHa
if (PL_DHASH_ENTRY_IS_FREE(entry)) {
METER(table->stats.misses++);
return entry;
}
/* Collision: double hash. */
sizeLog2 = PL_DHASH_BITS - table->hashShift;
hash2 = HASH2(keyHash, sizeLog2, hashShift);
- sizeMask = PR_BITMASK(sizeLog2);
+ sizeMask = (1u << sizeLog2) - 1;
for (;;) {
NS_ASSERTION(!ENTRY_IS_REMOVED(entry),
"!ENTRY_IS_REMOVED(entry)");
entry->keyHash |= COLLISION_FLAG;
METER(table->stats.steps++);
hash1 -= hash2;
@@ -510,18 +510,18 @@ ChangeTable(PLDHashTable *table, int del
PLDHashMoveEntry moveEntry;
#ifdef DEBUG
uint32_t recursionLevel;
#endif
/* Look, but don't touch, until we succeed in getting new entry store. */
oldLog2 = PL_DHASH_BITS - table->hashShift;
newLog2 = oldLog2 + deltaLog2;
- oldCapacity = PR_BIT(oldLog2);
- newCapacity = PR_BIT(newLog2);
+ oldCapacity = 1u << oldLog2;
+ newCapacity = 1u << newLog2;
if (newCapacity >= PL_DHASH_SIZE_LIMIT)
return false;
entrySize = table->entrySize;
nbytes = newCapacity * entrySize;
newEntryStore = (char *) table->ops->allocTable(table,
nbytes + ENTRY_STORE_EXTRA);
if (!newEntryStore)
@@ -823,17 +823,17 @@ PL_DHashTableDumpMeter(PLDHashTable *tab
double sqsum, mean, variance, sigma;
PLDHashEntryHdr *entry, *probe;
entryAddr = table->entryStore;
entrySize = table->entrySize;
hashShift = table->hashShift;
sizeLog2 = PL_DHASH_BITS - hashShift;
tableSize = PL_DHASH_TABLE_SIZE(table);
- sizeMask = PR_BITMASK(sizeLog2);
+ sizeMask = (1u << sizeLog2) - 1;
chainCount = maxChainLen = 0;
hash2 = 0;
sqsum = 0;
for (i = 0; i < tableSize; i++) {
entry = (PLDHashEntryHdr *)entryAddr;
entryAddr += entrySize;
if (!ENTRY_IS_LIVE(entry))
--- a/xpcom/io/nsEscape.h
+++ b/xpcom/io/nsEscape.h
@@ -14,20 +14,20 @@
#include "nsString.h"
/**
* Valid mask values for nsEscape
* Note: these values are copied in nsINetUtil.idl. Any changes should be kept
* in sync.
*/
typedef enum {
- url_All = 0 /**< %-escape every byte unconditionally */
-, url_XAlphas = PR_BIT(0) /**< Normal escape - leave alphas intact, escape the rest */
-, url_XPAlphas = PR_BIT(1) /**< As url_XAlphas, but convert spaces (0x20) to '+' and plus to %2B */
-, url_Path = PR_BIT(2) /**< As url_XAlphas, but don't escape slash ('/') */
+ url_All = 0 /**< %-escape every byte unconditionally */
+, url_XAlphas = 1u << 0 /**< Normal escape - leave alphas intact, escape the rest */
+, url_XPAlphas = 1u << 1 /**< As url_XAlphas, but convert spaces (0x20) to '+' and plus to %2B */
+, url_Path = 1u << 2 /**< As url_XAlphas, but don't escape slash ('/') */
} nsEscapeMask;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Escape the given string according to mask
@@ -68,37 +68,37 @@ nsEscapeHTML2(const PRUnichar *aSourceBu
/**
* NS_EscapeURL/NS_UnescapeURL constants for |flags| parameter:
*
* Note: These values are copied to nsINetUtil.idl
* Any changes should be kept in sync
*/
enum EscapeMask {
/** url components **/
- esc_Scheme = PR_BIT(0),
- esc_Username = PR_BIT(1),
- esc_Password = PR_BIT(2),
- esc_Host = PR_BIT(3),
- esc_Directory = PR_BIT(4),
- esc_FileBaseName = PR_BIT(5),
- esc_FileExtension = PR_BIT(6),
+ esc_Scheme = 1u << 0,
+ esc_Username = 1u << 1,
+ esc_Password = 1u << 2,
+ esc_Host = 1u << 3,
+ esc_Directory = 1u << 4,
+ esc_FileBaseName = 1u << 5,
+ esc_FileExtension = 1u << 6,
esc_FilePath = esc_Directory | esc_FileBaseName | esc_FileExtension,
- esc_Param = PR_BIT(7),
- esc_Query = PR_BIT(8),
- esc_Ref = PR_BIT(9),
+ esc_Param = 1u << 7,
+ esc_Query = 1u << 8,
+ esc_Ref = 1u << 9,
/** special flags **/
esc_Minimal = esc_Scheme | esc_Username | esc_Password | esc_Host | esc_FilePath | esc_Param | esc_Query | esc_Ref,
- esc_Forced = PR_BIT(10), /* forces escaping of existing escape sequences */
- esc_OnlyASCII = PR_BIT(11), /* causes non-ascii octets to be skipped */
- esc_OnlyNonASCII = PR_BIT(12), /* causes _graphic_ ascii octets (0x20-0x7E)
+ esc_Forced = 1u << 10, /* forces escaping of existing escape sequences */
+ esc_OnlyASCII = 1u << 11, /* causes non-ascii octets to be skipped */
+ esc_OnlyNonASCII = 1u << 12, /* causes _graphic_ ascii octets (0x20-0x7E)
* to be skipped when escaping. causes all
* ascii octets (<= 0x7F) to be skipped when unescaping */
- esc_AlwaysCopy = PR_BIT(13), /* copy input to result buf even if escaping is unnecessary */
- esc_Colon = PR_BIT(14), /* forces escape of colon */
- esc_SkipControl = PR_BIT(15) /* skips C0 and DEL from unescaping */
+ esc_AlwaysCopy = 1u << 13, /* copy input to result buf even if escaping is unnecessary */
+ esc_Colon = 1u << 14, /* forces escape of colon */
+ esc_SkipControl = 1u << 15 /* skips C0 and DEL from unescaping */
};
/**
* NS_EscapeURL
*
* Escapes invalid char's in an URL segment. Has no side-effect if the URL
* segment is already escaped. Otherwise, the escaped URL segment is appended
* to |result|.
--- a/xpcom/threads/TimerThread.h
+++ b/xpcom/threads/TimerThread.h
@@ -67,18 +67,18 @@ private:
bool mShutdown;
bool mWaiting;
bool mSleeping;
nsTArray<nsTimerImpl*> mTimers;
#define DELAY_LINE_LENGTH_LOG2 5
-#define DELAY_LINE_LENGTH_MASK PR_BITMASK(DELAY_LINE_LENGTH_LOG2)
-#define DELAY_LINE_LENGTH PR_BIT(DELAY_LINE_LENGTH_LOG2)
+#define DELAY_LINE_LENGTH_MASK ((1u << DELAY_LINE_LENGTH_LOG2) - 1)
+#define DELAY_LINE_LENGTH (1u << DELAY_LINE_LENGTH_LOG2)
int32_t mDelayLine[DELAY_LINE_LENGTH]; // milliseconds
uint32_t mDelayLineCounter;
uint32_t mMinTimerPeriod; // milliseconds
TimeDuration mTimeoutAdjustment;
};
#endif /* TimerThread_h___ */