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/+/1832164
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Jaime Bernardo 2019-09-30 17:53:56 +01:00 коммит произвёл Commit Bot
Родитель 4a276034fb
Коммит 755417dd79
3 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -58,3 +58,4 @@ Jérôme Duval
Thomas Miller
Till Rathmann
Nick Shaforostov
Jaime Bernardo

Просмотреть файл

@ -345,4 +345,10 @@ std::string ToString(const T &value)
# define ANGLE_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_

Просмотреть файл

@ -35,9 +35,8 @@ namespace
{
static TLSIndex threadTLS = TLS_INVALID_INDEX;
Debug *g_Debug = nullptr;
std::atomic<std::mutex *> g_Mutex;
static_assert(std::is_trivially_constructible<decltype(g_Mutex)>::value,
"global mutex is not trivially constructible");
ANGLE_REQUIRE_CONSTANT_INIT std::atomic<std::mutex *> g_Mutex(nullptr);
static_assert(std::is_trivially_destructible<decltype(g_Mutex)>::value,
"global mutex is not trivially destructible");