diff --git a/dap-sdk/core/CMakeLists.txt b/dap-sdk/core/CMakeLists.txt index 31c0eea678deae9981cbe572f79b2145150b5bc3..c7d865b88b1e14f2e06fc7a0e61a20353338904e 100755 --- a/dap-sdk/core/CMakeLists.txt +++ b/dap-sdk/core/CMakeLists.txt @@ -100,7 +100,7 @@ endif() if(ANDROID) add_subdirectory(src/android) - target_link_libraries(${PROJECT_NAME} dap_core_android) + target_link_libraries(${PROJECT_NAME} dap_core_android rt) endif() if (WIN32) diff --git a/dap-sdk/core/src/dap_common.c b/dap-sdk/core/src/dap_common.c index 78b63ee843138428d81c0942e56645f498e1eeb0..11b631e93a27fcbc75fff90a16cade929e163ab3 100755 --- a/dap-sdk/core/src/dap_common.c +++ b/dap-sdk/core/src/dap_common.c @@ -827,7 +827,7 @@ static int s_timer_find(void *a_timer) static void CALLBACK s_win_callback(PVOID a_arg, BOOLEAN a_always_true) { UNUSED(a_always_true); - s_timers[(int)a_arg].callback(s_timers[(int)a_arg].param); + s_timers[(size_t)a_arg].callback(s_timers[(size_t)a_arg].param); } #else static void s_posix_callback(union sigval a_arg) @@ -847,16 +847,16 @@ void *dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_call if (s_timers_count == DAP_INTERVAL_TIMERS_MAX) { return NULL; } -#ifdef _WIN32 +#ifdef WIN32 if (s_timers_count == 0) { InitializeCriticalSection(&s_timers_lock); } HANDLE l_timer; - if (!CreateTimerQueueTimer(&l_timer, NULL, (WAITORTIMERCALLBACK)s_win_callback, (PVOID)s_timers_count, a_msec, a_msec, 0)) { + if (!CreateTimerQueueTimer(&l_timer, NULL, (WAITORTIMERCALLBACK)s_win_callback, (PVOID)(size_t)s_timers_count, a_msec, a_msec, 0)) { return NULL; } EnterCriticalSection(&s_timers_lock); -#else +#elif DAP_OS_UNIX if (s_timers_count == 0) { pthread_mutex_init(&s_timers_lock, NULL); } @@ -873,6 +873,8 @@ void *dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_call l_period.it_interval.tv_nsec = l_period.it_value.tv_nsec = (a_msec % 1000) * 1000000; timer_settime(l_timer, 0, &l_period, NULL); pthread_mutex_lock(&s_timers_lock); +#esle + //DARWIN #endif s_timers[s_timers_count].timer = (void *)l_timer; s_timers[s_timers_count].callback = a_callback; @@ -880,8 +882,10 @@ void *dap_interval_timer_create(unsigned int a_msec, dap_timer_callback_t a_call s_timers_count++; #ifdef _WIN32 LeaveCriticalSection(&s_timers_lock); -#else +#elif DAP_OS_UNIX pthread_mutex_unlock(&s_timers_lock); +#else + //DARWIN #endif return (void *)l_timer; } @@ -898,8 +902,10 @@ int dap_interval_timer_delete(void *a_timer) } #ifdef _WIN32 EnterCriticalSection(&s_timers_lock); -#else +#elif DAP_OS_UNIX pthread_mutex_lock(&s_timers_lock); +#else + //DARWIN #endif int l_timer_idx = s_timer_find(a_timer); if (l_timer_idx == -1) { @@ -915,10 +921,13 @@ int dap_interval_timer_delete(void *a_timer) DeleteCriticalSection(&s_timers_lock); } return !DeleteTimerQueueTimer(NULL, (HANDLE)a_timer, NULL); -#else +#elif DAP_OS_UNIX + pthread_mutex_unlock(&s_timers_lock); if (s_timers_count == 0) { pthread_mutex_destroy(&s_timers_lock); } return timer_delete((timer_t)a_timer); +#else + //DARWIN #endif }