From 09b64554328445e99a8cc78fc34ea49c2ea2e7f9 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Tue, 8 Nov 2016 15:32:14 +0100 Subject: core: Use gpgrt locking for thread safeness * configure.ac: Require libgpg-error 1.17. No longer check for pthread. * doc/gpgme.texi: Document removed neccessity for thread safe gpgme flavours. * src/sema.h (DEFINE_GLOBAL_LOCK), (DEFINE_STATIC_LOCK, INIT_LOCK, DECLARE_LOCK) (DESTROY_LOCK, LOCK, UNLOCK): Change to gpgrt equivalents. * src/posix-sema.c, src/w32-sema.c: Removed. * src/Makefile.am: Remove libpthread and Update accordingly. * src/ath.c, src/ath.h (ath_mutex_init) (ath_mutex_destroy, ath_mutex_lock, ath_mutex_unlock): Removed. * src/ath.h (ATH_MUTEX_INITIALIZER): Removed. * src/version.c (do_subsystem_inits): sema_subsystem_init is no longer required. * tests/gpg/Makefile.am: Add new threading tests. (t_thread1_LDADD, t_cancel_LDADD): Use just gpgme. * tests/gpg/t-thread-keylist-verify.c, tests/gpg/t-thread-keylist.c: New. * src/gpgme-config.in: Use -lgpgme for thread-model pthread. -- Using gpgrt locks instead of pthread locks removes the neccessity to link pthread directly to gpgme and have a different, thread safe flavor of gpgme. Now gpgme is thread-safe if the conditions mentioned in the doc are met. As the cpp bindings linked against libgpgme and not libgpgme-pthread this fixes threading problems with them. libgpgme-pthread is removed but gpgme-config still supports --thread=pthread for compatibility with find scripts. --- src/Makefile.am | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index eddd1920..dfe480c9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,20 +28,13 @@ nodist_include_HEADERS = gpgme.h bin_PROGRAMS = gpgme-tool -if HAVE_PTHREAD -ltlib_gpgme_pthread = libgpgme-pthread.la -else -ltlib_gpgme_pthread = -endif - if BUILD_W32_GLIB ltlib_gpgme_glib = libgpgme-glib.la else ltlib_gpgme_glib = endif -lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) $(ltlib_gpgme_qt) \ - $(ltlib_gpgme_pthread) +lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_glib) if HAVE_LD_VERSION_SCRIPT libgpgme_version_script_cmd = -Wl,--version-script=$(srcdir)/libgpgme.vers @@ -50,10 +43,10 @@ libgpgme_version_script_cmd = endif if HAVE_DOSISH_SYSTEM -system_components = w32-util.c w32-sema.c +system_components = w32-util.c system_components_not_extra = w32-io.c else -system_components = ath.h posix-util.c posix-sema.c posix-io.c +system_components = ath.h posix-util.c posix-io.c system_components_not_extra = endif @@ -93,12 +86,10 @@ main_sources = \ engine-spawn.c \ gpgconf.c queryswdb.c \ sema.h priv-io.h $(system_components) sys-util.h dirinfo.c \ - debug.c debug.h gpgme.c version.c error.c - -libgpgme_la_SOURCES = $(main_sources) \ + debug.c debug.h gpgme.c version.c error.c \ ath.h ath.c $(system_components_not_extra) -libgpgme_pthread_la_SOURCES = $(main_sources) \ - ath.h ath-pthread.c $(system_components_not_extra) + +libgpgme_la_SOURCES = $(main_sources) if BUILD_W32_GLIB libgpgme_glib_la_SOURCES = $(main_sources) ath.h ath.c w32-glib-io.c @@ -163,14 +154,6 @@ libgpgme_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers $(gpgme_deps) libgpgme_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \ @GPG_ERROR_LIBS@ -libgpgme_pthread_la_LDFLAGS = \ - $(no_undefined) $(export_symbols) $(extra_ltoptions) \ - $(libgpgme_version_script_cmd) -version-info \ - @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ -libgpgme_pthread_la_DEPENDENCIES = @LTLIBOBJS@ $(srcdir)/libgpgme.vers -libgpgme_pthread_la_LIBADD = $(gpgme_res) @LIBASSUAN_LIBS@ @LTLIBOBJS@ \ - -lpthread @GPG_ERROR_LIBS@ - if BUILD_W32_GLIB libgpgme_glib_la_LDFLAGS = \ $(no_undefined) $(export_symbols) $(extra_ltoptions) \ -- cgit v1.2.3