FC Updates from BitShares and myself #21
9 changed files with 55 additions and 23 deletions
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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<typename T>
|
||||
void to_variant( const safe<T>& s, variant& v, uint32_t max_depth ) {
|
||||
to_variant( s.value, v, max_depth );
|
||||
to_variant( static_cast<T>(s.value), v, max_depth );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
# include <malloc.h>
|
||||
#else
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
|
||||
/* stuff common to all ecc implementations */
|
||||
|
|
@ -231,12 +229,11 @@ namespace fc { namespace ecc {
|
|||
|
||||
static std::string _to_base58( const extended_key_data& key )
|
||||
{
|
||||
size_t buf_len = key.size() + 4;
|
||||
char *buffer = (char*)alloca(buf_len);
|
||||
char buffer[key.size() + 4]; // it's a small static array => allocate on stack
|
||||
memcpy( buffer, key.data(), key.size() );
|
||||
fc::sha256 double_hash = fc::sha256::hash( fc::sha256::hash( (char*) key.data(), key.size() ));
|
||||
fc::sha256 double_hash = fc::sha256::hash( fc::sha256::hash( (char*)key.data(), key.size() ));
|
||||
memcpy( buffer + key.size(), double_hash.data(), 4 );
|
||||
return fc::to_base58( buffer, buf_len );
|
||||
return fc::to_base58( buffer, sizeof(buffer) );
|
||||
}
|
||||
|
||||
static void _parse_extended_data( unsigned char* buffer, std::string base58 )
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#if _WIN32
|
||||
# include <malloc.h>
|
||||
#else
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
|
||||
#include "_elliptic_impl_priv.hpp"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@ namespace fc
|
|||
|
||||
~openssl_scope()
|
||||
{
|
||||
#if not defined(LIBRESSL_VERSION_NUMBER)
|
||||
// No FIPS in LibreSSL.
|
||||
// https://marc.info/?l=openbsd-misc&m=139819485423701&w=2
|
||||
FIPS_mode_set(0);
|
||||
#endif
|
||||
CONF_modules_unload(1);
|
||||
EVP_cleanup();
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@
|
|||
# include <mstcpip.h>
|
||||
#endif
|
||||
|
||||
#if defined __OpenBSD__
|
||||
# include <sys/types.h>
|
||||
# include <sys/sysctl.h>
|
||||
# include <netinet/tcp_timer.h>
|
||||
# include <netinet/tcp_var.h>
|
||||
#endif
|
||||
|
||||
namespace fc {
|
||||
|
||||
namespace detail
|
||||
|
|
@ -186,16 +193,37 @@ namespace fc {
|
|||
if (setsockopt(my->_sock.native_handle(), IPPROTO_TCP,
|
||||
#if defined( __APPLE__ )
|
||||
TCP_KEEPALIVE,
|
||||
#elif defined( __OpenBSD__ )
|
||||
SO_KEEPALIVE,
|
||||
#else
|
||||
TCP_KEEPIDLE,
|
||||
#endif
|
||||
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
|
||||
wlog("Error setting TCP keepalive idle time");
|
||||
# if !defined(__APPLE__) || defined(TCP_KEEPINTVL) // TCP_KEEPINTVL not defined before 10.9
|
||||
# if defined(__OpenBSD__)
|
||||
int name[4];
|
||||
name[0] = CTL_NET;
|
||||
name[1] = PF_INET;
|
||||
name[2] = IPPROTO_TCP;
|
||||
|
||||
int value;
|
||||
size_t sz;
|
||||
|
||||
// get tics per second
|
||||
name[3] = TCPCTL_SLOWHZ;
|
||||
if (sysctl(name, 4, &value, &sz, NULL, 0) == -1)
|
||||
wlog("Error setting TCP keepalive interval");
|
||||
|
||||
// set interval
|
||||
value *= timeout_sec;
|
||||
name[3] = TCPCTL_KEEPINTVL;
|
||||
if (sysctl(name, 4, NULL, NULL, &value, sizeof(value)) == -1)
|
||||
wlog("Error setting TCP keepalive interval");
|
||||
# elif !defined(__APPLE__) || defined(TCP_KEEPINTVL) // TCP_KEEPINTVL not defined before 10.9
|
||||
if (setsockopt(my->_sock.native_handle(), IPPROTO_TCP, TCP_KEEPINTVL,
|
||||
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
|
||||
wlog("Error setting TCP keepalive interval");
|
||||
# endif // !__APPLE__ || TCP_KEEPINTVL
|
||||
# endif // (__OpenBSD__) or (!__APPLE__ || TCP_KEEPINTVL)
|
||||
#endif // !WIN32
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
#if BOOST_VERSION / 100 >= 1065 && !defined(__APPLE__)
|
||||
#include <signal.h>
|
||||
#include <fc/log/logger.hpp>
|
||||
#if defined(__OpenBSD__)
|
||||
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
|
||||
#endif
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
namespace fc
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <fc/reflect/variant.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) or defined(__OpenBSD__)
|
||||
#include <boost/multiprecision/integer.hpp>
|
||||
#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<uint64_t*>(this) = val;
|
||||
|
|
@ -679,7 +679,7 @@ void from_variant( const variant& var, std::vector<char>& 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<boost::multiprecision::uint128_t>( var.as_string() );
|
||||
vo = static_cast<uint64_t>( 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)); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue