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 <agl@google.com>
diff --git a/crypto/ec/internal.h b/crypto/ec/internal.h
index 7c2335b..0a8bf24 100644
--- a/crypto/ec/internal.h
+++ b/crypto/ec/internal.h
@@ -81,8 +81,6 @@
/* 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 77549f7..796562b 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -132,6 +132,9 @@
#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 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 f9b9980..31ce3b3 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 <sys/types.h>
+
#include <openssl/base.h>
#if defined(__cplusplus)
@@ -72,6 +74,8 @@
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 @@
/* 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 ea97bfa..10078e2 100644
--- a/tool/rand.cc
+++ b/tool/rand.cc
@@ -16,6 +16,7 @@
#include <vector>
#include <stdint.h>
+#include <stdlib.h>
#include <openssl/rand.h>
diff --git a/tool/transport_common.cc b/tool/transport_common.cc
index ac4dfe1..3f5e631 100644
--- a/tool/transport_common.cc
+++ b/tool/transport_common.cc
@@ -19,6 +19,7 @@
#include <errno.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>