OSDN Git Service

Fix TLS for platforms without library constructors.
authorNicolas Capens <capn@google.com>
Fri, 7 Jul 2017 21:01:16 +0000 (17:01 -0400)
committerNicolas Capens <capn@google.com>
Mon, 10 Jul 2017 16:42:15 +0000 (16:42 +0000)
commit420b64d2fa291a02bc915f36c46776912f862a03
treedacf6a48262aa2193fc72accb846352c77bf9cdb
parenta781af7d5a1930d82d20c0cbc9d66fc8a42391e0
Fix TLS for platforms without library constructors.

Some platforms don't support constructors that get called when the
shared library gets loaded. This results in the thread-local-storage
key to never be allocated. Instead we can check if it was allocated on
each use. Also prevent creating new 'current' state if it already
exists, and avoid pthreads undefined behavior.

Bug b/25629882

Change-Id: I5e2486f88185150b976d88d0144e4d13a349eb79
Reviewed-on: https://swiftshader-review.googlesource.com/10451
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
src/Common/Thread.hpp
src/OpenGL/libEGL/main.cpp