Skip to content

Commit

Permalink
Merge pull request #679 from DenisBiryukov91/private/fix-bool
Browse files Browse the repository at this point in the history
Fix (C++) build for windows
  • Loading branch information
Mallets authored Sep 18, 2024
2 parents c17f8fd + 94bb578 commit c9deea0
Show file tree
Hide file tree
Showing 119 changed files with 555 additions and 554 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ if(CMAKE_EXPORT_COMPILE_COMMANDS)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(BUILD_SHARED_LIBS "OFF")
if (BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
if(WITH_ZEPHYR)
set(BUILD_SHARED_LIBS "OFF")
Expand Down Expand Up @@ -337,6 +339,7 @@ install(TARGETS ${Libname}
EXPORT zenohpicoTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
COMPONENT Library
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/zenoh-pico.h
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_get_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef struct kv_pairs_rx_t {
static z_owned_condvar_t cond;
static z_owned_mutex_t mutex;

_Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context) {
bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context) {
kv_pairs_tx_t *kvs = (kv_pairs_tx_t *)(context);
z_owned_bytes_t k, v;
if (kvs->current_idx >= kvs->len) {
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct kv_pairs_t {

#if Z_FEATURE_PUBLICATION == 1

_Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context) {
bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context) {
kv_pairs_t *kvs = (kv_pairs_t *)(context);
z_owned_bytes_t k, v;
if (kvs->current_idx >= kvs->len) {
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_queryable_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ size_t kv_pairs_size(kv_pairs_tx_t *kvp) {
return ret;
}

_Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context) {
bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context) {
kv_pairs_tx_t *kvs = (kv_pairs_tx_t *)(context);
z_owned_bytes_t k, v;
if (kvs->current_idx >= kvs->len) {
Expand Down
186 changes: 93 additions & 93 deletions include/zenoh-pico/api/handlers.h

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions include/zenoh-pico/api/olv_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

#define _Z_OWNED_FUNCTIONS_DEF(name) \
void z_internal_##name##_null(z_owned_##name##_t *obj); \
_Bool z_internal_##name##_check(const z_owned_##name##_t *obj); \
bool z_internal_##name##_check(const z_owned_##name##_t *obj); \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *obj); \
z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *obj); \
z_moved_##name##_t *z_##name##_move(z_owned_##name##_t *obj); \
Expand All @@ -67,7 +67,7 @@

#define _Z_OWNED_FUNCTIONS_NO_COPY_DEF(name) \
void z_internal_##name##_null(z_owned_##name##_t *obj); \
_Bool z_internal_##name##_check(const z_owned_##name##_t *obj); \
bool z_internal_##name##_check(const z_owned_##name##_t *obj); \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *obj); \
z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *obj); \
z_moved_##name##_t *z_##name##_move(z_owned_##name##_t *obj); \
Expand All @@ -82,7 +82,7 @@
z_moved_##name##_t *z_##name##_move(z_owned_##name##_t *obj);

#define _Z_VIEW_FUNCTIONS_DEF(name) \
_Bool z_view_##name##_is_empty(const z_view_##name##_t *obj); \
bool z_view_##name##_is_empty(const z_view_##name##_t *obj); \
const z_loaned_##name##_t *z_view_##name##_loan(const z_view_##name##_t *name); \
z_loaned_##name##_t *z_view_##name##_loan_mut(z_view_##name##_t *name); \
void z_view_##name##_empty(z_view_##name##_t *name);
Expand All @@ -97,7 +97,7 @@
#define _Z_OWNED_FUNCTIONS_VALUE_IMPL(type, name, f_check, f_null, f_copy, f_drop) \
_Z_OWNED_FUNCTIONS_IMPL_MOVE_TAKE(name) \
void z_internal_##name##_null(z_owned_##name##_t *obj) { obj->_val = f_null(); } \
_Bool z_internal_##name##_check(const z_owned_##name##_t *obj) { return f_check((&obj->_val)); } \
bool z_internal_##name##_check(const z_owned_##name##_t *obj) { return f_check((&obj->_val)); } \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *obj) { return &obj->_val; } \
z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *obj) { return &obj->_val; } \
int8_t z_##name##_clone(z_owned_##name##_t *obj, const z_loaned_##name##_t *src) { \
Expand All @@ -109,7 +109,7 @@

#define _Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL_INNER(type, name, f_check, f_null, f_drop, attribute) \
attribute void z_internal_##name##_null(z_owned_##name##_t *obj) { obj->_val = f_null(); } \
attribute _Bool z_internal_##name##_check(const z_owned_##name##_t *obj) { return f_check((&obj->_val)); } \
attribute bool z_internal_##name##_check(const z_owned_##name##_t *obj) { return f_check((&obj->_val)); } \
attribute const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *obj) { return &obj->_val; } \
attribute z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *obj) { return &obj->_val; } \
attribute z_moved_##name##_t *z_##name##_move(z_owned_##name##_t *obj) { return (z_moved_##name##_t *)(obj); } \
Expand All @@ -129,24 +129,24 @@
#define _Z_OWNED_FUNCTIONS_VALUE_NO_COPY_INLINE_IMPL(type, name, f_check, f_null, f_drop) \
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL_INNER(type, name, f_check, f_null, f_drop, static inline)

#define _Z_OWNED_FUNCTIONS_RC_IMPL(name) \
_Z_OWNED_FUNCTIONS_IMPL_MOVE_TAKE(name) \
void z_internal_##name##_null(z_owned_##name##_t *val) { val->_rc = _z_##name##_rc_null(); } \
_Bool z_internal_##name##_check(const z_owned_##name##_t *val) { return !_Z_RC_IS_NULL(&val->_rc); } \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *val) { return &val->_rc; } \
z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *val) { return &val->_rc; } \
int8_t z_##name##_clone(z_owned_##name##_t *obj, const z_loaned_##name##_t *src) { \
int8_t ret = _Z_RES_OK; \
obj->_rc = _z_##name##_rc_clone((z_loaned_##name##_t *)src); \
if (_Z_RC_IS_NULL(&obj->_rc)) { \
ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; \
} \
return ret; \
} \
void z_##name##_drop(z_moved_##name##_t *obj) { \
if (!_Z_RC_IS_NULL(&obj->_this._rc)) { \
_z_##name##_rc_drop(&obj->_this._rc); \
} \
#define _Z_OWNED_FUNCTIONS_RC_IMPL(name) \
_Z_OWNED_FUNCTIONS_IMPL_MOVE_TAKE(name) \
void z_internal_##name##_null(z_owned_##name##_t *val) { val->_rc = _z_##name##_rc_null(); } \
bool z_internal_##name##_check(const z_owned_##name##_t *val) { return !_Z_RC_IS_NULL(&val->_rc); } \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *val) { return &val->_rc; } \
z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *val) { return &val->_rc; } \
int8_t z_##name##_clone(z_owned_##name##_t *obj, const z_loaned_##name##_t *src) { \
int8_t ret = _Z_RES_OK; \
obj->_rc = _z_##name##_rc_clone((z_loaned_##name##_t *)src); \
if (_Z_RC_IS_NULL(&obj->_rc)) { \
ret = _Z_ERR_SYSTEM_OUT_OF_MEMORY; \
} \
return ret; \
} \
void z_##name##_drop(z_moved_##name##_t *obj) { \
if (!_Z_RC_IS_NULL(&obj->_this._rc)) { \
_z_##name##_rc_drop(&obj->_this._rc); \
} \
}

