diff options
author | Werner Koch <[email protected]> | 2014-01-09 18:14:09 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-01-24 16:41:20 +0000 |
commit | f209d163a8167caa6910cd367aba923f703ac69e (patch) | |
tree | da4a07bdfa7648ce05c0165b68c53b83b577b555 | |
parent | Allow using gpgrt_lock_init on an unitialized variable. (diff) | |
download | libgpg-error-f209d163a8167caa6910cd367aba923f703ac69e.tar.gz libgpg-error-f209d163a8167caa6910cd367aba923f703ac69e.zip |
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.
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | m4/threadlib.m4 | 20 | ||||
-rw-r--r-- | src/gpg-error-config.in | 11 | ||||
-rw-r--r-- | src/gpg-error.m4 | 16 |
5 files changed, 57 insertions, 9 deletions
@@ -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) ]) |