From 7dfd0b71ee8d1c8409d2f09ad3ccfcb467f16d6b Mon Sep 17 00:00:00 2001 From: Gilles Talis Date: Sun, 26 May 2013 12:08:18 +0400 Subject: Enable build using toolchain without pthreads * 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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/atomic_ops.c') diff --git a/src/atomic_ops.c b/src/atomic_ops.c index 3017fc4..30dd21c 100644 --- a/src/atomic_ops.c +++ b/src/atomic_ops.c @@ -49,7 +49,9 @@ #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__BORLANDC__) \ || defined(AO_USE_NO_SIGNALS) -#include +#ifndef AO_NO_PTHREADS +# include +#endif #ifndef AO_USE_NO_SIGNALS # include @@ -71,11 +73,10 @@ # 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. -- cgit v1.2.1