#define _Z_OWNED_FUNCTIONS_SYSTEM_IMPL(type, name) \
Expand All @@ -156,42 +156,42 @@
z_loaned_##name##_t *z_##name##_loan_mut(z_owned_##name##_t *obj) { return &obj->_val; }

#define _Z_VIEW_FUNCTIONS_IMPL(type, name, f_check, f_null) \
_Bool z_view_##name##_is_empty(const z_view_##name##_t *obj) { return !f_check((&obj->_val)); } \
bool z_view_##name##_is_empty(const z_view_##name##_t *obj) { return !f_check((&obj->_val)); } \
const z_loaned_##name##_t *z_view_##name##_loan(const z_view_##name##_t *obj) { return &obj->_val; } \
z_loaned_##name##_t *z_view_##name##_loan_mut(z_view_##name##_t *obj) { return &obj->_val; } \
void z_view_##name##_empty(z_view_##name##_t *obj) { obj->_val = f_null(); }

#define _Z_OWNED_FUNCTIONS_CLOSURE_DEF(name) \
void z_internal_##name##_null(z_owned_##name##_t *name); \
_Bool z_internal_##name##_check(const z_owned_##name##_t *val); \
bool z_internal_##name##_check(const z_owned_##name##_t *val); \
z_moved_##name##_t *z_##name##_move(z_owned_##name##_t *val); \
void z_##name##_take(z_owned_##name##_t *obj, z_moved_##name##_t *src); \
void z_##name##_drop(z_moved_##name##_t *obj); \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *val);

