Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1036789 - Convert the third quarter of MFBT to Gecko style. r=Ms2…
Browse files Browse the repository at this point in the history
…ger.
  • Loading branch information
nnethercote committed Jul 11, 2014
1 parent 9f0b979 commit bb8bad3
Show file tree
Hide file tree
Showing 48 changed files with 1,935 additions and 1,773 deletions.
2 changes: 1 addition & 1 deletion content/base/src/nsDOMFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ class DOMFileImplMemoryDataOwnerMemoryReporter MOZ_FINAL
} else {
SHA1Sum sha1;
sha1.update(owner->mData, owner->mLength);
uint8_t digest[SHA1Sum::HashSize]; // SHA1 digests are 20 bytes long.
uint8_t digest[SHA1Sum::kHashSize]; // SHA1 digests are 20 bytes long.
sha1.finish(digest);

nsAutoCString digestString;
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/LayerScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ class LayerScopeWebSocketHandler : public nsIInputStreamCallback {
SHA1Sum sha1;
nsCString combined(wsKey + guid);
sha1.update(combined.get(), combined.Length());
uint8_t digest[SHA1Sum::HashSize]; // SHA1 digests are 20 bytes long.
uint8_t digest[SHA1Sum::kHashSize]; // SHA1 digests are 20 bytes long.
sha1.finish(digest);
nsCString newString(reinterpret_cast<char*>(digest), SHA1Sum::HashSize);
nsCString newString(reinterpret_cast<char*>(digest), SHA1Sum::kHashSize);
Base64Encode(newString, res);

nsCString response("HTTP/1.1 101 Switching Protocols\r\n");
Expand Down
6 changes: 3 additions & 3 deletions js/public/HashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ class HashTable : private AllocPolicy
#endif

friend class mozilla::ReentrancyGuard;
mutable mozilla::DebugOnly<bool> entered;
mutable mozilla::DebugOnly<bool> mEntered;
mozilla::DebugOnly<uint64_t> mutationCount;

// The default initial capacity is 32 (enough to hold 16 elements), but it
Expand Down Expand Up @@ -1076,7 +1076,7 @@ class HashTable : private AllocPolicy
gen(0),
removedCount(0),
table(nullptr),
entered(false),
mEntered(false),
mutationCount(0)
{}

Expand Down Expand Up @@ -1452,7 +1452,7 @@ class HashTable : private AllocPolicy

void finish()
{
MOZ_ASSERT(!entered);
MOZ_ASSERT(!mEntered);

if (!table)
return;
Expand Down
4 changes: 2 additions & 2 deletions js/src/gc/StoreBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,14 @@ class StoreBuffer

bool aboutToOverflow_;
bool enabled_;
mozilla::DebugOnly<bool> entered; /* For ReentrancyGuard. */
mozilla::DebugOnly<bool> mEntered; /* For ReentrancyGuard. */

public:
explicit StoreBuffer(JSRuntime *rt, const Nursery &nursery)
: bufferVal(), bufferCell(), bufferSlot(), bufferWholeCell(),
bufferRelocVal(), bufferRelocCell(), bufferGeneric(),
runtime_(rt), nursery_(nursery), aboutToOverflow_(false), enabled_(false),
entered(false)
mEntered(false)
{
}

Expand Down
4 changes: 2 additions & 2 deletions mfbt/Alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ template<size_t Align>
struct AlignedElem;

/*
* We have to specialize this template because GCC doesn't like __attribute__((aligned(foo))) where
* foo is a template parameter.
* We have to specialize this template because GCC doesn't like
* __attribute__((aligned(foo))) where foo is a template parameter.
*/

template<>
Expand Down
3 changes: 2 additions & 1 deletion mfbt/ArrayUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ template<typename T>
inline bool
IsInRange(T* aPtr, uintptr_t aBegin, uintptr_t aEnd)
{
return IsInRange(aPtr, reinterpret_cast<T*>(aBegin), reinterpret_cast<T*>(aEnd));
return IsInRange(aPtr,
reinterpret_cast<T*>(aBegin), reinterpret_cast<T*>(aEnd));
}

namespace detail {
Expand Down
7 changes: 4 additions & 3 deletions mfbt/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine)
}

static MOZ_ALWAYS_INLINE void
MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine) MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
{
#ifdef ANDROID
__android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
Expand Down Expand Up @@ -254,7 +255,7 @@ __declspec(noreturn) __inline void MOZ_NoReturn() {}
do { \
MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \
MOZ_REALLY_CRASH(); \
} while(0)
} while (0)
#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -384,7 +385,7 @@ void ValidateAssertConditionType()
#ifdef DEBUG
# define MOZ_ASSERT(...) MOZ_RELEASE_ASSERT(__VA_ARGS__)
#else
# define MOZ_ASSERT(...) do { } while(0)
# define MOZ_ASSERT(...) do { } while (0)
#endif /* DEBUG */

/*
Expand Down
3 changes: 2 additions & 1 deletion mfbt/Atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ struct IntrinsicAddSub<T*, Order> : public IntrinsicBase<T*, Order>
* atomic<T*> is not the same as adding X to a T*. Hence the need
* for this function to provide the correct addend.
*/
static ptrdiff_t fixupAddend(ptrdiff_t aVal) {
static ptrdiff_t fixupAddend(ptrdiff_t aVal)
{
#if defined(__clang__) || defined(_MSC_VER)
return aVal;
#elif defined(__GNUC__) && MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) && \
Expand Down
16 changes: 9 additions & 7 deletions mfbt/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@
* template<typename T>
* class Ptr
* {
* T* ptr;
* MOZ_EXPLICIT_CONVERSION operator bool() const {
* return ptr != nullptr;
* T* mPtr;
* MOZ_EXPLICIT_CONVERSION operator bool() const
* {
* return mPtr != nullptr;
* }
* };
*
Expand Down Expand Up @@ -206,7 +207,8 @@
* function does not return. (The function definition does not need to be
* annotated.)
*
* MOZ_ReportCrash(const char* s, const char* file, int ln) MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
* MOZ_ReportCrash(const char* s, const char* file, int ln)
* MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
*
* Some static analyzers, like scan-build from clang, can use this information
* to eliminate false positives. From the upstream documentation of scan-build:
Expand Down Expand Up @@ -447,13 +449,13 @@
*
* typedef int MOZ_TYPE_ATTRIBUTE MagicInt;
* int MOZ_TYPE_ATTRIBUTE someVariable;
* int * MOZ_TYPE_ATTRIBUTE magicPtrInt;
* int MOZ_TYPE_ATTRIBUTE * ptrToMagicInt;
* int* MOZ_TYPE_ATTRIBUTE magicPtrInt;
* int MOZ_TYPE_ATTRIBUTE* ptrToMagicInt;
*
* Attributes that apply to statements precede the statement:
*
* MOZ_IF_ATTRIBUTE if (x == 0)
* MOZ_DO_ATTRIBUTE do { } while(0);
* MOZ_DO_ATTRIBUTE do { } while (0);
*
* Attributes that apply to labels precede the label:
*
Expand Down
3 changes: 2 additions & 1 deletion mfbt/BinarySearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ namespace mozilla {
* Vector<int> sortedInts = ...
*
* size_t match;
* if (BinarySearch(sortedInts, 0, sortedInts.length(), 13, &match))
* if (BinarySearch(sortedInts, 0, sortedInts.length(), 13, &match)) {
* printf("found 13 at %lu\n", match);
* }
*/

template <typename Container, typename T>
Expand Down
15 changes: 8 additions & 7 deletions mfbt/Char16.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ class char16ptr_t
}

/**
* Some Windows API calls accept BYTE* but require that data actually be WCHAR*.
* Supporting this requires explicit operators to support the requisite explicit
* casts.
* Some Windows API calls accept BYTE* but require that data actually be
* WCHAR*. Supporting this requires explicit operators to support the
* requisite explicit casts.
*/
explicit operator const char*() const
{
Expand All @@ -121,7 +121,8 @@ class char16ptr_t
}
explicit operator unsigned char*() const
{
return const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(mPtr));
return
const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(mPtr));
}
explicit operator void*() const
{
Expand All @@ -133,15 +134,15 @@ class char16ptr_t
{
return mPtr[aIndex];
}
bool operator==(const char16ptr_t &aOther) const
bool operator==(const char16ptr_t& aOther) const
{
return mPtr == aOther.mPtr;
}
bool operator==(decltype(nullptr)) const
{
return mPtr == nullptr;
}
bool operator!=(const char16ptr_t &aOther) const
bool operator!=(const char16ptr_t& aOther) const
{
return mPtr != aOther.mPtr;
}
Expand All @@ -153,7 +154,7 @@ class char16ptr_t
{
return char16ptr_t(mPtr + aValue);
}
ptrdiff_t operator-(const char16ptr_t &aOther) const
ptrdiff_t operator-(const char16ptr_t& aOther) const
{
return mPtr - aOther.mPtr;
}
Expand Down
2 changes: 1 addition & 1 deletion mfbt/CheckedInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ struct NegateImpl<T, true>
* (aX+aY)/aZ, that doesn't crash if aZ==0, and that reports on error (divide by
* zero or integer overflow). You could code it as follows:
@code
bool computeXPlusYOverZ(int aX, int aY, int aZ, int *aResult)
bool computeXPlusYOverZ(int aX, int aY, int aZ, int* aResult)
{
CheckedInt<int> checkedResult = (CheckedInt<int>(aX) + aY) / aZ;
if (checkedResult.isValid()) {
Expand Down
2 changes: 1 addition & 1 deletion mfbt/Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ LZ4::decompress(const char* aSource, char* aDest, size_t aOutputSize)

bool
LZ4::decompress(const char* aSource, size_t aInputSize, char* aDest,
size_t aMaxOutputSize, size_t *aOutputSize)
size_t aMaxOutputSize, size_t* aOutputSize)
{
CheckedInt<int> maxOutputSizeChecked = aMaxOutputSize;
MOZ_ASSERT(maxOutputSizeChecked.isValid());
Expand Down
2 changes: 1 addition & 1 deletion mfbt/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class LZ4
*/
static MFBT_API bool
decompress(const char* aSource, size_t aInputSize, char* aDest,
size_t aMaxOutputSize, size_t *aOutputSize);
size_t aMaxOutputSize, size_t* aOutputSize);

/*
* Provides the maximum size that LZ4 may output in a "worst case"
Expand Down
3 changes: 2 additions & 1 deletion mfbt/Endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ class Endian : private EndianUtils
* Likewise, but converts values in place.
*/
template<typename T>
static void swapToBigEndianInPlace(T* aPtr, size_t aCount) {
static void swapToBigEndianInPlace(T* aPtr, size_t aCount)
{
maybeSwapInPlace<ThisEndian, Big>(aPtr, aCount);
}

Expand Down
3 changes: 2 additions & 1 deletion mfbt/FloatingPoint.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
Expand Down
3 changes: 2 additions & 1 deletion mfbt/HashFunctions.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
Expand Down
7 changes: 4 additions & 3 deletions mfbt/IntegerPrintfMacros.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
* 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/. */

/* Implements the C99 <inttypes.h> interface, minus the SCN* format macros. */

Expand Down
9 changes: 6 additions & 3 deletions mfbt/IntegerTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ struct UnsignedStdintTypeForSize
template<typename IntegerType>
struct PositionOfSignBit
{
static_assert(IsIntegral<IntegerType>::value, "PositionOfSignBit is only for integral types");
static_assert(IsIntegral<IntegerType>::value,
"PositionOfSignBit is only for integral types");
// 8 here should be CHAR_BIT from limits.h, but the world has moved on.
static const size_t value = 8 * sizeof(IntegerType) - 1;
};
Expand All @@ -96,7 +97,8 @@ template<typename IntegerType>
struct MinValue
{
private:
static_assert(IsIntegral<IntegerType>::value, "MinValue is only for integral types");
static_assert(IsIntegral<IntegerType>::value,
"MinValue is only for integral types");

typedef typename MakeUnsigned<IntegerType>::Type UnsignedIntegerType;
static const size_t PosOfSignBit = PositionOfSignBit<IntegerType>::value;
Expand All @@ -122,7 +124,8 @@ struct MinValue
template<typename IntegerType>
struct MaxValue
{
static_assert(IsIntegral<IntegerType>::value, "MaxValue is only for integral types");
static_assert(IsIntegral<IntegerType>::value,
"MaxValue is only for integral types");

// Tricksy, but covered by the CheckedInt unit test.
// Relies on the type of MinValue<IntegerType>::value
Expand Down
3 changes: 2 additions & 1 deletion mfbt/LinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ class LinkedList
private:
friend class LinkedListElement<T>;

void assertContains(const T* aValue) const {
void assertContains(const T* aValue) const
{
#ifdef DEBUG
for (const T* elem = getFirst(); elem; elem = elem->getNext()) {
if (elem == aValue) {
Expand Down
6 changes: 4 additions & 2 deletions mfbt/MathAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ template<> struct AbsReturnTypeFixed<int64_t> { typedef uint64_t Type; };
template<typename T>
struct AbsReturnType : AbsReturnTypeFixed<T> {};

template<> struct AbsReturnType<char> : EnableIf<char(-1) < char(0), unsigned char> {};
template<> struct AbsReturnType<char> :
EnableIf<char(-1) < char(0), unsigned char> {};
template<> struct AbsReturnType<signed char> { typedef unsigned char Type; };
template<> struct AbsReturnType<short> { typedef unsigned short Type; };
template<> struct AbsReturnType<int> { typedef unsigned int Type; };
Expand Down Expand Up @@ -145,7 +146,8 @@ Abs<long double>(const long double aLongDouble)

} // namespace mozilla

#if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
#if defined(_WIN32) && (_MSC_VER >= 1300) && \
(defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
# define MOZ_BITSCAN_WINDOWS

# include <intrin.h>
Expand Down
15 changes: 9 additions & 6 deletions mfbt/MaybeOneOf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include "mozilla/Move.h"
#include "mozilla/TemplateLib.h"

// For placement new
#include <new>
#include <new> // For placement new

namespace mozilla {

Expand All @@ -35,13 +34,15 @@ class MaybeOneOf
template <class T, class Ignored = void> struct Type2State {};

template <class T>
T& as() {
T& as()
{
MOZ_ASSERT(state == Type2State<T>::result);
return *(T*)storage.addr();
}

template <class T>
const T& as() const {
const T& as() const
{
MOZ_ASSERT(state == Type2State<T>::result);
return *(T*)storage.addr();
}
Expand Down Expand Up @@ -124,14 +125,16 @@ class MaybeOneOf

template <class T1, class T2>
template <class Ignored>
struct MaybeOneOf<T1, T2>::Type2State<T1, Ignored> {
struct MaybeOneOf<T1, T2>::Type2State<T1, Ignored>
{
typedef MaybeOneOf<T1, T2> Enclosing;
static const typename Enclosing::State result = Enclosing::SomeT1;
};

template <class T1, class T2>
template <class Ignored>
struct MaybeOneOf<T1, T2>::Type2State<T2, Ignored> {
struct MaybeOneOf<T1, T2>::Type2State<T2, Ignored>
{
typedef MaybeOneOf<T1, T2> Enclosing;
static const typename Enclosing::State result = Enclosing::SomeT2;
};
Expand Down
Loading

0 comments on commit bb8bad3

Please sign in to comment.