Bug 699731 - Remove PR_INT64_MAX / PR_UINT64_MAX from non-nsprpub source; r=ted
authorMs2ger <ms2ger@gmail.com>
Wed, 11 Jan 2012 09:23:07 +0100
changeset 85386 1fd016e845378ce75338579310d278d2afe77a80
parent 85385 df571c75b4c04ddfdc3a4a6dc97e5029d8446aca
child 85387 581a264557030eb6e37be2ecd900d2d102498669
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs699731
milestone12.0a1
Bug 699731 - Remove PR_INT64_MAX / PR_UINT64_MAX from non-nsprpub source; r=ted
content/base/public/nsDOMFile.h
content/base/src/nsDOMBlobBuilder.cpp
content/media/VideoUtils.cpp
content/media/VideoUtils.h
content/media/nsBuiltinDecoderReader.cpp
content/media/nsBuiltinDecoderStateMachine.cpp
content/media/ogg/nsOggCodecState.cpp
content/media/ogg/nsOggCodecState.h
content/media/wave/nsWaveReader.cpp
image/src/RasterImage.cpp
image/src/RasterImage.h
--- a/content/base/public/nsDOMFile.h
+++ b/content/base/public/nsDOMFile.h
@@ -53,20 +53,17 @@
 #include "nsIXMLHttpRequest.h"
 #include "prmem.h"
 #include "nsAutoPtr.h"
 #include "mozilla/dom/indexedDB/FileInfo.h"
 #include "mozilla/dom/indexedDB/FileManager.h"
 #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
 
 #include "mozilla/GuardObjects.h"
-
-#ifndef PR_UINT64_MAX
-#define PR_UINT64_MAX (~(PRUint64)(0))
-#endif
+#include "mozilla/StdInt.h"
 
 class nsIFile;
 class nsIInputStream;
 class nsIClassInfo;
 class nsIBlobBuilder;
 
 nsresult NS_NewBlobBuilder(nsISupports* *aSupports);
 
