summaryrefslogtreecommitdiff
path: root/random/random-csprng.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2014-01-09 19:14:09 +0100
committerWerner Koch <wk@gnupg.org>2014-01-16 17:23:21 +0100
commitcfc151ba637200e4fc05d9481a8df2071b2f9a47 (patch)
treef1a1c3e1fc81663d622dd5189462a249bd01eac3 /random/random-csprng.c
parent49edeebb43174865cf4fa2c170a42a8e4274c4f0 (diff)
downloadlibgcrypt-cfc151ba637200e4fc05d9481a8df2071b2f9a47.tar.gz
Replace ath based mutexes by gpgrt based locks.
* configure.ac (NEED_GPG_ERROR_VERSION): Require 1.13. (gl_LOCK): Remove. * src/ath.c, src/ath.h: Remove. Remove from all files. Replace all mutexes by gpgrt based statically initialized locks. * src/global.c (global_init): Remove ath_init. (_gcry_vcontrol): Make ath install a dummy function. (print_config): Remove threads info line. * doc/gcrypt.texi: Simplify the multi-thread related documentation. -- The current code does only work on ELF systems with weak symbol support. In particular no locks were used under Windows. With the new gpgrt_lock functions from the soon to be released libgpg-error 1.13 we have a better portable scheme which also allows for static initialized mutexes. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'random/random-csprng.c')
-rw-r--r--random/random-csprng.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/random/random-csprng.c b/random/random-csprng.c
index 87235d82..429c84f8 100644
--- a/random/random-csprng.c
+++ b/random/random-csprng.c
@@ -60,7 +60,6 @@
#include "random.h"
#include "rand-internal.h"
#include "cipher.h" /* Required for the rmd160_hash_buffer() prototype. */
-#include "ath.h"
#ifndef RAND_MAX /* For SunOS. */
#define RAND_MAX 32767
@@ -181,7 +180,7 @@ static int quick_test;
static int faked_rng;
/* This is the lock we use to protect all pool operations. */
-static ath_mutex_t pool_lock;
+GPGRT_LOCK_DEFINE (pool_lock);
/* This is a helper for assert calls. These calls are used to assert
that functions are called in a locked state. It is not meant to be
@@ -259,14 +258,10 @@ static void
initialize_basics(void)
{
static int initialized;
- int err;
if (!initialized)
{
initialized = 1;
- err = ath_mutex_init (&pool_lock);
- if (err)
- log_fatal ("failed to create the pool lock: %s\n", strerror (err) );
#ifdef USE_RANDOM_DAEMON
_gcry_daemon_initialize_basics ();
@@ -286,9 +281,9 @@ lock_pool (void)
{
int err;
- err = ath_mutex_lock (&pool_lock);
+ err = gpgrt_lock_lock (&pool_lock);
if (err)
- log_fatal ("failed to acquire the pool lock: %s\n", strerror (err));
+ log_fatal ("failed to acquire the pool lock: %s\n", gpg_strerror (err));
pool_is_locked = 1;
}
@@ -299,9 +294,9 @@ unlock_pool (void)
int err;
pool_is_locked = 0;
- err = ath_mutex_unlock (&pool_lock);
+ err = gpgrt_lock_unlock (&pool_lock);
if (err)
- log_fatal ("failed to release the pool lock: %s\n", strerror (err));
+ log_fatal ("failed to release the pool lock: %s\n", gpg_strerror (err));
}