diff --git a/egg/egg-libgcrypt.c b/egg/egg-libgcrypt.c index 22f005d..e215001 100644 --- a/egg/egg-libgcrypt.c +++ b/egg/egg-libgcrypt.c @@ -30,6 +30,8 @@ #include +#include + EGG_SECURE_DECLARE (libgcrypt); static void @@ -55,42 +57,9 @@ fatal_handler (gpointer unused, int unknown, const gchar *msg) g_log ("gcrypt", G_LOG_LEVEL_ERROR, "%s", msg); } -static int -glib_thread_mutex_init (void **lock) -{ - *lock = g_slice_new (GMutex); - g_mutex_init (*lock); - return 0; -} - -static int -glib_thread_mutex_destroy (void **lock) -{ - g_mutex_clear (*lock); - g_slice_free (GMutex, *lock); - return 0; -} - -static int -glib_thread_mutex_lock (void **lock) -{ - g_mutex_lock (*lock); - return 0; -} - -static int -glib_thread_mutex_unlock (void **lock) -{ - g_mutex_unlock (*lock); - return 0; -} - -static struct gcry_thread_cbs glib_thread_cbs = { - GCRY_THREAD_OPTION_USER, NULL, - glib_thread_mutex_init, glib_thread_mutex_destroy, - glib_thread_mutex_lock, glib_thread_mutex_unlock, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; +#if GCRYPT_VERSION_NUMBER < 0x010600 +GCRY_THREAD_OPTION_PTHREAD_IMPL; +#endif void egg_libgcrypt_initialize (void) @@ -102,7 +71,9 @@ egg_libgcrypt_initialize (void) /* Only initialize libgcrypt if it hasn't already been initialized */ if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) { - gcry_control (GCRYCTL_SET_THREAD_CBS, &glib_thread_cbs); +#if GCRYPT_VERSION_NUMBER < 0x010600 + gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#endif gcry_check_version (LIBGCRYPT_VERSION); gcry_set_log_handler (log_handler, NULL); gcry_set_outofcore_handler (no_mem_handler, NULL);