diff options
author | Werner Koch <wk@gnupg.org> | 2014-01-09 19:14:09 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-01-16 17:23:21 +0100 |
commit | cfc151ba637200e4fc05d9481a8df2071b2f9a47 (patch) | |
tree | f1a1c3e1fc81663d622dd5189462a249bd01eac3 /random/random-system.c | |
parent | 49edeebb43174865cf4fa2c170a42a8e4274c4f0 (diff) | |
download | libgcrypt-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-system.c')
-rw-r--r-- | random/random-system.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/random/random-system.c b/random/random-system.c index 3962ab88..8b79511c 100644 --- a/random/random-system.c +++ b/random/random-system.c @@ -35,13 +35,12 @@ #include "g10lib.h" #include "random.h" #include "rand-internal.h" -#include "ath.h" /* This is the lock we use to serialize access to this RNG. The extra integer variable is only used to check the locking state; that is, it is not meant to be thread-safe but merely as a failsafe feature to assert proper locking. */ -static ath_mutex_t system_rng_lock; +GPGRT_LOCK_DEFINE (system_rng_lock); static int system_rng_is_locked; @@ -58,16 +57,11 @@ static void basic_initialization (void) { static int initialized; - int my_errno; if (initialized) return; initialized = 1; - my_errno = ath_mutex_init (&system_rng_lock); - if (my_errno) - log_fatal ("failed to create the System RNG lock: %s\n", - strerror (my_errno)); system_rng_is_locked = 0; /* Make sure that we are still using the values we traditionally @@ -83,12 +77,12 @@ basic_initialization (void) static void lock_rng (void) { - int my_errno; + gpg_err_code_t rc; - my_errno = ath_mutex_lock (&system_rng_lock); - if (my_errno) + rc = gpgrt_lock_lock (&system_rng_lock); + if (rc) log_fatal ("failed to acquire the System RNG lock: %s\n", - strerror (my_errno)); + gpg_strerror (rc)); system_rng_is_locked = 1; } @@ -97,13 +91,13 @@ lock_rng (void) static void unlock_rng (void) { - int my_errno; + gpg_err_code_t rc; system_rng_is_locked = 0; - my_errno = ath_mutex_unlock (&system_rng_lock); - if (my_errno) + rc = gpgrt_lock_unlock (&system_rng_lock); + if (rc) log_fatal ("failed to release the System RNG lock: %s\n", - strerror (my_errno)); + gpg_strerror (rc)); } |