Bug 785321 - Replace PRUptrdiff with uintptr_t, prtdiff_t or etc; r=ehsan,jrmuizel
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 14 Sep 2012 16:09:52 -0400
changeset 107128 1ff74108db1dd1b983bffff69135ae6116a4b7ae
parent 107127 1ff8c8e3eedd596c11ac0cd2cc2ec90ce1a132a8
child 107129 6e9c93b6dbc27765bb4d50f4890402c0476cca72
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersehsan, jrmuizel
bugs785321
milestone18.0a1
Bug 785321 - Replace PRUptrdiff with uintptr_t, prtdiff_t or etc; r=ehsan,jrmuizel
content/base/src/nsAttrName.h
content/base/src/nsAttrValue.h
content/base/src/nsGenericElement.h
content/base/src/nsPropertyTable.h
content/xbl/src/nsXBLProtoImplMethod.h
dom/base/nsDOMClassInfo.h
dom/base/nsWrapperCache.h
gfx/qcms/qcmstypes.h
gfx/thebes/gfxFont.h
gfx/ycbcr/convert.patch
gfx/ycbcr/yuv_convert.cpp
layout/generic/nsFrame.cpp
layout/generic/nsSplittableFrame.cpp
netwerk/protocol/websocket/WebSocketChannel.cpp
tools/trace-malloc/lib/nsTraceMalloc.c
xpcom/base/nsStackWalk.h
xpcom/io/nsBinaryStream.cpp
--- a/content/base/src/nsAttrName.h
+++ b/content/base/src/nsAttrName.h
@@ -11,17 +11,17 @@
 
 #ifndef nsAttrName_h___
 #define nsAttrName_h___
 
 #include "nsINodeInfo.h"
 #include "nsIAtom.h"
 #include "nsDOMString.h"
 