#define _Z_OWNED_FUNCTIONS_CLOSURE_IMPL(name, f_call, f_drop) \
_Z_OWNED_FUNCTIONS_IMPL_MOVE_TAKE(name) \
void z_internal_##name##_null(z_owned_##name##_t *val) { \
val->_val.call = NULL; \
val->_val.drop = NULL; \
val->_val.context = NULL; \
} \
_Bool z_internal_##name##_check(const z_owned_##name##_t *val) { return val->_val.call != NULL; } \
void z_##name##_drop(z_moved_##name##_t *obj) { \
if (obj->_this._val.drop != NULL) { \
(obj->_this._val.drop)(obj->_this._val.context); \
obj->_this._val.drop = NULL; \
} \
obj->_this._val.call = NULL; \
obj->_this._val.context = NULL; \
} \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *val) { return &val->_val; } \
int8_t z_##name(z_owned_##name##_t *closure, f_call call, f_drop drop, void *context) { \
closure->_val.call = call; \
closure->_val.drop = drop; \
closure->_val.context = context; \
\
return _Z_RES_OK; \
#define _Z_OWNED_FUNCTIONS_CLOSURE_IMPL(name, f_call, f_drop) \
_Z_OWNED_FUNCTIONS_IMPL_MOVE_TAKE(name) \
void z_internal_##name##_null(z_owned_##name##_t *val) { \
val->_val.call = NULL; \
val->_val.drop = NULL; \
val->_val.context = NULL; \
} \
bool z_internal_##name##_check(const z_owned_##name##_t *val) { return val->_val.call != NULL; } \
void z_##name##_drop(z_moved_##name##_t *obj) { \
if (obj->_this._val.drop != NULL) { \
(obj->_this._val.drop)(obj->_this._val.context); \
obj->_this._val.drop = NULL; \
} \
obj->_this._val.call = NULL; \
obj->_this._val.context = NULL; \
} \
const z_loaned_##name##_t *z_##name##_loan(const z_owned_##name##_t *val) { return &val->_val; } \
int8_t z_##name(z_owned_##name##_t *closure, f_call call, f_drop drop, void *context) { \
closure->_val.call = call; \
closure->_val.drop = drop; \
closure->_val.context = context; \
\
return _Z_RES_OK; \
}

#endif /* INCLUDE_ZENOH_PICO_API_OLV_MACROS_H */
20 changes: 10 additions & 10 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int8_t z_keyexpr_canonize_null_terminated(char *start);
* ``true`` if ``l`` includes ``r``, i.e. the set defined by ``l`` contains every key belonging to the set
* defined by ``r``. Otherwise, returns ``false``.
*/
_Bool z_keyexpr_includes(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r);
bool z_keyexpr_includes(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r);

/**
* Checks if a given keyexpr intersects with another keyexpr.
Expand All @@ -265,7 +265,7 @@ _Bool z_keyexpr_includes(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *
* ``true`` if keyexprs intersect, i.e. there exists at least one key which is contained in both of the
* sets defined by ``l`` and ``r``. Otherwise, returns ``false``.
*/
_Bool z_keyexpr_intersects(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r);
bool z_keyexpr_intersects(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r);

