Merge pull request #213 from neilcook/arc4locks

pthread-based locking for arc4random
This commit is contained in:
wtoorop 2016-10-27 15:55:38 +02:00 committed by GitHub
commit 45643b6da5
2 changed files with 22 additions and 1 deletions

View File

@ -924,6 +924,10 @@ if [ test -n "$DOXYGEN" ]
fi 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 -----
dnl ----- Start of "Things needed for gldns" section dnl ----- Start of "Things needed for gldns" section
dnl ----- dnl -----

View File

@ -34,6 +34,23 @@
#include "config.h" #include "config.h"
#define LOCKRET(func) func #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) void _ARC4_LOCK(void)
{ {
} }
@ -41,4 +58,4 @@ void _ARC4_LOCK(void)
void _ARC4_UNLOCK(void) void _ARC4_UNLOCK(void)
{ {
} }
#endif