You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.6 KiB

diff --git a/base/macros.h b/base/macros.h
index 3064a1b..8685117 100644
--- a/base/macros.h
+++ b/base/macros.h
@@ -12,6 +12,13 @@
#include <stddef.h> // For size_t.
+#if defined(ANDROID)
+// Prefer Android's libbase definitions to our own.
+#include <android-base/macros.h>
+#endif // defined(ANDROID)
+
+// We define following macros conditionally as they may be defined by another libraries.
+
// Distinguish mips32.
#if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__)
#define __mips32__
@@ -23,23 +30,31 @@
#endif
// Put this in the declarations for a class to be uncopyable.
+#if !defined(DISALLOW_COPY)
#define DISALLOW_COPY(TypeName) \
TypeName(const TypeName&) = delete
+#endif
// Put this in the declarations for a class to be unassignable.
+#if !defined(DISALLOW_ASSIGN)
#define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
+#endif
// Put this in the declarations for a class to be uncopyable and unassignable.
+#if !defined(DISALLOW_COPY_AND_ASSIGN)
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
DISALLOW_COPY(TypeName); \
DISALLOW_ASSIGN(TypeName)
+#endif
// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
// This is especially useful for classes containing only static methods.
+#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName)
+#endif
// The arraysize(arr) macro returns the # of elements in an array arr. The
// expression is a compile-time constant, and therefore can be used in defining
@@ -53,8 +68,10 @@
//
// DEPRECATED, please use base::size(array) instead.
// TODO(https://crbug.com/837308): Replace existing arraysize usages.
+#if !defined(arraysize)
template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N];
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+#endif
// Used to explicitly mark the return value of a function as unused. If you are
// really sure you don't want to do anything with the return value of a function
@@ -83,8 +100,10 @@ namespace base {
// return *instance;
// }
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#if !defined(CR_DEFINE_STATIC_LOCAL)
#define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
static type& name = *new type arguments
+#endif
// Workaround for MSVC, which expands __VA_ARGS__ as one macro argument. To
// work around this bug, wrap the entire expression in this macro...