From b02ac28bcc4c78eed7e2c9b707b6c17e5de5dbc7 Mon Sep 17 00:00:00 2001 From: liukun Date: Thu, 10 May 2018 14:59:50 +0800 Subject: [PATCH] support macOS refs: https://gist.github.com/yinyin/2027912 https://github.com/nodejs/node-gyp/issues/17 --- binding.gyp | 9 ++++++++- crypto/common.h | 23 ++++++++++++++++++++++- crypto/equihash.cpp | 2 +- serialize.h | 3 ++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/binding.gyp b/binding.gyp index 5259d40..a3210ed 100644 --- a/binding.gyp +++ b/binding.gyp @@ -48,7 +48,14 @@ "-lsodium" ] }, + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' + } + }] + ] } - ] + ] } diff --git a/crypto/common.h b/crypto/common.h index 15d63a6..fedd0cf 100644 --- a/crypto/common.h +++ b/crypto/common.h @@ -9,7 +9,28 @@ #include #include "sodium.h" -#include + +#ifndef __APPLE__ + #include +#else + #include + #include + + #define htobe16(x) OSSwapHostToBigInt16(x) + #define htole16(x) OSSwapHostToLittleInt16(x) + #define be16toh(x) OSSwapBigToHostInt16(x) + #define le16toh(x) OSSwapLittleToHostInt16(x) + + #define htobe32(x) OSSwapHostToBigInt32(x) + #define htole32(x) OSSwapHostToLittleInt32(x) + #define be32toh(x) OSSwapBigToHostInt32(x) + #define le32toh(x) OSSwapLittleToHostInt32(x) + + #define htobe64(x) OSSwapHostToBigInt64(x) + #define htole64(x) OSSwapHostToLittleInt64(x) + #define be64toh(x) OSSwapBigToHostInt64(x) + #define le64toh(x) OSSwapLittleToHostInt64(x) +#endif #if defined(NDEBUG) # error "Zcash cannot be compiled without assertions." diff --git a/crypto/equihash.cpp b/crypto/equihash.cpp index b49e749..c108707 100644 --- a/crypto/equihash.cpp +++ b/crypto/equihash.cpp @@ -16,7 +16,7 @@ #include "config/bitcoin-config.h" #endif -#include +#include "crypto/common.h" #include "crypto/equihash.h" #include #include diff --git a/serialize.h b/serialize.h index d46780d..1402035 100644 --- a/serialize.h +++ b/serialize.h @@ -6,7 +6,6 @@ #ifndef BITCOIN_SERIALIZE_H #define BITCOIN_SERIALIZE_H -#include #include #include #include @@ -23,6 +22,8 @@ #include #include +#include "crypto/common.h" + class CScript; static const unsigned int MAX_SIZE = 0x02000000;