[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-35-gcfc151b

by Werner Koch cvs at cvs.gnupg.org
Thu Jan 16 17:25:19 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, master has been updated
       via  cfc151ba637200e4fc05d9481a8df2071b2f9a47 (commit)
      from  49edeebb43174865cf4fa2c170a42a8e4274c4f0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cfc151ba637200e4fc05d9481a8df2071b2f9a47
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 9 19:14:09 2014 +0100

    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 at gnupg.org>

diff --git a/cipher/cipher-aeswrap.c b/cipher/cipher-aeswrap.c
index 50ac107..698742d 100644
--- a/cipher/cipher-aeswrap.c
+++ b/cipher/cipher-aeswrap.c
@@ -25,7 +25,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "bufhelp.h"
 #include "./cipher-internal.h"
 
diff --git a/cipher/cipher-cbc.c b/cipher/cipher-cbc.c
index 4b929da..67814b7 100644
--- a/cipher/cipher-cbc.c
+++ b/cipher/cipher-cbc.c
@@ -26,7 +26,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "./cipher-internal.h"
 #include "bufhelp.h"
 
diff --git a/cipher/cipher-ccm.c b/cipher/cipher-ccm.c
index 9d0bf0a..3d5f220 100644
--- a/cipher/cipher-ccm.c
+++ b/cipher/cipher-ccm.c
@@ -25,7 +25,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "bufhelp.h"
 #include "./cipher-internal.h"
 
diff --git a/cipher/cipher-cfb.c b/cipher/cipher-cfb.c
index 8539f54..f289ed3 100644
--- a/cipher/cipher-cfb.c
+++ b/cipher/cipher-cfb.c
@@ -26,7 +26,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "bufhelp.h"
 #include "./cipher-internal.h"
 
diff --git a/cipher/cipher-ctr.c b/cipher/cipher-ctr.c
index 1e7133c..4bbfaae 100644
--- a/cipher/cipher-ctr.c
+++ b/cipher/cipher-ctr.c
@@ -26,7 +26,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "bufhelp.h"
 #include "./cipher-internal.h"
 
diff --git a/cipher/cipher-gcm.c b/cipher/cipher-gcm.c
index cdd35ad..0534761 100644
--- a/cipher/cipher-gcm.c
+++ b/cipher/cipher-gcm.c
@@ -26,7 +26,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "bufhelp.h"
 #include "./cipher-internal.h"
 
diff --git a/cipher/cipher-ofb.c b/cipher/cipher-ofb.c
index 3842774..7db7658 100644
--- a/cipher/cipher-ofb.c
+++ b/cipher/cipher-ofb.c
@@ -26,7 +26,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "bufhelp.h"
 #include "./cipher-internal.h"
 
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 8c5a0b4..baa4720 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -27,7 +27,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "./cipher-internal.h"
 
 
diff --git a/cipher/kdf.c b/cipher/kdf.c
index af0dc48..ad5c46e 100644
--- a/cipher/kdf.c
+++ b/cipher/kdf.c
@@ -26,7 +26,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 #include "kdf-internal.h"
 
 
diff --git a/cipher/md.c b/cipher/md.c
index 1b59765..f4fb129 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -27,7 +27,6 @@
 
 #include "g10lib.h"
 #include "cipher.h"
-#include "ath.h"
 
 #include "rmd.h"
 
diff --git a/cipher/primegen.c b/cipher/primegen.c
index 645b0f8..9f6ec70 100644
--- a/cipher/primegen.c
+++ b/cipher/primegen.c
@@ -29,7 +29,6 @@
 #include "g10lib.h"
 #include "mpi.h"
 #include "cipher.h"
-#include "ath.h"
 
 static gcry_mpi_t gen_prime (unsigned int nbits, int secret, int randomlevel,
                              int (*extra_check)(void *, gcry_mpi_t),
@@ -141,18 +140,15 @@ struct primepool_s
 };
 struct primepool_s *primepool;
 /* Mutex used to protect access to the primepool.  */
-static ath_mutex_t primepool_lock;
+GPGRT_LOCK_DEFINE (primepool_lock);
 
 
 gcry_err_code_t
 _gcry_primegen_init (void)
 {
-  gcry_err_code_t ec;
-
-  ec = ath_mutex_init (&primepool_lock);
-  if (ec)
-    return gpg_err_code_from_errno (ec);
-  return ec;
+  /* This function was formerly used to initialize the primepool
+     Mutex. This has been replace by a static initialization.  */
+  return 0;
 }
 
 
@@ -446,12 +442,11 @@ prime_generate_internal (int need_q_factor,
               goto leave;
             }
 
-          if (ath_mutex_lock (&primepool_lock))
-            {
-              err = GPG_ERR_INTERNAL;
-              goto leave;
-            }
+          err = gpgrt_lock_lock (&primepool_lock);
+          if (err)
+            goto leave;
           is_locked = 1;
+
           for (i = 0; i < n; i++)
             {
               perms[i] = 1;
@@ -470,11 +465,9 @@ prime_generate_internal (int need_q_factor,
                   pool[i] = get_pool_prime (fbits, poolrandomlevel);
                   if (!pool[i])
                     {
-                      if (ath_mutex_unlock (&primepool_lock))
-                        {
-                          err = GPG_ERR_INTERNAL;
-                          goto leave;
-                        }
+                      err = gpgrt_lock_unlock (&primepool_lock);
+                      if (err)
+                        goto leave;
                       is_locked = 0;
                     }
                 }
@@ -483,23 +476,20 @@ prime_generate_internal (int need_q_factor,
               pool_in_use[i] = i;
               factors[i] = pool[i];
             }
-          if (is_locked && ath_mutex_unlock (&primepool_lock))
-            {
-              err = GPG_ERR_INTERNAL;
-              goto leave;
-            }
+
+          if (is_locked && (err = gpgrt_lock_unlock (&primepool_lock)))
+            goto leave;
           is_locked = 0;
         }
       else
         {
           /* Get next permutation. */
           m_out_of_n ( (char*)perms, n, m);
-          if (ath_mutex_lock (&primepool_lock))
-            {
-              err = GPG_ERR_INTERNAL;
-              goto leave;
-            }
+
+          if ((err = gpgrt_lock_lock (&primepool_lock)))
+            goto leave;
           is_locked = 1;
+
           for (i = j = 0; (i < m) && (j < n); i++)
             if (perms[i])
               {
@@ -509,11 +499,8 @@ prime_generate_internal (int need_q_factor,
                     pool[i] = get_pool_prime (fbits, poolrandomlevel);
                     if (!pool[i])
                       {
-                        if (ath_mutex_unlock (&primepool_lock))
-                          {
-                            err = GPG_ERR_INTERNAL;
-                            goto leave;
-                          }
+                        if ((err = gpgrt_lock_unlock (&primepool_lock)))
+                          goto leave;
                         is_locked = 0;
                       }
                   }
@@ -522,12 +509,11 @@ prime_generate_internal (int need_q_factor,
                 pool_in_use[j] = i;
                 factors[j++] = pool[i];
               }
-          if (is_locked && ath_mutex_unlock (&primepool_lock))
-            {
-              err = GPG_ERR_INTERNAL;
-              goto leave;
-            }
+
+          if (is_locked && (err = gpgrt_lock_unlock (&primepool_lock)))
+            goto leave;
           is_locked = 0;
+
           if (i == n)
             {
               /* Ran out of permutations: Allocate new primes.  */
@@ -686,7 +672,7 @@ prime_generate_internal (int need_q_factor,
  leave:
   if (pool)
     {
-      is_locked = !ath_mutex_lock (&primepool_lock);
+      is_locked = !gpgrt_lock_lock (&primepool_lock);
       for(i = 0; i < m; i++)
         {
           if (pool[i])
@@ -703,8 +689,8 @@ prime_generate_internal (int need_q_factor,
                 mpi_free (pool[i]);
             }
         }
-      if (is_locked && ath_mutex_unlock (&primepool_lock))
-        err = GPG_ERR_INTERNAL;
+      if (is_locked)
+        err = gpgrt_lock_unlock (&primepool_lock);
       is_locked = 0;
       xfree (pool);
     }
diff --git a/cipher/pubkey.c b/cipher/pubkey.c
index d130388..9aeaced 100644
--- a/cipher/pubkey.c
+++ b/cipher/pubkey.c
@@ -28,7 +28,6 @@
 #include "g10lib.h"
 #include "mpi.h"
 #include "cipher.h"
-#include "ath.h"
 #include "context.h"
 #include "pubkey-internal.h"
 
diff --git a/compat/compat.c b/compat/compat.c
index 5678067..39d6498 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -31,8 +31,8 @@ _gcry_compat_identification (void)
     "\n\n"
     "This is Libgcrypt " PACKAGE_VERSION " - The GNU Crypto Library\n"
     "Copyright (C) 2000-2012 Free Software Foundation, Inc.\n"
-    "Copyright (C) 2012-2013 g10 Code GmbH\n"
-    "Copyright (C) 2013 Jussi Kivilinna\n"
+    "Copyright (C) 2012-2014 g10 Code GmbH\n"
+    "Copyright (C) 2013-2014 Jussi Kivilinna\n"
     "\n"
     "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n"
     "\n\n";
diff --git a/configure.ac b/configure.ac
index 7d37f94..6272871 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,7 +67,7 @@ LIBGCRYPT_CONFIG_API_VERSION=1
 
 # If you change the required gpg-error version, please remove
 # unnecessary error code defines in src/gcrypt-int.h.
-NEED_GPG_ERROR_VERSION=1.11
+NEED_GPG_ERROR_VERSION=1.13
 
 PACKAGE=$PACKAGE_NAME
 VERSION=$PACKAGE_VERSION
@@ -733,11 +733,6 @@ if test "$have_pthread" = yes; then
    AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.])
 fi
 
-#
-# See which thread system we have
-# FIXME: Thus duplicates the above check.
-#
-gl_LOCK
 
 # Solaris needs -lsocket and -lnsl. Unisys system includes
 # gethostbyname in libsocket but needs libnsl for socket.
diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi
index 25d8227..7712b80 100644
--- a/doc/gcrypt.texi
+++ b/doc/gcrypt.texi
@@ -188,8 +188,8 @@ the same handle, he has to take care of the serialization of such
 functions himself.  If not described otherwise, every function is
 thread-safe.
 
-Libgcrypt depends on the library `libgpg-error', which
-contains common error handling related code for GnuPG components.
+Libgcrypt depends on the library `libgpg-error', which contains some
+common code used by other GnuPG components.
 
 @c **********************************************************
 @c *******************  Preparation  ************************
@@ -343,8 +343,7 @@ after program startup.
 
 The function @code{gcry_check_version} initializes some subsystems used
 by Libgcrypt and must be invoked before any other function in the
-library, with the exception of the @code{GCRYCTL_SET_THREAD_CBS} command
-(called via the @code{gcry_control} function).
+library.
 @xref{Multi-Threading}.
 
 Furthermore, this function returns the version number of the library.
@@ -450,51 +449,16 @@ thread-safe if you adhere to the following requirements:
 
 @itemize @bullet
 @item
-If your application is multi-threaded, you must set the thread support
-callbacks with the @code{GCRYCTL_SET_THREAD_CBS} command
- at strong{before} any other function in the library.
-
-This is easy enough if you are indeed writing an application using
-Libgcrypt.  It is rather problematic if you are writing a library
-instead.  Here are some tips what to do if you are writing a library:
-
-If your library requires a certain thread package, just initialize
-Libgcrypt to use this thread package.  If your library supports multiple
-thread packages, but needs to be configured, you will have to
-implement a way to determine which thread package the application
-wants to use with your library anyway.  Then configure Libgcrypt to use
-this thread package.
-
-If your library is fully reentrant without any special support by a
-thread package, then you are lucky indeed.  Unfortunately, this does
-not relieve you from doing either of the two above, or use a third
-option.  The third option is to let the application initialize Libgcrypt
-for you.  Then you are not using Libgcrypt transparently, though.
-
-As if this was not difficult enough, a conflict may arise if two
-libraries try to initialize Libgcrypt independently of each others, and
-both such libraries are then linked into the same application.  To
-make it a bit simpler for you, this will probably work, but only if
-both libraries have the same requirement for the thread package.  This
-is currently only supported for the non-threaded case, GNU Pth and
-pthread.
-
 If you use pthread and your applications forks and does not directly
 call exec (even calling stdio functions), all kind of problems may
 occur.  Future versions of Libgcrypt will try to cleanup using
 pthread_atfork but even that may lead to problems.  This is a common
 problem with almost all applications using pthread and fork.
 
-Note that future versions of Libgcrypt will drop this flexible thread
-support and instead only support the platforms standard thread
-implementation.
-
 
 @item
 The function @code{gcry_check_version} must be called before any other
-function in the library, except the @code{GCRYCTL_SET_THREAD_CBS}
-command (called via the @code{gcry_control} function), because it
-initializes the thread support subsystem in Libgcrypt.  To
+function in the library.  To
 achieve this in multi-threaded programs, you must synchronize the
 memory with respect to other threads that also want to use
 Libgcrypt.  For this, it is sufficient to call
@@ -515,52 +479,6 @@ Just like the function @code{gpg_strerror}, the function
 @end itemize
 
 
-Libgcrypt contains convenient macros, which define the
-necessary thread callbacks for PThread and for GNU Pth:
-
- at table @code
- at item GCRY_THREAD_OPTION_PTH_IMPL
-
-This macro defines the following (static) symbols:
- at code{gcry_pth_init}, @code{gcry_pth_mutex_init},
- at code{gcry_pth_mutex_destroy}, @code{gcry_pth_mutex_lock},
- at code{gcry_pth_mutex_unlock}, @code{gcry_pth_read},
- at code{gcry_pth_write}, @code{gcry_pth_select},
- at code{gcry_pth_waitpid}, @code{gcry_pth_accept},
- at code{gcry_pth_connect}, @code{gcry_threads_pth}.
-
-After including this macro, @code{gcry_control()} shall be used with a
-command of @code{GCRYCTL_SET_THREAD_CBS} in order to register the
-thread callback structure named ``gcry_threads_pth''.  Example:
-
- at smallexample
-  ret = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
- at end smallexample
-
-
- at item GCRY_THREAD_OPTION_PTHREAD_IMPL
-
-This macro defines the following (static) symbols:
- at code{gcry_pthread_mutex_init}, @code{gcry_pthread_mutex_destroy},
- at code{gcry_pthread_mutex_lock}, @code{gcry_pthread_mutex_unlock},
- at code{gcry_threads_pthread}.
-
-After including this macro, @code{gcry_control()} shall be used with a
-command of @code{GCRYCTL_SET_THREAD_CBS} in order to register the
-thread callback structure named ``gcry_threads_pthread''.  Example:
-
- at smallexample
-  ret = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
- at end smallexample
-
-
- at end table
-
-Note that these macros need to be terminated with a semicolon.  Keep
-in mind that these are convenient macros for C programmers; C++
-programmers might have to wrap these macros in an ``extern C'' body.
-
-
 @node Enabling FIPS mode
 @section How to enable the FIPS mode
 @cindex FIPS mode
@@ -863,8 +781,7 @@ This command returns true if the command@*
 GCRYCTL_INITIALIZATION_FINISHED has already been run.
 
 @item GCRYCTL_SET_THREAD_CBS; Arguments: struct ath_ops *ath_ops
-This command registers a thread-callback structure.
- at xref{Multi-Threading}.
+This command is obsolete since version 1.6.
 
 @item GCRYCTL_FAST_POLL; Arguments: none
 Run a fast random poll.
@@ -2762,7 +2679,7 @@ operations.  @var{cmd} controls what is to be done. The return value is
 Disable the algorithm given as an algorithm id in @var{buffer}.
 @var{buffer} must point to an @code{int} variable with the algorithm
 id and @var{buflen} must have the value @code{sizeof (int)}.  This
-fucntion is not thread safe and should thus be used before any other
+function is not thread safe and should thus be used before any other
 threads are started.
 
 @end table
diff --git a/random/random-csprng.c b/random/random-csprng.c
index 87235d8..429c84f 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));
 }
 
 
