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