]> granicus.if.org Git - libatomic_ops/commitdiff
Enable build using toolchain without pthreads
authorGilles Talis <gilles.talis@gmail.com>
Sun, 26 May 2013 08:08:18 +0000 (12:08 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 26 May 2013 08:08:18 +0000 (12:08 +0400)
* src/atomic_ops.c: Include pthread.h only if not AO_NO_PTHREADS (new
macro).
* src/atomic_ops.c (AO_pt_lock): Define only unless AO_NO_PTHREADS.
* tests/test_atomic.c (main): Skip test_atomic_pthreads if both
AO_NO_PTHREADS and AO_USE_PTHREAD_DEFS are defined (preventing test
link failure if AO_NO_PTHREADS passed via CFLAGS).

src/atomic_ops.c
tests/test_atomic.c

index 3017fc45a03557c2f8ed0ada77d8a6de75b0b4b6..30dd21cac64a0c49d247f66152119a61d03081de 100644 (file)
@@ -49,7 +49,9 @@
 #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__BORLANDC__) \
     || defined(AO_USE_NO_SIGNALS)
 
-#include <pthread.h>
+#ifndef AO_NO_PTHREADS
+# include <pthread.h>
+#endif
 
 #ifndef AO_USE_NO_SIGNALS
 # include <signal.h>
 # include "atomic_ops/sysdeps/standard_ao_double_t.h"
 #endif
 
-/*
- * Lock for pthreads-based implementation.
- */
-
-pthread_mutex_t AO_pt_lock = PTHREAD_MUTEX_INITIALIZER;
+/* Lock for pthreads-based implementation.      */
+#ifndef AO_NO_PTHREADS
+  pthread_mutex_t AO_pt_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
 
 /*
  * Out of line compare-and-swap emulation based on test and set.
index 6ce690a2f516298f7668ffad75f17088a02db096..980fb6b03574d352a9eeb55abe5c13a274686cff 100644 (file)
 # include "config.h"
 #endif
 
+#if defined(AO_NO_PTHREADS) && defined(AO_USE_PTHREAD_DEFS)
+# include <stdio.h>
+
+  int main(void)
+  {
+    printf("test skipped\n");
+    return 0;
+  }
+
+#else
 
 #include "run_parallel.h"
 
@@ -190,3 +200,5 @@ int main(void)
 # endif
   return 0;
 }
+
+#endif /* !AO_NO_PTHREADS || !AO_USE_PTHREAD_DEFS */