summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ziv Scully <ziv@mit.edu>2015-10-13 14:22:05 -0400
committerGravatar Ziv Scully <ziv@mit.edu>2015-10-13 14:22:05 -0400
commitc25f458b3e1721027b76b0cf46593becfd6f2d5f (patch)
tree23cee56697878194298b1c5fcaa36da2fb1ed2f2
parent013ea39e9f187efbb0e3a613264a1c7adfebe692 (diff)
parent438e05e7ea9949b7ee61e40a2a6bc7e1c1d4b8f3 (diff)
Merge bbaren's fix for bug 209.
-rw-r--r--bin/.dir0
-rw-r--r--configure.ac16
-rw-r--r--src/c/openssl.c8
3 files changed, 23 insertions, 1 deletions
diff --git a/bin/.dir b/bin/.dir
deleted file mode 100644
index e69de29b..00000000
--- a/bin/.dir
+++ /dev/null
diff --git a/configure.ac b/configure.ac
index a6f8ac43..f074ccbf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,6 +112,22 @@ if test [$CLANG = "yes"]; then
PTHREAD_LIBS=""
fi
+# Check if pthread_t is a scalar or pointer type so we can use the correct
+# OpenSSL functions on it.
+AC_MSG_CHECKING([if pthread_t is a pointer type])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+#include <pthread.h>
+ ]],
+ [[
+pthread_t a;
+*a;
+ ]])],
+ AC_DEFINE([PTHREAD_T_IS_POINTER], [1], [Define if pthread_t is a pointer.])
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+
AC_SUBST(CC)
AC_SUBST(BIN)
AC_SUBST(LIB)
diff --git a/src/c/openssl.c b/src/c/openssl.c
index 533c3e21..981d48da 100644
--- a/src/c/openssl.c
+++ b/src/c/openssl.c
@@ -34,9 +34,15 @@ static void random_password() {
}
// OpenSSL callbacks
+#ifdef PTHREAD_T_IS_POINTER
+# define CRYPTO_THREADID_SET CRYPTO_THREADID_set_pointer
+#else
+# define CRYPTO_THREADID_SET CRYPTO_THREADID_set_numeric
+#endif
static void thread_id(CRYPTO_THREADID *const result) {
- CRYPTO_THREADID_set_numeric(result, (unsigned long)pthread_self());
+ CRYPTO_THREADID_SET(result, pthread_self());
}
+#undef CRYPTO_THREADID_SET
static void lock_or_unlock(const int mode, const int type, const char *file,
const int line) {
pthread_mutex_t *const lock = &openssl_locks[type];