diff options
author | Jonathan Roelofs <jonathan@codesourcery.com> | 2014-05-06 21:30:56 +0000 |
---|---|---|
committer | Jonathan Roelofs <jonathan@codesourcery.com> | 2014-05-06 21:30:56 +0000 |
commit | 40e9842854430ff34b0b687cbb94e9f4a044588a (patch) | |
tree | 6f9cfaa242398ebcd758477ff08448196d64ebaf /libcxxabi/test/test_exception_storage.cpp | |
parent | 9c928478f48384ad641a3c895856fbcef0c34f22 (diff) | |
download | bcm5719-llvm-40e9842854430ff34b0b687cbb94e9f4a044588a.tar.gz bcm5719-llvm-40e9842854430ff34b0b687cbb94e9f4a044588a.zip |
On single threaded systems, turn mutexes into nops
http://reviews.llvm.org/D3386
llvm-svn: 208135
Diffstat (limited to 'libcxxabi/test/test_exception_storage.cpp')
-rw-r--r-- | libcxxabi/test/test_exception_storage.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libcxxabi/test/test_exception_storage.cpp b/libcxxabi/test/test_exception_storage.cpp index e2b230ad7a6..f1d63fdfc43 100644 --- a/libcxxabi/test/test_exception_storage.cpp +++ b/libcxxabi/test/test_exception_storage.cpp @@ -7,10 +7,14 @@ // //===----------------------------------------------------------------------===// +#include "../src/config.h" + #include <cstdlib> #include <algorithm> #include <iostream> -#include <pthread.h> +#if !LIBCXXABI_SINGLE_THREADED +# include <pthread.h> +#endif #include <unistd.h> #include "../src/cxa_exception.hpp" @@ -34,10 +38,11 @@ void *thread_code (void *parm) { return parm; } - +#if !LIBCXXABI_SINGLE_THREADED #define NUMTHREADS 10 size_t thread_globals [ NUMTHREADS ] = { 0 }; pthread_t threads [ NUMTHREADS ]; +#endif void print_sizes ( size_t *first, size_t *last ) { std::cout << "{ " << std::hex; @@ -49,6 +54,10 @@ void print_sizes ( size_t *first, size_t *last ) { int main ( int argc, char *argv [] ) { int retVal = 0; +#if LIBCXXABI_SINGLE_THREADED + size_t thread_globals; + retVal = thread_code(&thread_globals) != 0; +#else // Make the threads, let them run, and wait for them to finish for ( int i = 0; i < NUMTHREADS; ++i ) pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i)); @@ -69,6 +78,7 @@ int main ( int argc, char *argv [] ) { retVal = 2; } // print_sizes ( thread_globals, thread_globals + NUMTHREADS ); - + +#endif return retVal; } |