]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
rwlock optional.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 7 Sep 2007 13:28:23 +0000 (13:28 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 7 Sep 2007 13:28:23 +0000 (13:28 +0000)
git-svn-id: file:///svn/unbound/trunk@606 be551aaa-1e26-0410-a405-d3ace91eadb9

configure.ac
util/locks.h

index ae8d442a8801dd5206958b77ed1e3e2634a7c1a3..ec1f728a066d5085526ad95b402abe9192534590 100644 (file)
@@ -407,7 +407,7 @@ if test x_$withval != x_no; then
                CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
                CC="$PTHREAD_CC"
                ub_have_pthreads=yes
-               AC_CHECK_TYPES(pthread_spinlock_t,,,[#include <pthread.h>])
+               AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
                ])
 fi
 
index 32aafc723f2d39b6c06c354fc1ffe3a97881c2ff..19f8b13bb8a37c4c244e1c80ddeeabf771ee9c0b 100644 (file)
 
 /******************* PTHREAD ************************/
 
+/** use pthread mutex for basic lock */
+typedef pthread_mutex_t lock_basic_t;
+/** small front for pthread init func, NULL is default attrs. */
+#define lock_basic_init(lock) LOCKRET(pthread_mutex_init(lock, NULL))
+#define lock_basic_destroy(lock) LOCKRET(pthread_mutex_destroy(lock))
+#define lock_basic_lock(lock) LOCKRET(pthread_mutex_lock(lock))
+#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
+
+#ifndef HAVE_PTHREAD_RWLOCK_T
+/** in case rwlocks are not supported, use a mutex. */
+typedef pthread_mutex_t lock_rw_t;
+#define lock_rw_init(lock) LOCKRET(pthread_mutex_init(lock, NULL))
+#define lock_rw_destroy(lock) LOCKRET(pthread_mutex_destroy(lock))
+#define lock_rw_rdlock(lock) LOCKRET(pthread_mutex_lock(lock))
+#define lock_rw_wrlock(lock) LOCKRET(pthread_mutex_lock(lock))
+#define lock_rw_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
+#else /* HAVE_PTHREAD_RWLOCK_T */
 /** we use the pthread rwlock */
 typedef pthread_rwlock_t lock_rw_t;
 /** small front for pthread init func, NULL is default attrs. */
@@ -99,14 +116,7 @@ typedef pthread_rwlock_t lock_rw_t;
 #define lock_rw_rdlock(lock) LOCKRET(pthread_rwlock_rdlock(lock))
 #define lock_rw_wrlock(lock) LOCKRET(pthread_rwlock_wrlock(lock))
 #define lock_rw_unlock(lock) LOCKRET(pthread_rwlock_unlock(lock))
-
-/** use pthread mutex for basic lock */
-typedef pthread_mutex_t lock_basic_t;
-/** small front for pthread init func, NULL is default attrs. */
-#define lock_basic_init(lock) LOCKRET(pthread_mutex_init(lock, NULL))
-#define lock_basic_destroy(lock) LOCKRET(pthread_mutex_destroy(lock))
-#define lock_basic_lock(lock) LOCKRET(pthread_mutex_lock(lock))
-#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
+#endif /* HAVE_PTHREAD_RWLOCK_T */
 
 #ifndef HAVE_PTHREAD_SPINLOCK_T
 /** in case spinlocks are not supported, use a mutex. */