mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-24 08:12:44 +00:00
network: use HAVE_THREADS instead of local hack
HAVE_THREADS is set in config.h if pthreads or w32threads is available, which presumably the proper condition here. Also fixes undefined behaviour in preprocessor directives. Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
67a68dcec2
commit
9efbfe57e0
@ -22,9 +22,7 @@
|
|||||||
#include "libavcodec/internal.h"
|
#include "libavcodec/internal.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
|
|
||||||
#define THREADS (HAVE_PTHREADS || (defined(WIN32) && !defined(__MINGW32CE__)))
|
#if HAVE_THREADS
|
||||||
|
|
||||||
#if THREADS
|
|
||||||
#if HAVE_PTHREADS
|
#if HAVE_PTHREADS
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#else
|
#else
|
||||||
@ -35,7 +33,7 @@
|
|||||||
#if CONFIG_OPENSSL
|
#if CONFIG_OPENSSL
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
static int openssl_init;
|
static int openssl_init;
|
||||||
#if THREADS
|
#if HAVE_THREADS
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include "libavutil/avutil.h"
|
#include "libavutil/avutil.h"
|
||||||
pthread_mutex_t *openssl_mutexes;
|
pthread_mutex_t *openssl_mutexes;
|
||||||
@ -56,7 +54,7 @@ static unsigned long openssl_thread_id(void)
|
|||||||
#endif
|
#endif
|
||||||
#if CONFIG_GNUTLS
|
#if CONFIG_GNUTLS
|
||||||
#include <gnutls/gnutls.h>
|
#include <gnutls/gnutls.h>
|
||||||
#if THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
|
#if HAVE_THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#undef malloc
|
#undef malloc
|
||||||
@ -72,7 +70,7 @@ void ff_tls_init(void)
|
|||||||
if (!openssl_init) {
|
if (!openssl_init) {
|
||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
#if THREADS
|
#if HAVE_THREADS
|
||||||
if (!CRYPTO_get_locking_callback()) {
|
if (!CRYPTO_get_locking_callback()) {
|
||||||
int i;
|
int i;
|
||||||
openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
|
openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
|
||||||
@ -88,7 +86,7 @@ void ff_tls_init(void)
|
|||||||
openssl_init++;
|
openssl_init++;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_GNUTLS
|
#if CONFIG_GNUTLS
|
||||||
#if THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
|
#if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
|
||||||
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
|
if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
|
||||||
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
|
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
|
||||||
#endif
|
#endif
|
||||||
@ -103,7 +101,7 @@ void ff_tls_deinit(void)
|
|||||||
#if CONFIG_OPENSSL
|
#if CONFIG_OPENSSL
|
||||||
openssl_init--;
|
openssl_init--;
|
||||||
if (!openssl_init) {
|
if (!openssl_init) {
|
||||||
#if THREADS
|
#if HAVE_THREADS
|
||||||
if (CRYPTO_get_locking_callback() == openssl_lock) {
|
if (CRYPTO_get_locking_callback() == openssl_lock) {
|
||||||
int i;
|
int i;
|
||||||
CRYPTO_set_locking_callback(NULL);
|
CRYPTO_set_locking_callback(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user