[libcxx-commits] [libcxxabi] 795ff77 - [libcxxabi] Fix NO_THREADS version of test_exception_storage.pass.cpp
Daniel McIntosh via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 4 16:30:26 PDT 2021
Author: Daniel McIntosh
Date: 2021-11-04T19:30:21-04:00
New Revision: 795ff77840e161018a44fe30ae53ad05e5d98f97
URL: https://github.com/llvm/llvm-project/commit/795ff77840e161018a44fe30ae53ad05e5d98f97
DIFF: https://github.com/llvm/llvm-project/commit/795ff77840e161018a44fe30ae53ad05e5d98f97.diff
LOG: [libcxxabi] Fix NO_THREADS version of test_exception_storage.pass.cpp
`thread_code` returns param, which for NO_THREADS is going to be
`&thread_globals`. Thus, the return value will never be null. The test
was probably meant to check if `*thread_code(&thread_globals) == 0`.
However, to avoid the extra cast, and to bring the NO_THREADS version
more in line with the regular version of the test, this changes it to
check if thread_globals == 0 directly.
Reviewed By: ldionne, #libc_abi
Differential Revision: https://reviews.llvm.org/D113048
Added:
Modified:
libcxxabi/test/test_exception_storage.pass.cpp
Removed:
################################################################################
diff --git a/libcxxabi/test/test_exception_storage.pass.cpp b/libcxxabi/test/test_exception_storage.pass.cpp
index 460d27b78ea7..5a68be7ec417 100644
--- a/libcxxabi/test/test_exception_storage.pass.cpp
+++ b/libcxxabi/test/test_exception_storage.pass.cpp
@@ -44,9 +44,7 @@ size_t thread_globals [ NUMTHREADS ] = { 0 };
std::__libcpp_thread_t threads [ NUMTHREADS ];
#endif
-int main () {
- int retVal = 0;
-
+int main() {
#ifndef _LIBCXXABI_HAS_NO_THREADS
// Make the threads, let them run, and wait for them to finish
for ( int i = 0; i < NUMTHREADS; ++i )
@@ -54,6 +52,7 @@ int main () {
for ( int i = 0; i < NUMTHREADS; ++i )
std::__libcpp_thread_join ( &threads [ i ] );
+ int retVal = 0;
for ( int i = 0; i < NUMTHREADS; ++i ) {
if ( 0 == thread_globals [ i ] ) {
std::printf("Thread #%d had a zero global\n", i);
@@ -68,12 +67,11 @@ int main () {
retVal = 2;
}
}
+ return retVal;
#else // _LIBCXXABI_HAS_NO_THREADS
size_t thread_globals;
+ thread_code(&thread_globals);
// Check that __cxa_get_globals() is not NULL.
- if (thread_code(&thread_globals) == 0) {
- retVal = 1;
- }
+ return (thread_globals == 0) ? 1 : 0;
#endif // !_LIBCXXABI_HAS_NO_THREADS
- return retVal;
}
More information about the libcxx-commits
mailing list