diff --git a/random/random-daemon.c b/random/random-daemon.c
index 98a0153..8ea4df2 100644
--- a/random/random-daemon.c
+++ b/random/random-daemon.c
@@ -28,8 +28,6 @@
    sensitive data.
  */
 
-#error This dameon needs to be fixed due to the ath changes
-
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -42,7 +40,6 @@
 
 #include "g10lib.h"
 #include "random.h"
-#include "ath.h"
 
 
 
@@ -51,7 +48,7 @@
 #define RANDOM_DAEMON_SOCKET "/var/run/libgcrypt/S.gcryptrnd"
 
 /* The lock serializing access to the daemon.  */
-static ath_mutex_t daemon_lock = ATH_MUTEX_INITIALIZER;
+GPGRT_LOCK_DEFINE (daemon_lock);
 
 /* The socket connected to the daemon.  */
 static int daemon_socket = -1;
@@ -129,16 +126,7 @@ connect_to_socket (const char *socketname, int *sock)
 void
 _gcry_daemon_initialize_basics (void)
 {
-  static int initialized;
-  int err;
-
-  if (!initialized)
-    {
-      initialized = 1;
-      err = ath_mutex_init (&daemon_lock);
-      if (err)
-        log_fatal ("failed to create the daemon lock: %s\n", strerror (err) );
-    }
+  /* Not anymore required.  */
 }
 
 
