Re: [PATCH] D24770: [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

2016-09-21 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

In https://reviews.llvm.org/D24770#547701, @jroelofs wrote:

> LGTM


Thanks!

Committed as r282062.

/ Asiri


https://reviews.llvm.org/D24770



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24770: [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

2016-09-20 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.
jroelofs accepted this revision.
jroelofs added a reviewer: jroelofs.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D24770



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24770: [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

2016-09-20 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: mclow.lists, EricWF.
rmaprath added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Align the naming / use of the macro ``LIBCXXABI_HAS_NO_THREADS`` to follow what 
we have in `libcxx`.

This change is mostly NFC, thought of putting it up for review as it involves a 
change in naming, and sometimes that can cause disagreements.

Will commit if there isn't much interest.

https://reviews.llvm.org/D24770

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  test/libcxxabi/test/config.py
  test/test_exception_storage.pass.cpp
  test/test_guard.pass.cpp

Index: test/test_guard.pass.cpp
===
--- test/test_guard.pass.cpp
+++ test/test_guard.pass.cpp
@@ -12,7 +12,7 @@
 
 #include 
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #include 
 #endif
 
@@ -80,7 +80,7 @@
 }
 }
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 // A simple thread test of two threads racing to initialize a variable. This
 // isn't guaranteed to catch any particular threading problems.
 namespace test4 {
@@ -132,14 +132,14 @@
 assert(run_count == 1);
 }
 }
-#endif /* LIBCXXABI_HAS_NO_THREADS */
+#endif /* _LIBCXXABI_HAS_NO_THREADS */
 
 int main()
 {
 test1::test();
 test2::test();
 test3::test();
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 test4::test();
 test5::test();
 #endif
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #  include 
 #endif
 #include 
@@ -38,29 +38,16 @@
 return parm;
 }
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #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;
-for ( size_t *iter = first; iter != last; ++iter )
-std::cout << *iter << " ";
-std::cout << "}" << std::dec << std::endl;
-}
-
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
-#if LIBCXXABI_HAS_NO_THREADS
-size_t thread_globals;
-// Check that __cxa_get_globals() is not NULL.
-if (thread_code(_globals) == 0) {
-retVal = 1;
-}
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 //  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));
@@ -73,15 +60,18 @@
 retVal = 1;
 }
 
-//  print_sizes ( thread_globals, thread_globals + NUMTHREADS );
 std::sort ( thread_globals, thread_globals + NUMTHREADS );
 for ( int i = 1; i < NUMTHREADS; ++i )
 if ( thread_globals [ i - 1 ] == thread_globals [ i ] ) {
 std::cerr << "Duplicate thread globals (" << i-1 << " and " << i << ")" << std::endl;
 retVal = 2;
 }
-//  print_sizes ( thread_globals, thread_globals + NUMTHREADS );
-
-#endif
-return retVal;
+#else // _LIBCXXABI_HAS_NO_THREADS
+size_t thread_globals;
+// Check that __cxa_get_globals() is not NULL.
+if (thread_code(_globals) == 0) {
+retVal = 1;
 }
+#endif // !_LIBCXXABI_HAS_NO_THREADS
+return retVal;
+}
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -47,7 +47,7 @@
 else:
 self.cxx.compile_flags += ['-fno-exceptions', '-DLIBCXXABI_HAS_NO_EXCEPTIONS']
 if not self.get_lit_bool('enable_threads', True):
-self.cxx.compile_flags += ['-DLIBCXXABI_HAS_NO_THREADS=1']
+self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS']
 super(Configuration, self).configure_compile_flags()
 
 def configure_compile_flags_header_includes(self):
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -26,25 +26,25 @@
 namespace {
 
 // When POSIX threads are not available, make the mutex operations a nop
-#if LIBCXXABI_HAS_NO_THREADS
-static void * heap_mutex = 0;
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+#else
+static void * heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
-#if LIBCXXABI_HAS_NO_THREADS
-mutexor ( void * ) {}
-~mutexor () {}
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 mutexor ( pthread_mutex_t *m ) : mtx_(m) {