From f0df86a1f62655528cd123e0d7867e3b9dc80c61 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 20 Apr 2015 11:32:12 -0400 Subject: [PATCH] Fix standalone build on Mac. CRYPTO_MUTEX was the wrong size. Fortunately, Apple was kind enough to define pthread_rwlock_t unconditionally, so we can be spared fighting with feature macros. Some of the stdlib.h removals were wrong and clang is pick about multiply-defined typedefs. Apparently that's a C11 thing? BUG=478598 Change-Id: Ibdcb8de9e5d83ca28e4c55b2979177d1ef0f9721 Reviewed-on: https://boringssl-review.googlesource.com/4404 Reviewed-by: Adam Langley --- crypto/ec/internal.h | 2 -- include/openssl/base.h | 4 +++- include/openssl/thread.h | 7 ++++--- tool/rand.cc | 1 + tool/transport_common.cc | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crypto/ec/internal.h b/crypto/ec/internal.h index 7c2335b6..0a8bf24a 100644 --- a/crypto/ec/internal.h +++ b/crypto/ec/internal.h @@ -81,8 +81,6 @@ extern "C" { /* Use default functions for poin2oct, oct2point and compressed coordinates */ #define EC_FLAGS_DEFAULT_OCT 0x1 -typedef struct ec_method_st EC_METHOD; - struct ec_method_st { /* Various method flags */ int flags; diff --git a/include/openssl/base.h b/include/openssl/base.h index 77549f78..796562b9 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -132,6 +132,9 @@ extern "C" { #endif /* defined(BORINGSSL_SHARED_LIBRARY) */ +/* CRYPTO_THREADID is a dummy value. */ +typedef int CRYPTO_THREADID; + typedef int ASN1_BOOLEAN; typedef int ASN1_NULL; typedef struct ASN1_ITEM_st ASN1_ITEM; @@ -176,7 +179,6 @@ typedef struct cbb_st CBB; typedef struct cbs_st CBS; typedef struct conf_st CONF; typedef struct conf_value_st CONF_VALUE; -typedef int CRYPTO_THREADID; typedef struct dh_method DH_METHOD; typedef struct dh_st DH; typedef struct dsa_method DSA_METHOD; diff --git a/include/openssl/thread.h b/include/openssl/thread.h index f9b9980d..31ce3b3a 100644 --- a/include/openssl/thread.h +++ b/include/openssl/thread.h @@ -57,6 +57,8 @@ #ifndef OPENSSL_HEADER_THREAD_H #define OPENSSL_HEADER_THREAD_H +#include + #include #if defined(__cplusplus) @@ -72,6 +74,8 @@ typedef union crypto_mutex_st { double alignment; uint8_t padding[4*sizeof(void*) + 2*sizeof(int)]; } CRYPTO_MUTEX; +#elif defined(__MACH__) && defined(__APPLE__) +typedef pthread_rwlock_t CRYPTO_MUTEX; #else /* It is reasonable to include pthread.h on non-Windows systems, however the * |pthread_rwlock_t| that we need is hidden under feature flags, and we can't @@ -133,9 +137,6 @@ OPENSSL_EXPORT const char *CRYPTO_get_lock_name(int lock_num); /* Deprecated functions */ -/* CRYPTO_THREADID is a dummy value. */ -typedef int CRYPTO_THREADID; - /* CRYPTO_THREADID_set_callback does nothing. */ OPENSSL_EXPORT int CRYPTO_THREADID_set_callback( void (*threadid_func)(CRYPTO_THREADID *threadid)); diff --git a/tool/rand.cc b/tool/rand.cc index ea97bfa4..10078e22 100644 --- a/tool/rand.cc +++ b/tool/rand.cc @@ -16,6 +16,7 @@ #include #include +#include #include diff --git a/tool/transport_common.cc b/tool/transport_common.cc index ac4dfe1f..3f5e631b 100644 --- a/tool/transport_common.cc +++ b/tool/transport_common.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include