@@ -213,7 +201,7 @@ call_daemon (const char *socketname,
   if (!req_nbytes)
     return 0;
 
-  ath_mutex_lock (&daemon_lock);
+  gpgrt_lock_lock (&daemon_lock);
 
   /* Open the socket if that has not been done. */
   if (!initialized)
@@ -225,7 +213,7 @@ call_daemon (const char *socketname,
         {
           daemon_socket = -1;
           log_info ("not using random daemon\n");
-          ath_mutex_unlock (&daemon_lock);
+          gpgrt_lock_unlock (&daemon_lock);
           return err;
         }
     }
@@ -233,7 +221,7 @@ call_daemon (const char *socketname,
   /* Check that we have a valid socket descriptor. */
   if ( daemon_socket == -1 )
     {
-      ath_mutex_unlock (&daemon_lock);
+      gpgrt_lock_unlock (&daemon_lock);
       return gcry_error (GPG_ERR_INTERNAL);
     }
 
@@ -325,7 +313,7 @@ call_daemon (const char *socketname,
     }
   while (req_nbytes);
 
-  ath_mutex_unlock (&daemon_lock);
+  gpgrt_lock_unlock (&daemon_lock);
 
   return err;
 }
diff --git a/random/random-fips.c b/random/random-fips.c
index d00825e..0a76362 100644
--- a/random/random-fips.c
+++ b/random/random-fips.c
@@ -66,13 +66,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 fips_rng_lock;
+GPGRT_LOCK_DEFINE (fips_rng_lock);
 static int fips_rng_is_locked;
 
 
@@ -190,15 +189,11 @@ static void
 basic_initialization (void)
 {
   static int initialized;
-  int my_errno;
 
   if (initialized)
     return;
   initialized = 1;
 
-  my_errno = ath_mutex_init (&fips_rng_lock);
-  if (my_errno)
-    log_fatal ("failed to create the RNG lock: %s\n", strerror (my_errno));
   fips_rng_is_locked = 0;
 
   /* Make sure that we are still using the values we have
@@ -214,11 +209,11 @@ basic_initialization (void)
 static void
 lock_rng (void)
 {
-  int my_errno;
+  gpg_err_code_t rc;
 
-  my_errno = ath_mutex_lock (&fips_rng_lock);
-  if (my_errno)
-    log_fatal ("failed to acquire the RNG lock: %s\n", strerror (my_errno));
+  rc = gpgrt_lock_lock (&fips_rng_lock);
+  if (rc)
+    log_fatal ("failed to acquire the RNG lock: %s\n", gpg_strerror (rc));
   fips_rng_is_locked = 1;
 }
 
@@ -227,12 +222,12 @@ lock_rng (void)
 static void
 unlock_rng (void)
 {
-  int my_errno;
+  gpg_err_code_t rc;
 
   fips_rng_is_locked = 0;
-  my_errno = ath_mutex_unlock (&fips_rng_lock);
-  if (my_errno)
-    log_fatal ("failed to release the RNG lock: %s\n", strerror (my_errno));
+  rc = gpgrt_lock_unlock (&fips_rng_lock);
+  if (rc)
+    log_fatal ("failed to release the RNG lock: %s\n", gpg_strerror (rc));
 }
 
 static void
diff --git a/random/random-system.c b/random/random-system.c
index 3962ab8..8b79511 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));
 }
 
 
diff --git a/random/random.c b/random/random.c
index ff9d6d2..41d4cb3 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));
 }
 
 
diff --git a/src/Makefile.am b/src/Makefile.am
index c020239..b764852 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,8 +61,7 @@ libgcrypt_la_SOURCES = \
 	stdmem.c stdmem.h secmem.c secmem.h \
 	mpi.h missing-string.c fips.c \
 	hmac256.c hmac256.h context.c context.h \
-	ec-context.h \
-	ath.h ath.c
+	ec-context.h
 
 EXTRA_libgcrypt_la_SOURCES = hwf-x86.c hwf-arm.c
 gcrypt_hwf_modules = @GCRYPT_HWF_MODULES@
diff --git a/src/ath.c b/src/ath.c
deleted file mode 100644
index 7a7035d..0000000
--- a/src/ath.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* ath.c - A Thread-safeness library.
- *  Copyright (C) 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
- *
- * This file is part of Libgcrypt.
- *
- * Libgcrypt is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser general Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * Libgcrypt is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <assert.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#if USE_POSIX_THREADS_WEAK
-# include <pthread.h>
-#endif
-
-#include "ath.h"
-
-
-
-/* On an ELF system it is easy to use pthreads using weak references.
-   Take care not to test the address of a weak referenced function we
-   actually use; some GCC versions have a bug were &foo != NULL is
-   always evaluated to true in PIC mode.  USING_PTHREAD_AS_DEFAULT is
-   used by ath_install to detect the default usage of pthread.  */
-#if USE_POSIX_THREADS_WEAK
-# pragma weak pthread_cancel
-# pragma weak pthread_mutex_init
-# pragma weak pthread_mutex_lock
-# pragma weak pthread_mutex_unlock
-# pragma weak pthread_mutex_destroy
-#endif
-
-/* For the dummy interface.  The MUTEX_NOTINIT value is used to check
-   that a mutex has been initialized.  */
-#define MUTEX_NOTINIT	((ath_mutex_t) 0)
-#define MUTEX_UNLOCKED	((ath_mutex_t) 1)
-#define MUTEX_LOCKED	((ath_mutex_t) 2)
-#define MUTEX_DESTROYED	((ath_mutex_t) 3)
-
-
-/* Return the thread type from the option field. */
-#define GET_OPTION(a)    ((a) & 0xff)
-
-
-
-enum ath_thread_model {
-  ath_model_undefined = 0,
-  ath_model_none,          /* No thread support.  */
-  ath_model_pthreads_weak, /* POSIX threads using weak symbols.  */
-  ath_model_pthreads,      /* POSIX threads directly linked.  */
-  ath_model_w32            /* Microsoft Windows threads.  */
-};
-
-
-/* The thread model in use.  */
-static enum ath_thread_model thread_model;
-
-
-/* Initialize the ath subsystem.  This is called as part of the
-   Libgcrypt initialization.  It's purpose is to initialize the
-   locking system.  It returns 0 on sucess or an ERRNO value on error.
-   In the latter case it is not defined whether ERRNO was changed.
-
-   Note: This should be called as early as possible because it is not
-   always possible to detect the thread model to use while already
-   running multi threaded.  */
-int
-ath_init (void)
-{
-  int err = 0;
-
-  if (thread_model)
-    return 0; /* Already initialized - no error.  */
-
-  if (0)
-    ;
-#if USE_POSIX_THREADS_WEAK
-  else if (pthread_cancel)
-    {
-      thread_model = ath_model_pthreads_weak;
-    }
-#endif
-  else
-    {
-      /* Assume a single threaded application.  */
-      thread_model = ath_model_none;
-    }
-
-  return err;
-}
-
-
-/* Return the used thread model as string for display purposes an if
-   R_MODEL is not null store its internal number at R_MODEL.  */
-const char *
-ath_get_model (int *r_model)
-{
-  if (r_model)
-    *r_model = thread_model;
-  switch (thread_model)
-    {
-    case ath_model_undefined:     return "undefined";
-    case ath_model_none:          return "none";
-    case ath_model_pthreads_weak: return "pthread(weak)";
-    case ath_model_pthreads:      return "pthread";
-    case ath_model_w32:           return "w32";
-    default:                      return "?";
-    }
-}
-
-
-/* This function was used in old Libgcrypt versions (via
-   GCRYCTL_SET_THREAD_CBS) to register the thread callback functions.
-   It is not anymore required.  However to allow existing code to
-   continue to work, we keep this function and check that no user
-   defined callbacks are used and that the requested thread system
-   matches the one Libgcrypt is using.  */
-gpg_err_code_t
-ath_install (struct ath_ops *ath_ops)
-{
-  gpg_err_code_t rc;
-  unsigned int thread_option;
-
-  /* Fist call ath_init so that we know our thread model.  */
-  rc = ath_init ();
-  if (rc)
-    return rc;
-
-  /* Check if the requested thread option is compatible to the
-     thread option we are already committed to.  */
-  thread_option = ath_ops? GET_OPTION (ath_ops->option) : 0;
-
-  /* Return an error if the requested thread model does not match the
-     configured one.  */
-  if (0)
-    ;
-#if USE_POSIX_THREADS_WEAK
-  else if (thread_model == ath_model_pthreads_weak)
-    {
-      if (thread_option == ATH_THREAD_OPTION_PTHREAD)
-        return 0; /* Okay - compatible.  */
-      if (thread_option == ATH_THREAD_OPTION_PTH)
-        return 0; /* Okay - compatible.  */
-    }
-#endif /*USE_POSIX_THREADS_WEAK*/
-  else if (thread_option == ATH_THREAD_OPTION_PTH)
-    {
-      if (thread_model == ath_model_none)
-        return 0; /* Okay - compatible.  */
-    }
-  else if (thread_option == ATH_THREAD_OPTION_DEFAULT)
-    return 0; /* No thread support requested.  */
-
-  return GPG_ERR_NOT_SUPPORTED;
-}
-
-
-/* Initialize a new mutex.  This function returns 0 on success or an
-   system error code (i.e. an ERRNO value).  ERRNO may or may not be
-   changed on error.  */
-int
-ath_mutex_init (ath_mutex_t *lock)
-{
-  int err;
-
-  switch (thread_model)
-    {
-    case ath_model_none:
-      *lock = MUTEX_UNLOCKED;
-      err = 0;
-      break;
-
-#if USE_POSIX_THREADS_WEAK
-    case ath_model_pthreads_weak:
-      {
-        pthread_mutex_t *plck;
-
-        plck = malloc (sizeof *plck);
-        if (!plck)
-          err = errno? errno : ENOMEM;
-        else
-          {
-            err = pthread_mutex_init (plck, NULL);
-            if (err)
-              free (plck);
-            else
-              *lock = (void*)plck;
-          }
-      }
-      break;
-#endif /*USE_POSIX_THREADS_WEAK*/
-
-    default:
-      err = EINVAL;
-      break;
-    }
-
-  return err;
-}
-
-
-/* Destroy a mutex.  This function is a NOP if LOCK is NULL.  If the
-   mutex is still locked it can't be destroyed and the function
-   returns EBUSY.  ERRNO may or may not be changed on error.  */
-int
-ath_mutex_destroy (ath_mutex_t *lock)
-{
-  int err;
-
-  if (!*lock)
-    return 0;
-
-  switch (thread_model)
-    {
-    case ath_model_none:
-      if (*lock != MUTEX_UNLOCKED)
-        err = EBUSY;
-      else
-        {
-          *lock = MUTEX_DESTROYED;
-          err = 0;
-        }
-      break;
-
-#if USE_POSIX_THREADS_WEAK
-    case ath_model_pthreads_weak:
-      {
-        pthread_mutex_t *plck = (pthread_mutex_t*) (*lock);
-
-        err = pthread_mutex_destroy (plck);
-        if (!err)
-          {
-            free (plck);
-            lock = NULL;
-          }
-      }
-      break;
-#endif /*USE_POSIX_THREADS_WEAK*/
-
-    default:
-      err = EINVAL;
-      break;
-    }
-
-  return err;
-}
-
-
-/* Lock the mutex LOCK.  On success the function returns 0; on error
-   an error code.  ERRNO may or may not be changed on error.  */
-int
-ath_mutex_lock (ath_mutex_t *lock)
-{
-  int err;
-
-  switch (thread_model)
-    {
-    case ath_model_none:
-      if (*lock == MUTEX_NOTINIT)
-	err = EINVAL;
-      else if (*lock == MUTEX_UNLOCKED)
-        {
-          *lock = MUTEX_LOCKED;
-          err = 0;
-        }
-      else
-        err = EDEADLK;
-      break;
-
-#if USE_POSIX_THREADS_WEAK
-    case ath_model_pthreads_weak:
-      err = pthread_mutex_lock ((pthread_mutex_t*)(*lock));
-      break;
-#endif /*USE_POSIX_THREADS_WEAK*/
-
-    default:
-      err = EINVAL;
-      break;
-    }
-
-  return err;
-}
-
-/* Unlock the mutex LOCK.  On success the function returns 0; on error
-   an error code.  ERRNO may or may not be changed on error.  */
-int
-ath_mutex_unlock (ath_mutex_t *lock)
-{
-  int err;
-
-  switch (thread_model)
-    {
-    case ath_model_none:
-      if (*lock == MUTEX_NOTINIT)
-	err = EINVAL;
-      else if (*lock == MUTEX_LOCKED)
-        {
-          *lock = MUTEX_UNLOCKED;
-          err = 0;
-        }
-      else
-        err = EPERM;
-      break;
-
-#if USE_POSIX_THREADS_WEAK
-    case ath_model_pthreads_weak:
-      err = pthread_mutex_unlock ((pthread_mutex_t*)(*lock));
-      break;
-#endif /*USE_POSIX_THREADS_WEAK*/
-
-    default:
-      err = EINVAL;
-      break;
-    }
-
-  return err;
-}
diff --git a/src/ath.h b/src/ath.h
deleted file mode 100644
index a132e0b..0000000
--- a/src/ath.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ath.h - Thread-safeness library.
- * Copyright (C) 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
- *
- * This file is part of Libgcrypt.
- *
- * Libgcrypt is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser general Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * Libgcrypt is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef ATH_H
-#define ATH_H
-
-#include <config.h>
-
-#ifdef _WIN32
-# include <winsock2.h>
-# include <windows.h>
-#else /* !_WIN32 */
-# ifdef HAVE_SYS_SELECT_H
-#  include <sys/select.h>
-# else
-#  include <sys/time.h>
-# endif
-# include <sys/types.h>
-# ifdef HAVE_SYS_MSG_H
-#  include <sys/msg.h>  /* (e.g. for zOS) */
-# endif
-# include <sys/socket.h>
-#endif /* !_WIN32 */
-#include <gpg-error.h>
-
-
-
-/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
-   a prefix.  */
-#define _ATH_EXT_SYM_PREFIX _gcry_
-
-#ifdef _ATH_EXT_SYM_PREFIX
-#define _ATH_PREFIX1(x,y) x ## y
-#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
-#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
-#define ath_install _ATH_PREFIX(ath_install)
-#define ath_init _ATH_PREFIX(ath_init)
-#define ath_get_model _ATH_PREFIX(ath_get_model)
-#define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
-#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
-#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
-#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
-#endif
-
-
-enum ath_thread_option
-  {
-    ATH_THREAD_OPTION_DEFAULT = 0,
-    ATH_THREAD_OPTION_USER = 1,
-    ATH_THREAD_OPTION_PTH = 2,
-    ATH_THREAD_OPTION_PTHREAD = 3
-  };
-
-struct ath_ops
-{
-  /* The OPTION field encodes the thread model and the version number
-     of this structure.
-       Bits  7 - 0  are used for the thread model
-       Bits 15 - 8  are used for the version number.
-  */
-  unsigned int option;
-
-};
-
-gpg_err_code_t ath_install (struct ath_ops *ath_ops);
-int ath_init (void);
-const char *ath_get_model (int *r_model);
-
-/* Functions for mutual exclusion.  */
-typedef void *ath_mutex_t;
-
-int ath_mutex_init (ath_mutex_t *mutex);
-int ath_mutex_destroy (ath_mutex_t *mutex);
-int ath_mutex_lock (ath_mutex_t *mutex);
-int ath_mutex_unlock (ath_mutex_t *mutex);
-
-#endif	/* ATH_H */
diff --git a/src/fips.c b/src/fips.c
index 3ab33f9..c90e4b6 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 ();
     }
diff --git a/src/global.c b/src/global.c
index 9af499e..b2b1de6 100644
--- a/src/global.c
+++ b/src/global.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
  *               2004, 2005, 2006, 2008, 2011,
  *               2012  Free Software Foundation, Inc.
- * Copyright (C) 2013 g10 Code GmbH
+ * Copyright (C) 2013, 2014 g10 Code GmbH
  *
  * This file is part of Libgcrypt.
  *
@@ -38,7 +38,7 @@
 #include "cipher.h"
 #include "stdmem.h" /* our own memory allocator */
 #include "secmem.h" /* our own secmem allocator */
-#include "ath.h"
+
 
 
 
@@ -86,14 +86,6 @@ global_init (void)
   /* Tell the random module that we have seen an init call.  */
   _gcry_set_preferred_rng_type (0);
 
-  /* Initialize our portable thread/mutex wrapper.  */
-  err = ath_init ();
-  if (err)
-    {
-      err = gpg_error_from_errno (err);
-      goto fail;
-    }
-
   /* See whether the system is in FIPS mode.  This needs to come as
      early as possible but after ATH has been initialized.  */
   _gcry_initialize_fips_mode (force_fips_mode);
@@ -304,7 +296,6 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp)
 #endif
        ":\n");
   fnc (fp, "mpi-asm:%s:\n", _gcry_mpi_get_hw_config ());
