From 08036d15e9acfb21e7d222fb15414eefb01cc678 Mon Sep 17 00:00:00 2001 From: Joshua Cranmer Date: Tue, 12 Nov 2013 18:22:38 -0600 Subject: [PATCH] Bug 935789, part 1: Kill most uses of prbit.h, r=ehsan --HG-- extra : rebase_source : 4c44e60c72e0ece3cea7ed1cf79079bd2a1b6487 --- content/base/src/nsAttrAndChildArray.cpp | 4 ++-- gfx/gl/GLContextProviderGLX.cpp | 5 ++--- modules/libpref/src/nsPrefBranch.h | 1 - netwerk/cache/nsDiskCacheDevice.cpp | 1 - netwerk/cache/nsMemoryCacheDevice.cpp | 3 ++- .../rtsp/controller/RtspController.cpp | 1 - rdf/base/src/nsRDFService.cpp | 1 - xpcom/ds/nsSupportsArray.cpp | 4 ++-- xpcom/glue/nsVoidArray.cpp | 4 ++-- xpcom/glue/pldhash.cpp | 20 +++++++++---------- xpcom/io/nsStorageStream.cpp | 4 ++-- 11 files changed, 21 insertions(+), 27 deletions(-) diff --git a/content/base/src/nsAttrAndChildArray.cpp b/content/base/src/nsAttrAndChildArray.cpp index 4275cd9eda8..70796e9af72 100644 --- a/content/base/src/nsAttrAndChildArray.cpp +++ b/content/base/src/nsAttrAndChildArray.cpp @@ -10,10 +10,10 @@ #include "nsAttrAndChildArray.h" +#include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "nsMappedAttributeElement.h" -#include "prbit.h" #include "nsString.h" #include "nsHTMLStyleSheet.h" #include "nsRuleWalker.h" @@ -772,7 +772,7 @@ nsAttrAndChildArray::GrowBy(uint32_t aGrowSize) } while (size < minSize); } else { - size = 1u << PR_CeilingLog2(minSize); + size = 1u << mozilla::CeilingLog2(minSize); } bool needToInitialize = !mImpl; diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 141cd7807b3..71bdbb61ddf 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -15,10 +15,10 @@ #include #include +#include "mozilla/MathAlgorithms.h" #include "mozilla/X11Util.h" #include "prenv.h" -#include "prbit.h" // for PR_FLOOR_LOG2 #include "GLContextProvider.h" #include "GLLibraryLoader.h" #include "nsDebug.h" @@ -299,8 +299,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface) return None; } const XRenderDirectFormat& direct = format->direct; - int alphaSize; - PR_FLOOR_LOG2(alphaSize, direct.alphaMask + 1); + int alphaSize = FloorLog2(direct.alphaMask + 1); NS_ASSERTION((1 << alphaSize) - 1 == direct.alphaMask, "Unexpected render format with non-adjacent alpha bits"); diff --git a/modules/libpref/src/nsPrefBranch.h b/modules/libpref/src/nsPrefBranch.h index 8884e60a284..b4f23447ae4 100644 --- a/modules/libpref/src/nsPrefBranch.h +++ b/modules/libpref/src/nsPrefBranch.h @@ -18,7 +18,6 @@ #include "nsWeakReference.h" #include "nsClassHashtable.h" #include "nsCRT.h" -#include "prbit.h" #include "nsTraceRefcnt.h" #include "mozilla/HashFunctions.h" #include "mozilla/MemoryReporting.h" diff --git a/netwerk/cache/nsDiskCacheDevice.cpp b/netwerk/cache/nsDiskCacheDevice.cpp index 6e3ae9d0cfc..b21c96f1a59 100644 --- a/netwerk/cache/nsDiskCacheDevice.cpp +++ b/netwerk/cache/nsDiskCacheDevice.cpp @@ -24,7 +24,6 @@ #endif #include "prthread.h" -#include "prbit.h" #include "private/pprio.h" diff --git a/netwerk/cache/nsMemoryCacheDevice.cpp b/netwerk/cache/nsMemoryCacheDevice.cpp index eb5926c302c..d0e765ae580 100644 --- a/netwerk/cache/nsMemoryCacheDevice.cpp +++ b/netwerk/cache/nsMemoryCacheDevice.cpp @@ -13,6 +13,7 @@ #include "nsIMemoryReporter.h" #include "nsCRT.h" #include "nsReadableUtils.h" +#include "mozilla/MathAlgorithms.h" #include "mozilla/Telemetry.h" #include @@ -429,7 +430,7 @@ nsMemoryCacheDevice::EvictionList(nsCacheEntry * entry, int32_t deltaSize) int32_t size = deltaSize + (int32_t)entry->DataSize(); int32_t fetchCount = std::max(1, entry->FetchCount()); - return std::min(PR_FloorLog2(size / fetchCount), kQueueCount - 1); + return std::min((int)mozilla::FloorLog2(size / fetchCount), kQueueCount - 1); } diff --git a/netwerk/protocol/rtsp/controller/RtspController.cpp b/netwerk/protocol/rtsp/controller/RtspController.cpp index c6426a7c82f..1eee5119dc5 100644 --- a/netwerk/protocol/rtsp/controller/RtspController.cpp +++ b/netwerk/protocol/rtsp/controller/RtspController.cpp @@ -38,7 +38,6 @@ #include "plbase64.h" #include "prmem.h" #include "prnetdb.h" -#include "prbit.h" #include "zlib.h" #include #include "nsDebug.h" diff --git a/rdf/base/src/nsRDFService.cpp b/rdf/base/src/nsRDFService.cpp index f5d83817757..76ac6bbe7a7 100644 --- a/rdf/base/src/nsRDFService.cpp +++ b/rdf/base/src/nsRDFService.cpp @@ -55,7 +55,6 @@ #include "rdf.h" #include "nsCRT.h" #include "nsCRTGlue.h" -#include "prbit.h" #include "mozilla/HashFunctions.h" using namespace mozilla; diff --git a/xpcom/ds/nsSupportsArray.cpp b/xpcom/ds/nsSupportsArray.cpp index 9e4207b1997..176c73cf28d 100644 --- a/xpcom/ds/nsSupportsArray.cpp +++ b/xpcom/ds/nsSupportsArray.cpp @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include -#include "prbit.h" +#include "mozilla/MathAlgorithms.h" #include "nsSupportsArray.h" #include "nsSupportsArrayEnumerator.h" #include "nsIObjectInputStream.h" @@ -129,7 +129,7 @@ void nsSupportsArray::GrowArrayBy(int32_t aGrowBy) // Select the next power-of-two size in bytes above that if newSize is // not a power of two. if (newSize & (newSize - 1)) - newSize = 1u << PR_CeilingLog2(newSize); + newSize = 1u << mozilla::CeilingLog2(newSize); newCount = newSize / sizeof(mArray[0]); } diff --git a/xpcom/glue/nsVoidArray.cpp b/xpcom/glue/nsVoidArray.cpp index 02f4e13857c..946e9a002e9 100644 --- a/xpcom/glue/nsVoidArray.cpp +++ b/xpcom/glue/nsVoidArray.cpp @@ -3,12 +3,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include #include "nsVoidArray.h" #include "nsQuickSort.h" -#include "prbit.h" #include "nsISupportsImpl.h" // for nsTraceRefcnt #include "nsAlgorithm.h" @@ -239,7 +239,7 @@ bool nsVoidArray::GrowArrayBy(int32_t aGrowBy) } else { - PR_CEILING_LOG2(newSize, newSize); + newSize = mozilla::CeilingLog2(newSize); newCapacity = CAPACITYOF_IMPL(1u << newSize); } } diff --git a/xpcom/glue/pldhash.cpp b/xpcom/glue/pldhash.cpp index 1492f48cacf..20a177138a8 100644 --- a/xpcom/glue/pldhash.cpp +++ b/xpcom/glue/pldhash.cpp @@ -9,9 +9,9 @@ #include #include #include -#include "prbit.h" #include "pldhash.h" #include "mozilla/HashFunctions.h" +#include "mozilla/MathAlgorithms.h" #include "nsDebug.h" /* for PR_ASSERT */ #include "nsAlgorithm.h" #include "mozilla/Likely.h" @@ -45,22 +45,22 @@ table_->recursionLevel == IMMUTABLE_RECURSION_LEVEL) #define INCREMENT_RECURSION_LEVEL(table_) \ - PR_BEGIN_MACRO \ + do { \ if (table_->recursionLevel != IMMUTABLE_RECURSION_LEVEL) \ ++table_->recursionLevel; \ - PR_END_MACRO + } while(0) #define DECREMENT_RECURSION_LEVEL(table_) \ - PR_BEGIN_MACRO \ + do { \ if (table->recursionLevel != IMMUTABLE_RECURSION_LEVEL) { \ MOZ_ASSERT(table->recursionLevel > 0); \ --table->recursionLevel; \ } \ - PR_END_MACRO + } while(0) #else -#define INCREMENT_RECURSION_LEVEL(table_) PR_BEGIN_MACRO PR_END_MACRO -#define DECREMENT_RECURSION_LEVEL(table_) PR_BEGIN_MACRO PR_END_MACRO +#define INCREMENT_RECURSION_LEVEL(table_) do { } while(0) +#define DECREMENT_RECURSION_LEVEL(table_) do { } while(0) #endif /* defined(DEBUG) */ @@ -206,8 +206,7 @@ PL_DHashTableInit(PLDHashTable *table, const PLDHashTableOps *ops, void *data, if (capacity < PL_DHASH_MIN_SIZE) capacity = PL_DHASH_MIN_SIZE; - int log2; - PR_CEILING_LOG2(log2, capacity); + int log2 = CeilingLog2(capacity); capacity = 1u << log2; if (capacity > PL_DHASH_MAX_SIZE) @@ -661,8 +660,7 @@ PL_DHashTableEnumerate(PLDHashTable *table, PLDHashEnumerator etor, void *arg) if (capacity < PL_DHASH_MIN_SIZE) capacity = PL_DHASH_MIN_SIZE; - uint32_t ceiling; - PR_CEILING_LOG2(ceiling, capacity); + uint32_t ceiling = CeilingLog2(capacity); ceiling -= PL_DHASH_BITS - table->hashShift; (void) ChangeTable(table, ceiling); diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index b71279c2706..c67e74ab46d 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -17,12 +17,12 @@ #include "nsSegmentedBuffer.h" #include "nsStreamUtils.h" #include "nsCOMPtr.h" -#include "prbit.h" #include "nsIInputStream.h" #include "nsISeekableStream.h" #include "prlog.h" #include "mozilla/Attributes.h" #include "mozilla/Likely.h" +#include "mozilla/MathAlgorithms.h" #if defined(PR_LOGGING) // @@ -72,7 +72,7 @@ nsStorageStream::Init(uint32_t segmentSize, uint32_t maxSize, return NS_ERROR_OUT_OF_MEMORY; mSegmentSize = segmentSize; - mSegmentSizeLog2 = PR_FloorLog2(segmentSize); + mSegmentSizeLog2 = mozilla::FloorLog2(segmentSize); // Segment size must be a power of two if (mSegmentSize != ((uint32_t)1 << mSegmentSizeLog2))