diff --git a/lib/ethash/builtins.h b/lib/ethash/builtins.h index 1d43ba99..e2571841 100644 --- a/lib/ethash/builtins.h +++ b/lib/ethash/builtins.h @@ -10,7 +10,7 @@ #pragma once -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #include #ifdef __cplusplus diff --git a/lib/ethash/endianness.hpp b/lib/ethash/endianness.hpp index cdb9750e..cb9ab39e 100644 --- a/lib/ethash/endianness.hpp +++ b/lib/ethash/endianness.hpp @@ -1,5 +1,5 @@ // ethash: C/C++ implementation of Ethash, the Ethereum Proof of Work algorithm. -// Copyright 2018-2019 Pawel Bylica. +// Copyright 2018 Pawel Bylica. // Licensed under the Apache License, Version 2.0. /// @file @@ -11,39 +11,31 @@ #pragma once +#include "../support/attributes.h" #include -#if _WIN32 - -#include - -#define bswap32 _byteswap_ulong -#define bswap64 _byteswap_uint64 - -// On Windows assume little endian. -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 -#define __BYTE_ORDER __LITTLE_ENDIAN - -#elif __APPLE__ - -#include - -#define bswap32 __builtin_bswap32 -#define bswap64 __builtin_bswap64 - +#ifndef __BYTE_ORDER__ +#if defined(_WIN32) // On Windows assume little endian. +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #else +#error "Unknown endianness" +#endif +#endif -#include - +#if __has_builtin(__builtin_bswap64) || defined(__GNUC__) #define bswap32 __builtin_bswap32 #define bswap64 __builtin_bswap64 - +#elif defined(_MSC_VER) +#include +#define bswap32 _byteswap_ulong +#define bswap64 _byteswap_uint64 #endif namespace ethash { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ struct le { @@ -61,7 +53,7 @@ struct be }; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ struct le { @@ -96,4 +88,4 @@ struct be }; #endif -} // namespace ethash \ No newline at end of file +} // namespace ethash