Commit 755417dd by Jaime Bernardo Committed by Commit Bot

GLES2: Use require_constant_initialization for g_Mutex

A static assert to verify that the global mutex g_Mutex is trivially constructed fails to compile with clang when using the STL shipped with Visual Studio 2019. Use __attribute__((require_constant_initialization)) instead to verify for constant initialization. BUG=angleproject:3936 Change-Id: I5969762ad5a99033143513d7c4992344da276b1a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1832164Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 4a276034
...@@ -58,3 +58,4 @@ Jérôme Duval ...@@ -58,3 +58,4 @@ Jérôme Duval
Thomas Miller Thomas Miller
Till Rathmann Till Rathmann
Nick Shaforostov Nick Shaforostov
Jaime Bernardo
...@@ -345,4 +345,10 @@ std::string ToString(const T &value) ...@@ -345,4 +345,10 @@ std::string ToString(const T &value)
# define ANGLE_MAYBE_UNUSED # define ANGLE_MAYBE_UNUSED
#endif // __has_cpp_attribute(maybe_unused) #endif // __has_cpp_attribute(maybe_unused)
#if __has_cpp_attribute(require_constant_initialization)
# define ANGLE_REQUIRE_CONSTANT_INIT [[require_constant_initialization]]
#else
# define ANGLE_REQUIRE_CONSTANT_INIT
#endif // __has_cpp_attribute(require_constant_initialization)
#endif // COMMON_ANGLEUTILS_H_ #endif // COMMON_ANGLEUTILS_H_
...@@ -35,9 +35,8 @@ namespace ...@@ -35,9 +35,8 @@ namespace
{ {
static TLSIndex threadTLS = TLS_INVALID_INDEX; static TLSIndex threadTLS = TLS_INVALID_INDEX;
Debug *g_Debug = nullptr; Debug *g_Debug = nullptr;
std::atomic<std::mutex *> g_Mutex;
static_assert(std::is_trivially_constructible<decltype(g_Mutex)>::value, ANGLE_REQUIRE_CONSTANT_INIT std::atomic<std::mutex *> g_Mutex(nullptr);
"global mutex is not trivially constructible");
static_assert(std::is_trivially_destructible<decltype(g_Mutex)>::value, static_assert(std::is_trivially_destructible<decltype(g_Mutex)>::value,
"global mutex is not trivially destructible"); "global mutex is not trivially destructible");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment