mirror of https://github.com/getdnsapi/getdns.git
Merge pull request #213 from neilcook/arc4locks
pthread-based locking for arc4random
This commit is contained in:
commit
45643b6da5
|
@ -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 -----
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue