History

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.

Mans Rullgard committed 14 years ago

Commit 9efbfe51 parent 67a68dc1 file · +6 −8Browse files

Unified · Split

libavformat/network.c+6−8
@@ -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_PTHREADS26#if HAVE_PTHREADS
29#include <pthread.h>27#include <pthread.h>
30#else28#else
@@ -35,7 +33,7 @@ · 4 unmodified lines
35#if CONFIG_OPENSSL33#if CONFIG_OPENSSL
36#include <openssl/ssl.h>34#include <openssl/ssl.h>
37static int openssl_init;35static int openssl_init;
38#if THREADS36#if HAVE_THREADS
39#include <openssl/crypto.h>37#include <openssl/crypto.h>
40#include "libavutil/avutil.h"38#include "libavutil/avutil.h"
41pthread_mutex_t *openssl_mutexes;39pthread_mutex_t *openssl_mutexes;
@@ -56,7 +54,7 @@ static unsigned long openssl_thread_id(void) · 14 unmodified lines
56#endif54#endif
57#if CONFIG_GNUTLS55#if CONFIG_GNUTLS
58#include <gnutls/gnutls.h>56#include <gnutls/gnutls.h>
59#if THREADS && GNUTLS_VERSION_NUMBER <= 0x020b0057#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 malloc60#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 THREADS73#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#endif87#endif
90#if CONFIG_GNUTLS88#if CONFIG_GNUTLS
91#if THREADS && GNUTLS_VERSION_NUMBER < 0x020b0089#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#endif92#endif
@@ -103,7 +101,7 @@ void ff_tls_deinit(void) · 8 unmodified lines
103#if CONFIG_OPENSSL101#if CONFIG_OPENSSL
104 openssl_init--;102 openssl_init--;
105 if (!openssl_init) {103 if (!openssl_init) {
106#if THREADS104#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);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t