[Ur] [PATCH] Use correct OpenSSL thread safety macros on OS X (closes #209)
Benjamin Barenblat
bbaren at mit.edu
Mon Sep 28 11:09:55 EDT 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
My mail client decided to send that as multipart/mixed, and it doesn’t
show up properly on Mailman. Let’s try that again.
On Monday, 28 September 2015, at 11.03 am EDT, Benjamin Barenblat wrote:
> Hi all,
>
> Please find enclosed a patch for issue #209 (‘Fix for bug 206 causes
> error when compiling Ur/Web’). OS X users, can you confirm that this
> causes builds to pass?
>
> For auditability, the patch’s SHA256 is
> a6728bfec6abd4d75b337db9e5fac89413252da0c45b834872d0e47c6a72bc28.
>
> Thanks in advance,
> Benjamin
-----BEGIN PGP SIGNATURE-----
iQF8BAEBCgBmBQJWCVgxXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ5OThCQjVEMTlDOEE3QjE3OUUwREFCODY5
RTczMDE0OUVCOTFDNTNCAAoJEJ5zAUnrkcU7TyEH/2bcBnVd50ByyseNq9p26yVD
UBn49tmJIlZLwOEPosl0FgiQX+MqgGL0hSUpZKQADiT5b4e9K4gzWPJOz0zDbIY2
83y+E9xWYEkC96kwMtswghwmP+jzZxB2uS1DeaDNbmj2Ig1zpYKENPs6Q2uO5/nZ
vcho8HnhRR8vZo0EHyg5Lh5A8eXY0XeENuISSTjaVMy6nabYppNaVMcfzZoGqM67
wdDIyGLmnGKC0DeoA6fJpZNOoUlRMu8596EMXQlL05qXJ5oHuIFhnIi5xK4M3oMN
U1kqiBTOUN/rWFpN4irpYdAv7iMsh+nP8v92WlPwC+CqOUQHx0n3Usa8bR9pT2c=
=it1/
-----END PGP SIGNATURE-----
---8<-----------------cut here----------------start--------------->8----
# HG changeset patch
# User Benjamin Barenblat <bbaren at mit.edu>
# Date 1442785567 14400
# Sun Sep 20 17:46:07 2015 -0400
# Node ID 795e661559adaa6c7fb3765d79ed73fe74d140de
# Parent 010ce27228f1894d2adc7672d11b39131ab91f47
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.
diff -r 010ce27228f1 -r 795e661559ad configure.ac
--- a/configure.ac Thu Aug 27 16:28:45 2015 -0400
+++ b/configure.ac Sun Sep 20 17:46:07 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)
diff -r 010ce27228f1 -r 795e661559ad src/c/openssl.c
--- a/src/c/openssl.c Thu Aug 27 16:28:45 2015 -0400
+++ b/src/c/openssl.c Sun Sep 20 17:46:07 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, 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];
---8<-----------------cut here----------------end----------------->8----
More information about the Ur
mailing list