From 0e9b44642b3f8ae3840aa2e26ec966bcc2147cf0 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 4 Jan 2024 11:37:51 +0100 Subject: [PATCH] feat: make all sync mechanisms public --- examples/freertos_plus_tcp/z_pub.c | 4 +-- examples/unix/c11/z_ping.c | 22 ++++++------ examples/unix/c99/z_ping.c | 20 +++++------ examples/windows/z_ping.c | 20 +++++------ include/zenoh-pico/api/types.h | 4 +-- include/zenoh-pico/net/session.h | 6 ++-- include/zenoh-pico/session/session.h | 4 +-- include/zenoh-pico/system/platform.h | 26 +++++++------- .../system/platform/arduino/esp32.h | 8 ++--- .../system/platform/arduino/opencr.h | 8 ++--- .../zenoh-pico/system/platform/emscripten.h | 8 ++--- include/zenoh-pico/system/platform/espidf.h | 8 ++--- .../system/platform/freertos_plus_tcp.h | 8 ++--- include/zenoh-pico/system/platform/mbed.h | 10 +++--- include/zenoh-pico/system/platform/unix.h | 8 ++--- include/zenoh-pico/system/platform/void.h | 8 ++--- include/zenoh-pico/system/platform/windows.h | 8 ++--- include/zenoh-pico/system/platform/zephyr.h | 8 ++--- .../zenoh-pico/transport/multicast/lease.h | 2 +- include/zenoh-pico/transport/multicast/read.h | 2 +- include/zenoh-pico/transport/raweth/read.h | 2 +- include/zenoh-pico/transport/transport.h | 18 +++++----- include/zenoh-pico/transport/unicast/lease.h | 2 +- include/zenoh-pico/transport/unicast/read.h | 2 +- src/net/session.c | 8 ++--- src/session/query.c | 24 ++++++------- src/session/queryable.c | 26 +++++++------- src/session/resource.c | 28 +++++++-------- src/session/subscription.c | 26 +++++++------- src/session/utils.c | 4 +-- src/system/arduino/esp32/system.c | 36 +++++++++---------- src/system/arduino/opencr/system.c | 28 +++++++-------- src/system/emscripten/system.c | 28 +++++++-------- src/system/espidf/system.c | 36 +++++++++---------- src/system/freertos_plus_tcp/system.c | 34 +++++++++--------- src/system/mbed/system.cpp | 28 +++++++-------- src/system/unix/system.c | 28 +++++++-------- src/system/windows/system.c | 28 +++++++-------- src/system/zephyr/system.c | 32 ++++++++--------- src/transport/multicast/lease.c | 12 +++---- src/transport/multicast/read.c | 8 ++--- src/transport/multicast/rx.c | 8 ++--- src/transport/multicast/transport.c | 32 ++++++++--------- src/transport/multicast/tx.c | 10 +++--- src/transport/raweth/read.c | 4 +-- src/transport/raweth/rx.c | 4 +-- src/transport/raweth/tx.c | 12 +++---- src/transport/unicast/lease.c | 4 +-- src/transport/unicast/read.c | 8 ++--- src/transport/unicast/rx.c | 4 +-- src/transport/unicast/transport.c | 22 ++++++------ src/transport/unicast/tx.c | 10 +++--- 52 files changed, 373 insertions(+), 375 deletions(-) diff --git a/examples/freertos_plus_tcp/z_pub.c b/examples/freertos_plus_tcp/z_pub.c index f53a786da..75af7596c 100644 --- a/examples/freertos_plus_tcp/z_pub.c +++ b/examples/freertos_plus_tcp/z_pub.c @@ -48,7 +48,7 @@ void app_main(void) { static StackType_t read_task_stack[1000]; static StaticTask_t read_task_buffer; - _z_task_attr_t read_task_attr = { + z_task_attr_t read_task_attr = { .name = "ZenohReadTask", .priority = 10, .stack_depth = 1000, @@ -62,7 +62,7 @@ void app_main(void) { static StackType_t lease_task_stack[1000]; static StaticTask_t lease_task_buffer; - _z_task_attr_t lease_task_attr = { + z_task_attr_t lease_task_attr = { .name = "ZenohLeaseTask", .priority = 10, .stack_depth = 1000, diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index cfd57744f..ac8ccb667 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -27,19 +27,17 @@ #define DEFAULT_PING_NB 100 #define DEFAULT_WARMUP_MS 1000 -// WARNING: for the sake of this example we are using "internal" structs and functions (starting with "_"). -// Synchronisation primitives are planned to be added to the API in the future. -_z_condvar_t cond; -_z_mutex_t mutex; +static z_condvar_t cond; +static z_mutex_t mutex; void callback(const z_sample_t* sample, void* context) { (void)sample; (void)context; - _z_condvar_signal(&cond); + z_condvar_signal(&cond); } void drop(void* context) { (void)context; - _z_condvar_free(&cond); + z_condvar_free(&cond); } struct args_t { @@ -63,8 +61,8 @@ int main(int argc, char** argv) { DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS); return 1; } - _z_mutex_init(&mutex); - _z_condvar_init(&cond); + z_mutex_init(&mutex); + z_condvar_init(&cond); z_owned_config_t config = z_config_default(); z_owned_session_t session = z_open(z_move(config)); if (!z_check(session)) { @@ -97,14 +95,14 @@ int main(int argc, char** argv) { for (unsigned int i = 0; i < args.size; i++) { data[i] = i % 10; } - _z_mutex_lock(&mutex); + z_mutex_lock(&mutex); if (args.warmup_ms) { printf("Warming up for %dms...\n", args.warmup_ms); z_clock_t warmup_start = z_clock_now(); unsigned long elapsed_us = 0; while (elapsed_us < args.warmup_ms * 1000) { z_publisher_put(z_loan(pub), data, args.size, NULL); - _z_condvar_wait(&cond, &mutex); + z_condvar_wait(&cond, &mutex); elapsed_us = z_clock_elapsed_us(&warmup_start); } } @@ -112,13 +110,13 @@ int main(int argc, char** argv) { for (unsigned int i = 0; i < args.number_of_pings; i++) { z_clock_t measure_start = z_clock_now(); z_publisher_put(z_loan(pub), data, args.size, NULL); - _z_condvar_wait(&cond, &mutex); + z_condvar_wait(&cond, &mutex); results[i] = z_clock_elapsed_us(&measure_start); } for (unsigned int i = 0; i < args.number_of_pings; i++) { printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2); } - _z_mutex_unlock(&mutex); + z_mutex_unlock(&mutex); z_free(results); z_free(data); z_drop(z_move(pub)); diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index a3b4bcea2..d19e0e931 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -28,17 +28,17 @@ #define DEFAULT_PING_NB 100 #define DEFAULT_WARMUP_MS 1000 -_z_condvar_t cond; -_z_mutex_t mutex; +static z_condvar_t cond; +static z_mutex_t mutex; void callback(const z_sample_t* sample, void* context) { (void)sample; (void)context; - _z_condvar_signal(&cond); + z_condvar_signal(&cond); } void drop(void* context) { (void)context; - _z_condvar_free(&cond); + z_condvar_free(&cond); } struct args_t { @@ -62,8 +62,8 @@ int main(int argc, char** argv) { DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS); return 1; } - _z_mutex_init(&mutex); - _z_condvar_init(&cond); + z_mutex_init(&mutex); + z_condvar_init(&cond); z_owned_config_t config = z_config_default(); z_owned_session_t session = z_open(z_config_move(&config)); if (!z_session_check(&session)) { @@ -97,14 +97,14 @@ int main(int argc, char** argv) { for (unsigned int i = 0; i < args.size; i++) { data[i] = i % 10; } - _z_mutex_lock(&mutex); + z_mutex_lock(&mutex); if (args.warmup_ms) { printf("Warming up for %dms...\n", args.warmup_ms); z_clock_t warmup_start = z_clock_now(); unsigned long elapsed_us = 0; while (elapsed_us < args.warmup_ms * 1000) { z_publisher_put(z_publisher_loan(&pub), data, args.size, NULL); - _z_condvar_wait(&cond, &mutex); + z_condvar_wait(&cond, &mutex); elapsed_us = z_clock_elapsed_us(&warmup_start); } } @@ -112,13 +112,13 @@ int main(int argc, char** argv) { for (unsigned int i = 0; i < args.number_of_pings; i++) { z_clock_t measure_start = z_clock_now(); z_publisher_put(z_publisher_loan(&pub), data, args.size, NULL); - _z_condvar_wait(&cond, &mutex); + z_condvar_wait(&cond, &mutex); results[i] = z_clock_elapsed_us(&measure_start); } for (unsigned int i = 0; i < args.number_of_pings; i++) { printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2); } - _z_mutex_unlock(&mutex); + z_mutex_unlock(&mutex); z_free(results); z_free(data); z_undeclare_subscriber(z_subscriber_move(&sub)); diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index 7a5387321..e3fc496ad 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -27,17 +27,17 @@ #define DEFAULT_PING_NB 100 #define DEFAULT_WARMUP_MS 1000 -_z_condvar_t cond; -_z_mutex_t mutex; +static z_condvar_t cond; +static z_mutex_t mutex; void callback(const z_sample_t* sample, void* context) { (void)sample; (void)context; - _z_condvar_signal(&cond); + z_condvar_signal(&cond); } void drop(void* context) { (void)context; - _z_condvar_free(&cond); + z_condvar_free(&cond); } struct args_t { @@ -61,8 +61,8 @@ int main(int argc, char** argv) { DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS); return 1; } - _z_mutex_init(&mutex); - _z_condvar_init(&cond); + z_mutex_init(&mutex); + z_condvar_init(&cond); z_owned_config_t config = z_config_default(); z_owned_session_t session = z_open(z_move(config)); if (!z_check(session)) { @@ -94,14 +94,14 @@ int main(int argc, char** argv) { for (unsigned int i = 0; i < args.size; i++) { data[i] = i % 10; } - _z_mutex_lock(&mutex); + z_mutex_lock(&mutex); if (args.warmup_ms) { printf("Warming up for %dms...\n", args.warmup_ms); z_clock_t warmup_start = z_clock_now(); unsigned long elapsed_us = 0; while (elapsed_us < args.warmup_ms * 1000) { z_publisher_put(z_loan(pub), data, args.size, NULL); - _z_condvar_wait(&cond, &mutex); + z_condvar_wait(&cond, &mutex); elapsed_us = z_clock_elapsed_us(&warmup_start); } } @@ -109,13 +109,13 @@ int main(int argc, char** argv) { for (unsigned int i = 0; i < args.number_of_pings; i++) { z_clock_t measure_start = z_clock_now(); z_publisher_put(z_loan(pub), data, args.size, NULL); - _z_condvar_wait(&cond, &mutex); + z_condvar_wait(&cond, &mutex); results[i] = z_clock_elapsed_us(&measure_start); } for (unsigned int i = 0; i < args.number_of_pings; i++) { printf("%d bytes: seq=%d rtt=%luus, lat=%luus\n", args.size, i, results[i], results[i] / 2); } - _z_mutex_unlock(&mutex); + z_mutex_unlock(&mutex); z_free(results); z_free(data); z_drop(z_move(pub)); diff --git a/include/zenoh-pico/api/types.h b/include/zenoh-pico/api/types.h index 96bd2158d..3c0b3a68e 100644 --- a/include/zenoh-pico/api/types.h +++ b/include/zenoh-pico/api/types.h @@ -344,7 +344,7 @@ typedef struct { */ typedef struct { #if Z_FEATURE_MULTI_THREAD == 1 - _z_task_attr_t *task_attributes; + z_task_attr_t *task_attributes; #else uint8_t __dummy; // Just to avoid empty structures that might cause undefined behavior #endif @@ -356,7 +356,7 @@ typedef struct { */ typedef struct { #if Z_FEATURE_MULTI_THREAD == 1 - _z_task_attr_t *task_attributes; + z_task_attr_t *task_attributes; #else uint8_t __dummy; // Just to avoid empty structures that might cause undefined behavior #endif diff --git a/include/zenoh-pico/net/session.h b/include/zenoh-pico/net/session.h index aa6e14f06..0c41328c6 100644 --- a/include/zenoh-pico/net/session.h +++ b/include/zenoh-pico/net/session.h @@ -29,7 +29,7 @@ */ typedef struct { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_t _mutex_inner; + z_mutex_t _mutex_inner; #endif // Z_FEATURE_MULTI_THREAD == 1 // Zenoh-pico is considering a single transport per session. @@ -139,7 +139,7 @@ int8_t _zp_send_join(_z_session_t *z); * Returns: * ``0`` in case of success, ``-1`` in case of failure. */ -int8_t _zp_start_read_task(_z_session_t *z, _z_task_attr_t *attr); +int8_t _zp_start_read_task(_z_session_t *z, z_task_attr_t *attr); /** * Stop the read task. This may result in stopping a thread or a process depending @@ -166,7 +166,7 @@ int8_t _zp_stop_read_task(_z_session_t *z); * Returns: * ``0`` in case of success, ``-1`` in case of failure. */ -int8_t _zp_start_lease_task(_z_session_t *z, _z_task_attr_t *attr); +int8_t _zp_start_lease_task(_z_session_t *z, z_task_attr_t *attr); /** * Stop the lease task. This may result in stopping a thread or a process depending diff --git a/include/zenoh-pico/session/session.h b/include/zenoh-pico/session/session.h index ee3f1653e..3e54db985 100644 --- a/include/zenoh-pico/session/session.h +++ b/include/zenoh-pico/session/session.h @@ -172,8 +172,8 @@ _Z_LIST_DEFINE(_z_pending_query, _z_pending_query_t) typedef struct { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_t _mutex; - _z_condvar_t _cond_var; + z_mutex_t _mutex; + z_condvar_t _cond_var; #endif // Z_FEATURE_MULTI_THREAD == 1 _z_reply_data_list_t *_replies; } _z_pending_query_collect_t; diff --git a/include/zenoh-pico/system/platform.h b/include/zenoh-pico/system/platform.h index 858e63ae9..0d6d367b2 100644 --- a/include/zenoh-pico/system/platform.h +++ b/include/zenoh-pico/system/platform.h @@ -60,25 +60,25 @@ 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 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); /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m); -int8_t _z_mutex_free(_z_mutex_t *m); +int8_t z_mutex_init(z_mutex_t *m); +int8_t z_mutex_free(z_mutex_t *m); -int8_t _z_mutex_lock(_z_mutex_t *m); -int8_t _z_mutex_trylock(_z_mutex_t *m); -int8_t _z_mutex_unlock(_z_mutex_t *m); +int8_t z_mutex_lock(z_mutex_t *m); +int8_t z_mutex_trylock(z_mutex_t *m); +int8_t z_mutex_unlock(z_mutex_t *m); /*------------------ CondVar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv); -int8_t _z_condvar_free(_z_condvar_t *cv); +int8_t z_condvar_init(z_condvar_t *cv); +int8_t z_condvar_free(z_condvar_t *cv); -int8_t _z_condvar_signal(_z_condvar_t *cv); -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m); +int8_t z_condvar_signal(z_condvar_t *cv); +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m); #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/include/zenoh-pico/system/platform/arduino/esp32.h b/include/zenoh-pico/system/platform/arduino/esp32.h index 569efe46f..abdc37f67 100644 --- a/include/zenoh-pico/system/platform/arduino/esp32.h +++ b/include/zenoh-pico/system/platform/arduino/esp32.h @@ -24,10 +24,10 @@ #endif // Z_FEATURE_MULTI_THREAD == 1 #if Z_FEATURE_MULTI_THREAD == 1 -typedef TaskHandle_t _z_task_t; -typedef void *_z_task_attr_t; // Not used in ESP32 -typedef pthread_mutex_t _z_mutex_t; -typedef pthread_cond_t _z_condvar_t; +typedef TaskHandle_t z_task_t; +typedef void *z_task_attr_t; // Not used in ESP32 +typedef pthread_mutex_t z_mutex_t; +typedef pthread_cond_t z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; diff --git a/include/zenoh-pico/system/platform/arduino/opencr.h b/include/zenoh-pico/system/platform/arduino/opencr.h index 2a7488775..af16ce60b 100644 --- a/include/zenoh-pico/system/platform/arduino/opencr.h +++ b/include/zenoh-pico/system/platform/arduino/opencr.h @@ -21,10 +21,10 @@ #include "zenoh-pico/config.h" #if Z_FEATURE_MULTI_THREAD == 1 -typedef void *_z_task_t; -typedef void *_z_task_attr_t; -typedef void *_z_mutex_t; -typedef void *_z_condvar_t; +typedef void *z_task_t; +typedef void *z_task_attr_t; +typedef void *z_mutex_t; +typedef void *z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; diff --git a/include/zenoh-pico/system/platform/emscripten.h b/include/zenoh-pico/system/platform/emscripten.h index 7ceeb5f3e..b89921197 100644 --- a/include/zenoh-pico/system/platform/emscripten.h +++ b/include/zenoh-pico/system/platform/emscripten.h @@ -22,10 +22,10 @@ #if Z_FEATURE_MULTI_THREAD == 1 #include -typedef pthread_t _z_task_t; -typedef pthread_attr_t _z_task_attr_t; -typedef pthread_mutex_t _z_mutex_t; -typedef pthread_cond_t _z_condvar_t; +typedef pthread_t z_task_t; +typedef pthread_attr_t z_task_attr_t; +typedef pthread_mutex_t z_mutex_t; +typedef pthread_cond_t z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef double z_clock_t; diff --git a/include/zenoh-pico/system/platform/espidf.h b/include/zenoh-pico/system/platform/espidf.h index 1a19ccdc6..671617989 100644 --- a/include/zenoh-pico/system/platform/espidf.h +++ b/include/zenoh-pico/system/platform/espidf.h @@ -24,10 +24,10 @@ #if Z_FEATURE_MULTI_THREAD == 1 #include -typedef TaskHandle_t _z_task_t; -typedef void *_z_task_attr_t; // Not used in ESP32 -typedef pthread_mutex_t _z_mutex_t; -typedef pthread_cond_t _z_condvar_t; +typedef TaskHandle_t z_task_t; +typedef void *z_task_attr_t; // Not used in ESP32 +typedef pthread_mutex_t z_mutex_t; +typedef pthread_cond_t z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; diff --git a/include/zenoh-pico/system/platform/freertos_plus_tcp.h b/include/zenoh-pico/system/platform/freertos_plus_tcp.h index 17a7616a9..f85269dab 100644 --- a/include/zenoh-pico/system/platform/freertos_plus_tcp.h +++ b/include/zenoh-pico/system/platform/freertos_plus_tcp.h @@ -28,15 +28,15 @@ typedef struct { StackType_t *stack_buffer; StaticTask_t *task_buffer; #endif /* SUPPORT_STATIC_ALLOCATION */ -} _z_task_attr_t; +} z_task_attr_t; typedef struct { TaskHandle_t handle; EventGroupHandle_t join_event; -} _z_task_t; +} z_task_t; -typedef SemaphoreHandle_t _z_mutex_t; -typedef void *_z_condvar_t; +typedef SemaphoreHandle_t z_mutex_t; +typedef void *z_condvar_t; #endif // Z_MULTI_THREAD == 1 typedef TickType_t z_clock_t; diff --git a/include/zenoh-pico/system/platform/mbed.h b/include/zenoh-pico/system/platform/mbed.h index ba18844e8..170b230f3 100644 --- a/include/zenoh-pico/system/platform/mbed.h +++ b/include/zenoh-pico/system/platform/mbed.h @@ -23,11 +23,11 @@ typedef int _z_socket_t; #if Z_FEATURE_MULTI_THREAD == 1 -typedef void *_z_task_t; // Workaround as MBED is a C++ library -typedef void *_z_task_attr_t; // Workaround as MBED is a C++ library -typedef void *_z_mutex_t; // Workaround as MBED is a C++ library -typedef void *_z_condvar_t; // Workaround as MBED is a C++ library -#endif // Z_FEATURE_MULTI_THREAD == 1 +typedef void *z_task_t; // Workaround as MBED is a C++ library +typedef void *z_task_attr_t; // Workaround as MBED is a C++ library +typedef void *z_mutex_t; // Workaround as MBED is a C++ library +typedef void *z_condvar_t; // Workaround as MBED is a C++ library +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef void *z_clock_t; // Not defined typedef struct timeval z_time_t; diff --git a/include/zenoh-pico/system/platform/unix.h b/include/zenoh-pico/system/platform/unix.h index 615b02849..8fd10421e 100644 --- a/include/zenoh-pico/system/platform/unix.h +++ b/include/zenoh-pico/system/platform/unix.h @@ -25,10 +25,10 @@ #if Z_FEATURE_MULTI_THREAD == 1 #include -typedef pthread_t _z_task_t; -typedef pthread_attr_t _z_task_attr_t; -typedef pthread_mutex_t _z_mutex_t; -typedef pthread_cond_t _z_condvar_t; +typedef pthread_t z_task_t; +typedef pthread_attr_t z_task_attr_t; +typedef pthread_mutex_t z_mutex_t; +typedef pthread_cond_t z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; diff --git a/include/zenoh-pico/system/platform/void.h b/include/zenoh-pico/system/platform/void.h index 8bebe22f2..b6fc1dd99 100644 --- a/include/zenoh-pico/system/platform/void.h +++ b/include/zenoh-pico/system/platform/void.h @@ -18,10 +18,10 @@ #include "zenoh-pico/config.h" #if Z_FEATURE_MULTI_THREAD == 1 -typedef void *_z_task_t; -typedef void *_z_task_attr_t; -typedef void *_z_mutex_t; -typedef void *_z_condvar_t; +typedef void *z_task_t; +typedef void *z_task_attr_t; +typedef void *z_mutex_t; +typedef void *z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef void *z_clock_t; diff --git a/include/zenoh-pico/system/platform/windows.h b/include/zenoh-pico/system/platform/windows.h index f829c6a98..d003be987 100644 --- a/include/zenoh-pico/system/platform/windows.h +++ b/include/zenoh-pico/system/platform/windows.h @@ -21,10 +21,10 @@ #include "zenoh-pico/config.h" #if Z_FEATURE_MULTI_THREAD == 1 -typedef HANDLE *_z_task_t; -typedef void *_z_task_attr_t; // Not used in Windows -typedef SRWLOCK _z_mutex_t; -typedef CONDITION_VARIABLE _z_condvar_t; +typedef HANDLE *z_task_t; +typedef void *z_task_attr_t; // Not used in Windows +typedef SRWLOCK z_mutex_t; +typedef CONDITION_VARIABLE z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef LARGE_INTEGER z_clock_t; diff --git a/include/zenoh-pico/system/platform/zephyr.h b/include/zenoh-pico/system/platform/zephyr.h index c0ad3c378..da7b41997 100644 --- a/include/zenoh-pico/system/platform/zephyr.h +++ b/include/zenoh-pico/system/platform/zephyr.h @@ -31,10 +31,10 @@ #include "zenoh-pico/config.h" #if Z_FEATURE_MULTI_THREAD == 1 -typedef pthread_t _z_task_t; -typedef pthread_attr_t _z_task_attr_t; -typedef pthread_mutex_t _z_mutex_t; -typedef pthread_cond_t _z_condvar_t; +typedef pthread_t z_task_t; +typedef pthread_attr_t z_task_attr_t; +typedef pthread_mutex_t z_mutex_t; +typedef pthread_cond_t z_condvar_t; #endif // Z_FEATURE_MULTI_THREAD == 1 typedef struct timespec z_clock_t; diff --git a/include/zenoh-pico/transport/multicast/lease.h b/include/zenoh-pico/transport/multicast/lease.h index c0a545f39..628eaa088 100644 --- a/include/zenoh-pico/transport/multicast/lease.h +++ b/include/zenoh-pico/transport/multicast/lease.h @@ -23,7 +23,7 @@ int8_t _zp_multicast_stop_lease_task(_z_transport_multicast_t *ztm); void *_zp_multicast_lease_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks #if Z_FEATURE_MULTI_THREAD == 1 && (Z_FEATURE_MULTICAST_TRANSPORT == 1 || Z_FEATURE_RAWETH_TRANSPORT == 1) -int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, _z_task_attr_t *attr, _z_task_t *task); +int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, z_task_attr_t *attr, z_task_t *task); #else int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, void *attr, void *task); #endif /* Z_FEATURE_MULTI_THREAD == 1 && (Z_FEATURE_MULTICAST_TRANSPORT == 1 || Z_FEATURE_RAWETH_TRANSPORT == 1) */ diff --git a/include/zenoh-pico/transport/multicast/read.h b/include/zenoh-pico/transport/multicast/read.h index 1ac947b3a..67b046397 100644 --- a/include/zenoh-pico/transport/multicast/read.h +++ b/include/zenoh-pico/transport/multicast/read.h @@ -22,7 +22,7 @@ int8_t _zp_multicast_stop_read_task(_z_transport_t *zt); void *_zp_multicast_read_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks #if Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_MULTICAST_TRANSPORT == 1 -int8_t _zp_multicast_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task); +int8_t _zp_multicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task); #else int8_t _zp_multicast_start_read_task(_z_transport_t *zt, void *attr, void *task); #endif /* #if Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_MULTICAST_TRANSPORT == 1 */ diff --git a/include/zenoh-pico/transport/raweth/read.h b/include/zenoh-pico/transport/raweth/read.h index d35d32fce..3df0d2979 100644 --- a/include/zenoh-pico/transport/raweth/read.h +++ b/include/zenoh-pico/transport/raweth/read.h @@ -22,7 +22,7 @@ int8_t _zp_raweth_stop_read_task(_z_transport_t *zt); void *_zp_raweth_read_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks #if Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_RAWETH_TRANSPORT == 1 -int8_t _zp_raweth_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task); +int8_t _zp_raweth_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task); #else int8_t _zp_raweth_start_read_task(_z_transport_t *zt, void *attr, void *task); #endif /* Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_RAWETH_TRANSPORT == 1 */ diff --git a/include/zenoh-pico/transport/transport.h b/include/zenoh-pico/transport/transport.h index 2c2132786..4f8ba58a3 100644 --- a/include/zenoh-pico/transport/transport.h +++ b/include/zenoh-pico/transport/transport.h @@ -63,8 +63,8 @@ typedef struct { #if Z_FEATURE_MULTI_THREAD == 1 // TX and RX mutexes - _z_mutex_t _mutex_rx; - _z_mutex_t _mutex_tx; + z_mutex_t _mutex_rx; + z_mutex_t _mutex_tx; #endif // Z_FEATURE_MULTI_THREAD == 1 _z_link_t _link; @@ -88,8 +88,8 @@ typedef struct { void *_session; #if Z_FEATURE_MULTI_THREAD == 1 - _z_task_t *_read_task; - _z_task_t *_lease_task; + z_task_t *_read_task; + z_task_t *_lease_task; volatile _Bool _read_task_running; volatile _Bool _lease_task_running; #endif // Z_FEATURE_MULTI_THREAD == 1 @@ -104,11 +104,11 @@ typedef struct _z_transport_multicast_t { #if Z_FEATURE_MULTI_THREAD == 1 // TX and RX mutexes - _z_mutex_t _mutex_rx; - _z_mutex_t _mutex_tx; + z_mutex_t _mutex_rx; + z_mutex_t _mutex_tx; // Peer list mutex - _z_mutex_t _mutex_peer; + z_mutex_t _mutex_peer; #endif // Z_FEATURE_MULTI_THREAD == 1 _z_link_t _link; @@ -130,8 +130,8 @@ typedef struct _z_transport_multicast_t { _zp_f_send_tmsg _send_f; #if Z_FEATURE_MULTI_THREAD == 1 - _z_task_t *_read_task; - _z_task_t *_lease_task; + z_task_t *_read_task; + z_task_t *_lease_task; volatile _Bool _read_task_running; volatile _Bool _lease_task_running; #endif // Z_FEATURE_MULTI_THREAD == 1 diff --git a/include/zenoh-pico/transport/unicast/lease.h b/include/zenoh-pico/transport/unicast/lease.h index bd5c4bd3d..8ccad0e7b 100644 --- a/include/zenoh-pico/transport/unicast/lease.h +++ b/include/zenoh-pico/transport/unicast/lease.h @@ -22,7 +22,7 @@ int8_t _zp_unicast_stop_lease_task(_z_transport_t *zt); void *_zp_unicast_lease_task(void *ztu_arg); // The argument is void* to avoid incompatible pointer types in tasks #if Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_UNICAST_TRANSPORT == 1 -int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task); +int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task); #else int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, void *attr, void *task); #endif /* Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_UNICAST_TRANSPORT == 1 */ diff --git a/include/zenoh-pico/transport/unicast/read.h b/include/zenoh-pico/transport/unicast/read.h index 1f40b8f20..c3c17bc05 100644 --- a/include/zenoh-pico/transport/unicast/read.h +++ b/include/zenoh-pico/transport/unicast/read.h @@ -22,7 +22,7 @@ int8_t _zp_unicast_stop_read_task(_z_transport_t *zt); void *_zp_unicast_read_task(void *ztu_arg); // The argument is void* to avoid incompatible pointer types in tasks #if Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_UNICAST_TRANSPORT == 1 -int8_t _zp_unicast_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task); +int8_t _zp_unicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task); #else int8_t _zp_unicast_start_read_task(_z_transport_t *zt, void *attr, void *task); #endif /* Z_FEATURE_MULTI_THREAD == 1 && Z_FEATURE_UNICAST_TRANSPORT == 1 */ diff --git a/src/net/session.c b/src/net/session.c index b9c4c947d..4539ee989 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -179,10 +179,10 @@ int8_t _zp_send_keep_alive(_z_session_t *zn) { return _z_send_keep_alive(&zn->_t int8_t _zp_send_join(_z_session_t *zn) { return _z_send_join(&zn->_tp); } #if Z_FEATURE_MULTI_THREAD == 1 -int8_t _zp_start_read_task(_z_session_t *zn, _z_task_attr_t *attr) { +int8_t _zp_start_read_task(_z_session_t *zn, z_task_attr_t *attr) { int8_t ret = _Z_RES_OK; // Allocate task - _z_task_t *task = (_z_task_t *)z_malloc(sizeof(_z_task_t)); + z_task_t *task = (z_task_t *)z_malloc(sizeof(z_task_t)); if (task == NULL) { ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; } @@ -208,10 +208,10 @@ int8_t _zp_start_read_task(_z_session_t *zn, _z_task_attr_t *attr) { return ret; } -int8_t _zp_start_lease_task(_z_session_t *zn, _z_task_attr_t *attr) { +int8_t _zp_start_lease_task(_z_session_t *zn, z_task_attr_t *attr) { int8_t ret = _Z_RES_OK; // Allocate task - _z_task_t *task = (_z_task_t *)z_malloc(sizeof(_z_task_t)); + z_task_t *task = (z_task_t *)z_malloc(sizeof(z_task_t)); if (task == NULL) { ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; } diff --git a/src/session/query.c b/src/session/query.c index d6a7a7910..65ffeccae 100644 --- a/src/session/query.c +++ b/src/session/query.c @@ -104,13 +104,13 @@ _z_pending_query_t *__unsafe__z_get_pending_query_by_id(_z_session_t *zn, const _z_pending_query_t *_z_get_pending_query_by_id(_z_session_t *zn, const _z_zint_t id) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_t *pql = __unsafe__z_get_pending_query_by_id(zn, id); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return pql; } @@ -122,7 +122,7 @@ int8_t _z_register_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) pen_qry->_parameters); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_t *pql = __unsafe__z_get_pending_query_by_id(zn, pen_qry->_id); @@ -133,7 +133,7 @@ int8_t _z_register_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -145,7 +145,7 @@ int8_t _z_trigger_query_reply_partial(_z_session_t *zn, const _z_zint_t id, cons int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_t *pen_qry = __unsafe__z_get_pending_query_by_id(zn, id); @@ -217,7 +217,7 @@ int8_t _z_trigger_query_reply_partial(_z_session_t *zn, const _z_zint_t id, cons } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 // Trigger the user callback @@ -236,7 +236,7 @@ int8_t _z_trigger_query_reply_final(_z_session_t *zn, _z_zint_t id) { int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 // Final reply received for unknown query id @@ -262,7 +262,7 @@ int8_t _z_trigger_query_reply_final(_z_session_t *zn, _z_zint_t id) { } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -270,25 +270,25 @@ int8_t _z_trigger_query_reply_final(_z_session_t *zn, _z_zint_t id) { void _z_unregister_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 zn->_pending_queries = _z_pending_query_list_drop_filter(zn->_pending_queries, _z_pending_query_eq, pen_qry); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_pending_queries(_z_session_t *zn) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_pending_query_list_free(&zn->_pending_queries); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } #endif \ No newline at end of file diff --git a/src/session/queryable.c b/src/session/queryable.c index 243519b69..b75081777 100644 --- a/src/session/queryable.c +++ b/src/session/queryable.c @@ -91,13 +91,13 @@ _z_questionable_sptr_list_t *__unsafe_z_get_questionable_by_key(_z_session_t *zn _z_questionable_sptr_t *_z_get_questionable_by_id(_z_session_t *zn, const _z_zint_t id) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_questionable_sptr_t *qle = __unsafe_z_get_questionable_by_id(zn, id); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return qle; @@ -105,14 +105,14 @@ _z_questionable_sptr_t *_z_get_questionable_by_id(_z_session_t *zn, const _z_zin _z_questionable_sptr_list_t *_z_get_questionable_by_key(_z_session_t *zn, const _z_keyexpr_t *keyexpr) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, keyexpr); _z_questionable_sptr_list_t *qles = __unsafe_z_get_questionable_by_key(zn, key); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return qles; @@ -123,7 +123,7 @@ _z_questionable_sptr_t *_z_register_questionable(_z_session_t *zn, _z_questionab _z_questionable_sptr_t *ret = NULL; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 ret = (_z_questionable_sptr_t *)z_malloc(sizeof(_z_questionable_sptr_t)); @@ -133,7 +133,7 @@ _z_questionable_sptr_t *_z_register_questionable(_z_session_t *zn, _z_questionab } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -143,7 +143,7 @@ int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, cons int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, &q_key); @@ -151,7 +151,7 @@ int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, cons _z_questionable_sptr_list_t *qles = __unsafe_z_get_questionable_by_key(zn, key); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 // Build the query @@ -192,7 +192,7 @@ int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, cons _z_msg_clear(&z_msg); } else { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 ret = _Z_ERR_KEYEXPR_UNKNOWN; @@ -203,26 +203,26 @@ int8_t _z_trigger_queryables(_z_session_t *zn, const _z_msg_query_t *query, cons void _z_unregister_questionable(_z_session_t *zn, _z_questionable_sptr_t *qle) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 zn->_local_questionable = _z_questionable_sptr_list_drop_filter(zn->_local_questionable, _z_questionable_sptr_eq, qle); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_questionables(_z_session_t *zn) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_questionable_sptr_list_free(&zn->_local_questionable); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/session/resource.c b/src/session/resource.c index 8a36ef951..d6c0f1ef8 100644 --- a/src/session/resource.c +++ b/src/session/resource.c @@ -175,13 +175,13 @@ _z_keyexpr_t __unsafe_z_get_expanded_key_from_key(_z_session_t *zn, const _z_key _z_resource_t *_z_get_resource_by_id(_z_session_t *zn, uint16_t mapping, _z_zint_t rid) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_t *res = __unsafe_z_get_resource_by_id(zn, mapping, rid); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return res; @@ -192,13 +192,13 @@ _z_resource_t *_z_get_resource_by_key(_z_session_t *zn, const _z_keyexpr_t *keye return _z_get_resource_by_id(zn, _z_keyexpr_mapping_id(keyexpr), keyexpr->_id); } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_t *res = __unsafe_z_get_resource_by_key(zn, keyexpr); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return res; @@ -206,12 +206,12 @@ _z_resource_t *_z_get_resource_by_key(_z_session_t *zn, const _z_keyexpr_t *keye _z_keyexpr_t _z_get_expanded_key_from_key(_z_session_t *zn, const _z_keyexpr_t *keyexpr) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_keyexpr_t res = __unsafe_z_get_expanded_key_from_key(zn, keyexpr); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return res; @@ -225,7 +225,7 @@ int16_t _z_register_resource(_z_session_t *zn, _z_keyexpr_t key, uint16_t id, ui uint16_t parent_mapping = _z_keyexpr_mapping_id(&key); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 if (key._id != Z_RESOURCE_ID_NONE) { @@ -256,7 +256,7 @@ int16_t _z_register_resource(_z_session_t *zn, _z_keyexpr_t key, uint16_t id, ui } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -266,7 +266,7 @@ void _z_unregister_resource(_z_session_t *zn, uint16_t id, uint16_t mapping) { _Bool is_local = mapping == _Z_KEYEXPR_MAPPING_LOCAL; _Z_DEBUG("unregistering: id %d, mapping: %d\n", id, mapping); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_list_t **parent_mut = is_local ? &zn->_local_resources : &zn->_remote_resources; while (id != 0) { @@ -290,7 +290,7 @@ void _z_unregister_resource(_z_session_t *zn, uint16_t id, uint16_t mapping) { } } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } @@ -300,26 +300,26 @@ _Bool _z_unregister_resource_for_peer_filter(const _z_resource_t *candidate, con } void _z_unregister_resources_for_peer(_z_session_t *zn, uint16_t mapping) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_t ctx = {._id = mapping, ._refcount = 0, ._key = {0}}; zn->_remote_resources = _z_resource_list_drop_filter(zn->_remote_resources, _z_unregister_resource_for_peer_filter, &ctx); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_resources(_z_session_t *zn) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_resource_list_free(&zn->_local_resources); _z_resource_list_free(&zn->_remote_resources); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/session/subscription.c b/src/session/subscription.c index fbb52e6b0..cfe66da32 100644 --- a/src/session/subscription.c +++ b/src/session/subscription.c @@ -98,13 +98,13 @@ _z_subscription_sptr_list_t *__unsafe_z_get_subscriptions_by_key(_z_session_t *z _z_subscription_sptr_t *_z_get_subscription_by_id(_z_session_t *zn, uint8_t is_local, const _z_zint_t id) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_t *sub = __unsafe_z_get_subscription_by_id(zn, is_local, id); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return sub; @@ -112,13 +112,13 @@ _z_subscription_sptr_t *_z_get_subscription_by_id(_z_session_t *zn, uint8_t is_l _z_subscription_sptr_list_t *_z_get_subscriptions_by_key(_z_session_t *zn, uint8_t is_local, const _z_keyexpr_t *key) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, is_local, *key); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return subs; @@ -129,7 +129,7 @@ _z_subscription_sptr_t *_z_register_subscription(_z_session_t *zn, uint8_t is_lo _z_subscription_sptr_t *ret = NULL; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, is_local, s->_key); @@ -146,7 +146,7 @@ _z_subscription_sptr_t *_z_register_subscription(_z_session_t *zn, uint8_t is_lo } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -157,7 +157,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _Z_DEBUG("Resolving %d - %s on mapping 0x%x\n", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); @@ -167,7 +167,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, _Z_RESOURCE_IS_LOCAL, key); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 // Build the sample @@ -189,7 +189,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co _z_subscription_sptr_list_free(&subs); } else { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 ret = _Z_ERR_KEYEXPR_UNKNOWN; } @@ -199,7 +199,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co void _z_unregister_subscription(_z_session_t *zn, uint8_t is_local, _z_subscription_sptr_t *sub) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 if (is_local == _Z_RESOURCE_IS_LOCAL) { @@ -211,20 +211,20 @@ void _z_unregister_subscription(_z_session_t *zn, uint8_t is_local, _z_subscript } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } void _z_flush_subscriptions(_z_session_t *zn) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&zn->_mutex_inner); + z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_subscription_sptr_list_free(&zn->_local_subscriptions); _z_subscription_sptr_list_free(&zn->_remote_subscriptions); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&zn->_mutex_inner); + z_mutex_unlock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } #endif \ No newline at end of file diff --git a/src/session/utils.c b/src/session/utils.c index 32b685b78..427ea5072 100644 --- a/src/session/utils.c +++ b/src/session/utils.c @@ -73,7 +73,7 @@ int8_t _z_session_init(_z_session_t *zn, _z_id_t *zid) { #endif #if Z_FEATURE_MULTI_THREAD == 1 - ret = _z_mutex_init(&zn->_mutex_inner); + ret = z_mutex_init(&zn->_mutex_inner); if (ret != _Z_RES_OK) { _z_transport_clear(&zn->_tp); return ret; @@ -117,7 +117,7 @@ void _z_session_clear(_z_session_t *zn) { #endif #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_free(&zn->_mutex_inner); + z_mutex_free(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/system/arduino/esp32/system.c b/src/system/arduino/esp32/system.c index 8f0773751..238b06de1 100644 --- a/src/system/arduino/esp32/system.c +++ b/src/system/arduino/esp32/system.c @@ -51,19 +51,19 @@ void z_free(void *ptr) { heap_caps_free(ptr); } typedef struct { void *(*_fun)(void *); void *_arg; -} __z_task_arg; +} z_task_arg; -void z_task_wrapper(__z_task_arg *targ) { +void z_task_wrapper(z_task_arg *targ) { targ->_fun(targ->_arg); vTaskDelete(NULL); z_free(targ); } /*------------------ Task ------------------*/ -int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t z_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)); + z_task_arg *z_arg = (z_task_arg *)z_malloc(sizeof(z_task_arg)); if (z_arg != NULL) { z_arg->_fun = fun; z_arg->_arg = arg; @@ -77,41 +77,41 @@ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), return ret; } -int8_t _z_task_join(_z_task_t *task) { +int8_t z_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 z_task_cancel(task); } -int8_t _z_task_cancel(_z_task_t *task) { +int8_t z_task_cancel(z_task_t *task) { vTaskDelete(*task); return 0; } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, NULL); } +int8_t z_mutex_init(z_mutex_t *m) { return pthread_mutex_init(m, NULL); } -int8_t _z_mutex_free(_z_mutex_t *m) { return pthread_mutex_destroy(m); } +int8_t z_mutex_free(z_mutex_t *m) { return pthread_mutex_destroy(m); } -int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); } +int8_t z_mutex_lock(z_mutex_t *m) { return pthread_mutex_lock(m); } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return pthread_mutex_trylock(m); } +int8_t z_mutex_trylock(z_mutex_t *m) { return pthread_mutex_trylock(m); } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return pthread_mutex_unlock(m); } +int8_t z_mutex_unlock(z_mutex_t *m) { return pthread_mutex_unlock(m); } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return pthread_cond_init(cv, NULL); } +int8_t z_condvar_init(z_condvar_t *cv) { return pthread_cond_init(cv, NULL); } -int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } +int8_t z_condvar_free(z_condvar_t *cv) { return pthread_cond_destroy(cv); } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } +int8_t z_condvar_signal(z_condvar_t *cv) { return pthread_cond_signal(cv); } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return pthread_cond_wait(cv, m); } #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/system/arduino/opencr/system.c b/src/system/arduino/opencr/system.c index 9ad314b5c..0d6dfc059 100644 --- a/src/system/arduino/opencr/system.c +++ b/src/system/arduino/opencr/system.c @@ -63,37 +63,37 @@ 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 z_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 z_task_join(z_task_t *task) { return -1; } -int8_t _z_task_cancel(_z_task_t *task) { return -1; } +int8_t z_task_cancel(z_task_t *task) { return -1; } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { return -1; } +int8_t z_mutex_init(z_mutex_t *m) { return -1; } -int8_t _z_mutex_free(_z_mutex_t *m) { return -1; } +int8_t z_mutex_free(z_mutex_t *m) { return -1; } -int8_t _z_mutex_lock(_z_mutex_t *m) { return -1; } +int8_t z_mutex_lock(z_mutex_t *m) { return -1; } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return -1; } +int8_t z_mutex_trylock(z_mutex_t *m) { return -1; } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return -1; } +int8_t z_mutex_unlock(z_mutex_t *m) { return -1; } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return -1; } +int8_t z_condvar_init(z_condvar_t *cv) { return -1; } -int8_t _z_condvar_free(_z_condvar_t *cv) { return -1; } +int8_t z_condvar_free(z_condvar_t *cv) { return -1; } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return -1; } +int8_t z_condvar_signal(z_condvar_t *cv) { return -1; } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return -1; } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return -1; } #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/system/emscripten/system.c b/src/system/emscripten/system.c index 0654898b3..99dbbf065 100644 --- a/src/system/emscripten/system.c +++ b/src/system/emscripten/system.c @@ -44,39 +44,39 @@ 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 z_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 z_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 z_task_cancel(z_task_t *task) { return pthread_cancel(*task); } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, 0); } +int8_t z_mutex_init(z_mutex_t *m) { return pthread_mutex_init(m, 0); } -int8_t _z_mutex_free(_z_mutex_t *m) { return pthread_mutex_destroy(m); } +int8_t z_mutex_free(z_mutex_t *m) { return pthread_mutex_destroy(m); } -int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); } +int8_t z_mutex_lock(z_mutex_t *m) { return pthread_mutex_lock(m); } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return pthread_mutex_trylock(m); } +int8_t z_mutex_trylock(z_mutex_t *m) { return pthread_mutex_trylock(m); } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return pthread_mutex_unlock(m); } +int8_t z_mutex_unlock(z_mutex_t *m) { return pthread_mutex_unlock(m); } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return pthread_cond_init(cv, 0); } +int8_t z_condvar_init(z_condvar_t *cv) { return pthread_cond_init(cv, 0); } -int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } +int8_t z_condvar_free(z_condvar_t *cv) { return pthread_cond_destroy(cv); } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } +int8_t z_condvar_signal(z_condvar_t *cv) { return pthread_cond_signal(cv); } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return pthread_cond_wait(cv, m); } #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/system/espidf/system.c b/src/system/espidf/system.c index a93c5b0e5..a1cdd3a2a 100644 --- a/src/system/espidf/system.c +++ b/src/system/espidf/system.c @@ -52,19 +52,19 @@ void z_free(void *ptr) { heap_caps_free(ptr); } typedef struct { void *(*_fun)(void *); void *_arg; -} __z_task_arg; +} z_task_arg; -void z_task_wrapper(__z_task_arg *targ) { +void z_task_wrapper(z_task_arg *targ) { targ->_fun(targ->_arg); vTaskDelete(NULL); z_free(targ); } /*------------------ Task ------------------*/ -int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), void *arg) { +int8_t z_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)); + z_task_arg *z_arg = (z_task_arg *)z_malloc(sizeof(z_task_arg)); if (z_arg != NULL) { z_arg->_fun = fun; z_arg->_arg = arg; @@ -78,41 +78,41 @@ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), return ret; } -int8_t _z_task_join(_z_task_t *task) { +int8_t z_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 z_task_cancel(task); } -int8_t _z_task_cancel(_z_task_t *task) { +int8_t z_task_cancel(z_task_t *task) { vTaskDelete(*task); return 0; } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, NULL); } +int8_t z_mutex_init(z_mutex_t *m) { return pthread_mutex_init(m, NULL); } -int8_t _z_mutex_free(_z_mutex_t *m) { return pthread_mutex_destroy(m); } +int8_t z_mutex_free(z_mutex_t *m) { return pthread_mutex_destroy(m); } -int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); } +int8_t z_mutex_lock(z_mutex_t *m) { return pthread_mutex_lock(m); } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return pthread_mutex_trylock(m); } +int8_t z_mutex_trylock(z_mutex_t *m) { return pthread_mutex_trylock(m); } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return pthread_mutex_unlock(m); } +int8_t z_mutex_unlock(z_mutex_t *m) { return pthread_mutex_unlock(m); } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return pthread_cond_init(cv, NULL); } +int8_t z_condvar_init(z_condvar_t *cv) { return pthread_cond_init(cv, NULL); } -int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } +int8_t z_condvar_free(z_condvar_t *cv) { return pthread_cond_destroy(cv); } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } +int8_t z_condvar_signal(z_condvar_t *cv) { return pthread_cond_signal(cv); } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return pthread_cond_wait(cv, m); } #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/system/freertos_plus_tcp/system.c b/src/system/freertos_plus_tcp/system.c index 7df351c41..9a64b987f 100644 --- a/src/system/freertos_plus_tcp/system.c +++ b/src/system/freertos_plus_tcp/system.c @@ -64,16 +64,16 @@ typedef struct { void *(*fun)(void *); void *arg; EventGroupHandle_t join_event; -} __z_task_arg; +} z_task_arg; static void z_task_wrapper(void *arg) { - __z_task_arg *targ = (__z_task_arg *)arg; + z_task_arg *targ = (z_task_arg *)arg; targ->fun(targ->arg); xEventGroupSetBits(targ->join_event, 1); vTaskDelete(NULL); } -static _z_task_attr_t z_default_task_attr = { +static z_task_attr_t z_default_task_attr = { .name = "", .priority = configMAX_PRIORITIES / 2, .stack_depth = 5120, @@ -85,8 +85,8 @@ 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) { - __z_task_arg *z_arg = (__z_task_arg *)z_malloc(sizeof(__z_task_arg)); +int8_t z_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,44 +119,44 @@ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), return 0; } -int8_t _z_task_join(_z_task_t *task) { +int8_t z_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 z_task_cancel(z_task_t *task) { vTaskDelete(task->handle); return 0; } -void _z_task_free(_z_task_t **task) { +void z_task_free(z_task_t **task) { z_free((*task)->join_event); z_free(*task); } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { +int8_t z_mutex_init(z_mutex_t *m) { *m = xSemaphoreCreateRecursiveMutex(); return *m == NULL ? -1 : 0; } -int8_t _z_mutex_free(_z_mutex_t *m) { +int8_t z_mutex_free(z_mutex_t *m) { z_free(*m); return 0; } -int8_t _z_mutex_lock(_z_mutex_t *m) { return xSemaphoreTakeRecursive(*m, portMAX_DELAY) == pdTRUE ? 0 : -1; } +int8_t z_mutex_lock(z_mutex_t *m) { return xSemaphoreTakeRecursive(*m, portMAX_DELAY) == pdTRUE ? 0 : -1; } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return xSemaphoreTakeRecursive(*m, 0) == pdTRUE ? 0 : -1; } +int8_t z_mutex_trylock(z_mutex_t *m) { return xSemaphoreTakeRecursive(*m, 0) == pdTRUE ? 0 : -1; } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return xSemaphoreGiveRecursive(*m) == pdTRUE ? 0 : -1; } +int8_t z_mutex_unlock(z_mutex_t *m) { return xSemaphoreGiveRecursive(*m) == pdTRUE ? 0 : -1; } /*------------------ CondVar ------------------*/ // Condition variables not supported in FreeRTOS -int8_t _z_condvar_init(_z_condvar_t *cv) { return -1; } -int8_t _z_condvar_free(_z_condvar_t *cv) { return -1; } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return -1; } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return -1; } +int8_t z_condvar_init(z_condvar_t *cv) { return -1; } +int8_t z_condvar_free(z_condvar_t *cv) { return -1; } +int8_t z_condvar_signal(z_condvar_t *cv) { return -1; } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return -1; } #endif // Z_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/system/mbed/system.cpp b/src/system/mbed/system.cpp index 2adeec297..f1df2ffbd 100644 --- a/src/system/mbed/system.cpp +++ b/src/system/mbed/system.cpp @@ -41,67 +41,67 @@ 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 z_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 z_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 z_task_cancel(z_task_t *task) { int res = ((Thread *)*task)->terminate(); delete ((Thread *)*task); return res; } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { +int8_t z_mutex_init(z_mutex_t *m) { *m = new Mutex(); return 0; } -int8_t _z_mutex_free(_z_mutex_t *m) { +int8_t z_mutex_free(z_mutex_t *m) { delete ((Mutex *)*m); return 0; } -int8_t _z_mutex_lock(_z_mutex_t *m) { +int8_t z_mutex_lock(z_mutex_t *m) { ((Mutex *)*m)->lock(); return 0; } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return (((Mutex *)*m)->trylock() == true) ? 0 : -1; } +int8_t z_mutex_trylock(z_mutex_t *m) { return (((Mutex *)*m)->trylock() == true) ? 0 : -1; } -int8_t _z_mutex_unlock(_z_mutex_t *m) { +int8_t z_mutex_unlock(z_mutex_t *m) { ((Mutex *)*m)->unlock(); return 0; } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return 0; } +int8_t z_condvar_init(z_condvar_t *cv) { return 0; } -int8_t _z_condvar_free(_z_condvar_t *cv) { +int8_t z_condvar_free(z_condvar_t *cv) { delete ((ConditionVariable *)*cv); return 0; } -int8_t _z_condvar_signal(_z_condvar_t *cv) { +int8_t z_condvar_signal(z_condvar_t *cv) { ((ConditionVariable *)*cv)->notify_all(); return 0; } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { *cv = new ConditionVariable(*((Mutex *)*m)); ((ConditionVariable *)*cv)->wait(); return 0; diff --git a/src/system/unix/system.c b/src/system/unix/system.c index 28223b83f..c1635bae4 100644 --- a/src/system/unix/system.c +++ b/src/system/unix/system.c @@ -101,39 +101,39 @@ 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 z_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 z_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 z_task_cancel(z_task_t *task) { return pthread_cancel(*task); } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, 0); } +int8_t z_mutex_init(z_mutex_t *m) { return pthread_mutex_init(m, 0); } -int8_t _z_mutex_free(_z_mutex_t *m) { return pthread_mutex_destroy(m); } +int8_t z_mutex_free(z_mutex_t *m) { return pthread_mutex_destroy(m); } -int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); } +int8_t z_mutex_lock(z_mutex_t *m) { return pthread_mutex_lock(m); } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return pthread_mutex_trylock(m); } +int8_t z_mutex_trylock(z_mutex_t *m) { return pthread_mutex_trylock(m); } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return pthread_mutex_unlock(m); } +int8_t z_mutex_unlock(z_mutex_t *m) { return pthread_mutex_unlock(m); } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return pthread_cond_init(cv, 0); } +int8_t z_condvar_init(z_condvar_t *cv) { return pthread_cond_init(cv, 0); } -int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } +int8_t z_condvar_free(z_condvar_t *cv) { return pthread_cond_destroy(cv); } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } +int8_t z_condvar_signal(z_condvar_t *cv) { return pthread_cond_signal(cv); } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return pthread_cond_wait(cv, m); } #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/system/windows/system.c b/src/system/windows/system.c index 47eca4206..13c1af220 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 z_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,45 +70,45 @@ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), return ret; } -int8_t _z_task_join(_z_task_t *task) { +int8_t z_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 z_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) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; CloseHandle(*ptr); z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { +int8_t z_mutex_init(z_mutex_t *m) { int8_t ret = _Z_RES_OK; InitializeSRWLock(m); return ret; } -int8_t _z_mutex_free(_z_mutex_t *m) { +int8_t z_mutex_free(z_mutex_t *m) { (void)(m); int8_t ret = _Z_RES_OK; return ret; } -int8_t _z_mutex_lock(_z_mutex_t *m) { +int8_t z_mutex_lock(z_mutex_t *m) { int8_t ret = _Z_RES_OK; AcquireSRWLockExclusive(m); return ret; } -int8_t _z_mutex_trylock(_z_mutex_t *m) { +int8_t z_mutex_trylock(z_mutex_t *m) { int8_t ret = _Z_RES_OK; if (TryAcquireSRWLockExclusive(m) == 0) { ret = _Z_ERR_GENERIC; @@ -116,32 +116,32 @@ int8_t _z_mutex_trylock(_z_mutex_t *m) { return ret; } -int8_t _z_mutex_unlock(_z_mutex_t *m) { +int8_t z_mutex_unlock(z_mutex_t *m) { int8_t ret = _Z_RES_OK; ReleaseSRWLockExclusive(m); return ret; } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { +int8_t z_condvar_init(z_condvar_t *cv) { int8_t ret = _Z_RES_OK; InitializeConditionVariable(cv); return ret; } -int8_t _z_condvar_free(_z_condvar_t *cv) { +int8_t z_condvar_free(z_condvar_t *cv) { (void)(cv); int8_t ret = _Z_RES_OK; return ret; } -int8_t _z_condvar_signal(_z_condvar_t *cv) { +int8_t z_condvar_signal(z_condvar_t *cv) { int8_t ret = _Z_RES_OK; WakeConditionVariable(cv); return ret; } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { int8_t ret = _Z_RES_OK; SleepConditionVariableSRW(cv, m, INFINITE, 0); return ret; diff --git a/src/system/zephyr/system.c b/src/system/zephyr/system.c index 93f9fd5f0..539bcb8cb 100644 --- a/src/system/zephyr/system.c +++ b/src/system/zephyr/system.c @@ -71,9 +71,9 @@ 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) { - _z_task_attr_t *lattr = NULL; - _z_task_attr_t tmp; +int8_t z_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) { (void)pthread_attr_init(&tmp); (void)pthread_attr_setstack(&tmp, &thread_stack_area[thread_index++], Z_PTHREAD_STACK_SIZE_DEFAULT); @@ -83,35 +83,35 @@ int8_t _z_task_init(_z_task_t *task, _z_task_attr_t *attr, void *(*fun)(void *), return pthread_create(task, lattr, fun, arg); } -int8_t _z_task_join(_z_task_t *task) { return pthread_join(*task, NULL); } +int8_t z_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 z_task_cancel(z_task_t *task) { return pthread_cancel(*task); } -void _z_task_free(_z_task_t **task) { - _z_task_t *ptr = *task; +void z_task_free(z_task_t **task) { + z_task_t *ptr = *task; z_free(ptr); *task = NULL; } /*------------------ Mutex ------------------*/ -int8_t _z_mutex_init(_z_mutex_t *m) { return pthread_mutex_init(m, 0); } +int8_t z_mutex_init(z_mutex_t *m) { return pthread_mutex_init(m, 0); } -int8_t _z_mutex_free(_z_mutex_t *m) { return pthread_mutex_destroy(m); } +int8_t z_mutex_free(z_mutex_t *m) { return pthread_mutex_destroy(m); } -int8_t _z_mutex_lock(_z_mutex_t *m) { return pthread_mutex_lock(m); } +int8_t z_mutex_lock(z_mutex_t *m) { return pthread_mutex_lock(m); } -int8_t _z_mutex_trylock(_z_mutex_t *m) { return pthread_mutex_trylock(m); } +int8_t z_mutex_trylock(z_mutex_t *m) { return pthread_mutex_trylock(m); } -int8_t _z_mutex_unlock(_z_mutex_t *m) { return pthread_mutex_unlock(m); } +int8_t z_mutex_unlock(z_mutex_t *m) { return pthread_mutex_unlock(m); } /*------------------ Condvar ------------------*/ -int8_t _z_condvar_init(_z_condvar_t *cv) { return pthread_cond_init(cv, 0); } +int8_t z_condvar_init(z_condvar_t *cv) { return pthread_cond_init(cv, 0); } -int8_t _z_condvar_free(_z_condvar_t *cv) { return pthread_cond_destroy(cv); } +int8_t z_condvar_free(z_condvar_t *cv) { return pthread_cond_destroy(cv); } -int8_t _z_condvar_signal(_z_condvar_t *cv) { return pthread_cond_signal(cv); } +int8_t z_condvar_signal(z_condvar_t *cv) { return pthread_cond_signal(cv); } -int8_t _z_condvar_wait(_z_condvar_t *cv, _z_mutex_t *m) { return pthread_cond_wait(cv, m); } +int8_t z_condvar_wait(z_condvar_t *cv, z_mutex_t *m) { return pthread_cond_wait(cv, m); } #endif // Z_FEATURE_MULTI_THREAD == 1 /*------------------ Sleep ------------------*/ diff --git a/src/transport/multicast/lease.c b/src/transport/multicast/lease.c index 2d3a0d496..a6f11c721 100644 --- a/src/transport/multicast/lease.c +++ b/src/transport/multicast/lease.c @@ -99,7 +99,7 @@ void *_zp_multicast_lease_task(void *ztm_arg) { _z_transport_peer_entry_list_t *it = NULL; while (ztm->_lease_task_running == true) { - _z_mutex_lock(&ztm->_mutex_peer); + z_mutex_lock(&ztm->_mutex_peer); if (next_lease <= 0) { it = ztm->_peers; @@ -158,13 +158,13 @@ void *_zp_multicast_lease_task(void *ztm_arg) { } } - _z_mutex_unlock(&ztm->_mutex_peer); + z_mutex_unlock(&ztm->_mutex_peer); // The keep alive and lease intervals are expressed in milliseconds z_sleep_ms(interval); // Decrement all intervals - _z_mutex_lock(&ztm->_mutex_peer); + z_mutex_lock(&ztm->_mutex_peer); it = ztm->_peers; while (it != NULL) { @@ -176,14 +176,14 @@ void *_zp_multicast_lease_task(void *ztm_arg) { next_keep_alive = next_keep_alive - interval; next_join = next_join - interval; - _z_mutex_unlock(&ztm->_mutex_peer); + z_mutex_unlock(&ztm->_mutex_peer); } return 0; } -int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, _z_task_attr_t *attr, _z_task_t *task) { +int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, z_task_attr_t *attr, z_task_t *task) { // Init memory - (void)memset(task, 0, sizeof(_z_task_t)); + (void)memset(task, 0, sizeof(z_task_t)); // Init task if (_z_task_init(task, attr, _zp_multicast_lease_task, ztm) != _Z_RES_OK) { return _Z_ERR_SYSTEM_TASK_FAILED; diff --git a/src/transport/multicast/read.c b/src/transport/multicast/read.c index 6d50f580d..8fe5e4d80 100644 --- a/src/transport/multicast/read.c +++ b/src/transport/multicast/read.c @@ -51,7 +51,7 @@ void *_zp_multicast_read_task(void *ztm_arg) { _z_transport_multicast_t *ztm = (_z_transport_multicast_t *)ztm_arg; // Acquire and keep the lock - _z_mutex_lock(&ztm->_mutex_rx); + z_mutex_lock(&ztm->_mutex_rx); // Prepare the buffer _z_zbuf_reset(&ztm->_zbuf); @@ -124,13 +124,13 @@ void *_zp_multicast_read_task(void *ztm_arg) { // Move the read position of the read buffer _z_zbuf_set_rpos(&ztm->_zbuf, _z_zbuf_get_rpos(&ztm->_zbuf) + to_read); } - _z_mutex_unlock(&ztm->_mutex_rx); + z_mutex_unlock(&ztm->_mutex_rx); return NULL; } -int8_t _zp_multicast_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task) { +int8_t _zp_multicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) { // Init memory - (void)memset(task, 0, sizeof(_z_task_t)); + (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) { return _Z_ERR_SYSTEM_TASK_FAILED; diff --git a/src/transport/multicast/rx.c b/src/transport/multicast/rx.c index cb8fdeeb7..c92bfa593 100644 --- a/src/transport/multicast/rx.c +++ b/src/transport/multicast/rx.c @@ -35,7 +35,7 @@ static int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_trans #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock - _z_mutex_lock(&ztm->_mutex_rx); + z_mutex_lock(&ztm->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 size_t to_read = 0; @@ -82,7 +82,7 @@ static int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_trans } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_rx); + z_mutex_unlock(&ztm->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -125,7 +125,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 // Acquire and keep the lock - _z_mutex_lock(&ztm->_mutex_peer); + z_mutex_lock(&ztm->_mutex_peer); #endif // Z_FEATURE_MULTI_THREAD == 1 // Mark the session that we have received data from this peer @@ -327,7 +327,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_peer); + z_mutex_unlock(&ztm->_mutex_peer); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; diff --git a/src/transport/multicast/transport.c b/src/transport/multicast/transport.c index 2e5796399..72a83069f 100644 --- a/src/transport/multicast/transport.c +++ b/src/transport/multicast/transport.c @@ -52,17 +52,17 @@ int8_t _z_multicast_transport_create(_z_transport_t *zt, _z_link_t *zl, } #if Z_FEATURE_MULTI_THREAD == 1 // Initialize the mutexes - ret = _z_mutex_init(&ztm->_mutex_tx); + ret = z_mutex_init(&ztm->_mutex_tx); if (ret == _Z_RES_OK) { - ret = _z_mutex_init(&ztm->_mutex_rx); + ret = z_mutex_init(&ztm->_mutex_rx); if (ret == _Z_RES_OK) { - ret = _z_mutex_init(&ztm->_mutex_peer); + ret = z_mutex_init(&ztm->_mutex_peer); if (ret != _Z_RES_OK) { - _z_mutex_free(&ztm->_mutex_tx); - _z_mutex_free(&ztm->_mutex_rx); + z_mutex_free(&ztm->_mutex_tx); + z_mutex_free(&ztm->_mutex_rx); } } else { - _z_mutex_free(&ztm->_mutex_tx); + z_mutex_free(&ztm->_mutex_tx); } } #endif // Z_FEATURE_MULTI_THREAD == 1 @@ -78,9 +78,9 @@ int8_t _z_multicast_transport_create(_z_transport_t *zt, _z_link_t *zl, ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_free(&ztm->_mutex_tx); - _z_mutex_free(&ztm->_mutex_rx); - _z_mutex_free(&ztm->_mutex_peer); + z_mutex_free(&ztm->_mutex_tx); + z_mutex_free(&ztm->_mutex_rx); + z_mutex_free(&ztm->_mutex_peer); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_wbuf_clear(&ztm->_wbuf); @@ -183,17 +183,17 @@ 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); + z_task_join(ztm->_read_task); + z_task_free(&ztm->_read_task); } if (ztm->_lease_task != NULL) { - _z_task_join(ztm->_lease_task); - _z_task_free(&ztm->_lease_task); + z_task_join(ztm->_lease_task); + z_task_free(&ztm->_lease_task); } // Clean up the mutexes - _z_mutex_free(&ztm->_mutex_tx); - _z_mutex_free(&ztm->_mutex_rx); - _z_mutex_free(&ztm->_mutex_peer); + z_mutex_free(&ztm->_mutex_tx); + z_mutex_free(&ztm->_mutex_rx); + z_mutex_free(&ztm->_mutex_peer); #endif // Z_FEATURE_MULTI_THREAD == 1 // Clean up the buffers diff --git a/src/transport/multicast/tx.c b/src/transport/multicast/tx.c index 4b2d77c6c..9d1375957 100644 --- a/src/transport/multicast/tx.c +++ b/src/transport/multicast/tx.c @@ -46,7 +46,7 @@ int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock - _z_mutex_lock(&ztm->_mutex_tx); + z_mutex_lock(&ztm->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 // Prepare the buffer eventually reserving space for the message length @@ -65,7 +65,7 @@ int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_tx); + z_mutex_unlock(&ztm->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -82,11 +82,11 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m _Bool drop = false; if (cong_ctrl == Z_CONGESTION_CONTROL_BLOCK) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&ztm->_mutex_tx); + z_mutex_lock(&ztm->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 } else { #if Z_FEATURE_MULTI_THREAD == 1 - int8_t locked = _z_mutex_trylock(&ztm->_mutex_tx); + int8_t locked = z_mutex_trylock(&ztm->_mutex_tx); if (locked != (int8_t)0) { _Z_INFO("Dropping zenoh message because of congestion control\n"); // We failed to acquire the lock, drop the message @@ -150,7 +150,7 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_tx); + z_mutex_unlock(&ztm->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 } diff --git a/src/transport/raweth/read.c b/src/transport/raweth/read.c index 11cb7141a..d9328e7e0 100644 --- a/src/transport/raweth/read.c +++ b/src/transport/raweth/read.c @@ -83,9 +83,9 @@ void *_zp_raweth_read_task(void *ztm_arg) { return NULL; } -int8_t _zp_raweth_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task) { +int8_t _zp_raweth_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) { // Init memory - (void)memset(task, 0, sizeof(_z_task_t)); + (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) { return _Z_ERR_SYSTEM_TASK_FAILED; diff --git a/src/transport/raweth/rx.c b/src/transport/raweth/rx.c index 6deec0839..f899af76d 100644 --- a/src/transport/raweth/rx.c +++ b/src/transport/raweth/rx.c @@ -78,7 +78,7 @@ int8_t _z_raweth_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_messa #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock - _z_mutex_lock(&ztm->_mutex_rx); + z_mutex_lock(&ztm->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 // Prepare the buffer @@ -106,7 +106,7 @@ int8_t _z_raweth_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_messa } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_rx); + z_mutex_unlock(&ztm->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; diff --git a/src/transport/raweth/tx.c b/src/transport/raweth/tx.c index 80d96f7b6..9c792c776 100644 --- a/src/transport/raweth/tx.c +++ b/src/transport/raweth/tx.c @@ -32,7 +32,7 @@ #if Z_FEATURE_RAWETH_TRANSPORT == 1 #if Z_FEATURE_MULTI_THREAD == 1 -static void _zp_raweth_unlock_tx_mutex(_z_transport_multicast_t *ztm) { _z_mutex_unlock(&ztm->_mutex_tx); } +static void _zp_raweth_unlock_tx_mutex(_z_transport_multicast_t *ztm) { z_mutex_unlock(&ztm->_mutex_tx); } #else static void _zp_raweth_unlock_tx_mutex(_z_transport_multicast_t *ztm) { _ZP_UNUSED(ztm); } #endif @@ -195,7 +195,7 @@ int8_t _z_raweth_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_me _Z_DEBUG(">> send session message\n"); #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&ztm->_mutex_tx); + z_mutex_lock(&ztm->_mutex_tx); #endif // Reset wbuf _z_wbuf_reset(&ztm->_wbuf); @@ -213,7 +213,7 @@ int8_t _z_raweth_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_me ztm->_transmitted = true; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_tx); + z_mutex_unlock(&ztm->_mutex_tx); #endif return ret; @@ -228,9 +228,9 @@ int8_t _z_raweth_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, // Acquire the lock and drop the message if needed #if Z_FEATURE_MULTI_THREAD == 1 if (cong_ctrl == Z_CONGESTION_CONTROL_BLOCK) { - _z_mutex_lock(&ztm->_mutex_tx); + z_mutex_lock(&ztm->_mutex_tx); } else { - if (_z_mutex_trylock(&ztm->_mutex_tx) != (int8_t)0) { + if (z_mutex_trylock(&ztm->_mutex_tx) != (int8_t)0) { _Z_INFO("Dropping zenoh message because of congestion control\n"); // We failed to acquire the lock, drop the message return ret; @@ -309,7 +309,7 @@ int8_t _z_raweth_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, _z_wbuf_clear(&fbf); } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztm->_mutex_tx); + z_mutex_unlock(&ztm->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; } diff --git a/src/transport/unicast/lease.c b/src/transport/unicast/lease.c index cd63416f5..fb1b3ad6c 100644 --- a/src/transport/unicast/lease.c +++ b/src/transport/unicast/lease.c @@ -95,9 +95,9 @@ void *_zp_unicast_lease_task(void *ztu_arg) { return 0; } -int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task) { +int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) { // Init memory - (void)memset(task, 0, sizeof(_z_task_t)); + (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) { return _Z_ERR_SYSTEM_TASK_FAILED; diff --git a/src/transport/unicast/read.c b/src/transport/unicast/read.c index 36598118a..551a3237f 100644 --- a/src/transport/unicast/read.c +++ b/src/transport/unicast/read.c @@ -49,7 +49,7 @@ void *_zp_unicast_read_task(void *ztu_arg) { _z_transport_unicast_t *ztu = (_z_transport_unicast_t *)ztu_arg; // Acquire and keep the lock - _z_mutex_lock(&ztu->_mutex_rx); + z_mutex_lock(&ztu->_mutex_rx); // Prepare the buffer _z_zbuf_reset(&ztu->_zbuf); @@ -117,13 +117,13 @@ void *_zp_unicast_read_task(void *ztu_arg) { // Move the read position of the read buffer _z_zbuf_set_rpos(&ztu->_zbuf, _z_zbuf_get_rpos(&ztu->_zbuf) + to_read); } - _z_mutex_unlock(&ztu->_mutex_rx); + z_mutex_unlock(&ztu->_mutex_rx); return NULL; } -int8_t _zp_unicast_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task) { +int8_t _zp_unicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) { // Init memory - (void)memset(task, 0, sizeof(_z_task_t)); + (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) { return _Z_ERR_SYSTEM_TASK_FAILED; diff --git a/src/transport/unicast/rx.c b/src/transport/unicast/rx.c index f925600f7..135bbcc3c 100644 --- a/src/transport/unicast/rx.c +++ b/src/transport/unicast/rx.c @@ -32,7 +32,7 @@ int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_messag int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock - _z_mutex_lock(&ztu->_mutex_rx); + z_mutex_lock(&ztu->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 size_t to_read = 0; @@ -85,7 +85,7 @@ int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_messag } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztu->_mutex_rx); + z_mutex_unlock(&ztu->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; diff --git a/src/transport/unicast/transport.c b/src/transport/unicast/transport.c index b41a9ce55..a3ca110a1 100644 --- a/src/transport/unicast/transport.c +++ b/src/transport/unicast/transport.c @@ -38,11 +38,11 @@ int8_t _z_unicast_transport_create(_z_transport_t *zt, _z_link_t *zl, _z_transpo #if Z_FEATURE_MULTI_THREAD == 1 // Initialize the mutexes - ret = _z_mutex_init(&zt->_transport._unicast._mutex_tx); + ret = z_mutex_init(&zt->_transport._unicast._mutex_tx); if (ret == _Z_RES_OK) { - ret = _z_mutex_init(&zt->_transport._unicast._mutex_rx); + ret = z_mutex_init(&zt->_transport._unicast._mutex_rx); if (ret != _Z_RES_OK) { - _z_mutex_free(&zt->_transport._unicast._mutex_tx); + z_mutex_free(&zt->_transport._unicast._mutex_tx); } } #endif // Z_FEATURE_MULTI_THREAD == 1 @@ -95,8 +95,8 @@ int8_t _z_unicast_transport_create(_z_transport_t *zt, _z_link_t *zl, _z_transpo ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_free(&zt->_transport._unicast._mutex_tx); - _z_mutex_free(&zt->_transport._unicast._mutex_rx); + z_mutex_free(&zt->_transport._unicast._mutex_tx); + z_mutex_free(&zt->_transport._unicast._mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 _z_wbuf_clear(&zt->_transport._unicast._wbuf); @@ -268,17 +268,17 @@ 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); + z_task_join(ztu->_read_task); + z_task_free(&ztu->_read_task); } if (ztu->_lease_task != NULL) { - _z_task_join(ztu->_lease_task); - _z_task_free(&ztu->_lease_task); + z_task_join(ztu->_lease_task); + z_task_free(&ztu->_lease_task); } // Clean up the mutexes - _z_mutex_free(&ztu->_mutex_tx); - _z_mutex_free(&ztu->_mutex_rx); + z_mutex_free(&ztu->_mutex_tx); + z_mutex_free(&ztu->_mutex_rx); #endif // Z_FEATURE_MULTI_THREAD == 1 // Clean up the buffers diff --git a/src/transport/unicast/tx.c b/src/transport/unicast/tx.c index 7fce59560..3b005b0ee 100644 --- a/src/transport/unicast/tx.c +++ b/src/transport/unicast/tx.c @@ -49,7 +49,7 @@ int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_mes #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock - _z_mutex_lock(&ztu->_mutex_tx); + z_mutex_lock(&ztu->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 // Prepare the buffer eventually reserving space for the message length @@ -68,7 +68,7 @@ int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_mes } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztu->_mutex_tx); + z_mutex_unlock(&ztu->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 return ret; @@ -85,11 +85,11 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg _Bool drop = false; if (cong_ctrl == Z_CONGESTION_CONTROL_BLOCK) { #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_lock(&ztu->_mutex_tx); + z_mutex_lock(&ztu->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 } else { #if Z_FEATURE_MULTI_THREAD == 1 - int8_t locked = _z_mutex_trylock(&ztu->_mutex_tx); + int8_t locked = z_mutex_trylock(&ztu->_mutex_tx); if (locked != (int8_t)0) { _Z_INFO("Dropping zenoh message because of congestion control\n"); // We failed to acquire the lock, drop the message @@ -159,7 +159,7 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg } #if Z_FEATURE_MULTI_THREAD == 1 - _z_mutex_unlock(&ztu->_mutex_tx); + z_mutex_unlock(&ztu->_mutex_tx); #endif // Z_FEATURE_MULTI_THREAD == 1 }