Home | History | Annotate | Download | only in patch
      1 diff --git a/base/macros.h b/base/macros.h
      2 index 3064a1b..8685117 100644
      3 --- a/base/macros.h
      4 +++ b/base/macros.h
      5 @@ -12,6 +12,13 @@
      6  
      7  #include <stddef.h>  // For size_t.
      8  
      9 +#if defined(ANDROID)
     10 +// Prefer Android's libbase definitions to our own.
     11 +#include <android-base/macros.h>
     12 +#endif  // defined(ANDROID)
     13 +
     14 +// We define following macros conditionally as they may be defined by another libraries.
     15 +
     16  // Distinguish mips32.
     17  #if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__)
     18  #define __mips32__
     19 @@ -23,23 +30,31 @@
     20  #endif
     21  
     22  // Put this in the declarations for a class to be uncopyable.
     23 +#if !defined(DISALLOW_COPY)
     24  #define DISALLOW_COPY(TypeName) \
     25    TypeName(const TypeName&) = delete
     26 +#endif
     27  
     28  // Put this in the declarations for a class to be unassignable.
     29 +#if !defined(DISALLOW_ASSIGN)
     30  #define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
     31 +#endif
     32  
     33  // Put this in the declarations for a class to be uncopyable and unassignable.
     34 +#if !defined(DISALLOW_COPY_AND_ASSIGN)
     35  #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
     36    DISALLOW_COPY(TypeName);                 \
     37    DISALLOW_ASSIGN(TypeName)
     38 +#endif
     39  
     40  // A macro to disallow all the implicit constructors, namely the
     41  // default constructor, copy constructor and operator= functions.
     42  // This is especially useful for classes containing only static methods.
     43 +#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
     44  #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
     45    TypeName() = delete;                           \
     46    DISALLOW_COPY_AND_ASSIGN(TypeName)
     47 +#endif
     48  
     49  // The arraysize(arr) macro returns the # of elements in an array arr.  The
     50  // expression is a compile-time constant, and therefore can be used in defining
     51 @@ -53,8 +68,10 @@
     52  //
     53  // DEPRECATED, please use base::size(array) instead.
     54  // TODO(https://crbug.com/837308): Replace existing arraysize usages.
     55 +#if !defined(arraysize)
     56  template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N];
     57  #define arraysize(array) (sizeof(ArraySizeHelper(array)))
     58 +#endif
     59  
     60  // Used to explicitly mark the return value of a function as unused. If you are
     61  // really sure you don't want to do anything with the return value of a function
     62 @@ -83,8 +100,10 @@ namespace base {
     63  //   return *instance;
     64  // }
     65  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     66 +#if !defined(CR_DEFINE_STATIC_LOCAL)
     67  #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
     68    static type& name = *new type arguments
     69 +#endif
     70  
     71  // Workaround for MSVC, which expands __VA_ARGS__ as one macro argument. To
     72  // work around this bug, wrap the entire expression in this macro...
     73