-  fnc (fp, "threads:%s:\n", ath_get_model (NULL));
   hwfeatures = _gcry_get_hw_features ();
   fnc (fp, "hwflist:");
   for (i=0; (s = _gcry_enum_hw_features (i, &afeature)); i++)
@@ -476,10 +467,10 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
       break;
 
     case GCRYCTL_SET_THREAD_CBS:
+      /* This is now a dummy call.  We used to install our own thread
+         library here. */
       _gcry_set_preferred_rng_type (0);
-      rc = ath_install (va_arg (arg_ptr, void *));
-      if (!rc)
-	global_init ();
+      global_init ();
       break;
 
     case GCRYCTL_FAST_POLL:
diff --git a/src/secmem.c b/src/secmem.c
index 2bf7d8c..cfea921 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -37,7 +37,6 @@
 #endif
 #endif
 
-#include "ath.h"
 #include "g10lib.h"
 #include "secmem.h"
 
@@ -86,11 +85,11 @@ static int no_priv_drop;
 static unsigned int cur_alloced, cur_blocks;
 
 /* Lock protecting accesses to the memory pool.  */
-static ath_mutex_t secmem_lock;
+GPGRT_LOCK_DEFINE (secmem_lock);
 
 /* Convenient macros.  */
-#define SECMEM_LOCK   ath_mutex_lock   (&secmem_lock)
-#define SECMEM_UNLOCK ath_mutex_unlock (&secmem_lock)
+#define SECMEM_LOCK   gpgrt_lock_lock   (&secmem_lock)
+#define SECMEM_UNLOCK gpgrt_lock_unlock (&secmem_lock)
 
 /* The size of the memblock structure; this does not include the
    memory that is available to the user.  */