@@ -94,17 +91,17 @@ public:
     mContentType.SetIsVoid(false);
   }
 
   nsDOMFileBase(const nsAString& aContentType,
                 PRUint64 aStart, PRUint64 aLength)
     : mIsFile(false), mImmutable(false), mContentType(aContentType),
       mStart(aStart), mLength(aLength)
   {
-    NS_ASSERTION(aLength != PR_UINT64_MAX,
+    NS_ASSERTION(aLength != UINT64_MAX,
                  "Must know length when creating slice");
     // Ensure non-null mContentType by default
     mContentType.SetIsVoid(false);
   }
 
   virtual ~nsDOMFileBase() {}
 
   virtual already_AddRefed<nsIDOMBlob>
@@ -115,17 +112,17 @@ public:
   NS_DECL_NSIDOMBLOB
   NS_DECL_NSIDOMFILE
   NS_DECL_NSIXHRSENDABLE
   NS_DECL_NSIMUTABLE
 
 protected:
   bool IsSizeUnknown()
   {
-    return mLength == PR_UINT64_MAX;
+    return mLength == UINT64_MAX;
   }
 
   virtual bool IsStoredFile()
   {
     return false;
   }
 
   virtual bool IsWholeFile()
@@ -147,29 +144,29 @@ protected:
 };
 
 class nsDOMFileFile : public nsDOMFileBase,
                       public nsIJSNativeInitializer
 {
 public:
   // Create as a file
   nsDOMFileFile(nsIFile *aFile)
-    : nsDOMFileBase(EmptyString(), EmptyString(), PR_UINT64_MAX),
+    : nsDOMFileBase(EmptyString(), EmptyString(), UINT64_MAX),
       mFile(aFile), mWholeFile(true), mStoredFile(false)
   {
     NS_ASSERTION(mFile, "must have file");
     // Lazily get the content type and size
     mContentType.SetIsVoid(true);
     mFile->GetLeafName(mName);
   }
 
   // Create as a blob
   nsDOMFileFile(nsIFile *aFile, const nsAString& aContentType,
                 nsISupports *aCacheToken = nsnull)
-    : nsDOMFileBase(aContentType, PR_UINT64_MAX),
+    : nsDOMFileBase(aContentType, UINT64_MAX),
       mFile(aFile), mWholeFile(true), mStoredFile(false),
       mCacheToken(aCacheToken)
   {
     NS_ASSERTION(mFile, "must have file");
   }
 
   // Create as a stored file
   nsDOMFileFile(const nsAString& aName, const nsAString& aContentType,
@@ -189,17 +186,17 @@ public:
       mFile(aFile), mWholeFile(true), mStoredFile(true)
   {
     NS_ASSERTION(mFile, "must have file");
     mFileInfos.AppendElement(aFileInfo);
   }
 
   // Create as a file to be later initialized
   nsDOMFileFile()
-    : nsDOMFileBase(EmptyString(), EmptyString(), PR_UINT64_MAX),
+    : nsDOMFileBase(EmptyString(), EmptyString(), UINT64_MAX),
       mWholeFile(true), mStoredFile(false)
   {
     // Lazily get the content type and size
     mContentType.SetIsVoid(true);
     mName.SetIsVoid(true);
   }
 
   NS_DECL_ISUPPORTS_INHERITED
--- a/content/base/src/nsDOMBlobBuilder.cpp
+++ b/content/base/src/nsDOMBlobBuilder.cpp
@@ -41,38 +41,36 @@
 #include "nsDOMFile.h"
 #include "nsIMultiplexInputStream.h"
 #include "nsStringStream.h"
 #include "nsTArray.h"
 #include "nsJSUtils.h"
 #include "nsContentUtils.h"
 #include "CheckedInt.h"
 
-// XXXkhuey shamelessly stolen from VideoUtils.h.  We should patch NSPR.
-#define PR_INT64_MAX (~((PRInt64)(1) << 63))
-#define PR_INT64_MIN (-PR_INT64_MAX - 1)
+#include "mozilla/StdInt.h"
 
 using namespace mozilla;
 
 class nsDOMMultipartFile : public nsDOMFileBase
 {
 public:
   // Create as a file
   nsDOMMultipartFile(nsTArray<nsCOMPtr<nsIDOMBlob> > aBlobs,
                      const nsAString& aName,
                      const nsAString& aContentType)
-    : nsDOMFileBase(aName, aContentType, PR_UINT64_MAX),
+    : nsDOMFileBase(aName, aContentType, UINT64_MAX),
       mBlobs(aBlobs)
   {
   }
 
   // Create as a blob
   nsDOMMultipartFile(nsTArray<nsCOMPtr<nsIDOMBlob> > aBlobs,
                      const nsAString& aContentType)
-    : nsDOMFileBase(aContentType, PR_UINT64_MAX),
+    : nsDOMFileBase(aContentType, UINT64_MAX),
       mBlobs(aBlobs)
   {
   }
 
   already_AddRefed<nsIDOMBlob>
   CreateSlice(PRUint64 aStart, PRUint64 aLength, const nsAString& aContentType);
 
   NS_IMETHOD GetSize(PRUint64*);
@@ -80,17 +78,17 @@ public:
 
 protected:
   nsTArray<nsCOMPtr<nsIDOMBlob> > mBlobs;
 };
 
 NS_IMETHODIMP
 nsDOMMultipartFile::GetSize(PRUint64* aLength)
 {
-  if (mLength == PR_UINT64_MAX) {
+  if (mLength == UINT64_MAX) {
     CheckedUint64 length = 0;
   
     PRUint32 i;
     PRUint32 len = mBlobs.Length();
     for (i = 0; i < len; i++) {
       nsIDOMBlob* blob = mBlobs.ElementAt(i).get();
       PRUint64 l = 0;
   
--- a/content/media/VideoUtils.cpp
+++ b/content/media/VideoUtils.cpp
@@ -34,16 +34,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "VideoUtils.h"
 #include "nsMathUtils.h"
 #include "prtypes.h"
 
+#include "mozilla/StdInt.h"
+
 // Adds two 32bit unsigned numbers, retuns true if addition succeeded,
 // or false the if addition would result in an overflow.
 bool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult) {
   PRUint64 rl = static_cast<PRUint64>(a) + static_cast<PRUint64>(b);
   if (rl > PR_UINT32_MAX) {
     return false;
   }
   aResult = static_cast<PRUint32>(rl);
@@ -63,21 +65,21 @@ bool MulOverflow32(PRUint32 a, PRUint32 
   aResult = static_cast<PRUint32>(r64);
   return true;
 }
 
 // Adds two 64bit numbers, retuns true if addition succeeded, or false
 // if addition would result in an overflow.
 bool AddOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
   if (b < 1) {
-    if (PR_INT64_MIN - b <= a) {
+    if (INT64_MIN - b <= a) {
       aResult = a + b;
       return true;
     }
-  } else if (PR_INT64_MAX - b >= a) {
+  } else if (INT64_MAX - b >= a) {
     aResult = a + b;
     return true;
   }
   return false;
 }
 
 // 64 bit integer multiplication with overflow checking. Returns true
 // if the multiplication was successful, or false if the operation resulted
@@ -94,38 +96,38 @@ bool MulOverflow(PRInt64 a, PRInt64 b, P
   // (sign_a * sign_b) *
   // ((a_hi * b_hi << 64) +
   //  (a_hi * b_lo << 32) + (a_lo * b_hi << 32) +
   //   a_lo * b_lo)
   //
   // So to check if a*b overflows, we must check each sub part of the above
   // sum.
   //
-  // Note: -1 * PR_INT64_MIN == PR_INT64_MIN ; we can't negate PR_INT64_MIN!
+  // Note: -1 * INT64_MIN == INT64_MIN ; we can't negate INT64_MIN!
   // Note: Shift of negative numbers is undefined.
   //
   // Figure out the sign after multiplication. Then we can just work with
   // unsigned numbers.
   PRInt64 sign = (!(a < 0) == !(b < 0)) ? 1 : -1;
 
   PRInt64 abs_a = (a < 0) ? -a : a;
   PRInt64 abs_b = (b < 0) ? -b : b;
 
   if (abs_a < 0) {
-    NS_ASSERTION(a == PR_INT64_MIN, "How else can this happen?");
+    NS_ASSERTION(a == INT64_MIN, "How else can this happen?");
     if (b == 0 || b == 1) {
       aResult = a * b;
       return true;
     } else {
       return false;
     }
   }
 
   if (abs_b < 0) {
-    NS_ASSERTION(b == PR_INT64_MIN, "How else can this happen?");
+    NS_ASSERTION(b == INT64_MIN, "How else can this happen?");
     if (a == 0 || a == 1) {
       aResult = a * b;
       return true;
     } else {
       return false;
     }
   }
 
@@ -157,17 +159,17 @@ bool MulOverflow(PRInt64 a, PRInt64 b, P
   if (q > PR_INT32_MAX) {
     // q will overflow when we shift by 32; abort.
     return false;
   }
   q <<= 32;
 
   // Both a_lo and b_lo are less than INT32_MAX, so can't overflow.
   PRUint64 lo = a_lo * b_lo;
-  if (lo > PR_INT64_MAX) {
+  if (lo > INT64_MAX) {
     return false;
   }
 
   // Add the final result. We must check for overflow during addition.
   if (!AddOverflow(q, static_cast<PRInt64>(lo), aResult)) {
     return false;
   }
 
--- a/content/media/VideoUtils.h
+++ b/content/media/VideoUtils.h
@@ -44,29 +44,16 @@
 #include "nsRect.h"
 #include "nsIThreadManager.h"
 
 // This file contains stuff we'd rather put elsewhere, but which is
 // dependent on other changes which we don't want to wait for. We plan to
 // remove this file in the near future.
 
 
-// This belongs in prtypes.h
-/************************************************************************
- * MACROS:      PR_INT64_MAX
- *              PR_INT64_MIN
- *              PR_UINT64_MAX
- * DESCRIPTION:
- *  The maximum and minimum values of a PRInt64 or PRUint64.
-************************************************************************/
-
-#define PR_INT64_MAX (~((PRInt64)(1) << 63))
-#define PR_INT64_MIN (-PR_INT64_MAX - 1)
-#define PR_UINT64_MAX (~(PRUint64)(0))
-
 // This belongs in xpcom/monitor/Monitor.h, once we've made
 // mozilla::Monitor non-reentrant.
 namespace mozilla {
 
 /**
  * ReentrantMonitorAutoExit
  * Exit the ReentrantMonitor when it enters scope, and enters it when it leaves 
  * scope.
--- a/content/media/nsBuiltinDecoderReader.cpp
+++ b/content/media/nsBuiltinDecoderReader.cpp
@@ -38,18 +38,20 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISeekableStream.h"
 #include "nsClassHashtable.h"
 #include "nsTArray.h"
 #include "nsBuiltinDecoder.h"
 #include "nsBuiltinDecoderReader.h"
 #include "nsBuiltinDecoderStateMachine.h"
+#include "VideoUtils.h"
+
 #include "mozilla/mozalloc.h"
-#include "VideoUtils.h"
+#include "mozilla/StdInt.h"
 
 using namespace mozilla;
 using mozilla::layers::ImageContainer;
 using mozilla::layers::PlanarYCbCrImage;
 
 // Verify these values are sane. Once we've checked the frame sizes, we then
 // can do less integer overflow checking.
 PR_STATIC_ASSERT(MAX_VIDEO_WIDTH < PlanarYCbCrImage::MAX_DIMENSION);
@@ -211,18 +213,18 @@ nsresult nsBuiltinDecoderReader::ResetDe
 
 VideoData* nsBuiltinDecoderReader::FindStartTime(PRInt64& aOutStartTime)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on state machine or decode thread.");
 
   // Extract the start times of the bitstreams in order to calculate
   // the duration.
-  PRInt64 videoStartTime = PR_INT64_MAX;
-  PRInt64 audioStartTime = PR_INT64_MAX;
+  PRInt64 videoStartTime = INT64_MAX;
+  PRInt64 audioStartTime = INT64_MAX;
   VideoData* videoData = nsnull;
 
   if (HasVideo()) {
     videoData = DecodeToFirstData(&nsBuiltinDecoderReader::DecodeVideoFrame,
                                   mVideoQueue);
     if (videoData) {
       videoStartTime = videoData->mTime;
     }
@@ -231,17 +233,17 @@ VideoData* nsBuiltinDecoderReader::FindS
     AudioData* audioData = DecodeToFirstData(&nsBuiltinDecoderReader::DecodeAudioData,
                                              mAudioQueue);
     if (audioData) {
       audioStartTime = audioData->mTime;
     }
   }
 
   PRInt64 startTime = NS_MIN(videoStartTime, audioStartTime);
-  if (startTime != PR_INT64_MAX) {
+  if (startTime != INT64_MAX) {
     aOutStartTime = startTime;
   }
 
   return videoData;
 }
 
 template<class Data>
 Data* nsBuiltinDecoderReader::DecodeToFirstData(DecodeFn aDecodeFn,
--- a/content/media/nsBuiltinDecoderStateMachine.cpp
+++ b/content/media/nsBuiltinDecoderStateMachine.cpp
@@ -40,17 +40,19 @@
 #include "nsAudioStream.h"
 #include "nsTArray.h"
 #include "nsBuiltinDecoder.h"
 #include "nsBuiltinDecoderReader.h"
 #include "nsBuiltinDecoderStateMachine.h"
 #include "mozilla/mozalloc.h"
 #include "VideoUtils.h"
 #include "nsTimeRanges.h"
+
 #include "mozilla/Preferences.h"
+#include "mozilla/StdInt.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gBuiltinDecoderLog;
 #define LOG(type, msg) PR_LOG(gBuiltinDecoderLog, type, msg)
 #else
@@ -1157,17 +1159,17 @@ void nsBuiltinDecoderStateMachine::Seek(
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   // nsBuiltinDecoder::mPlayState should be SEEKING while we seek, and
   // in that case nsBuiltinDecoder shouldn't be calling us.
   NS_ASSERTION(mState != DECODER_STATE_SEEKING,
                "We shouldn't already be seeking");
   NS_ASSERTION(mState >= DECODER_STATE_DECODING,
                "We should have loaded metadata");
   double t = aTime * static_cast<double>(USECS_PER_S);
-  if (t > PR_INT64_MAX) {
+  if (t > INT64_MAX) {
     // Prevent integer overflow.
     return;
   }
 
   mSeekTime = static_cast<PRInt64>(t) + mStartTime;
   NS_ASSERTION(mSeekTime >= mStartTime && mSeekTime <= mEndTime,
                "Can only seek in range [0,duration]");
 
--- a/content/media/ogg/nsOggCodecState.cpp
+++ b/content/media/ogg/nsOggCodecState.cpp
@@ -39,16 +39,18 @@
 #include "nsDebug.h"
 #include "nsOggCodecState.h"
 #include "nsOggDecoder.h"
 #include <string.h>
 #include "nsTraceRefcnt.h"
 #include "VideoUtils.h"
 #include "nsBuiltinDecoderReader.h"
 
+#include "mozilla/StdInt.h"
+
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gBuiltinDecoderLog;
 #define LOG(type, msg) PR_LOG(gBuiltinDecoderLog, type, msg)
 #else
 #define LOG(type, msg)
 #endif
 
 nsOggCodecState*
@@ -1040,18 +1042,18 @@ nsresult nsSkeletonState::GetDuration(co
 {
   if (!mActive ||
       mVersion < SKELETON_VERSION(4,0) ||
       !HasIndex() ||
       aTracks.Length() == 0)
   {
     return NS_ERROR_FAILURE;
   }
-  PRInt64 endTime = PR_INT64_MIN;
-  PRInt64 startTime = PR_INT64_MAX;
+  PRInt64 endTime = INT64_MIN;
+  PRInt64 startTime = INT64_MAX;
   for (PRUint32 i=0; i<aTracks.Length(); i++) {
     nsKeyFrameIndex* index = nsnull;
     mIndex.Get(aTracks[i], &index);
     if (!index) {
       // Can't get the timestamps for one of the required tracks, fail.
       return NS_ERROR_FAILURE;
     }
     if (index->mEndTime > endTime) {
--- a/content/media/ogg/nsOggCodecState.h
+++ b/content/media/ogg/nsOggCodecState.h
@@ -46,16 +46,18 @@
 #else
 #include <vorbis/codec.h>
 #endif
 #include <nsDeque.h>
 #include <nsTArray.h>
 #include <nsClassHashtable.h>
 #include "VideoUtils.h"
 
+#include "mozilla/StdInt.h"
+
 // Uncomment the following to validate that we're predicting the number
 // of Vorbis samples in each packet correctly.
 #define VALIDATE_VORBIS_SAMPLE_CALCULATION
 #ifdef  VALIDATE_VORBIS_SAMPLE_CALCULATION
 #include <map>
 #endif
 
 // Deallocates a packet, used in nsPacketQueue below.
@@ -335,32 +337,32 @@ public:
   // the presentation time defined in the skeleton track.
   bool IsPresentable(PRInt64 aTime) { return aTime >= mPresentationTime; }
 
   // Stores the offset of the page on which a keyframe starts,
   // and its presentation time.
   class nsKeyPoint {
   public:
     nsKeyPoint()
-      : mOffset(PR_INT64_MAX),
-        mTime(PR_INT64_MAX) {}
+      : mOffset(INT64_MAX),
+        mTime(INT64_MAX) {}
 
     nsKeyPoint(PRInt64 aOffset, PRInt64 aTime)
       : mOffset(aOffset),
         mTime(aTime) {}
 
     // Offset from start of segment/link-in-the-chain in bytes.
     PRInt64 mOffset;
 
     // Presentation time in usecs.
     PRInt64 mTime;
 
     bool IsNull() {
-      return mOffset == PR_INT64_MAX &&
-             mTime == PR_INT64_MAX;
+      return mOffset == INT64_MAX &&
+             mTime == INT64_MAX;
     }
   };
 
   // Stores a keyframe's byte-offset, presentation time and the serialno
   // of the stream it belongs to.
   class nsSeekTarget {
   public:
     nsSeekTarget() : mSerial(0) {}
--- a/content/media/wave/nsWaveReader.cpp
+++ b/content/media/wave/nsWaveReader.cpp
@@ -38,16 +38,18 @@
 #include "nsError.h"
 #include "nsBuiltinDecoderStateMachine.h"
 #include "nsBuiltinDecoder.h"
 #include "nsMediaStream.h"
 #include "nsWaveReader.h"
 #include "nsTimeRanges.h"
 #include "VideoUtils.h"
 
+#include "mozilla/StdInt.h"
+
 using namespace mozilla;
 
 // Un-comment to enable logging of seek bisections.
 //#define SEEK_LOGGING
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gBuiltinDecoderLog;
 #define LOG(type, msg) PR_LOG(gBuiltinDecoderLog, type, msg)
@@ -220,18 +222,18 @@ bool nsWaveReader::DecodeAudioData()
         *s++ = (PRInt32(v) - PR_INT16_MIN) / float(PR_UINT16_MAX) * 2.F - 1.F;
 #endif
       }
     }
   }
 
   double posTime = BytesToTime(pos);
   double readSizeTime = BytesToTime(readSize);
-  NS_ASSERTION(posTime <= PR_INT64_MAX / USECS_PER_S, "posTime overflow");
-  NS_ASSERTION(readSizeTime <= PR_INT64_MAX / USECS_PER_S, "readSizeTime overflow");
+  NS_ASSERTION(posTime <= INT64_MAX / USECS_PER_S, "posTime overflow");
+  NS_ASSERTION(readSizeTime <= INT64_MAX / USECS_PER_S, "readSizeTime overflow");
   NS_ASSERTION(frames < PR_INT32_MAX, "frames overflow");
 
   mAudioQueue.Push(new AudioData(pos,
                                  static_cast<PRInt64>(posTime * USECS_PER_S),
                                  static_cast<PRInt64>(readSizeTime * USECS_PER_S),
                                  static_cast<PRInt32>(frames),
                                  sampleBuffer.forget(),
                                  mChannels));
@@ -250,21 +252,21 @@ bool nsWaveReader::DecodeVideoFrame(bool
 nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
 {
   NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
   LOG(PR_LOG_DEBUG, ("%p About to seek to %lld", mDecoder, aTarget));
   if (NS_FAILED(ResetDecode())) {
     return NS_ERROR_FAILURE;
   }
   double d = BytesToTime(GetDataLength());
-  NS_ASSERTION(d < PR_INT64_MAX / USECS_PER_S, "Duration overflow"); 
+  NS_ASSERTION(d < INT64_MAX / USECS_PER_S, "Duration overflow"); 
   PRInt64 duration = static_cast<PRInt64>(d * USECS_PER_S);
   double seekTime = NS_MIN(aTarget, duration) / static_cast<double>(USECS_PER_S);
   PRInt64 position = RoundDownToFrame(static_cast<PRInt64>(TimeToBytes(seekTime)));
-  NS_ASSERTION(PR_INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
+  NS_ASSERTION(INT64_MAX - mWavePCMOffset > position, "Integer overflow during wave seek");
   position += mWavePCMOffset;
   return mDecoder->GetStream()->Seek(nsISeekableStream::NS_SEEK_SET, position);
 }
 
 static double RoundToUsecs(double aSeconds) {
   return floor(aSeconds * USECS_PER_S) / USECS_PER_S;
 }
 
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -51,30 +51,32 @@
 #include "RasterImage.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsAutoPtr.h"
 #include "nsStringStream.h"
 #include "prmem.h"
 #include "prenv.h"
 #include "ImageLogging.h"
-#include "mozilla/TimeStamp.h"
-#include "mozilla/Telemetry.h"
-#include "mozilla/Preferences.h"
 #include "ImageLayers.h"
 
 #include "nsPNGDecoder.h"
 #include "nsGIFDecoder2.h"
 #include "nsJPEGDecoder.h"
 #include "nsBMPDecoder.h"
 #include "nsICODecoder.h"
 #include "nsIconDecoder.h"
 
 #include "gfxContext.h"
 
+#include "mozilla/Preferences.h"
+#include "mozilla/StdInt.h"
+#include "mozilla/Telemetry.h"
+#include "mozilla/TimeStamp.h"
+
 using namespace mozilla;
 using namespace mozilla::imagelib;
 using namespace mozilla::layers;
 
 // a mask for flags that will affect the decoding
 #define DECODE_FLAGS_MASK (imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA | imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION)
 #define DECODE_FLAGS_DEFAULT 0
 
@@ -672,17 +674,17 @@ RasterImage::GetCurrentImgFrameEndTime()
   TimeStamp currentFrameTime = mAnim->currentAnimationFrameTime;
   PRInt64 timeout = currentFrame->GetTimeout();
 
   if (timeout < 0) {
     // We need to return a sentinel value in this case, because our logic
     // doesn't work correctly if we have a negative timeout value. The reason
     // this positive infinity was chosen was because it works with the loop in
     // RequestRefresh() above.
-    return TimeStamp() + TimeDuration::FromMilliseconds(UINT64_MAX_VAL);
+    return TimeStamp() + TimeDuration::FromMilliseconds(UINT64_MAX);
   }
 
   TimeDuration durationOfTimeout = TimeDuration::FromMilliseconds(timeout);
   TimeStamp currentFrameEndTime = currentFrameTime + durationOfTimeout;
 
   return currentFrameEndTime;
 }
 
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -78,22 +78,16 @@ class nsIInputStream;
 { /* 376ff2c1-9bf6-418a-b143-3340c00112f7 */         \
      0x376ff2c1,                                     \
      0x9bf6,                                         \
      0x418a,                                         \
     {0xb1, 0x43, 0x33, 0x40, 0xc0, 0x01, 0x12, 0xf7} \
 }
 
 /**
- * It would be nice if we had a macro for this in prtypes.h.
- * TODO: Place this macro in prtypes.h as PR_UINT64_MAX.
- */
-#define UINT64_MAX_VAL PRUint64(-1)
-
-/**
  * Handles static and animated image containers.
  *
  *
  * @par A Quick Walk Through
  * The decoder initializes this class and calls AppendFrame() to add a frame.
  * Once RasterImage detects more than one frame, it starts the animation
  * with StartAnimation(). Note that the invalidation events for RasterImage are
  * generated automatically using nsRefreshDriver.