summaryrefslogtreecommitdiff
path: root/src/fips.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 /src/fips.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 'src/fips.c')
-rw-r--r--src/fips.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/fips.c b/src/fips.c
index 3ab33f93..c90e4b69 100644
--- a/src/fips.c
+++ b/src/fips.c
@@ -31,7 +31,6 @@
#endif /*HAVE_SYSLOG*/
#include "g10lib.h"
-#include "ath.h"
#include "cipher-proto.h"
#include "hmac256.h"
@@ -69,7 +68,7 @@ static int enforced_fips_mode;
static int inactive_fips_mode;
/* This is the lock we use to protect the FSM. */
-static ath_mutex_t fsm_lock;
+GPGRT_LOCK_DEFINE (fsm_lock);
/* The current state of the FSM. The whole state machinery is only
used while in fips mode. Change this only while holding fsm_lock. */
@@ -181,18 +180,18 @@ _gcry_initialize_fips_mode (int force)
FILE *fp;
/* Intitialize the lock to protect the FSM. */
- err = ath_mutex_init (&fsm_lock);
+ err = gpgrt_lock_init (&fsm_lock);
if (err)
{
/* If that fails we can't do anything but abort the
process. We need to use log_info so that the FSM won't
get involved. */
log_info ("FATAL: failed to create the FSM lock in libgcrypt: %s\n",
- strerror (err));
+ gpg_strerror (err));
#ifdef HAVE_SYSLOG
syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
"creating FSM lock failed: %s - abort",
- strerror (err));
+ gpg_strerror (err));
#endif /*HAVE_SYSLOG*/
abort ();
}
@@ -222,15 +221,15 @@ lock_fsm (void)
{
gpg_error_t err;
- err = ath_mutex_lock (&fsm_lock);
+ err = gpgrt_lock_lock (&fsm_lock);
if (err)
{
log_info ("FATAL: failed to acquire the FSM lock in libgrypt: %s\n",
- strerror (err));
+ gpg_strerror (err));
#ifdef HAVE_SYSLOG
syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
"acquiring FSM lock failed: %s - abort",
- strerror (err));
+ gpg_strerror (err));
#endif /*HAVE_SYSLOG*/
abort ();
}
@@ -241,15 +240,15 @@ unlock_fsm (void)
{
gpg_error_t err;
- err = ath_mutex_unlock (&fsm_lock);
+ err = gpgrt_lock_unlock (&fsm_lock);
if (err)
{
log_info ("FATAL: failed to release the FSM lock in libgrypt: %s\n",
- strerror (err));
+ gpg_strerror (err));
#ifdef HAVE_SYSLOG
syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
"releasing FSM lock failed: %s - abort",
- strerror (err));
+ gpg_strerror (err));
#endif /*HAVE_SYSLOG*/
abort ();
}