-typedef PRUptrdiff PtrBits;
+typedef uintptr_t PtrBits;
 
 #define NS_ATTRNAME_NODEINFO_BIT 1
 class nsAttrName
 {
 public:
   nsAttrName(const nsAttrName& aOther)
     : mBits(aOther.mBits)
   {
--- a/content/base/src/nsAttrValue.h
+++ b/content/base/src/nsAttrValue.h
@@ -15,17 +15,17 @@
 #include "nsStringGlue.h"
 #include "nsStringBuffer.h"
 #include "nsColor.h"
 #include "nsCaseTreatment.h"
 #include "nsMargin.h"
 #include "nsCOMPtr.h"
 #include "SVGAttrValueWrapper.h"
 
-typedef PRUptrdiff PtrBits;
+typedef uintptr_t PtrBits;
 class nsAString;
 class nsIAtom;
 class nsIDocument;
 template<class E, class A> class nsTArray;
 struct nsTArrayDefaultAllocator;
 
 namespace mozilla {
 namespace css {
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -52,17 +52,17 @@ class nsEventChainVisitor;
 class nsEventListenerManager;
 class nsIScrollableFrame;
 class nsAttrValueOrString;
 class nsContentList;
 class nsDOMTokenList;
 class ContentUnbinder;
 struct nsRect;
 
-typedef PRUptrdiff PtrBits;
+typedef uintptr_t PtrBits;
 
 /**
  * A generic base class for DOM elements, implementing many nsIContent,
  * nsIDOMNode and nsIDOMElement methods.
  */
 class nsGenericElement : public mozilla::dom::Element
 {
 public:
--- a/content/base/src/nsPropertyTable.h
+++ b/content/base/src/nsPropertyTable.h
@@ -22,17 +22,17 @@
 
 #ifndef nsPropertyTable_h_
 #define nsPropertyTable_h_
 
 #include "nscore.h"
 #include "prtypes.h"
 
 class nsIAtom;
-typedef PRUptrdiff PtrBits;
+typedef uintptr_t PtrBits;
 
 typedef void
 (*NSPropertyFunc)(void           *aObject,
                   nsIAtom        *aPropertyName,
                   void           *aPropertyValue,
                   void           *aData);
 
 /**
--- a/content/xbl/src/nsXBLProtoImplMethod.h
+++ b/content/xbl/src/nsXBLProtoImplMethod.h
@@ -102,29 +102,29 @@ public:
   virtual nsresult Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream);
 
   bool IsCompiled() const
   {
     return !(mUncompiledMethod & BIT_UNCOMPILED);
   }
   void SetUncompiledMethod(nsXBLUncompiledMethod* aUncompiledMethod)
   {
-    mUncompiledMethod = PRUptrdiff(aUncompiledMethod) | BIT_UNCOMPILED;
+    mUncompiledMethod = uintptr_t(aUncompiledMethod) | BIT_UNCOMPILED;
   }
   nsXBLUncompiledMethod* GetUncompiledMethod() const
   {
-    PRUptrdiff unmasked = mUncompiledMethod & ~BIT_UNCOMPILED;
+    uintptr_t unmasked = mUncompiledMethod & ~BIT_UNCOMPILED;
     return reinterpret_cast<nsXBLUncompiledMethod*>(unmasked);
   }
 
 protected:
   enum { BIT_UNCOMPILED = 1 << 0 };
 
   union {
-    PRUptrdiff mUncompiledMethod; // An object that represents the method before being compiled.
+    uintptr_t mUncompiledMethod; // An object that represents the method before being compiled.
     JSObject* mJSMethodObject;    // The JS object for the method (after compilation)
   };
 
 #ifdef DEBUG
   bool mIsCompiled;
 #endif
 };
 
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -77,17 +77,17 @@ struct nsDOMClassInfoData
 };
 
 struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
 {
   const nsCID *mConstructorCID;
 };
 
 
-typedef PRUptrdiff PtrBits;
+typedef uintptr_t PtrBits;
 
 // To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
 // The low bit is set when we created a generic helper for an external
 // (which holds on to the nsDOMClassInfoData).
 #define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(PtrBits(_ptr) & ~0x1)
 #define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(PtrBits(_ptr) | 0x1)
 #define IS_EXTERNAL(_ptr) (PtrBits(_ptr) & 0x1)
 
--- a/dom/base/nsWrapperCache.h
+++ b/dom/base/nsWrapperCache.h
@@ -7,17 +7,17 @@
 #define nsWrapperCache_h___
 
 #include "nsCycleCollectionParticipant.h"
 
 struct JSObject;
 struct JSContext;
 class XPCWrappedNativeScope;
 
-typedef PRUptrdiff PtrBits;
+typedef uintptr_t PtrBits;
 
 namespace mozilla {
 namespace dom {
 namespace workers {
 
 class DOMBindingBase;
 
 } // namespace workers
--- a/gfx/qcms/qcmstypes.h
+++ b/gfx/qcms/qcmstypes.h
@@ -24,17 +24,17 @@ typedef int32_t int32_t;
 typedef uint32_t uint32_t;
 typedef int64_t int64_t;
 typedef uint64_t uint64_t;
 
 #ifdef __OS2__
 /* OS/2's stdlib typdefs uintptr_t. So we'll just include that so we don't collide */
 #include <stdlib.h>
 #elif !defined(__intptr_t_defined) && !defined(_UINTPTR_T_DEFINED)
-typedef PRUptrdiff uintptr_t;
+typedef unsigned long uintptr_t;
 #endif
 #endif
 
 #else // MOZ_QCMS
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 #define IS_LITTLE_ENDIAN
 #elif BYTE_ORDER == BIG_ENDIAN
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -1059,17 +1059,17 @@ private:
         HashEntry(KeyTypePointer aPtr) : nsUint32HashKey(aPtr) {}
         HashEntry(const HashEntry& toCopy) : nsUint32HashKey(toCopy) {
           x = toCopy.x; y = toCopy.y; width = toCopy.width; height = toCopy.height;
         }
 
         float x, y, width, height;
     };
 
-    typedef PRUptrdiff PtrBits;
+    typedef uintptr_t PtrBits;
     enum { BLOCK_SIZE_BITS = 7, BLOCK_SIZE = 1 << BLOCK_SIZE_BITS }; // 128-glyph blocks
 
     class GlyphWidths {
     public:
         void Set(uint32_t aIndex, uint16_t aValue);
         uint16_t Get(uint32_t aIndex) const {
             uint32_t block = aIndex >> BLOCK_SIZE_BITS;
             if (block >= mBlocks.Length())
--- a/gfx/ycbcr/convert.patch
+++ b/gfx/ycbcr/convert.patch
@@ -317,17 +317,17 @@ diff --git a/gfx/ycbcr/yuv_convert.cpp b
      }
    }
  
    // Need padding because FilterRows() will write 1 to 16 extra pixels
    // after the end for SSE2 version.
    uint8 yuvbuf[16 + kFilterBufferSize * 3 + 16];
    uint8* ybuf =
 -      reinterpret_cast<uint8*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15);
-+      reinterpret_cast<uint8*>(reinterpret_cast<PRUptrdiff>(yuvbuf + 15) & ~15);
++      reinterpret_cast<uint8*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15);
    uint8* ubuf = ybuf + kFilterBufferSize;
    uint8* vbuf = ubuf + kFilterBufferSize;
    // TODO(fbarchard): Fixed point math is off by 1 on negatives.
    int yscale_fixed = (source_height << kFractionBits) / height;
  
    // TODO(fbarchard): Split this into separate function for better efficiency.
    for (int y = 0; y < height; ++y) {
      uint8* dest_pixel = rgb_buf + y * rgb_pitch;
--- a/gfx/ycbcr/yuv_convert.cpp
+++ b/gfx/ycbcr/yuv_convert.cpp
@@ -247,17 +247,17 @@ NS_GFX_(void) ScaleYCbCrToRGB32(const ui
       uv_pitch = 1;
     }
   }
 
   // Need padding because FilterRows() will write 1 to 16 extra pixels
   // after the end for SSE2 version.
   uint8 yuvbuf[16 + kFilterBufferSize * 3 + 16];
   uint8* ybuf =
-      reinterpret_cast<uint8*>(reinterpret_cast<PRUptrdiff>(yuvbuf + 15) & ~15);
+      reinterpret_cast<uint8*>(reinterpret_cast<uintptr_t>(yuvbuf + 15) & ~15);
   uint8* ubuf = ybuf + kFilterBufferSize;
   uint8* vbuf = ubuf + kFilterBufferSize;
   // TODO(fbarchard): Fixed point math is off by 1 on negatives.
   int yscale_fixed = (source_height << kFractionBits) / height;
 
   // TODO(fbarchard): Split this into separate function for better efficiency.
   for (int y = 0; y < height; ++y) {
     uint8* dest_pixel = rgb_buf + y * rgb_pitch;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5627,45 +5627,45 @@ nsIFrame::GetConstFrameSelection() const
   return PresContext()->PresShell()->ConstFrameSelection();
 }
 
 #ifdef DEBUG
 NS_IMETHODIMP
 nsFrame::DumpRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
 {
   IndentBy(out, aIndent);
-  fprintf(out, "<frame va=\"%ld\" type=\"", PRUptrdiff(this));
+  fprintf(out, "<frame va=\"%p\" type=\"", (void*)this);
   nsAutoString name;
   GetFrameName(name);
   XMLQuote(name);
   fputs(NS_LossyConvertUTF16toASCII(name).get(), out);
-  fprintf(out, "\" state=\"%016llx\" parent=\"%ld\">\n",
-          (unsigned long long)GetDebugStateBits(), PRUptrdiff(mParent));
+  fprintf(out, "\" state=\"%016llx\" parent=\"%p\">\n",
+          (unsigned long long)GetDebugStateBits(), (void*)mParent);
 
   aIndent++;
   DumpBaseRegressionData(aPresContext, out, aIndent);
   aIndent--;
 
   IndentBy(out, aIndent);
   fprintf(out, "</frame>\n");
 
   return NS_OK;
 }
 
 void
 nsFrame::DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
 {
   if (GetNextSibling()) {
     IndentBy(out, aIndent);
-    fprintf(out, "<next-sibling va=\"%ld\"/>\n", PRUptrdiff(GetNextSibling()));
+    fprintf(out, "<next-sibling va=\"%p\"/>\n", (void*)GetNextSibling());
   }
 
   if (HasView()) {
     IndentBy(out, aIndent);
-    fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(GetView()));
+    fprintf(out, "<view va=\"%p\">\n", (void*)GetView());
     aIndent++;
     // XXX add in code to dump out view state too...
     aIndent--;
     IndentBy(out, aIndent);
     fprintf(out, "</view>\n");
   }
 
   IndentBy(out, aIndent);
--- a/layout/generic/nsSplittableFrame.cpp
+++ b/layout/generic/nsSplittableFrame.cpp
@@ -207,17 +207,17 @@ nsSplittableFrame::RemoveFromFlow(nsIFra
 
 #ifdef DEBUG
 void
 nsSplittableFrame::DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
 {
   nsFrame::DumpBaseRegressionData(aPresContext, out, aIndent);
   if (nullptr != mNextContinuation) {
     IndentBy(out, aIndent);
-    fprintf(out, "<next-continuation va=\"%ld\"/>\n", PRUptrdiff(mNextContinuation));
+    fprintf(out, "<next-continuation va=\"%p\"/>\n", (void*)mNextContinuation);
   }
   if (nullptr != mPrevContinuation) {
     IndentBy(out, aIndent);
-    fprintf(out, "<prev-continuation va=\"%ld\"/>\n", PRUptrdiff(mPrevContinuation));
+    fprintf(out, "<prev-continuation va=\"%p\"/>\n", (void*)mPrevContinuation);
   }
 
 }
 #endif
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -1451,17 +1451,17 @@ WebSocketChannel::ApplyMask(uint32_t mas
 {
   if (!data || len == 0)
     return;
 
   // Optimally we want to apply the mask 32 bits at a time,
   // but the buffer might not be alligned. So we first deal with
   // 0 to 3 bytes of preamble individually
 
-  while (len && (reinterpret_cast<PRUptrdiff>(data) & 3)) {
+  while (len && (reinterpret_cast<uintptr_t>(data) & 3)) {
     *data ^= mask >> 24;
     mask = PR_ROTATE_LEFT32(mask, 8);
     data++;
     len--;
   }
 
   // perform mask on full words of data
 
--- a/tools/trace-malloc/lib/nsTraceMalloc.c
+++ b/tools/trace-malloc/lib/nsTraceMalloc.c
@@ -1048,17 +1048,17 @@ static PLHashEntry *alloc_allocentry(voi
 
 static void alloc_freeentry(void *pool, PLHashEntry *he, unsigned flag)
 {
     allocation *alloc;
 
     if (flag != HT_FREE_ENTRY)
         return;
     alloc = (allocation*) he;
-    if ((PRUptrdiff)(alloc - alloc_heap) < (PRUptrdiff)ALLOC_HEAP_SIZE) {
+    if ((ptrdiff_t)(alloc - alloc_heap) < (ptrdiff_t)ALLOC_HEAP_SIZE) {
         alloc->entry.next = &alloc_freelist->entry;
         alloc_freelist = alloc;
     } else {
         __libc_free((void*) alloc);
     }
 }
 
 static PLHashAllocOps alloc_hashallocops = {
--- a/xpcom/base/nsStackWalk.h
+++ b/xpcom/base/nsStackWalk.h
@@ -51,30 +51,30 @@ NS_StackWalk(NS_WalkStackCallback aCallb
 
 typedef struct {
     /*
      * The name of the shared library or executable containing an
      * address and the address's offset within that library, or empty
      * string and zero if unknown.
      */
     char library[256];
-    PRUptrdiff loffset;
+    ptrdiff_t loffset;
     /*
      * The name of the file name and line number of the code
      * corresponding to the address, or empty string and zero if
      * unknown.
      */
     char filename[256];
     unsigned long lineno;
     /*
      * The name of the function containing an address and the address's
      * offset within that function, or empty string and zero if unknown.
      */
     char function[256];
-    PRUptrdiff foffset;
+    ptrdiff_t foffset;
 } nsCodeAddressDetails;
 
 /**
  * For a given pointer to code, fill in the pieces of information used
  * when printing a stack trace.
  *
  * @param aPC         The code address.
  * @param aDetails    A structure to be filled in with the result.
--- a/xpcom/io/nsBinaryStream.cpp
+++ b/xpcom/io/nsBinaryStream.cpp
@@ -185,17 +185,17 @@ nsBinaryOutputStream::WriteWStringZ(cons
     PRUnichar *copy, temp[64];
     if (length <= 64) {
         copy = temp;
     } else {
         copy = reinterpret_cast<PRUnichar*>(moz_malloc(byteCount));
         if (!copy)
             return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ASSERTION((PRUptrdiff(aString) & 0x1) == 0, "aString not properly aligned");
+    NS_ASSERTION((uintptr_t(aString) & 0x1) == 0, "aString not properly aligned");
     for (uint32_t i = 0; i < length; i++)
         copy[i] = NS_SWAP16(aString[i]);
     rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
     if (copy != temp)
         moz_free(copy);
 #endif
 
     return rv;