diff --git a/configure.ac b/configure.ac index b2c066a2..e8a1650b 100644 --- a/configure.ac +++ b/configure.ac @@ -924,6 +924,10 @@ if [ test -n "$DOXYGEN" ] fi +#---- check for pthreads library +AC_SEARCH_LIBS([pthread_mutex_init],[pthread],[AC_DEFINE([HAVE_PTHREADS], [1], [Have pthreads library])], [AC_MSG_WARN([pthreads not available])]) + + dnl ----- dnl ----- Start of "Things needed for gldns" section dnl ----- diff --git a/src/compat/arc4_lock.c b/src/compat/arc4_lock.c index 44662841..facf9575 100644 --- a/src/compat/arc4_lock.c +++ b/src/compat/arc4_lock.c @@ -34,6 +34,23 @@ #include "config.h" #define LOCKRET(func) func +#ifdef HAVE_PTHREADS +#include "pthread.h" + +static pthread_mutex_t arc_lock = PTHREAD_MUTEX_INITIALIZER; + +void _ARC4_LOCK(void) +{ + pthread_mutex_lock(&arc_lock); +} + +void _ARC4_UNLOCK(void) +{ + pthread_mutex_unlock(&arc_lock); +} + +#else +/* XXX - add windows-(or at least non pthread) specific lock routines here */ void _ARC4_LOCK(void) { } @@ -41,4 +58,4 @@ void _ARC4_LOCK(void) void _ARC4_UNLOCK(void) { } - +#endif