diff options
author | Adam Langley <agl@chromium.org> | 2014-07-11 04:07:14 +0400 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-07-11 23:04:04 +0400 |
commit | 0113a4fb60c3b6e9e93a217d5b4d373eb343a8c6 (patch) | |
tree | 249fa04520e982bfe7c62b9342070a366288e2cc | |
parent | 925fee36e1f6dcad56e60fccca5fa069e09979f7 (diff) |
Support building with PNaCl.
PNaCl needs OPENSSL_NO_ASM to work and a couple of cases were missing
because it hasn't previously been tested.
Additionally, it defined _BSD_SOURCE and others on the command line,
causing duplicate definition errors when defined in source code.
It's missing readdir_r.
It uses newlib, which appears to use u_short in socket.h without ever
defining it.
Change-Id: Ieccfc7365723d0521f6327eebe9f44a2afc57406
Reviewed-on: https://boringssl-review.googlesource.com/1140
Reviewed-by: Adam Langley <agl@google.com>
-rw-r--r-- | crypto/base.h | 4 | ||||
-rw-r--r-- | crypto/bio/internal.h | 5 | ||||
-rw-r--r-- | crypto/bio/printf.c | 2 | ||||
-rw-r--r-- | crypto/bn/mul.c | 2 | ||||
-rw-r--r-- | crypto/bn/rsaz_exp.c | 2 | ||||
-rw-r--r-- | crypto/chacha/chacha_generic.c | 4 | ||||
-rw-r--r-- | crypto/chacha/chacha_vec.c | 4 | ||||
-rw-r--r-- | crypto/directory_posix.c | 17 | ||||
-rw-r--r-- | crypto/mem.c | 2 | ||||
-rw-r--r-- | crypto/mem_clear.c | 2 | ||||
-rw-r--r-- | crypto/rand/urandom.c | 2 | ||||
-rw-r--r-- | crypto/time_support.c | 2 |
12 files changed, 39 insertions, 9 deletions
diff --git a/crypto/base.h b/crypto/base.h index 632d5512..be9973f1 100644 --- a/crypto/base.h +++ b/crypto/base.h @@ -58,7 +58,6 @@ #include <string.h> #include <sys/types.h> - #if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) #define OPENSSL_64_BIT #define OPENSSL_X86_64 @@ -74,6 +73,9 @@ #elif defined(__mips__) #define OPENSSL_32_BIT #define OPENSSL_MIPS +#elif defined(__pnacl__) +#define OPENSSL_32_BIT +#define OPENSSL_PNACL #else #error "Unknown target CPU" #endif diff --git a/crypto/bio/internal.h b/crypto/bio/internal.h index d4987084..2eb28754 100644 --- a/crypto/bio/internal.h +++ b/crypto/bio/internal.h @@ -60,6 +60,11 @@ #include <openssl/base.h> #if !defined(OPENSSL_WINDOWS) +#if defined(OPENSSL_PNACL) +/* newlib uses u_short in socket.h without defining it. */ +typedef unsigned short u_short; +#endif +#include <sys/types.h> #include <sys/socket.h> #else #include <WinSock2.h> diff --git a/crypto/bio/printf.c b/crypto/bio/printf.c index e513ff3a..7f7106f4 100644 --- a/crypto/bio/printf.c +++ b/crypto/bio/printf.c @@ -54,7 +54,9 @@ * copied and put under another distribution licence * [including the GNU Public Licence.] */ +#if !defined(_BSD_SOURCE) #define _BSD_SOURCE /* for snprintf, vprintf etc */ +#endif #include <openssl/bio.h> diff --git a/crypto/bn/mul.c b/crypto/bn/mul.c index af26eba7..8c74e2f0 100644 --- a/crypto/bn/mul.c +++ b/crypto/bn/mul.c @@ -131,7 +131,7 @@ void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { } } -#if !defined(OPENSSL_X86) +#if !defined(OPENSSL_X86) || defined(OPENSSL_NO_ASM) /* Here follows specialised variants of bn_add_words() and bn_sub_words(). They * have the property performing operations on arrays of different sizes. The * sizes of those arrays is expressed through cl, which is the common length ( diff --git a/crypto/bn/rsaz_exp.c b/crypto/bn/rsaz_exp.c index 10376870..c8027520 100644 --- a/crypto/bn/rsaz_exp.c +++ b/crypto/bn/rsaz_exp.c @@ -42,7 +42,7 @@ #include <openssl/base.h> -#if defined(OPENSSL_X86_64) +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) #include "rsaz_exp.h" diff --git a/crypto/chacha/chacha_generic.c b/crypto/chacha/chacha_generic.c index b5daed29..40a6f20e 100644 --- a/crypto/chacha/chacha_generic.c +++ b/crypto/chacha/chacha_generic.c @@ -18,7 +18,7 @@ #include <openssl/cpu.h> -#if defined(OPENSSL_WINDOWS) || !defined(OPENSSL_X86_64) && !defined(OPENSSL_X86) +#if defined(OPENSSL_WINDOWS) || (!defined(OPENSSL_X86_64) && !defined(OPENSSL_X86)) || !defined(__SSE2__) /* sigma contains the ChaCha constants, which happen to be an ASCII string. */ static const char sigma[16] = "expand 32-byte k"; @@ -137,4 +137,4 @@ void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len, } } -#endif /* OPENSSL_WINDOWS || !OPENSSL_X86_64 && !OPENSSL_X86 && !OPENSSL_ARM */ +#endif /* OPENSSL_WINDOWS || !OPENSSL_X86_64 && !OPENSSL_X86 || !__SSE2__ */ diff --git a/crypto/chacha/chacha_vec.c b/crypto/chacha/chacha_vec.c index d06d1dd5..90629a4f 100644 --- a/crypto/chacha/chacha_vec.c +++ b/crypto/chacha/chacha_vec.c @@ -25,7 +25,7 @@ #include <openssl/chacha.h> -#if !defined(OPENSSL_WINDOWS) && (defined(OPENSSL_X86_64) || defined(OPENSSL_X86)) +#if !defined(OPENSSL_WINDOWS) && (defined(OPENSSL_X86_64) || defined(OPENSSL_X86)) && defined(__SSE2__) #define CHACHA_RNDS 20 /* 8 (high speed), 20 (conservative), 12 (middle) */ @@ -326,4 +326,4 @@ void CRYPTO_chacha_20( } } -#endif /* !OPENSSL_WINDOWS && (OPENSSL_X86_64 || OPENSSL_X86) */ +#endif /* !OPENSSL_WINDOWS && (OPENSSL_X86_64 || OPENSSL_X86) && SSE2 */ diff --git a/crypto/directory_posix.c b/crypto/directory_posix.c index 990f663f..6f0acc51 100644 --- a/crypto/directory_posix.c +++ b/crypto/directory_posix.c @@ -24,7 +24,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if !defined(_POSIX_C_SOURCE) #define _POSIX_C_SOURCE 1 /* for readdir_r */ +#endif #include "directory.h" @@ -34,6 +36,21 @@ #include <dirent.h> #include <errno.h> +#if defined(OPENSSL_PNACL) +/* pnacl doesn't include readdir_r! So we do the best we can. */ +int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { + errno = 0; + *result = readdir(dirp); + if (*result != NULL) { + return 0; + } + if (errno) { + return 1; + } + return 0; +} +#endif + struct OPENSSL_dir_context_st { DIR *dir; struct dirent dirent; diff --git a/crypto/mem.c b/crypto/mem.c index 9cf0aa00..a5f639bb 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -53,7 +53,9 @@ * copied and put under another distribution licence * [including the GNU Public Licence.] */ +#if !defined(_BSD_SOURCE) #define _BSD_SOURCE /* needed for strdup, snprintf, vprintf etc */ +#endif #include <openssl/mem.h> diff --git a/crypto/mem_clear.c b/crypto/mem_clear.c index c13ecd88..2c46ffee 100644 --- a/crypto/mem_clear.c +++ b/crypto/mem_clear.c @@ -58,7 +58,7 @@ #include <string.h> -#if !defined(OPENSSL_X86) +#if !defined(OPENSSL_X86) || defined(OPENSSL_NO_ASM) /* OPENSSL_cleanse is given its own compilation unit in the hopes that the * compiler won't be able to optimise it away. */ diff --git a/crypto/rand/urandom.c b/crypto/rand/urandom.c index 44fe1d65..6cd92719 100644 --- a/crypto/rand/urandom.c +++ b/crypto/rand/urandom.c @@ -91,7 +91,7 @@ static int urandom_get_fd_locked() { if (urandom_fd != -2) return urandom_fd; - urandom_fd = open("/dev/urandom", O_RDONLY | O_NOCTTY); + urandom_fd = open("/dev/urandom", O_RDONLY); return urandom_fd; } diff --git a/crypto/time_support.c b/crypto/time_support.c index 5c6e9c04..f845e983 100644 --- a/crypto/time_support.c +++ b/crypto/time_support.c @@ -55,7 +55,9 @@ * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). */ +#if !defined(_BSD_SOURCE) #define _BSD_SOURCE /* for gmtime_r */ +#endif #include <openssl/time_support.h> |