@@ -536,12 +535,7 @@ _gcry_secmem_init (size_t n)
 gcry_err_code_t
 _gcry_secmem_module_init ()
 {
-  int err;
-
-  err = ath_mutex_init (&secmem_lock);
-  if (err)
-    log_fatal ("could not allocate secmem lock\n");
-
+  /* No anymore needed.  */
   return 0;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 cipher/cipher-aeswrap.c |    1 -
 cipher/cipher-cbc.c     |    1 -
 cipher/cipher-ccm.c     |    1 -
 cipher/cipher-cfb.c     |    1 -
 cipher/cipher-ctr.c     |    1 -
 cipher/cipher-gcm.c     |    1 -
 cipher/cipher-ofb.c     |    1 -
 cipher/cipher.c         |    1 -
 cipher/kdf.c            |    1 -
 cipher/md.c             |    1 -
 cipher/primegen.c       |   68 ++++------
 cipher/pubkey.c         |    1 -
 compat/compat.c         |    4 +-
 configure.ac            |    7 +-
 doc/gcrypt.texi         |   95 +-------------
 random/random-csprng.c  |   15 +--
 random/random-daemon.c  |   24 +---
 random/random-fips.c    |   23 ++--
 random/random-system.c  |   24 ++--
 random/random.c         |   23 +---
 src/Makefile.am         |    3 +-
 src/ath.c               |  333 -----------------------------------------------
 src/ath.h               |   93 -------------
 src/fips.c              |   21 ++-
 src/global.c            |   19 +--
 src/secmem.c            |   14 +-
 26 files changed, 90 insertions(+), 687 deletions(-)
 delete mode 100644 src/ath.c
 delete mode 100644 src/ath.h


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list