summaryrefslogtreecommitdiff
path: root/random/random.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.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.c')
-rw-r--r--random/random.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/random/random.c b/random/random.c
index ff9d6d25..41d4cb36 100644
--- a/random/random.c
+++ b/random/random.c
@@ -34,7 +34,6 @@
#include "random.h"
#include "rand-internal.h"
#include "cipher.h" /* For _gcry_sha1_hash_buffer(). */
-#include "ath.h"
/* If not NULL a progress function called from certain places and the
@@ -54,7 +53,7 @@ static struct
/* This is the lock we use to protect the buffer used by the nonce
generation. */
-static ath_mutex_t nonce_buffer_lock;
+GPGRT_LOCK_DEFINE (nonce_buffer_lock);
@@ -140,18 +139,6 @@ _gcry_set_preferred_rng_type (int type)
void
_gcry_random_initialize (int full)
{
- static int nonce_initialized;
- int err;
-
- if (!nonce_initialized)
- {
- nonce_initialized = 1;
- err = ath_mutex_init (&nonce_buffer_lock);
- if (err)
- log_fatal ("failed to create the nonce buffer lock: %s\n",
- strerror (err) );
- }
-
if (fips_mode ())
_gcry_rngfips_initialize (full);
else if (rng_types.standard)
@@ -450,10 +437,10 @@ _gcry_create_nonce (void *buffer, size_t length)
_gcry_random_initialize (1);
/* Acquire the nonce buffer lock. */
- err = ath_mutex_lock (&nonce_buffer_lock);
+ err = gpgrt_lock_lock (&nonce_buffer_lock);
if (err)
log_fatal ("failed to acquire the nonce buffer lock: %s\n",
- strerror (err));
+ gpg_strerror (err));
apid = getpid ();
/* The first time initialize our buffer. */
@@ -501,10 +488,10 @@ _gcry_create_nonce (void *buffer, size_t length)
}
/* Release the nonce buffer lock. */
- err = ath_mutex_unlock (&nonce_buffer_lock);
+ err = gpgrt_lock_unlock (&nonce_buffer_lock);
if (err)
log_fatal ("failed to release the nonce buffer lock: %s\n",
- strerror (err));
+ gpg_strerror (err));
}