[git] GPG-ERROR - branch, master, updated. libgpg-error-1.12-16-gf209d16

by Werner Koch cvs at cvs.gnupg.org
Fri Jan 24 17:44:07 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 "Error codes used by GnuPG et al.".

The branch, master has been updated
       via  f209d163a8167caa6910cd367aba923f703ac69e (commit)
       via  4e8a88e7632b1f1d2b31ae738a159802549882c3 (commit)
      from  e07538c0ed3c5cb3d870a490a4c12bef4375278a (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 f209d163a8167caa6910cd367aba923f703ac69e
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 9 19:14:09 2014 +0100

    Make multi-threading flags available via gpg-error-config.
    
    * m4/threadlib.m4: Set THREADLIB_CPPFLAGS.
    * src/gpg-error-config.in: Add option --mt.
    * configure.ac: Add support for the --mt option.
    * src/gpg-error.m4: Add ac_subst GPG_ERROR_MT_CFLAGS and
    GPG_ERROR_MT_LIBS.
    --
    
    Although, libgpg-error does not yet provide an API for multi-thread
    support, it is useful to add the already available detection to the
    config script.  This allows the latest Libgcrypt to take advantage of
    this in its regression tests.  In particular for the regression tests
    a gpgrt_thread functions would be useful and eventually added to
    libgpg-error.  The new gpg-error.m4 script should already be used by
    other packages to be prepared for future updates.

diff --git a/NEWS b/NEWS
index c7f666b..87d7a86 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,12 @@
 Noteworthy changes in version 1.13 (unreleased)
 -----------------------------------------------
 
- Add a portable mutex API.
+ * Added a portable mutex API.
+
+ * The AM_PATH_GPG_ERROR macro now defines GPG_ERROR_MT_CFLAGS and
+   GPG_ERROR_MT_LIBS autoconf output variables for use by programs
+   which need gpgrt based thread support.  gpg-error-config has a new
+   option --mt.
 
  * Interface changes relative to the 1.12 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/configure.ac b/configure.ac
index 21a36e9..e3fa795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,11 +179,23 @@ GPG_ERROR_CONFIG_LIBS="-lgpg-error"
 if test "x$LIBTHREAD" != x; then
   GPG_ERROR_CONFIG_LIBS="${GPG_ERROR_CONFIG_LIBS} ${LIBTHREAD}"
 fi
+if test "x$LIBMULTITHREAD" != x; then
+  GPG_ERROR_CONFIG_MT_LIBS="${LIBMULTITHREAD}"
+else
+  GPG_ERROR_CONFIG_MT_LIBS=""
+fi
 GPG_ERROR_CONFIG_CFLAGS=""
+if test "x$THREADLIB_CPPFLAGS" != x; then
+  GPG_ERROR_CONFIG_MT_CFLAGS="${THREADLIB_CPPFLAGS}"
+else
+  GPG_ERROR_CONFIG_MT_CFLAGS=""
+fi
 GPG_ERROR_CONFIG_ISUBDIRAFTER=""
 GPG_ERROR_CONFIG_HOST="$host"
 AC_SUBST(GPG_ERROR_CONFIG_LIBS)
 AC_SUBST(GPG_ERROR_CONFIG_CFLAGS)
+AC_SUBST(GPG_ERROR_CONFIG_MT_LIBS)
+AC_SUBST(GPG_ERROR_CONFIG_MT_CFLAGS)
 AC_SUBST(GPG_ERROR_CONFIG_ISUBDIRAFTER)
 AC_SUBST(GPG_ERROR_CONFIG_HOST)
 
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index a91e819..b015365 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-15.
+# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-24.
 dnl Copyright (C) 2005-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -23,8 +23,8 @@ dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
 dnl programs that really need multithread functionality. The difference
 dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
 dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
-dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
-dnl multithread-safe programs.
+dnl Sets THREADLIB_CPPFLAGS to -D_REENTRANT or -D_THREAD_SAFE if needed for
+dnl multithread-safe programs and adds THREADLIB_CPPFLAGS to CPPFLAGS.
 
 AC_DEFUN([gl_THREADLIB_EARLY],
 [
@@ -49,6 +49,7 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
     [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
     [AC_REQUIRE([AC_GNU_SOURCE])])
   dnl Check for multithreading.
+  THREADLIB_CPPFLAGS=""
   m4_ifdef([gl_THREADLIB_DEFAULT_NO],
     [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
     [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
@@ -89,17 +90,24 @@ changequote([,])dnl
         # 2. putting a flag into CPPFLAGS that has an effect on the linker
         # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
         # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
-        CPPFLAGS="$CPPFLAGS -D_REENTRANT"
+        THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT"
         ;;
     esac
     # Some systems optimize for single-threaded programs by default, and
     # need special flags to disable these optimizations. For example, the
     # definition of 'errno' in <errno.h>.
     case "$host_os" in
-      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
-      solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
+      aix* | freebsd*)
+           THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_THREAD_SAFE"
+           ;;
+      solaris*)
+           THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT"
+           ;;
     esac
   fi
+  if test x"$THREADLIB_CPPFLAGS" != x ; then
+      CPPFLAGS="$CPPFLAGS $THREADLIB_CPPFLAGS"
+  fi
 ])
 
 dnl The guts of gl_THREADLIB. Needs to be expanded only once.
diff --git a/src/gpg-error-config.in b/src/gpg-error-config.in
index b132314..bc1c583 100644
--- a/src/gpg-error-config.in
+++ b/src/gpg-error-config.in
@@ -17,12 +17,14 @@ libdir=@libdir@
 isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@"
 
 output=""
+mt=no
 
 usage()
 {
     cat <<EOF
 Usage: gpg-error-config [OPTIONS]
 Options:
+        [--mt]       (must be the first option)
 	[--prefix]
 	[--exec-prefix]
 	[--version]
@@ -47,6 +49,9 @@ while test $# -gt 0; do
     esac
 
     case $1 in
+        --mt)
+            mt=yes
+            ;;
         --prefix)
 	    output="$output $prefix"
 	    ;;
@@ -67,6 +72,9 @@ while test $# -gt 0; do
                 output="$output -idirafter ${includedir}/${i}"
             done
 	    output="$output @GPG_ERROR_CONFIG_CFLAGS@"
+            if test $mt = yes ; then
+                output="$output @GPG_ERROR_CONFIG_MT_CFLAGS@"
+            fi
 	    ;;
 	--libs)
 	    case "$libdir" in
