summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-04-13 12:06:41 -0700
committerChristopher Wiley <wiley@google.com>2016-04-13 12:10:56 -0700
commit5c054c1699b231d8f227d8cb67e9f94fe94316f3 (patch)
treedfd4f77c7b8353cc4ade9481518ee65f7ed0c6ef
parent40ac85cc7dabfbaafde73357a900c4a296be09ee (diff)
downloadlibchrome-5c054c1699b231d8f227d8cb67e9f94fe94316f3.tar.gz
Defer to libbase macros on Android
On Android, prefer the libbase definitions of macros. This prevents compiler errors about macro redefinition. Allow consumers of libchrome to see libbase headers implicitly by exporting headers on libbase's include path. Fix a small bug in how libchrome-dbus was defined. It needs to export libchrome's headers, since to work with libchrome-dbus, you need all the headers necessary to consume libchrome as well. Bug: 28117776 Test: Compiles Change-Id: I35e969d7037d3374af9d2e931814740e29691029
-rw-r--r--Android.mk8
-rw-r--r--base/compiler_specific.h5
-rw-r--r--base/macros.h13
3 files changed, 24 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk
index 47ca1ac93a..018bd4ed07 100644
--- a/Android.mk
+++ b/Android.mk
@@ -428,7 +428,8 @@ LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension)
LOCAL_CFLAGS := $(libchromeCommonCFlags)
LOCAL_CLANG := $(libchromeUseClang)
LOCAL_C_INCLUDES := $(libchromeCommonCIncludes)
-LOCAL_SHARED_LIBRARIES := libevent liblog libcutils
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbase
+LOCAL_SHARED_LIBRARIES := libbase libevent liblog libcutils
LOCAL_STATIC_LIBRARIES := libmodpb64
LOCAL_EXPORT_C_INCLUDE_DIRS := $(libchromeExportedCIncludes)
include $(BUILD_SHARED_LIBRARY)
@@ -442,7 +443,8 @@ LOCAL_CLANG := $(libchromeUseClang)
LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension)
LOCAL_C_INCLUDES := $(libchromeCommonCIncludes)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(libchromeExportedCIncludes)
-LOCAL_SHARED_LIBRARIES := libevent-host
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbase
+LOCAL_SHARED_LIBRARIES := libbase libevent-host
LOCAL_STATIC_LIBRARIES := libmodpb64-host
LOCAL_SRC_FILES := $(libchromeCommonSrc) $(libchromeHostSrc)
LOCAL_LDFLAGS := $(libchromeHostLdFlags)
@@ -473,6 +475,7 @@ LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension)
LOCAL_CFLAGS := $(libchromeCommonCFlags)
LOCAL_CLANG := $(libchromeUseClang)
LOCAL_C_INCLUDES := $(libchromeCommonCIncludes)
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libchrome
LOCAL_SHARED_LIBRARIES := \
libchrome \
libdbus \
@@ -480,6 +483,7 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES :=
LOCAL_EXPORT_C_INCLUDE_DIRS := $(libchromeExportedCIncludes)
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libchrome
include $(BUILD_SHARED_LIBRARY)
endif # local_use_dbus == 1
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 339e9b74e9..4067d61b9a 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -7,6 +7,11 @@
#include "build/build_config.h"
+#if defined(ANDROID)
+// Prefer Android's libbase definitions to our own.
+#include <android-base/macros.h>
+#endif // defined(ANDROID)
+
#if defined(COMPILER_MSVC)
// For _Printf_format_string_.
diff --git a/base/macros.h b/base/macros.h
index b9dd8993a6..f971da9060 100644
--- a/base/macros.h
+++ b/base/macros.h
@@ -12,13 +12,22 @@
#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)
+
// 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) \
void operator=(const TypeName&) = delete
+#endif
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
@@ -50,8 +59,10 @@
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
+#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
@@ -84,8 +95,10 @@ enum LinkerInitialized { LINKER_INITIALIZED };
// Use these to declare and define a static local variable (static T;) so that
// it is leaked so that its destructors are not called at exit. If you need
// thread-safe initialization, use base/lazy_instance.h instead.
+#if !defined(CR_DEFINE_STATIC_LOCAL)
#define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
static type& name = *new type arguments
+#endif
} // base