From a1c2ff99434977a6a66d3e11089a3613f6973893 Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Tue, 13 Aug 2019 17:31:22 +0200 Subject: [PATCH] support openbsd // make code compliant with clang --- CMakeLists.txt | 8 ++++---- include/fc/string.hpp | 2 +- include/fc/variant.hpp | 6 +++--- src/stacktrace.cpp | 3 +++ src/variant.cpp | 12 +++++++----- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bad2407..e391325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,11 +141,11 @@ ENDIF(WIN32) FIND_PACKAGE(Boost CONFIG COMPONENTS ${BOOST_COMPONENTS}) IF(NOT WIN32) - MESSAGE(STATUS "Configuring fc to build on Unix/Apple") + MESSAGE(STATUS "Configuring fc to build on Unix/Apple") - if(NOT APPLE) - SET(rt_library rt) - endif(NOT APPLE) + IF(NOT APPLE AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") + SET(rt_library rt ) + ENDIF(NOT APPLE AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") ENDIF(NOT WIN32) IF($ENV{OPENSSL_ROOT_DIR}) diff --git a/include/fc/string.hpp b/include/fc/string.hpp index 7fbe2e5..8f269f0 100644 --- a/include/fc/string.hpp +++ b/include/fc/string.hpp @@ -17,7 +17,7 @@ namespace fc std::string to_pretty_string( int64_t ); inline std::string to_string( int32_t v ) { return to_string( int64_t(v) ); } inline std::string to_string( uint32_t v ){ return to_string( uint64_t(v) ); } -#ifdef __APPLE__ +#if defined(__APPLE__) or defined(__OpenBSD__) inline std::string to_string( size_t s) { return to_string(uint64_t(s)); } #endif diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index f7ef613..66c422e 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -153,7 +153,7 @@ namespace fc void to_variant( const uint128_t& var, variant& vo, uint32_t max_depth = 1 ); void from_variant( const variant& var, uint128_t& vo, uint32_t max_depth = 1 ); - #ifdef __APPLE__ + #if defined(__APPLE__) or defined(__OpenBSD__) void to_variant( size_t s, variant& v, uint32_t max_depth = 1 ); #elif !defined(_WIN32) void to_variant( long long int s, variant& v, uint32_t max_depth = 1 ); @@ -229,7 +229,7 @@ namespace fc variant( uint32_t val, uint32_t max_depth = 1 ); variant( int32_t val, uint32_t max_depth = 1 ); variant( uint64_t val, uint32_t max_depth = 1 ); -#ifdef __APPLE__ +#if defined(__APPLE__) or defined(__OpenBSD__) variant( size_t val, uint32_t max_depth = 1 ); #endif variant( int64_t val, uint32_t max_depth = 1 ); @@ -632,7 +632,7 @@ namespace fc template void to_variant( const safe& s, variant& v, uint32_t max_depth ) { - to_variant( s.value, v, max_depth ); + to_variant( static_cast(s.value), v, max_depth ); } template diff --git a/src/stacktrace.cpp b/src/stacktrace.cpp index 126691f..910b48f 100644 --- a/src/stacktrace.cpp +++ b/src/stacktrace.cpp @@ -8,6 +8,9 @@ #if BOOST_VERSION / 100 >= 1065 && !defined(__APPLE__) #include #include +#if defined(__OpenBSD__) + #define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED +#endif #include namespace fc diff --git a/src/variant.cpp b/src/variant.cpp index 7a527e9..eaa12d3 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -11,7 +11,7 @@ #include #include -#ifdef __APPLE__ +#if defined(__APPLE__) or defined(__OpenBSD__) #include #endif @@ -79,7 +79,7 @@ variant::variant( uint64_t val, uint32_t max_depth ) set_variant_type( this, uint64_type ); } -#ifdef __APPLE__ +#if defined(__APPLE__) or defined(__OpenBSD__) variant::variant( size_t val, uint32_t max_depth ) { *reinterpret_cast(this) = val; @@ -679,7 +679,7 @@ void from_variant( const variant& var, std::vector& vo, uint32_t max_depth void to_variant( const uint128_t& var, variant& vo, uint32_t max_depth ) { -#ifdef __APPLE__ +#if defined(__APPLE__) or defined(__OpenBSD__) boost::multiprecision::uint128_t helper = uint128_hi64( var ); helper <<= 64; helper += uint128_lo64( var ); @@ -691,7 +691,7 @@ void to_variant( const uint128_t& var, variant& vo, uint32_t max_depth ) void from_variant( const variant& var, uint128_t& vo, uint32_t max_depth ) { -#ifdef __APPLE__ +#if defined(__APPLE__) or defined(__OpenBSD__) boost::multiprecision::uint128_t helper = boost::lexical_cast( var.as_string() ); vo = static_cast( helper >> 64 ); vo <<= 64; @@ -701,7 +701,9 @@ void from_variant( const variant& var, uint128_t& vo, uint32_t max_depth ) #endif } -#ifdef __APPLE__ +#if defined(__APPLE__) +#elif defined(__OpenBSD__) + void to_variant( size_t s, variant& v, uint32_t max_depth ) { v = variant( int64_t(s) ); } #elif !defined(_WIN32) void to_variant( long long int s, variant& v, uint32_t max_depth ) { v = variant( int64_t(s) ); } void to_variant( unsigned long long int s, variant& v, uint32_t max_depth ) { v = variant( uint64_t(s)); }