@@ -76,6 +84,9 @@ while test $# -gt 0; do
 		    ;;
 	    esac
 	    output="$output @GPG_ERROR_CONFIG_LIBS@"
+            if test $mt = yes ; then
+                output="$output @GPG_ERROR_CONFIG_MT_LIBS@"
+            fi
 	    ;;
         --host)
             echo "@GPG_ERROR_CONFIG_HOST@"
diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
index feb963c..053eceb 100644
--- a/src/gpg-error.m4
+++ b/src/gpg-error.m4
@@ -1,5 +1,5 @@
 # gpg-error.m4 - autoconf macro to detect libgpg-error.
-# Copyright (C) 2002, 2003, 2004, 2011 g10 Code GmbH
+# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
 #
 # This file is free software; as a special exception the author gives
 # unlimited permission to copy and/or distribute it, with or without
@@ -8,10 +8,16 @@
 # This file is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Last-changed: 2014-01-24
+
 
 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
+dnl
+dnl Test for libgpg-error and define GPG_ERROR_CFLAGS, GPG_ERROR_LIBS,
+dnl GPG_ERROR_MT_CFLAGS, and GPG_ERROR_MT_LIBS.  The _MT_ variants are
+dnl used for programs requireding real multi thread support.
 dnl
 AC_DEFUN([AM_PATH_GPG_ERROR],
 [ AC_REQUIRE([AC_CANONICAL_HOST])
@@ -64,6 +70,8 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
   if test $ok = yes; then
     GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
     GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
+    GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
+    GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
     AC_MSG_RESULT([yes ($gpg_error_config_version)])
     ifelse([$2], , :, [$2])
     gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none`
@@ -82,9 +90,13 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
   else
     GPG_ERROR_CFLAGS=""
     GPG_ERROR_LIBS=""
+    GPG_ERROR_MT_CFLAGS=""
+    GPG_ERROR_MT_LIBS=""
     AC_MSG_RESULT(no)
     ifelse([$3], , :, [$3])
   fi
   AC_SUBST(GPG_ERROR_CFLAGS)
   AC_SUBST(GPG_ERROR_LIBS)
+  AC_SUBST(GPG_ERROR_MT_CFLAGS)
+  AC_SUBST(GPG_ERROR_MT_LIBS)
 ])

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

    Allow using gpgrt_lock_init on an unitialized variable.
    
    * src/posix-lock.c (gpgrt_lock_init): Detect unitialized lock var.
    * src/w32-lock.c (gpgrt_lock_init): Ditto.
    --
    
    gpgrt_lock_init may be used for dynamically allocated locks.  For
    example
    
       gpgrt_lock_t *lock = xcalloc (1, sizeof *lock);
       gpgrt_lock_init (lock);
       gpgrt_lock_lock (lock);
       foo ();
       gpgrt_lock_unlock (lock);
       gpgrt_lock_destroy (lock);
       free (lock);
    
    This patch actually allows for this.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index adb796b..4bd28bf 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -291,7 +291,8 @@ gpg_error_from_syserror (void)
 #define GPGRT_LOCK_DEFINE(name) \
   static gpgrt_lock_t name  = GPGRT_LOCK_INITIALIZER
 
-
+/* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable
+   before passing it to gpgrt_lock_init.  */
 gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd);
 gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd);
 gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
diff --git a/src/posix-lock.c b/src/posix-lock.c
index 363cc09..5b0cab5 100644
--- a/src/posix-lock.c
+++ b/src/posix-lock.c
@@ -116,9 +116,21 @@ get_lock_object (gpgrt_lock_t *lockhd)
 gpg_err_code_t
 gpgrt_lock_init (gpgrt_lock_t *lockhd)
 {
-  _gpgrt_lock_t *lock = get_lock_object (lockhd);
+  _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
   int rc;
 
+  /* If VERS is zero we assume that no static initialization has been
+     done, so we setup our ABI version right here.  The caller might
+     have called us to test whether lock support is at all available. */
+  if (!lock->vers)
+    {
+      if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
+        abort ();
+      lock->vers = LOCK_ABI_VERSION;
+    }
+  else /* Run the usual check.  */
+    lock = get_lock_object (lockhd);
+
 #if USE_POSIX_THREADS
   if (use_pthread_p())
     {
@@ -198,7 +210,7 @@ gpgrt_lock_destroy (gpgrt_lock_t *lockhd)
         rc = gpg_err_code_from_errno (rc);
       else
         {
-          /* Re-init the the mutex so that it can be re-used.  */
+          /* Re-init the mutex so that it can be re-used.  */
           gpgrt_lock_t tmp = GPGRT_LOCK_INITIALIZER;
           memcpy (lockhd, &tmp, sizeof tmp);
         }
diff --git a/src/w32-lock.c b/src/w32-lock.c
index 0ad9409..56a0ed5 100644
--- a/src/w32-lock.c
+++ b/src/w32-lock.c
@@ -52,10 +52,24 @@ get_lock_object (gpgrt_lock_t *lockhd)
 gpg_err_code_t
 gpgrt_lock_init (gpgrt_lock_t *lockhd)
 {
-  _gpgrt_lock_t *lock = get_lock_object (lockhd);
+  _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
+
+  /* If VERS is zero we assume that no static initialization has been
+     done, so we setup our ABI version right here.  The caller might
+     have called us to test whether lock support is at all available. */
+  if (!lock->vers)
+    {
+      if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
+        abort ();
+      lock->vers = LOCK_ABI_VERSION;
+    }
+  else /* Run the usual check.  */
+    {
+      lock = get_lock_object (lockhd);
+      if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
+        abort ();
+    }
 
-  if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
-    abort ();
   InitializeCriticalSection (&lock->csec);
   lock->initdone = 1;
 }

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

Summary of changes:
 NEWS                    |    7 ++++++-
 configure.ac            |   12 ++++++++++++
 m4/threadlib.m4         |   20 ++++++++++++++------
 src/gpg-error-config.in |   11 +++++++++++
 src/gpg-error.h.in      |    3 ++-
 src/gpg-error.m4        |   16 ++++++++++++++--
 src/posix-lock.c        |   16 ++++++++++++++--
 src/w32-lock.c          |   20 +++++++++++++++++---
 8 files changed, 90 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
Error codes used by GnuPG et al.
http://git.gnupg.org




More information about the Gnupg-commits mailing list