From e8cbad6015059adaf8f7936698facc7789db127d Mon Sep 17 00:00:00 2001 From: Dirk Helbig Date: Thu, 2 Jun 2022 21:04:02 +0200 Subject: [PATCH] btstack_run_loop: support uint64_t timer variable btstack_run_loop: cleanup whitespaces --- src/btstack_run_loop.c | 2 +- src/btstack_run_loop.h | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/btstack_run_loop.c b/src/btstack_run_loop.c index 4ac57c6b1..4a29ae46b 100644 --- a/src/btstack_run_loop.c +++ b/src/btstack_run_loop.c @@ -119,7 +119,7 @@ void btstack_run_loop_base_dump_timer(void){ uint16_t i = 0; for (it = (btstack_linked_item_t *) btstack_run_loop_base_timers; it ; it = it->next){ btstack_timer_source_t * timer = (btstack_timer_source_t*) it; - log_info("timer %u (%p): timeout %" PRIu32 "u\n", i, (void *) timer, timer->timeout); + log_info("timer %u (%p): timeout %" PRIbtstack_time_t "\n", i, (void *) timer, timer->timeout); } #endif diff --git a/src/btstack_run_loop.h b/src/btstack_run_loop.h index 11f4151e4..ca816bb6b 100644 --- a/src/btstack_run_loop.h +++ b/src/btstack_run_loop.h @@ -56,33 +56,41 @@ #include +#ifdef ENABLE_TESTING_SUPPORT +typedef uint64_t btstack_time_t; +#define PRIbtstack_time_t PRIu64 +#else +typedef uint32_t btstack_time_t; +#define PRIbtstack_time_t PRIu32 +#endif + #if defined __cplusplus extern "C" { #endif - + /** * Callback types for run loop data sources */ typedef enum { - DATA_SOURCE_CALLBACK_POLL = 1 << 0, - DATA_SOURCE_CALLBACK_READ = 1 << 1, - DATA_SOURCE_CALLBACK_WRITE = 1 << 2, + DATA_SOURCE_CALLBACK_POLL = 1 << 0, + DATA_SOURCE_CALLBACK_READ = 1 << 1, + DATA_SOURCE_CALLBACK_WRITE = 1 << 2, } btstack_data_source_callback_type_t; typedef struct btstack_data_source { - // linked item + // linked item btstack_linked_item_t item; // item to watch in run loop union { - // file descriptor for posix systems - int fd; - // handle on windows - void * handle; + // file descriptor for posix systems + int fd; + // handle on windows + void * handle; } source; // callback to call for enabled callback types - void (*process)(struct btstack_data_source *ds, btstack_data_source_callback_type_t callback_type); + void (*process)(struct btstack_data_source *ds, btstack_data_source_callback_type_t callback_type); // flags storing enabled callback types uint16_t flags; @@ -90,11 +98,11 @@ typedef struct btstack_data_source { } btstack_data_source_t; typedef struct btstack_timer_source { - btstack_linked_item_t item; + btstack_linked_item_t item; // timeout in system ticks (HAVE_EMBEDDED_TICK) or milliseconds (HAVE_EMBEDDED_TIME_MS) - uint32_t timeout; + btstack_time_t timeout; // will be called when timer fired - void (*process)(struct btstack_timer_source *ts); + void (*process)(struct btstack_timer_source *ts); void * context; } btstack_timer_source_t;