Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1467)

Unified Diff: third_party/WebKit/Source/wtf/StdLibExtras.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/StaticConstructors.h ('k') | third_party/WebKit/Source/wtf/StringExtras.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/StdLibExtras.h
diff --git a/third_party/WebKit/Source/wtf/StdLibExtras.h b/third_party/WebKit/Source/wtf/StdLibExtras.h
index 62acd8582e0fdf7eee3a7b68cec156a9236f5512..5cb809bd33891159049d19167b7b2f42baea9716 100644
--- a/third_party/WebKit/Source/wtf/StdLibExtras.h
+++ b/third_party/WebKit/Source/wtf/StdLibExtras.h
@@ -36,25 +36,23 @@
#include "wtf/Threading.h"
class WTF_EXPORT StaticLocalVerifier {
- WTF_MAKE_NONCOPYABLE(StaticLocalVerifier);
-public:
- StaticLocalVerifier()
- : m_safelyInitialized(WTF::isBeforeThreadCreated())
- , m_thread(WTF::currentThread())
- {
- }
-
- bool isNotRacy()
- {
- // Make sure that this 1) is safely initialized, 2) keeps being called
- // on the same thread, or 3) is called within
- // AtomicallyInitializedStatic (i.e. with a lock held).
- return m_safelyInitialized || m_thread == WTF::currentThread() || WTF::isAtomicallyInitializedStaticMutexLockHeld();
- }
-
-private:
- bool m_safelyInitialized;
- ThreadIdentifier m_thread;
+ WTF_MAKE_NONCOPYABLE(StaticLocalVerifier);
+
+ public:
+ StaticLocalVerifier()
+ : m_safelyInitialized(WTF::isBeforeThreadCreated()), m_thread(WTF::currentThread()) {
+ }
+
+ bool isNotRacy() {
+ // Make sure that this 1) is safely initialized, 2) keeps being called
+ // on the same thread, or 3) is called within
+ // AtomicallyInitializedStatic (i.e. with a lock held).
+ return m_safelyInitialized || m_thread == WTF::currentThread() || WTF::isAtomicallyInitializedStaticMutexLockHeld();
+ }
+
+ private:
+ bool m_safelyInitialized;
+ ThreadIdentifier m_thread;
};
#endif
@@ -63,25 +61,24 @@ private:
#ifndef DEFINE_STATIC_LOCAL
#if ENABLE(ASSERT)
-#define DEFINE_STATIC_LOCAL(type, name, arguments) \
- static StaticLocalVerifier name##StaticLocalVerifier; \
- ASSERT(name##StaticLocalVerifier.isNotRacy()); \
- static type& name = *new type arguments
+#define DEFINE_STATIC_LOCAL(type, name, arguments) \
+ static StaticLocalVerifier name##StaticLocalVerifier; \
+ ASSERT(name##StaticLocalVerifier.isNotRacy()); \
+ static type& name = *new type arguments
#else
#define DEFINE_STATIC_LOCAL(type, name, arguments) \
- static type& name = *new type arguments
+ static type& name = *new type arguments
#endif
#endif
-
// Use this to declare and define a static local pointer to a ref-counted object so that
// it is leaked so that the object's destructors are not called at exit.
// This macro should be used with ref-counted objects rather than DEFINE_STATIC_LOCAL macro,
// as this macro does not lead to an extra memory allocation.
#ifndef DEFINE_STATIC_REF
#define DEFINE_STATIC_REF(type, name, arguments) \
- static type* name = PassRefPtr<type>(arguments).leakRef();
+ static type* name = PassRefPtr<type>(arguments).leakRef();
#endif
/*
@@ -95,30 +92,26 @@ private:
* - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976
*/
#if CPU(ARM) && COMPILER(GCC)
-template<typename Type>
-bool isPointerTypeAlignmentOkay(Type* ptr)
-{
- return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type));
+template <typename Type>
+bool isPointerTypeAlignmentOkay(Type* ptr) {
+ return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type));
}
-template<typename TypePtr>
-TypePtr reinterpret_cast_ptr(void* ptr)
-{
- ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
- return reinterpret_cast<TypePtr>(ptr);
+template <typename TypePtr>
+TypePtr reinterpret_cast_ptr(void* ptr) {
+ ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
+ return reinterpret_cast<TypePtr>(ptr);
}
-template<typename TypePtr>
-TypePtr reinterpret_cast_ptr(const void* ptr)
-{
- ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
- return reinterpret_cast<TypePtr>(ptr);
+template <typename TypePtr>
+TypePtr reinterpret_cast_ptr(const void* ptr) {
+ ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr)));
+ return reinterpret_cast<TypePtr>(ptr);
}
#else
-template<typename Type>
-bool isPointerTypeAlignmentOkay(Type*)
-{
- return true;
+template <typename Type>
+bool isPointerTypeAlignmentOkay(Type*) {
+ return true;
}
#define reinterpret_cast_ptr reinterpret_cast
#endif
@@ -128,44 +121,43 @@ namespace WTF {
/*
* C++'s idea of a reinterpret_cast lacks sufficient cojones.
*/
-template<typename TO, typename FROM>
-inline TO bitwise_cast(FROM from)
-{
- static_assert(sizeof(TO) == sizeof(FROM), "WTF::bitwise_cast sizeof casted types should be equal");
- union {
- FROM from;
- TO to;
- } u;
- u.from = from;
- return u.to;
+template <typename TO, typename FROM>
+inline TO bitwise_cast(FROM from) {
+ static_assert(sizeof(TO) == sizeof(FROM), "WTF::bitwise_cast sizeof casted types should be equal");
+ union {
+ FROM from;
+ TO to;
+ } u;
+ u.from = from;
+ return u.to;
}
-template<typename To, typename From>
-inline To safeCast(From value)
-{
- ASSERT(isInBounds<To>(value));
- return static_cast<To>(value);
+template <typename To, typename From>
+inline To safeCast(From value) {
+ ASSERT(isInBounds<To>(value));
+ return static_cast<To>(value);
}
// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array.
-template<typename T, size_t Size> char (&ArrayLengthHelperFunction(T (&)[Size]))[Size];
+template <typename T, size_t Size>
+char(&ArrayLengthHelperFunction(T(&)[Size]))[Size];
// GCC needs some help to deduce a 0 length array.
#if COMPILER(GCC)
-template<typename T> char (&ArrayLengthHelperFunction(T (&)[0]))[0];
+template <typename T>
+char(&ArrayLengthHelperFunction(T(&)[0]))[0];
#endif
#define WTF_ARRAY_LENGTH(array) sizeof(::WTF::ArrayLengthHelperFunction(array))
-} // namespace WTF
+} // namespace WTF
// This version of placement new omits a 0 check.
enum NotNullTag { NotNull };
-inline void* operator new(size_t, NotNullTag, void* location)
-{
- ASSERT(location);
- return location;
+inline void* operator new(size_t, NotNullTag, void* location) {
+ ASSERT(location);
+ return location;
}
using WTF::bitwise_cast;
using WTF::safeCast;
-#endif // WTF_StdLibExtras_h
+#endif // WTF_StdLibExtras_h
« no previous file with comments | « third_party/WebKit/Source/wtf/StaticConstructors.h ('k') | third_party/WebKit/Source/wtf/StringExtras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698