Skip to content

Commit

Permalink
feat: switch types to zp namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jan 9, 2024
1 parent 339983b commit d98dfab
Show file tree
Hide file tree
Showing 43 changed files with 229 additions and 229 deletions.
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
zp_task_attr_t read_task_attr = {
.name = "ZenohReadTask",
.priority = 10,
.stack_depth = 1000,
Expand All @@ -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 = {
zp_task_attr_t lease_task_attr = {
.name = "ZenohLeaseTask",
.priority = 10,
.stack_depth = 1000,
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#define DEFAULT_PING_NB 100
#define DEFAULT_WARMUP_MS 1000

static z_condvar_t cond;
static z_mutex_t mutex;
static zp_condvar_t cond;
static zp_mutex_t mutex;

void callback(const z_sample_t* sample, void* context) {
(void)sample;
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c99/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#define DEFAULT_PING_NB 100
#define DEFAULT_WARMUP_MS 1000

static z_condvar_t cond;
static z_mutex_t mutex;
static zp_condvar_t cond;
static zp_mutex_t mutex;

void callback(const z_sample_t* sample, void* context) {
(void)sample;
Expand Down
4 changes: 2 additions & 2 deletions examples/windows/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#define DEFAULT_PING_NB 100
#define DEFAULT_WARMUP_MS 1000

static z_condvar_t cond;
static z_mutex_t mutex;
static zp_condvar_t cond;
static zp_mutex_t mutex;

void callback(const z_sample_t* sample, void* context) {
(void)sample;
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ typedef struct {
*/
typedef struct {
#if Z_FEATURE_MULTI_THREAD == 1
z_task_attr_t *task_attributes;
zp_task_attr_t *task_attributes;
#else
uint8_t __dummy; // Just to avoid empty structures that might cause undefined behavior
#endif
Expand All @@ -356,7 +356,7 @@ typedef struct {
*/
typedef struct {
#if Z_FEATURE_MULTI_THREAD == 1
z_task_attr_t *task_attributes;
zp_task_attr_t *task_attributes;
#else
uint8_t __dummy; // Just to avoid empty structures that might cause undefined behavior
#endif
Expand Down
6 changes: 3 additions & 3 deletions include/zenoh-pico/net/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
typedef struct {
#if Z_FEATURE_MULTI_THREAD == 1
z_mutex_t _mutex_inner;
zp_mutex_t _mutex_inner;
#endif // Z_FEATURE_MULTI_THREAD == 1

// Zenoh-pico is considering a single transport per session.
Expand Down Expand Up @@ -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, zp_task_attr_t *attr);

/**
* Stop the read task. This may result in stopping a thread or a process depending
Expand All @@ -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, zp_task_attr_t *attr);

/**
* Stop the lease task. This may result in stopping a thread or a process depending
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/session/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
zp_mutex_t _mutex;
zp_condvar_t _cond_var;
#endif // Z_FEATURE_MULTI_THREAD == 1
_z_reply_data_list_t *_replies;
} _z_pending_query_collect_t;
Expand Down
26 changes: 13 additions & 13 deletions include/zenoh-pico/system/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ void z_free(void *ptr);

#if Z_FEATURE_MULTI_THREAD == 1
/*------------------ Thread ------------------*/
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);
int8_t zp_task_init(zp_task_t *task, zp_task_attr_t *attr, void *(*fun)(void *), void *arg);
int8_t zp_task_join(zp_task_t *task);
int8_t zp_task_cancel(zp_task_t *task);
void zp_task_free(zp_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(zp_mutex_t *m);
int8_t z_mutex_free(zp_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(zp_mutex_t *m);
int8_t zp_mutex_trylock(zp_mutex_t *m);
int8_t z_mutex_unlock(zp_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(zp_condvar_t *cv);
int8_t z_condvar_free(zp_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(zp_condvar_t *cv);
int8_t z_condvar_wait(zp_condvar_t *cv, zp_mutex_t *m);
#endif // Z_FEATURE_MULTI_THREAD == 1

/*------------------ Sleep ------------------*/
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/arduino/esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 zp_task_t;
typedef void *zp_task_attr_t; // Not used in ESP32
typedef pthread_mutex_t zp_mutex_t;
typedef pthread_cond_t zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef struct timespec z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/arduino/opencr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *zp_task_t;
typedef void *zp_task_attr_t;
typedef void *zp_mutex_t;
typedef void *zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef struct timespec z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/emscripten.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#if Z_FEATURE_MULTI_THREAD == 1
#include <pthread.h>

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 zp_task_t;
typedef pthread_attr_t zp_task_attr_t;
typedef pthread_mutex_t zp_mutex_t;
typedef pthread_cond_t zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef double z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/espidf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#if Z_FEATURE_MULTI_THREAD == 1
#include <pthread.h>

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 zp_task_t;
typedef void *zp_task_attr_t; // Not used in ESP32
typedef pthread_mutex_t zp_mutex_t;
typedef pthread_cond_t zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef struct timespec z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/freertos_plus_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ typedef struct {
StackType_t *stack_buffer;
StaticTask_t *task_buffer;
#endif /* SUPPORT_STATIC_ALLOCATION */
} z_task_attr_t;
} zp_task_attr_t;

typedef struct {
TaskHandle_t handle;
EventGroupHandle_t join_event;
} z_task_t;
} zp_task_t;

typedef SemaphoreHandle_t z_mutex_t;
typedef void *z_condvar_t;
typedef SemaphoreHandle_t zp_mutex_t;
typedef void *zp_condvar_t;
#endif // Z_MULTI_THREAD == 1

typedef TickType_t z_clock_t;
Expand Down
10 changes: 5 additions & 5 deletions include/zenoh-pico/system/platform/mbed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *zp_task_t; // Workaround as MBED is a C++ library
typedef void *zp_task_attr_t; // Workaround as MBED is a C++ library
typedef void *zp_mutex_t; // Workaround as MBED is a C++ library
typedef void *zp_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;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#if Z_FEATURE_MULTI_THREAD == 1
#include <pthread.h>

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 zp_task_t;
typedef pthread_attr_t zp_task_attr_t;
typedef pthread_mutex_t zp_mutex_t;
typedef pthread_cond_t zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef struct timespec z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/void.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *zp_task_t;
typedef void *zp_task_attr_t;
typedef void *zp_mutex_t;
typedef void *zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef void *z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *zp_task_t;
typedef void *zp_task_attr_t; // Not used in Windows
typedef SRWLOCK zp_mutex_t;
typedef CONDITION_VARIABLE zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef LARGE_INTEGER z_clock_t;
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/system/platform/zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 zp_task_t;
typedef pthread_attr_t zp_task_attr_t;
typedef pthread_mutex_t zp_mutex_t;
typedef pthread_cond_t zp_condvar_t;
#endif // Z_FEATURE_MULTI_THREAD == 1

typedef struct timespec z_clock_t;
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/transport/multicast/lease.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, zp_task_attr_t *attr, zp_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) */
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/transport/multicast/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, zp_task_attr_t *attr, zp_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 */
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/transport/raweth/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, zp_task_attr_t *attr, zp_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 */
Expand Down
18 changes: 9 additions & 9 deletions include/zenoh-pico/transport/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
zp_mutex_t _mutex_rx;
zp_mutex_t _mutex_tx;
#endif // Z_FEATURE_MULTI_THREAD == 1

_z_link_t _link;
Expand All @@ -88,8 +88,8 @@ typedef struct {
void *_session;

#if Z_FEATURE_MULTI_THREAD == 1
z_task_t *_read_task;
z_task_t *_lease_task;
zp_task_t *_read_task;
zp_task_t *_lease_task;
volatile _Bool _read_task_running;
volatile _Bool _lease_task_running;
#endif // Z_FEATURE_MULTI_THREAD == 1
Expand All @@ -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;
zp_mutex_t _mutex_rx;
zp_mutex_t _mutex_tx;

// Peer list mutex
z_mutex_t _mutex_peer;
zp_mutex_t _mutex_peer;
#endif // Z_FEATURE_MULTI_THREAD == 1

_z_link_t _link;
Expand All @@ -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;
zp_task_t *_read_task;
zp_task_t *_lease_task;
volatile _Bool _read_task_running;
volatile _Bool _lease_task_running;
#endif // Z_FEATURE_MULTI_THREAD == 1
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/transport/unicast/lease.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, zp_task_attr_t *attr, zp_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 */
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/transport/unicast/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, zp_task_attr_t *attr, zp_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 */
Expand Down
Loading

0 comments on commit d98dfab

Please sign in to comment.