From 6c810e7f9ce21a8a518aa5ce71372bb96c2efada Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 5 Oct 2015 21:43:49 +0530 Subject: Set threadid_func on linux/osx (fixes #281) --- openssl-sys/src/openssl_shim.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'openssl-sys/src/openssl_shim.c') diff --git a/openssl-sys/src/openssl_shim.c b/openssl-sys/src/openssl_shim.c index 7fabe06e..abfa3918 100644 --- a/openssl-sys/src/openssl_shim.c +++ b/openssl-sys/src/openssl_shim.c @@ -3,6 +3,33 @@ #include #include +#if defined(__APPLE__) || defined(__linux) + +#include +#include + +unsigned long thread_id() +{ + unsigned long ret = (unsigned long)pthread_self(); + return ret; +} + +void rust_openssl_set_id_callback() { + CRYPTO_set_id_callback((unsigned long (*)())thread_id); +} + +#else +// Openssl already handles Windows directly, so we don't +// need to explicitly set it + +void rust_openssl_set_id_callback() { + // We don't know how to set the callback for arbitrary OSes + // Let openssl use its defaults and hope they work. +} + +#endif + + #if OPENSSL_VERSION_NUMBER < 0x1000000L // Copied from openssl crypto/hmac/hmac.c int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx) -- cgit v1.2.3