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 ...@@ -3966,22 +3966,23 @@ dnl libgcrypt
dnl dnl
AC_ARG_ENABLE(libgcrypt, AC_ARG_ENABLE(libgcrypt,
[ --disable-libgcrypt gcrypt support (default enabled)]) [ --disable-libgcrypt gcrypt support (default enabled)])
# require libgcrypt >= 1.6.0
AS_IF([test "${enable_libgcrypt}" != "no"], [ AS_IF([test "${enable_libgcrypt}" != "no"], [
AC_CHECK_DECL([GCRYCTL_SET_THREAD_CBS], [ AC_TRY_COMPILE([
libgcrypt-config --version >/dev/null || \ #include <gcrypt.h>
AC_MSG_ERROR([gcrypt.h present but libgcrypt-config could not be found]) #if GCRYPT_VERSION_NUMBER < 0x010600
AC_CHECK_LIB(gcrypt, gcry_control, [ #error
have_libgcrypt="yes" #endif],
AC_DEFINE([HAVE_GCRYPT], 1, [Defined if having gcrypt]) [], [
GCRYPT_CFLAGS="`libgcrypt-config --cflags`" have_libgcrypt="yes"
GCRYPT_LIBS="`libgcrypt-config --libs`" AC_DEFINE([HAVE_GCRYPT], 1, [Defined if having gcrypt])
], [ GCRYPT_CFLAGS="`libgcrypt-config --cflags`"
AC_MSG_ERROR([libgcrypt not found. Install libgcrypt or pass --disable-libgcrypt.]) GCRYPT_LIBS="`libgcrypt-config --libs`"
], [`libgcrypt-config --libs`])
], [ ], [
AC_MSG_ERROR([libgcrypt version 1.1.94 or higher not found. Install libgcrypt or pass --disable-libgcrypt.]) AS_IF([test "${enable_libgcrypt}" == "yes"], [
], [#include <gcrypt.h>] AC_MSG_ERROR([libgcrypt version 1.6.0 or higher not found. Install libgcrypt or pass --disable-libgcrypt.])
) ])
])
]) ])
AC_SUBST(GCRYPT_CFLAGS) AC_SUBST(GCRYPT_CFLAGS)
......
...@@ -25,65 +25,6 @@ ...@@ -25,65 +25,6 @@
#include <errno.h> #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) static inline void vlc_gcrypt_init (void)
{ {
/* This would need a process-wide static mutex with all libraries linking /* This would need a process-wide static mutex with all libraries linking
...@@ -96,7 +37,10 @@ static inline void vlc_gcrypt_init (void) ...@@ -96,7 +37,10 @@ static inline void vlc_gcrypt_init (void)
vlc_global_lock (VLC_GCRYPT_MUTEX); vlc_global_lock (VLC_GCRYPT_MUTEX);
if (!done) 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; done = true;
} }
vlc_global_unlock (VLC_GCRYPT_MUTEX); 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