[libcxx-commits] [PATCH] D113054: [libcxxabi][SystemZ][z/OS] Update libcxxabi/src/cxa_exception_storage.cpp to support POSIX(OFF)

Daniel McIntosh via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 8 11:51:47 PST 2021


DanielMcIntosh-IBM updated this revision to Diff 385582.
DanielMcIntosh-IBM added a comment.

Rebase and update intentation to match the rest of the file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113054/new/

https://reviews.llvm.org/D113054

Files:
  libcxxabi/src/cxa_exception_storage.cpp
  libcxxabi/test/test_exception_storage.pass.cpp


Index: libcxxabi/test/test_exception_storage.pass.cpp
===================================================================
--- libcxxabi/test/test_exception_storage.pass.cpp
+++ libcxxabi/test/test_exception_storage.pass.cpp
@@ -45,7 +45,19 @@
 #endif
 
 int main() {
-#ifndef _LIBCXXABI_HAS_NO_THREADS
+#ifdef _LIBCXXABI_HAS_NO_THREADS
+    size_t thread_globals;
+    thread_code(&thread_globals);
+    // Check that __cxa_get_globals() is not NULL.
+    return (thread_globals == 0) ? 1 : 0;
+#else  // !_LIBCXXABI_HAS_NO_THREADS
+    // If threads are disabled at runtime, revert to single-threaded test.
+    if (!std::__libcpp_is_threading_api_enabled()) {
+        thread_code((void*)thread_globals);
+        // Check that __cxa_get_globals() is not NULL.
+        return (thread_globals[0] == 0) ? 1 : 0;
+    }
+
 //  Make the threads, let them run, and wait for them to finish
     for ( int i = 0; i < NUMTHREADS; ++i )
         std::__libcpp_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
@@ -68,10 +80,5 @@
         }
     }
     return retVal;
-#else // _LIBCXXABI_HAS_NO_THREADS
-    size_t thread_globals;
-    thread_code(&thread_globals);
-    // Check that __cxa_get_globals() is not NULL.
-    return (thread_globals == 0) ? 1 : 0;
 #endif // !_LIBCXXABI_HAS_NO_THREADS
 }
Index: libcxxabi/src/cxa_exception_storage.cpp
===================================================================
--- libcxxabi/src/cxa_exception_storage.cpp
+++ libcxxabi/src/cxa_exception_storage.cpp
@@ -92,6 +92,11 @@
     // to the Itanium ABI and is taken advantage of in several places in
     // libc++abi.
     __cxa_eh_globals *__cxa_get_globals_fast() {
+        // If threads are disabled at runtime, revert to single-threaded implementation.
+        if (!std::__libcpp_is_threading_api_enabled()) {
+            static __cxa_eh_globals eh_globals;
+            return &eh_globals;
+        }
         // First time through, create the key.
         if (0 != std::__libcpp_execute_once(&flag_, construct_))
             abort_message("execute once failure in __cxa_get_globals_fast()");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113054.385582.patch
Type: text/x-patch
Size: 2120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211108/e87a74c6/attachment.bin>


More information about the libcxx-commits mailing list