mirror of https://github.com/getdnsapi/getdns.git
pthread-based locking for arc4random
This commit is contained in:
parent
22c1eb7f3f
commit
393b24fe89
|
@ -644,7 +644,7 @@ CHECK_CFLAGS=""
|
|||
PKG_CHECK_MODULES([CHECK],[check >= 0.9.6],[CHECK_GETDNS="check_getdns"],[
|
||||
AC_SEARCH_LIBS([floor], [m])
|
||||
AC_SEARCH_LIBS([timer_create], [rt])
|
||||
AC_SEARCH_LIBS([pthread_create], [pthread])
|
||||
AC_SEARCH_LIBS([pthread_create], [pthread], [AC_DEFINE([HAVE_PTHREADS], [1], [Define if pthreads exist.])])
|
||||
AC_SEARCH_LIBS([srunner_create],[check check_pic],[
|
||||
CHECK_GETDNS="check_getdns"
|
||||
CHECK_LIBS="$LIBS"],[
|
||||
|
|
|
@ -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