diff --git a/CMakeLists.txt b/CMakeLists.txt index 7625da2378af08e706ed771ad041ded417a3e630..a5a304ef07ce40e349071ebdf0df1d475b2589ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ project(cellframe-sdk C) cmake_minimum_required(VERSION 2.8) set(CMAKE_C_STANDARD 11) -set(CELLFRAME_SDK_NATIVE_VERSION "2.3-1") +set(CELLFRAME_SDK_NATIVE_VERSION "2.3-3") add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"") set(DAPSDK_MODULES "") diff --git a/dap-sdk/core/include/dap_math_ops.h b/dap-sdk/core/include/dap_math_ops.h index 5a8e8feeb3f7ad97788c53f93856b25b24b82fc4..d67bad88e18d48a11ebf3fb6d4abde20f41aa39d 100755 --- a/dap-sdk/core/include/dap_math_ops.h +++ b/dap-sdk/core/include/dap_math_ops.h @@ -1,5 +1,7 @@ #pragma once #include <stdint.h> + +#include "dap_common.h" //#include "common/int-util.h" #if defined(__GNUC__) ||defined (__clang__) @@ -12,12 +14,20 @@ typedef __int128 _dap_int128_t; #if !defined (int128_t) typedef __int128 int128_t; #endif + #if !defined (uint128_t) typedef unsigned __int128 uint128_t; -#else -typedef unsigned uint64_t[2] uint128_t; #endif + +#endif + +#if __SIZEOF_INT128__ != 16 +typedef union uint128{uint64_t u64[2];} uint128_t; +typedef union int128{int64_t i64[2];} int128_t; + #endif + + #endif typedef union dap_uint128{ diff --git a/dap-sdk/core/libdap.pri b/dap-sdk/core/libdap.pri index bf87862a3cb15373b69076707321308244cfb4ac..8aa16a0fa378fd051b81bab4910222834880748f 100755 --- a/dap-sdk/core/libdap.pri +++ b/dap-sdk/core/libdap.pri @@ -1,5 +1,5 @@ -QMAKE_CFLAGS_DEBUG = -std=gnu11 -QMAKE_CFLAGS_RELEASE = -std=gnu11 +QMAKE_CFLAGS_DEBUG = -std=gnu11 -fforce-enable-int128 +QMAKE_CFLAGS_RELEASE = -std=gnu11 -fforce-enable-int128 unix { include(src/unix/unix.pri) DEFINES += DAP_OS_UNIX diff --git a/modules/common/include/dap_chain_common.h b/modules/common/include/dap_chain_common.h index 059855fbfe05c49a30250ed7f15b33a67a5a1421..c2b2d7651ce46a6428a936e82765a974ba73c448 100644 --- a/modules/common/include/dap_chain_common.h +++ b/modules/common/include/dap_chain_common.h @@ -210,11 +210,21 @@ void dap_chain_addr_fill(dap_chain_addr_t *a_addr, dap_enc_key_t *a_key, dap_cha int dap_chain_addr_check_sum(const dap_chain_addr_t *a_addr); static inline long double dap_chain_balance_to_coins( uint128_t a_balance){ - return (long double) a_balance / DATOSHI_LD; +#ifdef DAP_GLOBAL_IS_INT128 + return (long double) a_balance / DATOSHI_LD; +#else + return (long double) (a_balance.u64[0] / DATOSHI_LD); +#endif } static inline uint128_t dap_chain_coins_to_balance( long double a_balance){ +#ifdef DAP_GLOBAL_IS_INT128 return (uint128_t)( a_balance * DATOSHI_LD) ; +#else + uint128_t l_ret={0}; + l_ret.u64[0]=a_balance *DATOSHI_LD; + return l_ret; +#endif } /**