about summary refs log tree commit diff
path: root/absl/base/internal/thread_identity.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base/internal/thread_identity.cc')
-rw-r--r--absl/base/internal/thread_identity.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/absl/base/internal/thread_identity.cc b/absl/base/internal/thread_identity.cc
index 678e8568d742..cff9c1b4f4dc 100644
--- a/absl/base/internal/thread_identity.cc
+++ b/absl/base/internal/thread_identity.cc
@@ -68,6 +68,14 @@ void SetCurrentThreadIdentity(
   // NOTE: Not async-safe.  But can be open-coded.
   absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey,
                   reclaimer);
+
+#ifdef __EMSCRIPTEN__
+  // Emscripten PThread implementation does not support signals.
+  // See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html
+  // for more information.
+  pthread_setspecific(thread_identity_pthread_key,
+                      reinterpret_cast<void*>(identity));
+#else
   // We must mask signals around the call to setspecific as with current glibc,
   // a concurrent getspecific (needed for GetCurrentThreadIdentityIfPresent())
   // may zero our value.
@@ -81,6 +89,8 @@ void SetCurrentThreadIdentity(
   pthread_setspecific(thread_identity_pthread_key,
                       reinterpret_cast<void*>(identity));
   pthread_sigmask(SIG_SETMASK, &curr_signals, nullptr);
+#endif  // !__EMSCRIPTEN__
+
 #elif ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS
   // NOTE: Not async-safe.  But can be open-coded.
   absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey,