From b5c702b8ae19bdc257dabe75369b1609b03ccf6b Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Sat, 24 Feb 2024 13:52:28 +0100 Subject: [PATCH 1/4] move z_n_qos_t related functions into .c (to hide designated initializers from c++) --- .../zenoh-pico/protocol/definitions/network.h | 17 ++++------------- src/protocol/definitions/network.c | 9 +++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/zenoh-pico/protocol/definitions/network.h b/include/zenoh-pico/protocol/definitions/network.h index 512ad2c8d..3c3afd8e9 100644 --- a/include/zenoh-pico/protocol/definitions/network.h +++ b/include/zenoh-pico/protocol/definitions/network.h @@ -60,19 +60,10 @@ typedef _z_qos_t _z_n_qos_t; -static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, - z_priority_t priority) { - _Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1; - _z_n_qos_t ret = {._val = (uint8_t)((express << 4) | (nodrop << 3) | priority)}; - return ret; -} -static inline z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) { - return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */); -} -static inline z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) { - return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP; -} -static inline _Bool _z_n_qos_get_express(_z_n_qos_t n_qos) { return (_Bool)(n_qos._val & 0x10 /* 0b10000 */); } +_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority); +z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos); +z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos); +_Bool _z_n_qos_get_express(_z_n_qos_t n_qos); #define _z_n_qos_make(express, nodrop, priority) \ _z_n_qos_create((_Bool)express, nodrop ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP, \ (z_priority_t)priority) diff --git a/src/protocol/definitions/network.c b/src/protocol/definitions/network.c index af5192b14..8c2fcf212 100644 --- a/src/protocol/definitions/network.c +++ b/src/protocol/definitions/network.c @@ -276,3 +276,12 @@ void _z_msg_fix_mapping(_z_zenoh_message_t *msg, uint16_t mapping) { break; } } +_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) { + _Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1; + _z_n_qos_t ret = {._val = (uint8_t)((express << 4) | (nodrop << 3) | priority)}; + return ret; +} +z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) { return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */); } +z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) { + return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP; +} From 8e37ab813f6aec4a7c0f0165a6d104f89e38baa1 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Sat, 24 Feb 2024 13:54:30 +0100 Subject: [PATCH 2/4] z_sample_t docs update to include qos --- include/zenoh-pico/api/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/zenoh-pico/api/types.h b/include/zenoh-pico/api/types.h index 06117dd06..11dc18478 100644 --- a/include/zenoh-pico/api/types.h +++ b/include/zenoh-pico/api/types.h @@ -450,6 +450,7 @@ static inline z_qos_t z_qos_default(void) { return _Z_N_QOS_DEFAULT; } * z_encoding_t encoding: The encoding of the value of this data sample. * z_sample_kind_t kind: The kind of this data sample (PUT or DELETE). * z_timestamp_t timestamp: The timestamp of this data sample. + * z_qos_t qos: Quality of service settings used to deliver this sample. */ typedef _z_sample_t z_sample_t; From cac8b3d8c65b16285c178e37825b4b45272233d5 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Sat, 24 Feb 2024 19:06:22 +0100 Subject: [PATCH 3/4] move qos functions back to header and remove usage of designated initializers --- .../zenoh-pico/protocol/definitions/network.h | 17 +++++++++++++---- src/protocol/definitions/network.c | 9 --------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/zenoh-pico/protocol/definitions/network.h b/include/zenoh-pico/protocol/definitions/network.h index 3c3afd8e9..d0e763ca9 100644 --- a/include/zenoh-pico/protocol/definitions/network.h +++ b/include/zenoh-pico/protocol/definitions/network.h @@ -60,10 +60,19 @@ typedef _z_qos_t _z_n_qos_t; -_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority); -z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos); -z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos); -_Bool _z_n_qos_get_express(_z_n_qos_t n_qos); +static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) { + _z_n_qos_t ret; + _Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1; + ret._val = (uint8_t)((express << 4) | (nodrop << 3) | priority); + return ret; +} +static inline z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) { + return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */); +} +static inline z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) { + return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP; +} +static inline _Bool _z_n_qos_get_express(_z_n_qos_t n_qos) { return (_Bool)(n_qos._val & 0x10 /* 0b10000 */); } #define _z_n_qos_make(express, nodrop, priority) \ _z_n_qos_create((_Bool)express, nodrop ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP, \ (z_priority_t)priority) diff --git a/src/protocol/definitions/network.c b/src/protocol/definitions/network.c index 8c2fcf212..af5192b14 100644 --- a/src/protocol/definitions/network.c +++ b/src/protocol/definitions/network.c @@ -276,12 +276,3 @@ void _z_msg_fix_mapping(_z_zenoh_message_t *msg, uint16_t mapping) { break; } } -_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) { - _Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1; - _z_n_qos_t ret = {._val = (uint8_t)((express << 4) | (nodrop << 3) | priority)}; - return ret; -} -z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) { return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */); } -z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) { - return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP; -} From 54c291ee6102e55b1707552f73a6c2403e4ef93e Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Sat, 24 Feb 2024 19:07:59 +0100 Subject: [PATCH 4/4] format --- include/zenoh-pico/protocol/definitions/network.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/zenoh-pico/protocol/definitions/network.h b/include/zenoh-pico/protocol/definitions/network.h index d0e763ca9..ce9c280f9 100644 --- a/include/zenoh-pico/protocol/definitions/network.h +++ b/include/zenoh-pico/protocol/definitions/network.h @@ -60,7 +60,8 @@ typedef _z_qos_t _z_n_qos_t; -static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) { +static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, + z_priority_t priority) { _z_n_qos_t ret; _Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1; ret._val = (uint8_t)((express << 4) | (nodrop << 3) | priority);