Commit 07c9677d authored by Thomas Guillem's avatar Thomas Guillem

gcrypt: require libgcrypt >= 1.6.0

And remove setup thread callbacks init since it's not supported anymore.
parent 1a2f7b20
......@@ -3966,22 +3966,23 @@ dnl libgcrypt
dnl
AC_ARG_ENABLE(libgcrypt,
[ --disable-libgcrypt gcrypt support (default enabled)])
# require libgcrypt >= 1.6.0
AS_IF([test "${enable_libgcrypt}" != "no"], [
AC_CHECK_DECL([GCRYCTL_SET_THREAD_CBS], [
libgcrypt-config --version >/dev/null || \
AC_MSG_ERROR([gcrypt.h present but libgcrypt-config could not be found])
AC_CHECK_LIB(gcrypt, gcry_control, [
have_libgcrypt="yes"
AC_DEFINE([HAVE_GCRYPT], 1, [Defined if having gcrypt])
GCRYPT_CFLAGS="`libgcrypt-config --cflags`"
GCRYPT_LIBS="`libgcrypt-config --libs`"
], [
AC_MSG_ERROR([libgcrypt not found. Install libgcrypt or pass --disable-libgcrypt.])
], [`libgcrypt-config --libs`])
AC_TRY_COMPILE([
#include <gcrypt.h>
#if GCRYPT_VERSION_NUMBER < 0x010600
#error
#endif],
[], [
have_libgcrypt="yes"
AC_DEFINE([HAVE_GCRYPT], 1, [Defined if having gcrypt])
GCRYPT_CFLAGS="`libgcrypt-config --cflags`"
GCRYPT_LIBS="`libgcrypt-config --libs`"
], [
AC_MSG_ERROR([libgcrypt version 1.1.94 or higher not found. Install libgcrypt or pass --disable-libgcrypt.])
], [#include <gcrypt.h>]
)
AS_IF([test "${enable_libgcrypt}" == "yes"], [
AC_MSG_ERROR([libgcrypt version 1.6.0 or higher not found. Install libgcrypt or pass --disable-libgcrypt.])
])
])
])
AC_SUBST(GCRYPT_CFLAGS)
......
......@@ -25,65 +25,6 @@
#include <errno.h>
#ifdef LIBVLC_USE_PTHREAD
/**
* If possible, use gcrypt-provided thread implementation. This is so that
* other non-VLC components (inside the process) can also use gcrypt safely.
*/
GCRY_THREAD_OPTION_PTHREAD_IMPL;
# define gcry_threads_vlc gcry_threads_pthread
#else
/**
* gcrypt thread option VLC implementation
*/
static int gcry_vlc_mutex_init( void **p_sys )
{
vlc_mutex_t *p_lock = (vlc_mutex_t *)malloc( sizeof( vlc_mutex_t ) );
if( p_lock == NULL)
return ENOMEM;
vlc_mutex_init( p_lock );
*p_sys = p_lock;
return VLC_SUCCESS;
}
static int gcry_vlc_mutex_destroy( void **p_sys )
{
vlc_mutex_t *p_lock = (vlc_mutex_t *)*p_sys;
vlc_mutex_destroy( p_lock );
free( p_lock );
return VLC_SUCCESS;
}
static int gcry_vlc_mutex_lock( void **p_sys )
{
vlc_mutex_lock( (vlc_mutex_t *)*p_sys );
return VLC_SUCCESS;
}
static int gcry_vlc_mutex_unlock( void **lock )
{
vlc_mutex_unlock( (vlc_mutex_t *)*lock );
return VLC_SUCCESS;
}
static const struct gcry_thread_cbs gcry_threads_vlc =
{
GCRY_THREAD_OPTION_USER,
NULL,
gcry_vlc_mutex_init,
gcry_vlc_mutex_destroy,
gcry_vlc_mutex_lock,
gcry_vlc_mutex_unlock,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
#endif
/**
* Initializes gcrypt with proper locking.
*/
static inline void vlc_gcrypt_init (void)
{
/* This would need a process-wide static mutex with all libraries linking
......@@ -96,7 +37,10 @@ static inline void vlc_gcrypt_init (void)
vlc_global_lock (VLC_GCRYPT_MUTEX);
if (!done)
{
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_vlc);
/* The suggested way for an application to make sure that global_init
* has been called is by using gcry_check_version. (see global_init
* comments in gcrypt sources) */
gcry_check_version(NULL);
done = true;
}
vlc_global_unlock (VLC_GCRYPT_MUTEX);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment