summaryrefslogtreecommitdiffstats
path: root/libutils/include
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-02-24 04:09:48 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-02-24 04:09:48 +0000
commitdafd6876178c5684f1be720c4838fc149f1e8599 (patch)
treea3baf8034d18e5caf285959f1daf918dd7c096c9 /libutils/include
parentd93e05052ae5b949c2f09920b6e158523f4b266c (diff)
parent6d7751a13bfab37aed5ae4e9bc6507a8105ba50c (diff)
downloadsystem_core-dafd6876178c5684f1be720c4838fc149f1e8599.tar.gz
system_core-dafd6876178c5684f1be720c4838fc149f1e8599.tar.bz2
system_core-dafd6876178c5684f1be720c4838fc149f1e8599.zip
Merge "Fix multiton issue" am: 78b285b367
am: 6d7751a13b Change-Id: Ie09b193b7f6fce5bfa9998193bc050d9469064c9
Diffstat (limited to 'libutils/include')
-rw-r--r--libutils/include/utils/Singleton.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/libutils/include/utils/Singleton.h b/libutils/include/utils/Singleton.h
index 7cc4c18be..a989a4703 100644
--- a/libutils/include/utils/Singleton.h
+++ b/libutils/include/utils/Singleton.h
@@ -26,6 +26,16 @@
namespace android {
// ---------------------------------------------------------------------------
+// Singleton<TYPE> may be used in multiple libraries, only one of which should
+// define the static member variables using ANDROID_SINGLETON_STATIC_INSTANCE.
+// Turn off -Wundefined-var-template so other users don't get:
+// instantiation of variable 'android::Singleton<TYPE>::sLock' required here,
+// but no definition is available
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wundefined-var-template"
+#endif
+
template <typename TYPE>
class ANDROID_API Singleton
{
@@ -56,11 +66,9 @@ private:
static TYPE* sInstance;
};
-template <typename TYPE>
-Mutex Singleton<TYPE>::sLock;
-
-template <typename TYPE>
-TYPE* Singleton<TYPE>::sInstance;
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
/*
* use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file