diff --git a/content/base/public/nsDOMFile.h b/content/base/public/nsDOMFile.h index 7b6a8a9ae4fd..6efdf1d6605c 100644 --- a/content/base/public/nsDOMFile.h +++ b/content/base/public/nsDOMFile.h @@ -58,10 +58,7 @@ #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; @@ -99,7 +96,7 @@ public: : 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); @@ -120,7 +117,7 @@ public: protected: bool IsSizeUnknown() { - return mLength == PR_UINT64_MAX; + return mLength == UINT64_MAX; } virtual bool IsStoredFile() @@ -152,7 +149,7 @@ class nsDOMFileFile : public nsDOMFileBase, 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"); @@ -164,7 +161,7 @@ public: // 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) { @@ -194,7 +191,7 @@ public: // 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 diff --git a/content/base/src/nsDOMBlobBuilder.cpp b/content/base/src/nsDOMBlobBuilder.cpp index c0b99c59de52..4f6644d5d14b 100644 --- a/content/base/src/nsDOMBlobBuilder.cpp +++ b/content/base/src/nsDOMBlobBuilder.cpp @@ -46,9 +46,7 @@ #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; @@ -59,7 +57,7 @@ public: nsDOMMultipartFile(nsTArray > aBlobs, const nsAString& aName, const nsAString& aContentType) - : nsDOMFileBase(aName, aContentType, PR_UINT64_MAX), + : nsDOMFileBase(aName, aContentType, UINT64_MAX), mBlobs(aBlobs) { } @@ -67,7 +65,7 @@ public: // Create as a blob nsDOMMultipartFile(nsTArray > aBlobs, const nsAString& aContentType) - : nsDOMFileBase(aContentType, PR_UINT64_MAX), + : nsDOMFileBase(aContentType, UINT64_MAX), mBlobs(aBlobs) { } @@ -85,7 +83,7 @@ protected: NS_IMETHODIMP nsDOMMultipartFile::GetSize(PRUint64* aLength) { - if (mLength == PR_UINT64_MAX) { + if (mLength == UINT64_MAX) { CheckedUint64 length = 0; PRUint32 i; diff --git a/content/media/VideoUtils.cpp b/content/media/VideoUtils.cpp index 489e6fc3cbee..f9471c1457d6 100644 --- a/content/media/VideoUtils.cpp +++ b/content/media/VideoUtils.cpp @@ -39,6 +39,8 @@ #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) { @@ -68,11 +70,11 @@ bool MulOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult) // 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; } @@ -99,7 +101,7 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) { // 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 @@ -110,7 +112,7 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) { 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; @@ -120,7 +122,7 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) { } 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; @@ -162,7 +164,7 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) { // 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; } diff --git a/content/media/VideoUtils.h b/content/media/VideoUtils.h index 9791cb3330b7..eca859651cef 100644 --- a/content/media/VideoUtils.h +++ b/content/media/VideoUtils.h @@ -49,19 +49,6 @@ // 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 { diff --git a/content/media/nsBuiltinDecoderReader.cpp b/content/media/nsBuiltinDecoderReader.cpp index 02283affb7cf..f2611dd028ac 100644 --- a/content/media/nsBuiltinDecoderReader.cpp +++ b/content/media/nsBuiltinDecoderReader.cpp @@ -43,9 +43,11 @@ #include "nsBuiltinDecoder.h" #include "nsBuiltinDecoderReader.h" #include "nsBuiltinDecoderStateMachine.h" -#include "mozilla/mozalloc.h" #include "VideoUtils.h" +#include "mozilla/mozalloc.h" +#include "mozilla/StdInt.h" + using namespace mozilla; using mozilla::layers::ImageContainer; using mozilla::layers::PlanarYCbCrImage; @@ -216,8 +218,8 @@ VideoData* nsBuiltinDecoderReader::FindStartTime(PRInt64& aOutStartTime) // 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()) { @@ -236,7 +238,7 @@ VideoData* nsBuiltinDecoderReader::FindStartTime(PRInt64& aOutStartTime) } PRInt64 startTime = NS_MIN(videoStartTime, audioStartTime); - if (startTime != PR_INT64_MAX) { + if (startTime != INT64_MAX) { aOutStartTime = startTime; } diff --git a/content/media/nsBuiltinDecoderStateMachine.cpp b/content/media/nsBuiltinDecoderStateMachine.cpp index 8e6206ef5263..92d37b6f8fb7 100644 --- a/content/media/nsBuiltinDecoderStateMachine.cpp +++ b/content/media/nsBuiltinDecoderStateMachine.cpp @@ -45,7 +45,9 @@ #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; @@ -1162,7 +1164,7 @@ void nsBuiltinDecoderStateMachine::Seek(double aTime) NS_ASSERTION(mState >= DECODER_STATE_DECODING, "We should have loaded metadata"); double t = aTime * static_cast(USECS_PER_S); - if (t > PR_INT64_MAX) { + if (t > INT64_MAX) { // Prevent integer overflow. return; } diff --git a/content/media/ogg/nsOggCodecState.cpp b/content/media/ogg/nsOggCodecState.cpp index 6cfd7df35777..036420a0df27 100644 --- a/content/media/ogg/nsOggCodecState.cpp +++ b/content/media/ogg/nsOggCodecState.cpp @@ -44,6 +44,8 @@ #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) @@ -1045,8 +1047,8 @@ nsresult nsSkeletonState::GetDuration(const nsTArray& aTracks, { 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 #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 @@ -340,8 +342,8 @@ public: 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), @@ -354,8 +356,8 @@ public: PRInt64 mTime; bool IsNull() { - return mOffset == PR_INT64_MAX && - mTime == PR_INT64_MAX; + return mOffset == INT64_MAX && + mTime == INT64_MAX; } }; diff --git a/content/media/wave/nsWaveReader.cpp b/content/media/wave/nsWaveReader.cpp index 9721b4d32dbc..18ace2935778 100644 --- a/content/media/wave/nsWaveReader.cpp +++ b/content/media/wave/nsWaveReader.cpp @@ -43,6 +43,8 @@ #include "nsTimeRanges.h" #include "VideoUtils.h" +#include "mozilla/StdInt.h" + using namespace mozilla; // Un-comment to enable logging of seek bisections. @@ -225,8 +227,8 @@ bool nsWaveReader::DecodeAudioData() 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, @@ -255,11 +257,11 @@ nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTim 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(d * USECS_PER_S); double seekTime = NS_MIN(aTarget, duration) / static_cast(USECS_PER_S); PRInt64 position = RoundDownToFrame(static_cast(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); } diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index bf33f74bb50a..9873112a5fa1 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -56,9 +56,6 @@ #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" @@ -70,6 +67,11 @@ #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; @@ -677,7 +679,7 @@ RasterImage::GetCurrentImgFrameEndTime() const // 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); diff --git a/image/src/RasterImage.h b/image/src/RasterImage.h index d78355ffd0db..7e7c34e585c4 100644 --- a/image/src/RasterImage.h +++ b/image/src/RasterImage.h @@ -82,12 +82,6 @@ class nsIInputStream; {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. *