From bf0442120ab2cd11920cbee5bec5ceb244a9b420 Mon Sep 17 00:00:00 2001
From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net>
Date: Thu, 14 Jan 2021 17:02:16 +0700
Subject: [PATCH] [*] Fixes for platforms without native 128bit integer

---
 CMakeLists.txt                            | 2 +-
 dap-sdk/crypto/src/dap_uuid.c             | 3 +--
 modules/common/dap_chain_common.c         | 8 ++++----
 modules/common/include/dap_chain_common.h | 6 +++---
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecc576ac07..91754f5a56 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.6-110")
+set(CELLFRAME_SDK_NATIVE_VERSION "2.6-111")
 add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"")
 set(DAPSDK_MODULES "")
 
diff --git a/dap-sdk/crypto/src/dap_uuid.c b/dap-sdk/crypto/src/dap_uuid.c
index 4299f0a1b0..c96ff4164c 100644
--- a/dap-sdk/crypto/src/dap_uuid.c
+++ b/dap-sdk/crypto/src/dap_uuid.c
@@ -45,8 +45,7 @@ uint128_t dap_uuid_generate_uint128()
         [2]=s_global_counter++,
         [3]=random_uint32_t(UINT32_MAX)
     };
-    uint128_t l_output=0;
-    memcpy(&l_output,&l_input,sizeof (l_output));
+    uint128_t l_output;
     SHAKE128((unsigned char *) &l_output,sizeof (l_output), (unsigned char*) &l_input,sizeof (l_input));
     uint64_t *l_output_u64 =(uint64_t*) &l_output;
     log_it(L_DEBUG,"UUID generated 0x%016X%016X ",l_output_u64[0],l_output_u64[1] );
diff --git a/modules/common/dap_chain_common.c b/modules/common/dap_chain_common.c
index d6590dedcd..e25d84909b 100644
--- a/modules/common/dap_chain_common.c
+++ b/modules/common/dap_chain_common.c
@@ -427,18 +427,18 @@ uint128_t dap_chain_balance_scan(char *a_balance)
         uint128_t l_tmp;
         l_tmp.u64[0] = 0;
         l_tmp.u64[1] = c_pow10[i].u32[2] * l_digit;
-        l_ret = dap_chain_balance_add(l_ret, l_tmp);
+        l_ret = dap_uint128_add(l_ret, l_tmp);
         if (l_ret.u64[0] == 0 && l_ret.u64[1] == 0)
             return l_nul;
         uint64_t l_mul = c_pow10[i].u32[3] * l_digit;
         l_tmp.u64[1] = l_mul << 32;
         l_tmp.u64[0] = l_mul >> 32;
-        l_ret = dap_chain_balance_add(l_ret, l_tmp);
+        l_ret = dap_uint128_add(l_ret, l_tmp);
         if (l_ret.u64[0] == 0 && l_ret.u64[1] == 0)
             return l_nul;
         l_tmp.u64[1] = 0;
         l_tmp.u64[0] = c_pow10[i].u32[0] * l_digit;
-        l_ret = dap_chain_balance_add(l_ret, l_tmp);
+        l_ret = dap_uint128_add(l_ret, l_tmp);
         if (l_ret.u64[0] == 0 && l_ret.u64[1] == 0)
             return l_nul;
         l_mul = c_pow10[i].u32[1] * l_digit;
@@ -447,7 +447,7 @@ uint128_t dap_chain_balance_scan(char *a_balance)
             return l_nul;
         }
         l_tmp.u64[0] = l_mul << 32;
-        l_ret = dap_chain_balance_add(l_ret, l_tmp);
+        l_ret = dap_uint128_add(l_ret, l_tmp);
         if (l_ret.u64[0] == 0 && l_ret.u64[1] == 0)
             return l_nul;
 #endif
diff --git a/modules/common/include/dap_chain_common.h b/modules/common/include/dap_chain_common.h
index 7d53aa8a61..543931b83e 100644
--- a/modules/common/include/dap_chain_common.h
+++ b/modules/common/include/dap_chain_common.h
@@ -264,9 +264,9 @@ static inline char * dap_chain_hash_slow_to_str_new(dap_chain_hash_slow_t * a_ha
  */
 static inline dap_chain_hash_slow_kind_t dap_chain_hash_slow_kind_check(dap_chain_hash_slow_t * a_hash, const uint8_t a_valuable_head  )
 {
-    register uint8_t i;
-    register uint8_t l_hash_first = a_hash->raw[0];
-    register uint8_t * l_hash_data = a_hash->raw;
+    uint8_t i;
+    uint8_t l_hash_first = a_hash->raw[0];
+    uint8_t * l_hash_data = a_hash->raw;
     for ( i = 1; i < a_valuable_head; ++i ){
         if ( l_hash_data[i] != l_hash_first  )
             return HASH_USELESS;
-- 
GitLab