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.
Unified · Split
| @@ -22,9 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include "libavcodec/internal.h" | 22 | #include "libavcodec/internal.h" |
| 23 | #include "libavutil/mem.h" | 23 | #include "libavutil/mem.h" |
| 24 | 24 | ||
| 25 | #define THREADS (HAVE_PTHREADS || (defined(WIN32) && !defined(__MINGW32CE__))) | 25 | #if HAVE_THREADS |
| 26 | |||
| 27 | #if THREADS | ||
| 28 | #if HAVE_PTHREADS | 26 | #if HAVE_PTHREADS |
| 29 | #include <pthread.h> | 27 | #include <pthread.h> |
| 30 | #else | 28 | #else |
| @@ -35,7 +33,7 @@ · 4 unmodified lines | |||
| 35 | #if CONFIG_OPENSSL | 33 | #if CONFIG_OPENSSL |
| 36 | #include <openssl/ssl.h> | 34 | #include <openssl/ssl.h> |
| 37 | static int openssl_init; | 35 | static int openssl_init; |
| 38 | #if THREADS | 36 | #if HAVE_THREADS |
| 39 | #include <openssl/crypto.h> | 37 | #include <openssl/crypto.h> |
| 40 | #include "libavutil/avutil.h" | 38 | #include "libavutil/avutil.h" |
| 41 | pthread_mutex_t *openssl_mutexes; | 39 | pthread_mutex_t *openssl_mutexes; |
| @@ -56,7 +54,7 @@ static unsigned long openssl_thread_id(void) · 14 unmodified lines | |||
| 56 | #endif | 54 | #endif |
| 57 | #if CONFIG_GNUTLS | 55 | #if CONFIG_GNUTLS |
| 58 | #include <gnutls/gnutls.h> | 56 | #include <gnutls/gnutls.h> |
| 59 | #if THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00 | 57 | #if HAVE_THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00 |
| 60 | #include <gcrypt.h> | 58 | #include <gcrypt.h> |
| 61 | #include <errno.h> | 59 | #include <errno.h> |
| 62 | #undef malloc | 60 | #undef malloc |
| @@ -72,7 +70,7 @@ void ff_tls_init(void) · 9 unmodified lines | |||
| 72 | if (!openssl_init) { | 70 | if (!openssl_init) { |
| 73 | SSL_library_init(); | 71 | SSL_library_init(); |
| 74 | SSL_load_error_strings(); | 72 | SSL_load_error_strings(); |
| 75 | #if THREADS | 73 | #if HAVE_THREADS |
| 76 | if (!CRYPTO_get_locking_callback()) { | 74 | if (!CRYPTO_get_locking_callback()) { |
| 77 | int i; | 75 | int i; |
| 78 | openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks()); | 76 | openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks()); |
| @@ -88,7 +86,7 @@ void ff_tls_init(void) · 9 unmodified lines | |||
| 88 | openssl_init++; | 86 | openssl_init++; |
| 89 | #endif | 87 | #endif |
| 90 | #if CONFIG_GNUTLS | 88 | #if CONFIG_GNUTLS |
| 91 | #if THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 | 89 | #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 |
| 92 | if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) | 90 | if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) |
| 93 | gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); | 91 | gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); |
| 94 | #endif | 92 | #endif |
| @@ -103,7 +101,7 @@ void ff_tls_deinit(void) · 8 unmodified lines | |||
| 103 | #if CONFIG_OPENSSL | 101 | #if CONFIG_OPENSSL |
| 104 | openssl_init--; | 102 | openssl_init--; |
| 105 | if (!openssl_init) { | 103 | if (!openssl_init) { |
| 106 | #if THREADS | 104 | #if HAVE_THREADS |
| 107 | if (CRYPTO_get_locking_callback() == openssl_lock) { | 105 | if (CRYPTO_get_locking_callback() == openssl_lock) { |
| 108 | int i; | 106 | int i; |
| 109 | CRYPTO_set_locking_callback(NULL); | 107 | CRYPTO_set_locking_callback(NULL); |