From 9efbfe57e082b0f42bf0c830a4fdc6b80d2b13ca Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 26 Oct 2012 19:33:59 +0100 Subject: [PATCH] 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 --- libavformat/network.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libavformat/network.c b/libavformat/network.c index 5b2b958c83..fe17bdf2eb 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -22,9 +22,7 @@ #include "libavcodec/internal.h" #include "libavutil/mem.h" -#define THREADS (HAVE_PTHREADS || (defined(WIN32) && !defined(__MINGW32CE__))) - -#if THREADS +#if HAVE_THREADS #if HAVE_PTHREADS #include #else @@ -35,7 +33,7 @@ #if CONFIG_OPENSSL #include static int openssl_init; -#if THREADS +#if HAVE_THREADS #include #include "libavutil/avutil.h" pthread_mutex_t *openssl_mutexes; @@ -56,7 +54,7 @@ static unsigned long openssl_thread_id(void) #endif #if CONFIG_GNUTLS #include -#if THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00 +#if HAVE_THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00 #include #include #undef malloc @@ -72,7 +70,7 @@ void ff_tls_init(void) if (!openssl_init) { SSL_library_init(); SSL_load_error_strings(); -#if THREADS +#if HAVE_THREADS if (!CRYPTO_get_locking_callback()) { int i; openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks()); @@ -88,7 +86,7 @@ void ff_tls_init(void) openssl_init++; #endif #if CONFIG_GNUTLS -#if THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 +#if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif @@ -103,7 +101,7 @@ void ff_tls_deinit(void) #if CONFIG_OPENSSL openssl_init--; if (!openssl_init) { -#if THREADS +#if HAVE_THREADS if (CRYPTO_get_locking_callback() == openssl_lock) { int i; CRYPTO_set_locking_callback(NULL);