Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility fixes for Zenoh-cpp #525

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/zenoh-pico/api/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "zenoh-pico/collections/ring_mt.h"
#include "zenoh-pico/utils/logging.h"

#ifdef __cplusplus
extern "C" {
#endif

// -- Channel
#define _Z_CHANNEL_DEFINE_IMPL(handler_type, handler_name, handler_new_f_name, callback_type, callback_new_f, \
collection_type, collection_new_f, collection_free_f, collection_push_f, \
Expand Down Expand Up @@ -187,4 +191,7 @@ _Z_CHANNEL_DEFINE_DUMMY(reply, ring)
_Z_CHANNEL_DEFINE_DUMMY(reply, fifo)
#endif // Z_FEATURE_QUERY

#ifdef __cplusplus
}
#endif
#endif // INCLUDE_ZENOH_PICO_API_HANDLERS_H
49 changes: 48 additions & 1 deletion include/zenoh-pico/api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,54 @@ template <>
struct z_loaned_to_owned_type_t<z_loaned_closure_zid_t> {
typedef z_owned_closure_zid_t type;
};

template <>
struct z_loaned_to_owned_type_t<z_loaned_fifo_handler_query_t> {
typedef z_owned_fifo_handler_query_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_fifo_handler_query_t> {
typedef z_loaned_fifo_handler_query_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_fifo_handler_reply_t> {
typedef z_owned_fifo_handler_reply_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_fifo_handler_reply_t> {
typedef z_loaned_fifo_handler_reply_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_fifo_handler_sample_t> {
typedef z_owned_fifo_handler_sample_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_fifo_handler_sample_t> {
typedef z_loaned_fifo_handler_sample_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_ring_handler_query_t> {
typedef z_owned_ring_handler_query_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_ring_handler_query_t> {
typedef z_loaned_ring_handler_query_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_ring_handler_reply_t> {
typedef z_owned_ring_handler_reply_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_ring_handler_reply_t> {
typedef z_loaned_ring_handler_reply_t type;
};
template <>
struct z_loaned_to_owned_type_t<z_loaned_ring_handler_sample_t> {
typedef z_owned_ring_handler_sample_t type;
};
template <>
struct z_owned_to_loaned_type_t<z_owned_ring_handler_sample_t> {
typedef z_loaned_ring_handler_sample_t type;
};
#endif

#endif /* ZENOH_C_STANDARD != 99 */
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -1419,9 +1419,9 @@ const z_loaned_bytes_t *z_sample_payload(const z_loaned_sample_t *sample);
* sample: Pointer to a :c:type:`z_loaned_sample_t` to get the timestamp from.
*
* Return:
* The timestamp wrapped as a :c:type:`z_timestamp_t`.
* The pointer to timestamp wrapped as a :c:type:`z_timestamp_t`. Returns NULL if no timestamp was set.
*/
z_timestamp_t z_sample_timestamp(const z_loaned_sample_t *sample);
const z_timestamp_t *z_sample_timestamp(const z_loaned_sample_t *sample);

/**
* Gets the encoding of a sample by aliasing it.
Expand Down
8 changes: 8 additions & 0 deletions include/zenoh-pico/collections/fifo_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "zenoh-pico/collections/fifo.h"
#include "zenoh-pico/system/platform.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-------- Fifo Buffer Multithreaded --------*/
typedef struct {
_z_fifo_t _fifo;
Expand All @@ -43,4 +47,8 @@ int8_t _z_fifo_mt_push(const void *src, void *context, z_element_free_f element_
int8_t _z_fifo_mt_pull(void *dst, void *context, z_element_move_f element_move);
int8_t _z_fifo_mt_try_pull(void *dst, void *context, z_element_move_f element_move);

#ifdef __cplusplus
}
#endif

#endif // ZENOH_PICO_COLLECTIONS_FIFO_MT_H
7 changes: 7 additions & 0 deletions include/zenoh-pico/collections/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

#define _Z_RC_MAX_COUNT INT32_MAX // Based on Rust lazy overflow check

#ifdef __cplusplus
extern "C++" {
#endif
#if Z_FEATURE_MULTI_THREAD == 1
#if ZENOH_C_STANDARD != 99

Expand Down Expand Up @@ -324,4 +327,8 @@
return sizeof(name##_rc_t); \
}

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_COLLECTIONS_REFCOUNT_H */
8 changes: 8 additions & 0 deletions include/zenoh-pico/collections/ring_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "zenoh-pico/collections/fifo.h"
#include "zenoh-pico/system/platform.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-------- Ring Buffer Multithreaded --------*/
typedef struct {
_z_ring_t _ring;
Expand All @@ -42,4 +46,8 @@ int8_t _z_ring_mt_push(const void *src, void *context, z_element_free_f element_
int8_t _z_ring_mt_pull(void *dst, void *context, z_element_move_f element_move);
int8_t _z_ring_mt_try_pull(void *dst, void *context, z_element_move_f element_move);

#ifdef __cplusplus
}
#endif

#endif // ZENOH_PICO_COLLECTIONS_RING_MT_H
3 changes: 2 additions & 1 deletion include/zenoh-pico/net/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ typedef struct _z_reply_data_t {

void _z_reply_data_clear(_z_reply_data_t *rd);
int8_t _z_reply_data_copy(_z_reply_data_t *dst, const _z_reply_data_t *src);
_z_reply_t _z_reply_move(_z_reply_t *src_reply);

_Z_ELEM_DEFINE(_z_reply_data, _z_reply_data_t, _z_noop_size, _z_reply_data_clear, _z_noop_copy)
_Z_LIST_DEFINE(_z_reply_data, _z_reply_data_t)
Expand All @@ -57,6 +56,8 @@ typedef struct _z_reply_t {
z_reply_tag_t _tag;
} _z_reply_t;

_z_reply_t _z_reply_move(_z_reply_t *src_reply);

_z_reply_t _z_reply_null(void);
_Bool _z_reply_check(const _z_reply_t *reply);
void _z_reply_clear(_z_reply_t *src);
Expand Down
1 change: 1 addition & 0 deletions include/zenoh-pico/utils/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typedef enum {

_Z_ERR_DID_NOT_READ = -76,
_Z_ERR_INVALID = -75,
Z_EINVAL = -75,

_Z_ERR_GENERIC = -128
} _z_res_t;
Expand Down
8 changes: 7 additions & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,13 @@ z_id_t z_info_zid(const z_loaned_session_t *zs) { return _Z_RC_IN_VAL(zs)._local
const z_loaned_keyexpr_t *z_sample_keyexpr(const z_loaned_sample_t *sample) { return &sample->keyexpr; }
z_sample_kind_t z_sample_kind(const z_loaned_sample_t *sample) { return sample->kind; }
const z_loaned_bytes_t *z_sample_payload(const z_loaned_sample_t *sample) { return &sample->payload; }
z_timestamp_t z_sample_timestamp(const z_loaned_sample_t *sample) { return sample->timestamp; }
const z_timestamp_t *z_sample_timestamp(const z_loaned_sample_t *sample) {
if (_z_timestamp_check(&sample->timestamp)) {
return &sample->timestamp;
} else {
return NULL;
}
}
const z_loaned_encoding_t *z_sample_encoding(const z_loaned_sample_t *sample) { return &sample->encoding; }
z_qos_t z_sample_qos(const z_loaned_sample_t *sample) { return sample->qos; }
const z_loaned_bytes_t *z_sample_attachment(const z_loaned_sample_t *sample) { return &sample->attachment; }
Expand Down
Loading