changeset 2263:dfadb5effdc0

Merge bbaren's fix for bug 209.
author Ziv Scully <ziv@mit.edu>
date Tue, 13 Oct 2015 14:22:05 -0400
parents 34ad83d9b729 ce312cad5ecd
children bbcf9ba9b39a
files bin/.dir src/c/openssl.c
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Wed Oct 07 08:58:08 2015 -0400
+++ b/configure.ac	Tue Oct 13 14:22:05 2015 -0400
@@ -112,6 +112,22 @@
    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)
--- a/src/c/openssl.c	Wed Oct 07 08:58:08 2015 -0400
+++ b/src/c/openssl.c	Tue Oct 13 14:22:05 2015 -0400
@@ -34,9 +34,15 @@
 }
 
 // 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];