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