/**
* Checks if two keyexpr are equal.
Expand All @@ -277,7 +277,7 @@ _Bool z_keyexpr_intersects(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t
* Return:
* ``true`` if both ``l`` and ``r`` are equal. Otherwise, returns ``false``.
*/
_Bool z_keyexpr_equals(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r);
bool z_keyexpr_equals(const z_loaned_keyexpr_t *l, const z_loaned_keyexpr_t *r);

/**
* Builds a new, zenoh-allocated, empty configuration.
Expand Down Expand Up @@ -895,7 +895,7 @@ int8_t z_bytes_serialize_from_str(z_owned_bytes_t *bytes, const char *value);
* Return:
* ``0`` if encode successful, ``negative value`` otherwise.
*/
int8_t z_bytes_from_iter(z_owned_bytes_t *bytes, _Bool (*iterator_body)(z_owned_bytes_t *data, void *context),
int8_t z_bytes_from_iter(z_owned_bytes_t *bytes, bool (*iterator_body)(z_owned_bytes_t *data, void *context),
void *context);

/**
Expand Down Expand Up @@ -935,7 +935,7 @@ size_t z_bytes_len(const z_loaned_bytes_t *bytes);
* Return:
* ``true`` if conainer is empty, ``false`` otherwise.
*/
_Bool z_bytes_is_empty(const z_loaned_bytes_t *bytes);
bool z_bytes_is_empty(const z_loaned_bytes_t *bytes);

/**
* Returns an iterator for multi-element serialized data.
Expand All @@ -959,7 +959,7 @@ z_bytes_iterator_t z_bytes_get_iterator(const z_loaned_bytes_t *bytes);
* Return:
* ``false`` when iterator reaches the end, ``true`` otherwise.
*/
_Bool z_bytes_iterator_next(z_bytes_iterator_t *iter, z_owned_bytes_t *out);
bool z_bytes_iterator_next(z_bytes_iterator_t *iter, z_owned_bytes_t *out);

/**
* Returns an iterator on raw bytes slices contained in the `z_loaned_bytes_t`.
Expand Down Expand Up @@ -987,7 +987,7 @@ z_bytes_slice_iterator_t z_bytes_get_slice_iterator(const z_loaned_bytes_t *byte
* Return:
* ``false`` when iterator reaches the end, ``true`` otherwise.
*/
_Bool z_bytes_slice_iterator_next(z_bytes_slice_iterator_t *iter, z_view_slice_t *out);
bool z_bytes_slice_iterator_next(z_bytes_slice_iterator_t *iter, z_view_slice_t *out);

/**
* Returns a reader for the `bytes`.
Expand Down Expand Up @@ -1135,7 +1135,7 @@ z_id_t z_timestamp_id(const z_timestamp_t *ts);
* Return:
* ``true`` if timestamp is valid, ``false`` otherwise.
*/
_Bool z_timestamp_check(z_timestamp_t ts);
bool z_timestamp_check(z_timestamp_t ts);

/**
* Builds a default query target.
Expand Down Expand Up @@ -1885,7 +1885,7 @@ int8_t z_get(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, co
* Return:
* ``true`` if queryable answered with an OK, ``false`` otherwise.
*/
_Bool z_reply_is_ok(const z_loaned_reply_t *reply);
bool z_reply_is_ok(const z_loaned_reply_t *reply);

/**
* Gets the content of an OK reply.
Expand Down Expand Up @@ -1922,7 +1922,7 @@ const z_loaned_reply_err_t *z_reply_err(const z_loaned_reply_t *reply);
* Return:
* `true` if id is present
*/
_Bool z_reply_replier_id(const z_loaned_reply_t *reply, z_id_t *out_id);
bool z_reply_replier_id(const z_loaned_reply_t *reply, z_id_t *out_id);
#endif

#if Z_FEATURE_QUERYABLE == 1
Expand Down
Loading

0 comments on commit c9deea0

Please sign in to comment.