From 79095942d73abaf486f3866d3c4f2bae15d94270 Mon Sep 17 00:00:00 2001
From: "pavel.uhanov" <pavel.uhanov@demlabs.net>
Date: Tue, 25 Feb 2025 07:35:04 +0300
Subject: [PATCH 1/3] [+] add dap_time_from_str_custom func

---
 core/include/dap_common.h |  2 +-
 core/include/dap_time.h   |  2 +-
 core/src/dap_time.c       | 17 +++++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/core/include/dap_common.h b/core/include/dap_common.h
index 43233995f..74951b435 100755
--- a/core/include/dap_common.h
+++ b/core/include/dap_common.h
@@ -229,7 +229,7 @@ static inline void *s_vm_extend(const char *a_rtn_name, int a_rtn_line, void *a_
 #define DAP_DELETE(p)         free((void*)(p))
 #define DAP_DEL_Z(p)          do { DAP_FREE(p); (p) = NULL; } while (0);
 #define DAP_DEL_ARRAY(p, c)   for ( intmax_t _c = p ? (intmax_t)(c) : 0; _c > 0; DAP_DELETE(p[--_c]) );
-#define DAP_DUP_SIZE(p, s)    ({ intmax_t _s = (intmax_t)(s); __typeof__(p) _p = ( (uintptr_t)(p) && _s >= DAP_TYPE_SIZE(p) ) ? DAP_CAST(__typeof__(p), calloc(1, _s)) : NULL; _p ? DAP_CAST(__typeof__(p), memcpy(_p, (p), _s)) : NULL; })
+#define DAP_DUP_SIZE(p, s)    ({ intmax_t _s = (intmax_t)(s); void *_p = ( (uintptr_t)(p) && _s >= DAP_TYPE_SIZE(p) ) ? calloc(1, _s) : NULL; _p ? DAP_CAST(__typeof__(p), memcpy(_p, (p), _s)) : NULL; })
 #define DAP_DUP(p)            ({ __typeof__(p) _p = p; _p = (uintptr_t)_p ? calloc(1, sizeof(*(p))) : NULL; if (_p) *_p = *(p); _p; })
 
 #endif
diff --git a/core/include/dap_time.h b/core/include/dap_time.h
index 68e92c44f..0fbd5f8b4 100644
--- a/core/include/dap_time.h
+++ b/core/include/dap_time.h
@@ -64,4 +64,4 @@ int dap_nanotime_to_str_rfc822(char *a_out, size_t a_out_size_max, dap_nanotime_
 int timespec_diff(struct timespec *a_start, struct timespec *a_stop, struct timespec *a_result);
 
 dap_time_t dap_time_from_str_simplified(const char *a_time_str);
-
+dap_time_t dap_time_from_str_custom(const char *a_time_str, const char *a_format_str);
diff --git a/core/src/dap_time.c b/core/src/dap_time.c
index eb45e4bab..a4cef5ffa 100644
--- a/core/src/dap_time.c
+++ b/core/src/dap_time.c
@@ -216,3 +216,20 @@ int dap_nanotime_to_str_rfc822(char *a_out, size_t a_out_size_max, dap_nanotime_
     time_t l_time = dap_nanotime_to_sec(a_chain_time);
     return dap_time_to_str_rfc822(a_out, a_out_size_max, l_time);
 }
+
+/**
+ * @brief Convert time str to dap_time_t by custom format
+ * @param a_time_str
+ * @param a_format_str
+ * @return time from string or 0 if bad time format
+ */
+dap_time_t dap_time_from_str_custom(const char *a_time_str, const char *a_format_str)
+{
+    dap_return_val_if_pass(!a_time_str || !a_format_str, 0);
+    struct tm l_tm = {};
+    char *ret = strptime(a_time_str, a_format_str, &l_tm);
+    if ( !ret || *ret )
+        return log_it(L_ERROR, "Invalid timestamp \"%s\" by format \"%s\"", a_time_str, a_format_str), 0;
+    time_t tmp = mktime(&l_tm);
+    return tmp > 0 ? (dap_time_t)tmp : 0;
+}
\ No newline at end of file
-- 
GitLab


From 3eaad7241b33e24d8f9d9be5da30aa0d24478f71 Mon Sep 17 00:00:00 2001
From: "pavel.uhanov" <pavel.uhanov@demlabs.net>
Date: Tue, 25 Feb 2025 11:08:08 +0300
Subject: [PATCH 2/3] [*] warning fix

---
 global-db/dap_global_db.c           | 9 +++++++--
 global-db/test/dap_global_db_test.c | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/global-db/dap_global_db.c b/global-db/dap_global_db.c
index 58e57ed8d..31175cd98 100644
--- a/global-db/dap_global_db.c
+++ b/global-db/dap_global_db.c
@@ -1880,6 +1880,11 @@ static bool s_check_pinned_db_objs_callback() {
     return false;
 }
 
+DAP_STATIC_INLINE void s_check_pinned_db_objs_callback_void()
+{
+    s_check_pinned_db_objs_callback();
+}
+
 static bool s_start_check_pinned_db_objs_callback() {
     int l_ret = dap_proc_thread_callback_add(NULL, s_check_pinned_db_objs_callback, NULL);
     if (l_ret != 0) {
@@ -1921,7 +1926,7 @@ static void s_set_pinned_timer(const char * a_group) {
             s_minimal_ttl = dap_nanotime_from_sec(l_cluster->ttl);
         s_check_pinned_db_objs_timer = dap_timerfd_start(dap_nanotime_to_millitime(s_minimal_ttl/2), 
                                                         (dap_timerfd_callback_t)s_start_check_pinned_db_objs_callback, NULL);
-        debug_if(g_dap_global_db_debug_more, L_INFO, "New pinned callback timer %llu sec", dap_nanotime_to_sec(s_minimal_ttl/2));
+        debug_if(g_dap_global_db_debug_more, L_INFO, "New pinned callback timer %"DAP_UINT64_FORMAT_U" sec", dap_nanotime_to_sec(s_minimal_ttl/2));
     }
 }
 
@@ -1976,7 +1981,7 @@ static int s_pinned_objs_group_init() {
         s_get_all_pinned_objs_in_group(l_ret, l_ret_count);
         dap_store_obj_free(l_ret, l_ret_count);
     }
-    dap_proc_thread_timer_add_pri(NULL, (dap_thread_timer_callback_t)s_check_pinned_db_objs_callback, NULL, 300000, true, DAP_QUEUE_MSG_PRIORITY_NORMAL);  // 5 min wait before repin
+    dap_proc_thread_timer_add_pri(NULL, s_check_pinned_db_objs_callback_void, NULL, 300000, true, DAP_QUEUE_MSG_PRIORITY_NORMAL);  // 5 min wait before repin
     return 0;
 }
 
diff --git a/global-db/test/dap_global_db_test.c b/global-db/test/dap_global_db_test.c
index 076810098..5349d6f26 100644
--- a/global-db/test/dap_global_db_test.c
+++ b/global-db/test/dap_global_db_test.c
@@ -772,7 +772,7 @@ static void s_test_multithread(size_t a_count)
 {
     uint32_t l_thread_count = 3;
 #ifdef DAP_CHAIN_GDB_ENGINE_SQLITE
-    dap_global_db_driver_sqlite_set_attempts_count(l_thread_count);
+    dap_global_db_driver_sqlite_set_attempts_count(l_thread_count, false);
 #endif
     dap_test_msg("Test with %u threads", l_thread_count);
     pthread_t *l_threads = DAP_NEW_Z_COUNT(pthread_t, l_thread_count);
-- 
GitLab


From 2df49883ee40e8f4b3a8b95309c4fe904393bb20 Mon Sep 17 00:00:00 2001
From: Roman Khlopkov <roman.khlopkov@demlabs.net>
Date: Tue, 25 Feb 2025 11:58:14 +0000
Subject: [PATCH 3/3] Update dap_common.h

---
 core/include/dap_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/include/dap_common.h b/core/include/dap_common.h
index 74951b435..43233995f 100755
--- a/core/include/dap_common.h
+++ b/core/include/dap_common.h
@@ -229,7 +229,7 @@ static inline void *s_vm_extend(const char *a_rtn_name, int a_rtn_line, void *a_
 #define DAP_DELETE(p)         free((void*)(p))
 #define DAP_DEL_Z(p)          do { DAP_FREE(p); (p) = NULL; } while (0);
 #define DAP_DEL_ARRAY(p, c)   for ( intmax_t _c = p ? (intmax_t)(c) : 0; _c > 0; DAP_DELETE(p[--_c]) );
-#define DAP_DUP_SIZE(p, s)    ({ intmax_t _s = (intmax_t)(s); void *_p = ( (uintptr_t)(p) && _s >= DAP_TYPE_SIZE(p) ) ? calloc(1, _s) : NULL; _p ? DAP_CAST(__typeof__(p), memcpy(_p, (p), _s)) : NULL; })
+#define DAP_DUP_SIZE(p, s)    ({ intmax_t _s = (intmax_t)(s); __typeof__(p) _p = ( (uintptr_t)(p) && _s >= DAP_TYPE_SIZE(p) ) ? DAP_CAST(__typeof__(p), calloc(1, _s)) : NULL; _p ? DAP_CAST(__typeof__(p), memcpy(_p, (p), _s)) : NULL; })
 #define DAP_DUP(p)            ({ __typeof__(p) _p = p; _p = (uintptr_t)_p ? calloc(1, sizeof(*(p))) : NULL; if (_p) *_p = *(p); _p; })
 
 #endif
-- 
GitLab