From 6df2e19c22361cfa4a50074753576e154dbd4700 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 8 Jan 2024 16:14:00 +0100 Subject: [PATCH] feat: switch tasks to zp namespace --- include/zenoh-pico/system/platform.h | 8 ++++---- src/system/arduino/esp32/system.c | 10 +++++----- src/system/arduino/opencr/system.c | 8 ++++---- src/system/emscripten/system.c | 8 ++++---- src/system/espidf/system.c | 10 +++++----- src/system/freertos_plus_tcp/system.c | 8 ++++---- src/system/mbed/system.cpp | 8 ++++---- src/system/unix/system.c | 8 ++++---- src/system/windows/system.c | 8 ++++---- src/system/zephyr/system.c | 8 ++++---- src/transport/multicast/lease.c | 2 +- src/transport/multicast/read.c | 2 +- src/transport/multicast/transport.c | 8 ++++---- src/transport/raweth/read.c | 2 +- src/transport/unicast/lease.c | 2 +- src/transport/unicast/read.c | 2 +- src/transport/unicast/transport.c | 8 ++++---- 17 files changed, 55 insertions(+), 55 deletions(-) diff --git a/include/zenoh-pico/system/platform.h b/include/zenoh-pico/system/platform.h index 0d6d367b2..e4d4c32a8 100644 --- a/include/zenoh-pico/system/platform.h +++ b/include/zenoh-pico/system/platform.h @@ -60,10 +60,10 @@ void z_free(void *ptr); #if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Thread ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg); -int8_t z_task_join(z_task_t *task); -int8_t z_task_cancel(z_task_t *task); -void z_task_free(z_task_t **task); +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg); +int8_t zp_task_join(z_task_t *task); +int8_t zp_task_cancel(z_task_t *task); +void zp_task_free(z_task_t **task); /*------------------ Mutex ------------------*/ int8_t z_mutex_init(z_mutex_t *m); diff --git a/src/system/arduino/esp32/system.c b/src/system/arduino/esp32/system.c index 238b06de1..009395f1f 100644 --- a/src/system/arduino/esp32/system.c +++ b/src/system/arduino/esp32/system.c @@ -60,7 +60,7 @@ void z_task_wrapper(z_task_arg *targ) { } /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { int ret = 0; z_task_arg *z_arg = (z_task_arg *)z_malloc(sizeof(z_task_arg)); @@ -77,17 +77,17 @@ int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), vo return ret; } -int8_t z_task_join(z_task_t *task) { +int8_t zp_task_join(z_task_t *task) { // Note: task/thread join not supported on FreeRTOS API, so we force its deletion instead. - return z_task_cancel(task); + return zp_task_cancel(task); } -int8_t z_task_cancel(z_task_t *task) { +int8_t zp_task_cancel(z_task_t *task) { vTaskDelete(*task); return 0; } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/system/arduino/opencr/system.c b/src/system/arduino/opencr/system.c index 0d6dfc059..18134c494 100644 --- a/src/system/arduino/opencr/system.c +++ b/src/system/arduino/opencr/system.c @@ -63,13 +63,13 @@ void z_free(void *ptr) { #error "Multi-threading not supported yet on OpenCR port. Disable it by defining Z_FEATURE_MULTI_THREAD=0" /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { return -1; } +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { return -1; } -int8_t z_task_join(z_task_t *task) { return -1; } +int8_t zp_task_join(z_task_t *task) { return -1; } -int8_t z_task_cancel(z_task_t *task) { return -1; } +int8_t zp_task_cancel(z_task_t *task) { return -1; } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/system/emscripten/system.c b/src/system/emscripten/system.c index 99dbbf065..319475134 100644 --- a/src/system/emscripten/system.c +++ b/src/system/emscripten/system.c @@ -44,15 +44,15 @@ void z_free(void *ptr) { free(ptr); } #if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, pthread_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, pthread_attr_t *attr, void *(*fun)(void *), void *arg) { return pthread_create(task, attr, fun, arg); } -int8_t z_task_join(z_task_t *task) { return pthread_join(*task, NULL); } +int8_t zp_task_join(z_task_t *task) { return pthread_join(*task, NULL); } -int8_t z_task_cancel(z_task_t *task) { return pthread_cancel(*task); } +int8_t zp_task_cancel(z_task_t *task) { return pthread_cancel(*task); } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/system/espidf/system.c b/src/system/espidf/system.c index a1cdd3a2a..75b02ae5f 100644 --- a/src/system/espidf/system.c +++ b/src/system/espidf/system.c @@ -61,7 +61,7 @@ void z_task_wrapper(z_task_arg *targ) { } /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { int ret = 0; z_task_arg *z_arg = (z_task_arg *)z_malloc(sizeof(z_task_arg)); @@ -78,17 +78,17 @@ int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), vo return ret; } -int8_t z_task_join(z_task_t *task) { +int8_t zp_task_join(z_task_t *task) { // Note: task/thread join not supported on FreeRTOS API, so we force its deletion instead. - return z_task_cancel(task); + return zp_task_cancel(task); } -int8_t z_task_cancel(z_task_t *task) { +int8_t zp_task_cancel(z_task_t *task) { vTaskDelete(*task); return 0; } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/system/freertos_plus_tcp/system.c b/src/system/freertos_plus_tcp/system.c index 9a64b987f..8991090b9 100644 --- a/src/system/freertos_plus_tcp/system.c +++ b/src/system/freertos_plus_tcp/system.c @@ -85,7 +85,7 @@ static z_task_attr_t z_default_task_attr = { }; /*------------------ Thread ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { z_task_arg *z_arg = (z_task_arg *)z_malloc(sizeof(z_task_arg)); if (z_arg == NULL) { return -1; @@ -119,17 +119,17 @@ int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), vo return 0; } -int8_t z_task_join(z_task_t *task) { +int8_t zp_task_join(z_task_t *task) { xEventGroupWaitBits(task->join_event, 1, pdFALSE, pdFALSE, portMAX_DELAY); return 0; } -int8_t z_task_cancel(z_task_t *task) { +int8_t zp_task_cancel(z_task_t *task) { vTaskDelete(task->handle); return 0; } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_free((*task)->join_event); z_free(*task); } diff --git a/src/system/mbed/system.cpp b/src/system/mbed/system.cpp index f1df2ffbd..4562b0048 100644 --- a/src/system/mbed/system.cpp +++ b/src/system/mbed/system.cpp @@ -41,25 +41,25 @@ void z_free(void *ptr) { free(ptr); } #if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { *task = new Thread(); mbed::Callback c = mbed::Callback(fun, arg); return ((Thread *)*task)->start(c); } -int8_t z_task_join(z_task_t *task) { +int8_t zp_task_join(z_task_t *task) { int res = ((Thread *)*task)->join(); delete ((Thread *)*task); return res; } -int8_t z_task_cancel(z_task_t *task) { +int8_t zp_task_cancel(z_task_t *task) { int res = ((Thread *)*task)->terminate(); delete ((Thread *)*task); return res; } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/system/unix/system.c b/src/system/unix/system.c index c1635bae4..b8d8f2ac2 100644 --- a/src/system/unix/system.c +++ b/src/system/unix/system.c @@ -101,15 +101,15 @@ void z_free(void *ptr) { free(ptr); } #if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { return pthread_create(task, attr, fun, arg); } -int8_t z_task_join(z_task_t *task) { return pthread_join(*task, NULL); } +int8_t zp_task_join(z_task_t *task) { return pthread_join(*task, NULL); } -int8_t z_task_cancel(z_task_t *task) { return pthread_cancel(*task); } +int8_t zp_task_cancel(z_task_t *task) { return pthread_cancel(*task); } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/system/windows/system.c b/src/system/windows/system.c index 13c1af220..6d96645da 100644 --- a/src/system/windows/system.c +++ b/src/system/windows/system.c @@ -60,7 +60,7 @@ void z_free(void *ptr) { free(ptr); } #if Z_FEATURE_MULTI_THREAD == 1 /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { (void)(attr); int8_t ret = _Z_RES_OK; *task = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)fun, arg, 0, NULL); @@ -70,19 +70,19 @@ int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), vo return ret; } -int8_t z_task_join(z_task_t *task) { +int8_t zp_task_join(z_task_t *task) { int8_t ret = _Z_RES_OK; WaitForSingleObject(*task, INFINITE); return ret; } -int8_t z_task_cancel(z_task_t *task) { +int8_t zp_task_cancel(z_task_t *task) { int8_t ret = _Z_RES_OK; TerminateThread(*task, 0); return ret; } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; CloseHandle(*ptr); z_free(ptr); diff --git a/src/system/zephyr/system.c b/src/system/zephyr/system.c index 539bcb8cb..063a0e911 100644 --- a/src/system/zephyr/system.c +++ b/src/system/zephyr/system.c @@ -71,7 +71,7 @@ K_THREAD_STACK_ARRAY_DEFINE(thread_stack_area, Z_THREADS_NUM, Z_PTHREAD_STACK_SI static int thread_index = 0; /*------------------ Task ------------------*/ -int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t zp_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), void *arg) { z_task_attr_t *lattr = NULL; z_task_attr_t tmp; if (attr == NULL) { @@ -83,11 +83,11 @@ int8_t z_task_init(z_task_t *task, z_task_attr_t *attr, void *(*fun)(void *), vo return pthread_create(task, lattr, fun, arg); } -int8_t z_task_join(z_task_t *task) { return pthread_join(*task, NULL); } +int8_t zp_task_join(z_task_t *task) { return pthread_join(*task, NULL); } -int8_t z_task_cancel(z_task_t *task) { return pthread_cancel(*task); } +int8_t zp_task_cancel(z_task_t *task) { return pthread_cancel(*task); } -void z_task_free(z_task_t **task) { +void zp_task_free(z_task_t **task) { z_task_t *ptr = *task; z_free(ptr); *task = NULL; diff --git a/src/transport/multicast/lease.c b/src/transport/multicast/lease.c index c844084d8..b9f4017a0 100644 --- a/src/transport/multicast/lease.c +++ b/src/transport/multicast/lease.c @@ -185,7 +185,7 @@ int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, z_task_attr // Init memory (void)memset(task, 0, sizeof(z_task_t)); // Init task - if (z_task_init(task, attr, _zp_multicast_lease_task, ztm) != _Z_RES_OK) { + if (zp_task_init(task, attr, _zp_multicast_lease_task, ztm) != _Z_RES_OK) { return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task diff --git a/src/transport/multicast/read.c b/src/transport/multicast/read.c index 62b870a9e..74b6b0be3 100644 --- a/src/transport/multicast/read.c +++ b/src/transport/multicast/read.c @@ -132,7 +132,7 @@ int8_t _zp_multicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_ // Init memory (void)memset(task, 0, sizeof(z_task_t)); // Init task - if (z_task_init(task, attr, _zp_multicast_read_task, &zt->_transport._multicast) != _Z_RES_OK) { + if (zp_task_init(task, attr, _zp_multicast_read_task, &zt->_transport._multicast) != _Z_RES_OK) { return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task diff --git a/src/transport/multicast/transport.c b/src/transport/multicast/transport.c index 72a83069f..c7bcfe3cb 100644 --- a/src/transport/multicast/transport.c +++ b/src/transport/multicast/transport.c @@ -183,12 +183,12 @@ void _z_multicast_transport_clear(_z_transport_t *zt) { #if Z_FEATURE_MULTI_THREAD == 1 // Clean up tasks if (ztm->_read_task != NULL) { - z_task_join(ztm->_read_task); - z_task_free(&ztm->_read_task); + zp_task_join(ztm->_read_task); + zp_task_free(&ztm->_read_task); } if (ztm->_lease_task != NULL) { - z_task_join(ztm->_lease_task); - z_task_free(&ztm->_lease_task); + zp_task_join(ztm->_lease_task); + zp_task_free(&ztm->_lease_task); } // Clean up the mutexes z_mutex_free(&ztm->_mutex_tx); diff --git a/src/transport/raweth/read.c b/src/transport/raweth/read.c index f7b8098e7..384782097 100644 --- a/src/transport/raweth/read.c +++ b/src/transport/raweth/read.c @@ -87,7 +87,7 @@ int8_t _zp_raweth_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_tas // Init memory (void)memset(task, 0, sizeof(z_task_t)); // Init task - if (z_task_init(task, attr, _zp_raweth_read_task, &zt->_transport._raweth) != _Z_RES_OK) { + if (zp_task_init(task, attr, _zp_raweth_read_task, &zt->_transport._raweth) != _Z_RES_OK) { return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task diff --git a/src/transport/unicast/lease.c b/src/transport/unicast/lease.c index aa0ae66e5..bc13e9f83 100644 --- a/src/transport/unicast/lease.c +++ b/src/transport/unicast/lease.c @@ -99,7 +99,7 @@ int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, z_task_attr_t *attr, z_t // Init memory (void)memset(task, 0, sizeof(z_task_t)); // Init task - if (z_task_init(task, attr, _zp_unicast_lease_task, &zt->_transport._unicast) != _Z_RES_OK) { + if (zp_task_init(task, attr, _zp_unicast_lease_task, &zt->_transport._unicast) != _Z_RES_OK) { return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task diff --git a/src/transport/unicast/read.c b/src/transport/unicast/read.c index 98d124319..9d1bdb55b 100644 --- a/src/transport/unicast/read.c +++ b/src/transport/unicast/read.c @@ -125,7 +125,7 @@ int8_t _zp_unicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_ta // Init memory (void)memset(task, 0, sizeof(z_task_t)); // Init task - if (z_task_init(task, attr, _zp_unicast_read_task, &zt->_transport._unicast) != _Z_RES_OK) { + if (zp_task_init(task, attr, _zp_unicast_read_task, &zt->_transport._unicast) != _Z_RES_OK) { return _Z_ERR_SYSTEM_TASK_FAILED; } // Attach task diff --git a/src/transport/unicast/transport.c b/src/transport/unicast/transport.c index a3ca110a1..d9ed4dc4c 100644 --- a/src/transport/unicast/transport.c +++ b/src/transport/unicast/transport.c @@ -268,12 +268,12 @@ void _z_unicast_transport_clear(_z_transport_t *zt) { #if Z_FEATURE_MULTI_THREAD == 1 // Clean up tasks if (ztu->_read_task != NULL) { - z_task_join(ztu->_read_task); - z_task_free(&ztu->_read_task); + zp_task_join(ztu->_read_task); + zp_task_free(&ztu->_read_task); } if (ztu->_lease_task != NULL) { - z_task_join(ztu->_lease_task); - z_task_free(&ztu->_lease_task); + zp_task_join(ztu->_lease_task); + zp_task_free(&ztu->_lease_task); } // Clean up the mutexes