Mercurial > urweb
comparison src/c/openssl.c @ 2174:ce312cad5ecd
Use correct OpenSSL thread safety macros on OS X (closes #209)
Create an Autoconf test to determine if pthread_t is a pointer or scalar
type, and use the appropriate CRYPTO_THREADID_set macro based on the
result.
author | Benjamin Barenblat <bbaren at mit.edu> |
---|---|
date | Sun, 20 Sep 2015 17:46:07 -0400 |
parents | 8a01e8f21de9 |
children | dfadb5effdc0 |
comparison
equal
deleted
inserted
replaced
2173:010ce27228f1 | 2174:ce312cad5ecd |
---|---|
32 exit(1); | 32 exit(1); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 // OpenSSL callbacks | 36 // OpenSSL callbacks |
37 #ifdef PTHREAD_T_IS_POINTER | |
38 # define CRYPTO_THREADID_SET CRYPTO_THREADID_set_pointer | |
39 #else | |
40 # define CRYPTO_THREADID_SET CRYPTO_THREADID_set_numeric | |
41 #endif | |
37 static void thread_id(CRYPTO_THREADID *const result) { | 42 static void thread_id(CRYPTO_THREADID *const result) { |
38 CRYPTO_THREADID_set_numeric(result, pthread_self()); | 43 CRYPTO_THREADID_SET(result, pthread_self()); |
39 } | 44 } |
45 #undef CRYPTO_THREADID_SET | |
40 static void lock_or_unlock(const int mode, const int type, const char *file, | 46 static void lock_or_unlock(const int mode, const int type, const char *file, |
41 const int line) { | 47 const int line) { |
42 pthread_mutex_t *const lock = &openssl_locks[type]; | 48 pthread_mutex_t *const lock = &openssl_locks[type]; |
43 if (mode & CRYPTO_LOCK) { | 49 if (mode & CRYPTO_LOCK) { |
44 if (pthread_mutex_lock(lock)) { | 50 if (pthread_mutex_lock(lock)) { |