From f613aec2ccb69ea6a14a317758a795c9434c0f7e Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Mon, 23 Sep 2024 16:29:42 +0400 Subject: [PATCH 01/38] separate LoanedCTypeMut trait --- src/collections.rs | 2 +- src/config.rs | 2 +- src/encoding.rs | 2 +- src/get.rs | 2 +- src/payload.rs | 2 +- src/platform/synchronization.rs | 2 +- src/publisher.rs | 2 +- src/queryable.rs | 4 +++- src/scouting.rs | 2 +- src/subscriber.rs | 2 +- src/transmute.rs | 14 +++++++++++++- 11 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/collections.rs b/src/collections.rs index 624dfb55b..9add10e11 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -25,7 +25,7 @@ use libc::strlen; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, }; pub struct CSlice { diff --git a/src/config.rs b/src/config.rs index c1871c9da..930a5c4b9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,7 +18,7 @@ use zenoh::config::{Config, WhatAmI}; use crate::{ result::{self, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_internal_string_null, z_owned_string_t, z_string_copy_from_substr, }; diff --git a/src/encoding.rs b/src/encoding.rs index 1dcd3488f..19031c37f 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -26,7 +26,7 @@ use zenoh::bytes::Encoding; pub use crate::opaque_types::{z_loaned_encoding_t, z_owned_encoding_t}; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_moved_encoding_t, z_owned_string_t, z_string_copy_from_substr, }; diff --git a/src/get.rs b/src/get.rs index 2069e1af4..ac687a347 100644 --- a/src/get.rs +++ b/src/get.rs @@ -24,7 +24,7 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_reply_err_t, z_moved_reply_err_t, z_owned_reply_err_t}; use crate::{ result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_closure_reply_call, z_closure_reply_loan, z_congestion_control_t, z_consolidation_mode_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_sample_t, z_loaned_session_t, z_moved_bytes_t, z_moved_closure_reply_t, z_moved_encoding_t, z_priority_t, diff --git a/src/payload.rs b/src/payload.rs index 1fd11eae5..18bf8b7e2 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -35,7 +35,7 @@ pub use crate::opaque_types::{z_loaned_bytes_t, z_owned_bytes_t}; use crate::result::Z_ENULL; use crate::{ result::{self, z_result_t, Z_EINVAL, Z_EIO, Z_EPARSE, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_loaned_slice_t, z_loaned_string_t, z_moved_bytes_t, z_moved_slice_t, z_moved_string_t, z_owned_slice_t, z_owned_string_t, z_view_slice_t, CSlice, CSliceOwned, CSliceView, CString, CStringOwned, diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index d01904133..9ef48ee67 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -9,7 +9,7 @@ use libc::c_void; pub use crate::opaque_types::{z_loaned_mutex_t, z_moved_mutex_t, z_owned_mutex_t}; use crate::{ result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, }; decl_c_type!( diff --git a/src/publisher.rs b/src/publisher.rs index 45988959b..20761171e 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -28,7 +28,7 @@ use crate::z_moved_source_info_t; use crate::zc_moved_closure_matching_status_t; use crate::{ result::{self}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_congestion_control_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, z_moved_encoding_t, z_priority_t, z_timestamp_t, }; diff --git a/src/queryable.rs b/src/queryable.rs index dc934e2d1..2b92800ff 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -25,7 +25,9 @@ pub use crate::opaque_types::{z_loaned_queryable_t, z_owned_queryable_t}; use crate::transmute::IntoCType; use crate::{ result, - transmute::{IntoRustType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType, + }, z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, z_moved_closure_query_t, z_moved_encoding_t, z_moved_queryable_t, z_priority_t, z_timestamp_t, diff --git a/src/scouting.rs b/src/scouting.rs index 4b9dca2bf..e59276c9a 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -22,7 +22,7 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_hello_t, z_moved_hello_t, z_owned_hello_t}; use crate::{ result::{self, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_closure_hello_call, z_closure_hello_loan, z_moved_closure_hello_t, z_moved_config_t, z_owned_string_array_t, z_view_string_t, CString, CStringView, ZVector, }; diff --git a/src/subscriber.rs b/src/subscriber.rs index 6cf5bb401..c95471b47 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -20,7 +20,7 @@ pub use crate::opaque_types::{z_loaned_subscriber_t, z_moved_subscriber_t, z_own use crate::{ keyexpr::*, result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t, }; decl_c_type!( diff --git a/src/transmute.rs b/src/transmute.rs index c37b512cc..c0da9a183 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -30,6 +30,10 @@ pub(crate) trait OwnedCTypeRef: Sized { pub(crate) trait LoanedCTypeRef: Sized { type LoanedCType; fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType; +} +#[allow(dead_code)] +pub(crate) trait LoanedCTypeMut: Sized { + type LoanedCType; fn as_loaned_c_type_mut(&mut self) -> &mut Self::LoanedCType; } #[allow(dead_code)] @@ -145,13 +149,17 @@ macro_rules! impl_transmute { } } }; - (as_c_loaned ($rust_type:ty, $c_type:ty)) => { impl $crate::transmute::LoanedCTypeRef for $rust_type { type LoanedCType = $c_type; fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType { unsafe { &*(self as *const Self as *const Self::LoanedCType) } } + } + }; + (as_c_loaned_mut ($rust_type:ty, $c_type:ty)) => { + impl $crate::transmute::LoanedCTypeMut for $rust_type { + type LoanedCType = $c_type; fn as_loaned_c_type_mut(&mut self) -> &mut Self::LoanedCType { unsafe { &mut *(self as *mut Self as *mut Self::LoanedCType) } } @@ -244,6 +252,7 @@ macro_rules! impl_owned { (owned rust $c_owned_type:ty, loaned $c_loaned_type:ty) => { impl_transmute!(as_c_owned($c_loaned_type, $c_owned_type)); impl_transmute!(as_c_loaned($c_owned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut($c_owned_type, $c_loaned_type)); impl_transmute!(into_rust(itself $c_owned_type)); }; } @@ -297,6 +306,7 @@ macro_rules! decl_c_type_inequal { ); validate_equivalence!($c_loaned_type, $rust_loaned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), @@ -307,6 +317,7 @@ macro_rules! decl_c_type_inequal { ); validate_equivalence!($c_loaned_type, $rust_loaned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); }; @@ -507,6 +518,7 @@ macro_rules! decl_c_type { (loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { validate_equivalence!($c_loaned_type, $rust_loaned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); }; } From e7dee54a47f8da37632406793ae359151ae51772 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Mon, 23 Sep 2024 20:07:57 +0400 Subject: [PATCH 02/38] validate equivalece in transmute --- src/transmute.rs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/transmute.rs b/src/transmute.rs index c0da9a183..195d8780a 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -128,6 +128,7 @@ macro_rules! validate_equivalence { #[macro_export] macro_rules! impl_transmute { (as_c ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::CTypeRef for $rust_type { type CType = $c_type; fn as_ctype_ref(&self) -> &Self::CType { @@ -139,6 +140,7 @@ macro_rules! impl_transmute { } }; (as_c_owned ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::OwnedCTypeRef for $rust_type { type OwnedCType = $c_type; fn as_owned_c_type_ref(&self) -> &Self::OwnedCType { @@ -150,6 +152,7 @@ macro_rules! impl_transmute { } }; (as_c_loaned ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::LoanedCTypeRef for $rust_type { type LoanedCType = $c_type; fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType { @@ -158,6 +161,7 @@ macro_rules! impl_transmute { } }; (as_c_loaned_mut ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::LoanedCTypeMut for $rust_type { type LoanedCType = $c_type; fn as_loaned_c_type_mut(&mut self) -> &mut Self::LoanedCType { @@ -166,6 +170,7 @@ macro_rules! impl_transmute { } }; (as_c_view ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::ViewCTypeRef for $rust_type { type ViewCType = $c_type; fn as_view_c_type_ref(&self) -> &Self::ViewCType { @@ -177,6 +182,7 @@ macro_rules! impl_transmute { } }; (as_rust ($c_type:ty, $rust_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::RustTypeRef for $c_type { type RustType = $rust_type; fn as_rust_type_ref(&self) -> &Self::RustType { @@ -197,6 +203,7 @@ macro_rules! impl_transmute { } }; (into_rust ($c_type:ty, $rust_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::IntoRustType for $c_type { type RustType = $rust_type; fn into_rust_type(self) -> Self::RustType { @@ -213,6 +220,7 @@ macro_rules! impl_transmute { } }; (take_rust ($c_type:ty, $rust_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl Default for $c_type { fn default() -> Self { unsafe { std::mem::transmute::<$rust_type, $c_type>(<$rust_type>::default()) } @@ -220,6 +228,7 @@ macro_rules! impl_transmute { } }; (into_c ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); impl $crate::transmute::IntoCType for $rust_type { type CType = $c_type; fn into_c_type(self) -> Self::CType { @@ -304,7 +313,6 @@ macro_rules! decl_c_type_inequal { decl_c_type!( owned($c_owned_type, option $rust_inner_type), ); - validate_equivalence!($c_loaned_type, $rust_loaned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); @@ -315,7 +323,6 @@ macro_rules! decl_c_type_inequal { decl_c_type!( owned($c_owned_type, $rust_owned_type), ); - validate_equivalence!($c_loaned_type, $rust_loaned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); @@ -351,7 +358,6 @@ macro_rules! decl_c_type_inequal { owned($c_owned_type, option $rust_inner_type), loaned($c_loaned_type), ); - validate_equivalence!($c_view_type, $rust_view_type); impl_transmute!(as_c_view($rust_view_type, $c_view_type)); impl_transmute!(as_rust($c_view_type, $rust_view_type)); }; @@ -363,7 +369,6 @@ macro_rules! decl_c_type_inequal { owned($c_owned_type, $rust_owned_type), loaned($c_loaned_type), ); - validate_equivalence!($c_view_type, $rust_view_type); impl_transmute!(as_c_view($rust_view_type, $c_view_type)); impl_transmute!(as_rust($c_view_type, $rust_view_type)); }; @@ -375,7 +380,6 @@ macro_rules! decl_c_type_inequal { owned($c_owned_type, $rust_owned_type), loaned($c_loaned_type, $rust_loaned_type), ); - validate_equivalence!($c_view_type, $rust_view_type); impl_transmute!(as_c_view($rust_view_type, $c_view_type)); impl_transmute!(as_rust($c_view_type, $rust_view_type)); }; @@ -388,18 +392,15 @@ macro_rules! decl_c_type { // (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_owned_type, Option<$rust_inner_type>); impl_owned!(owned $c_owned_type, inner rust option $rust_inner_type); }; (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_owned_type, Option<$rust_inner_type>); impl_owned!(owned $c_owned_type, inner rust option $rust_inner_type); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_owned_type, $rust_owned_type); impl_owned!(owned $c_owned_type, inner rust $rust_owned_type); }; // @@ -454,8 +455,6 @@ macro_rules! decl_c_type { loaned($c_loaned_type), view($c_view_type, $rust_view_type), ); - validate_equivalence!($c_owned_type, $c_loaned_type); - validate_equivalence!($c_view_type, $c_loaned_type); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), loaned ($c_loaned_type:ty $(,)?), @@ -466,8 +465,6 @@ macro_rules! decl_c_type { loaned($c_loaned_type, $rust_owned_type), view($c_view_type, $rust_view_type), ); - validate_equivalence!($c_owned_type, $c_loaned_type); - validate_equivalence!($c_view_type, $c_loaned_type); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?), @@ -478,8 +475,6 @@ macro_rules! decl_c_type { loaned($c_loaned_type, $rust_loaned_type), view($c_view_type, $rust_view_type), ); - validate_equivalence!($c_owned_type, $c_loaned_type); - validate_equivalence!($c_view_type, $c_loaned_type); }; // @@ -491,7 +486,6 @@ macro_rules! decl_c_type { loaned ($c_loaned_type:ty $(,)?), moved ($c_moved_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_owned_type, $c_loaned_type); impl_owned!(owned rust $c_owned_type, loaned $c_loaned_type); impl $crate::transmute::TakeCType for $c_moved_type { type CType = $c_owned_type; @@ -505,7 +499,6 @@ macro_rules! decl_c_type { // Rust type is copyable plain data type, just allow to convert references or copy whole structure // (copy ($c_type:ty, $rust_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_type, $rust_type); impl_transmute!(as_c($rust_type, $c_type)); impl_transmute!(as_rust($c_type, $rust_type)); impl_transmute!(into_c($rust_type, $c_type)); @@ -516,7 +509,6 @@ macro_rules! decl_c_type { // Specific case: no owned type exists // (loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_loaned_type, $rust_loaned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); From c023e9b1418b7554bb06bcd7004f31825a21733a Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 24 Sep 2024 09:40:28 +0400 Subject: [PATCH 03/38] mutable loaned type wraps rust owned type for equal size types --- build.rs | 2 +- include/zenoh_commons.h | 607 ++++++++++++------ include/zenoh_macros.h | 364 +---------- src/closures/query_channel.rs | 2 +- src/closures/response_channel.rs | 2 +- src/closures/sample_channel.rs | 2 +- src/collections.rs | 4 +- src/commons.rs | 2 +- src/config.rs | 9 +- src/encoding.rs | 4 +- src/get.rs | 7 +- src/info.rs | 2 +- src/keyexpr.rs | 2 +- src/liveliness.rs | 2 +- src/payload.rs | 4 +- src/platform/synchronization.rs | 26 +- src/publication_cache.rs | 2 +- src/publisher.rs | 9 +- src/queryable.rs | 12 +- src/querying_subscriber.rs | 2 +- src/scouting.rs | 9 +- src/session.rs | 2 +- src/shm/buffer/zshm.rs | 2 +- src/shm/buffer/zshmmut.rs | 2 +- src/shm/client/shm_client.rs | 2 +- src/shm/client_storage/mod.rs | 2 +- .../posix/posix_shm_client.rs | 2 +- .../posix/posix_shm_provider.rs | 2 +- src/shm/provider/alloc_layout.rs | 2 +- src/shm/provider/alloc_layout_impl.rs | 2 +- src/shm/provider/shm_provider.rs | 2 +- src/shm/provider/shm_provider_impl.rs | 2 +- src/shm/provider/types.rs | 2 +- src/subscriber.rs | 12 +- src/transmute.rs | 82 ++- 35 files changed, 541 insertions(+), 652 deletions(-) diff --git a/build.rs b/build.rs index 84c8ac427..5947f8f80 100644 --- a/build.rs +++ b/build.rs @@ -192,7 +192,7 @@ impl crate::transmute::TakeCType for {moved_type_name} {{ impl Drop for {type_name} {{ fn drop(&mut self) {{ - use crate::transmute::RustTypeRef; + use crate::transmute::RustTypeMut; std::mem::take(self.as_rust_type_mut()); }} }} diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 0c418b5dd..141e92f85 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -16,6 +16,32 @@ #define ALIGN(n) #define ZENOHC_API #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Allocation errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_alloc_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Defragmentation needed. + */ + Z_ALLOC_ERROR_NEED_DEFRAGMENT, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * The provider is out of memory. + */ + Z_ALLOC_ERROR_OUT_OF_MEMORY, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Other error. + */ + Z_ALLOC_ERROR_OTHER, +#endif +} z_alloc_error_t; +#endif typedef enum z_congestion_control_t { /** * Messages are not dropped in case of congestion. @@ -77,6 +103,26 @@ typedef enum z_keyexpr_intersection_level_t { Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3, } z_keyexpr_intersection_level_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Layouting errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_layout_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout arguments are incorrect. + */ + Z_LAYOUT_ERROR_INCORRECT_LAYOUT_ARGS, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout incompatible with provider. + */ + Z_LAYOUT_ERROR_PROVIDER_INCOMPATIBLE_LAYOUT, +#endif +} z_layout_error_t; +#endif /** * The priority of zenoh messages. */ @@ -169,6 +215,52 @@ typedef enum z_whatami_t { Z_WHATAMI_PEER = 2, Z_WHATAMI_CLIENT = 4, } z_whatami_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +} zc_buf_alloc_status_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_layout_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layouting error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_LAYOUT_ERROR = 2, +#endif +} zc_buf_layout_alloc_status_t; +#endif /** * The locality of samples to be received by subscribers or targeted by publishers. */ @@ -237,10 +329,53 @@ typedef enum zc_reply_keyexpr_t { ZC_REPLY_KEYEXPR_MATCHING_QUERY = 1, } zc_reply_keyexpr_t; #endif -typedef struct z_moved_alloc_layout_t { - struct z_owned_alloc_layout_t _this; -} z_moved_alloc_layout_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_alloc_result_t { + enum zc_buf_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t error; +} z_buf_alloc_result_t; +#endif typedef int8_t z_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocAlignment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_alloc_alignment_t { + uint8_t pow; +} z_alloc_alignment_t; +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_data_t { + void *ptr; +} zc_threadsafe_context_data_t; +#endif +/** + * A tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a thread-safe context - the associated callbacks may be executed concurrently with the same + * zc_context_t instance. In other words, all the callbacks associated with this context data MUST be + * thread-safe. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_t { + struct zc_threadsafe_context_data_t context; + void (*delete_fn)(void*); +} zc_threadsafe_context_t; +#endif typedef struct z_moved_bytes_t { struct z_owned_bytes_t _this; } z_moved_bytes_t; @@ -256,15 +391,41 @@ typedef struct z_moved_string_t { typedef struct ALIGN(8) z_bytes_slice_iterator_t { uint8_t _0[24]; } z_bytes_slice_iterator_t; -typedef struct z_moved_shm_t { - struct z_owned_shm_t _this; -} z_moved_shm_t; -typedef struct z_moved_shm_mut_t { - struct z_owned_shm_mut_t _this; -} z_moved_shm_mut_t; -typedef struct z_moved_chunk_alloc_result_t { - struct z_owned_chunk_alloc_result_t _this; -} z_moved_chunk_alloc_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Unique segment identifier. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_segment_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Chunk id within it's segment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_chunk_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A ChunkDescriptor. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_chunk_descriptor_t { + z_segment_id_t segment; + z_chunk_id_t chunk; + size_t len; +} z_chunk_descriptor_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocatedChunk. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_allocated_chunk_t { + struct z_chunk_descriptor_t descriptpr; + void *data; +} z_allocated_chunk_t; +#endif /** * Monotonic clock */ @@ -422,7 +583,7 @@ typedef struct z_owned_closure_zid_t { /** * A callback function. */ - void (*call)(const struct z_id_t *z_id, void *context); + void (*call)(const z_id_t *z_id, void *context); /** * An optional function that will be called upon closure drop. */ @@ -554,9 +715,6 @@ typedef struct z_moved_fifo_handler_sample_t { typedef struct z_query_consolidation_t { enum z_consolidation_mode_t mode; } z_query_consolidation_t; -typedef struct z_moved_source_info_t { - struct z_owned_source_info_t _this; -} z_moved_source_info_t; /** * Options passed to the `z_get()` function. */ @@ -611,7 +769,7 @@ typedef struct z_get_options_t { * * The source info for the query. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * An optional attachment to attach to the query. @@ -628,9 +786,6 @@ typedef struct z_moved_hello_t { typedef struct z_moved_keyexpr_t { struct z_owned_keyexpr_t _this; } z_moved_keyexpr_t; -typedef struct z_moved_memory_layout_t { - struct z_owned_memory_layout_t _this; -} z_moved_memory_layout_t; typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; @@ -671,7 +826,7 @@ typedef struct z_publisher_put_options_t { * * The source info for the publication. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to attach to the publication. @@ -724,7 +879,7 @@ typedef struct z_put_options_t { * * The source info for the message. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this message. @@ -765,7 +920,7 @@ typedef struct z_query_reply_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -799,7 +954,7 @@ typedef struct z_query_reply_del_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -850,15 +1005,46 @@ typedef struct z_scout_options_t { */ enum z_what_t what; } z_scout_options_t; -typedef struct z_moved_shm_client_t { - struct z_owned_shm_client_t _this; -} z_moved_shm_client_t; -typedef struct z_moved_shm_client_storage_t { - struct z_owned_shm_client_storage_t _this; -} z_moved_shm_client_storage_t; -typedef struct z_moved_shm_provider_t { - struct z_owned_shm_provider_t _this; -} z_moved_shm_provider_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_segment_callbacks_t { + uint8_t *(*map_fn)(z_chunk_id_t chunk_id, void *context); +} zc_shm_segment_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_shm_segment_t { + struct zc_threadsafe_context_t context; + struct zc_shm_segment_callbacks_t callbacks; +} z_shm_segment_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callback for ShmClient. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_client_callbacks_t { + bool (*attach_fn)(struct z_shm_segment_t *out_segment, z_segment_id_t segment_id, void *context); +} zc_shm_client_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_layout_alloc_result_t { + enum zc_buf_layout_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t alloc_error; + enum z_layout_error_t layout_error; +} z_buf_layout_alloc_result_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Unique protocol identifier. @@ -868,6 +1054,47 @@ typedef struct z_moved_shm_provider_t { #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) typedef uint32_t z_protocol_id_t; #endif +/** + * A non-tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same + * zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated + * with this context data are not required to be thread-safe. + * + * NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can + * still be executed concurrently. The exact behavior depends on user's application, but we strongly + * discourage our users from pinning to some specific behavior unless they _really_ understand what they + * are doing. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_context_t { + void *context; + void (*delete_fn)(void*); +} zc_context_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmProviderBackend. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_provider_backend_callbacks_t { + void (*alloc_fn)(z_owned_chunk_alloc_result_t *out_result, + const z_loaned_memory_layout_t *layout, + void *context); + void (*free_fn)(const struct z_chunk_descriptor_t *chunk, void *context); + size_t (*defragment_fn)(void *context); + size_t (*available_fn)(void *context); + void (*layout_for_fn)(z_owned_memory_layout_t *layout, void *context); +} zc_shm_provider_backend_callbacks_t; +#endif typedef struct z_moved_string_array_t { struct z_owned_string_array_t _this; } z_moved_string_array_t; @@ -955,6 +1182,15 @@ typedef struct zc_owned_closure_matching_status_t { void (*drop)(void *context); } zc_owned_closure_matching_status_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Loaned closure. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +typedef struct zc_loaned_closure_matching_status_t { + size_t _0[3]; +} zc_loaned_closure_matching_status_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. @@ -991,15 +1227,6 @@ typedef struct zc_liveliness_get_options_t { uint32_t timeout_ms; } zc_liveliness_get_options_t; #endif -typedef struct zc_moved_liveliness_token_t { - struct zc_owned_liveliness_token_t _this; -} zc_moved_liveliness_token_t; -typedef struct zc_moved_matching_listener_t { - struct zc_owned_matching_listener_t _this; -} zc_moved_matching_listener_t; -typedef struct zc_moved_shm_client_list_t { - struct zc_owned_shm_client_list_t _this; -} zc_moved_shm_client_list_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Options passed to the `ze_declare_publication_cache()` function. @@ -1068,19 +1295,6 @@ typedef struct ze_querying_subscriber_options_t { uint64_t query_timeout_ms; } ze_querying_subscriber_options_t; #endif -typedef struct ze_moved_publication_cache_t { - struct ze_owned_publication_cache_t _this; -} ze_moved_publication_cache_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A loaned Zenoh publication cache. - */ -typedef struct ALIGN(8) ze_loaned_publication_cache_t { - uint8_t _0[96]; -} ze_loaned_publication_cache_t; -typedef struct ze_moved_querying_subscriber_t { - struct ze_owned_querying_subscriber_t _this; -} ze_moved_querying_subscriber_t; ZENOHC_API extern const unsigned int Z_ROUTER; ZENOHC_API extern const unsigned int Z_PEER; ZENOHC_API extern const unsigned int Z_CLIENT; @@ -1100,40 +1314,39 @@ ZENOHC_API extern const unsigned int Z_SHM_POSIX_PROTOCOL_ID; #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_blocking(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif /** * Deletes Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_alloc_layout_drop(struct z_moved_alloc_layout_t *this_); +ZENOHC_API void z_alloc_layout_drop(z_moved_alloc_layout_t *this_); #endif /** * Borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1141,15 +1354,15 @@ const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_a */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_alloc_layout_new(z_owned_alloc_layout_t *this_, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout, + const z_loaned_alloc_layout_t *layout, struct zc_threadsafe_context_t result_context, void (*result_callback)(void*, struct z_buf_alloc_result_t*)); @@ -1210,7 +1423,7 @@ z_result_t z_bytes_deserialize_into_int8(const struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_loaned_shm(const struct z_loaned_bytes_t *this_, - const struct z_loaned_shm_t **dst); + const z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1222,7 +1435,7 @@ z_result_t z_bytes_deserialize_into_loaned_shm(const struct z_loaned_bytes_t *th #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_mut_loaned_shm(struct z_loaned_bytes_t *this_, - struct z_loaned_shm_t **dst); + z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1234,7 +1447,7 @@ z_result_t z_bytes_deserialize_into_mut_loaned_shm(struct z_loaned_bytes_t *this #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_owned_shm(const struct z_loaned_bytes_t *this_, - struct z_owned_shm_t *dst); + z_owned_shm_t *dst); #endif /** * Deserializes into a pair of `z_owned_bytes_t` objects. @@ -1503,7 +1716,7 @@ ZENOHC_API void z_bytes_serialize_from_int8(struct z_owned_bytes_t *this_, int8_ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_serialize_from_shm(struct z_owned_bytes_t *this_, - struct z_moved_shm_t *shm); + z_moved_shm_t *shm); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1512,7 +1725,7 @@ z_result_t z_bytes_serialize_from_shm(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_serialize_from_shm_mut(struct z_owned_bytes_t *this_, - struct z_moved_shm_mut_t *shm); + z_moved_shm_mut_t *shm); #endif /** * Serializes a slice by copying. @@ -1591,7 +1804,7 @@ z_result_t z_bytes_writer_write_all(struct z_bytes_writer_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); +void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1599,7 +1812,7 @@ void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const struct z_owned_chunk_alloc_result_t *this_); +const z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1607,7 +1820,7 @@ const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const stru */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, +void z_chunk_alloc_result_new_error(z_owned_chunk_alloc_result_t *this_, enum z_alloc_error_t alloc_error); #endif /** @@ -1616,7 +1829,7 @@ void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this_, +z_result_t z_chunk_alloc_result_new_ok(z_owned_chunk_alloc_result_t *this_, struct z_allocated_chunk_t allocated_chunk); #endif /** @@ -1766,7 +1979,7 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid(struct z_owned_closure_zid_t *this_, - void (*call)(const struct z_id_t *z_id, void *context), + void (*call)(const z_id_t *z_id, void *context), void (*drop)(void *context), void *context); #endif @@ -1777,7 +1990,7 @@ void z_closure_zid(struct z_owned_closure_zid_t *this_, #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, - const struct z_id_t *z_id); + const z_id_t *z_id); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2430,7 +2643,7 @@ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_zenoh_uint8(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); +uint32_t z_entity_global_id_eid(const z_entity_global_id_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2438,7 +2651,7 @@ uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_entity_global_id_zid(const struct z_entity_global_id_t *this_); +z_id_t z_entity_global_id_zid(const z_entity_global_id_t *this_); #endif /** * Constructs send and recieve ends of the fifo channel @@ -2590,7 +2803,7 @@ ZENOHC_API enum z_whatami_t z_hello_whatami(const struct z_loaned_hello_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); +z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2598,7 +2811,7 @@ struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_id_to_string(const struct z_id_t *zid, +void z_id_to_string(const z_id_t *zid, struct z_owned_string_t *dst); #endif /** @@ -2639,19 +2852,19 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_info_zid(const struct z_loaned_session_t *session); +z_id_t z_info_zid(const struct z_loaned_session_t *session); #endif /** * Returns ``true`` if `this` is valid. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_internal_alloc_layout_check(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); #endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_internal_alloc_layout_null(struct z_owned_alloc_layout_t *this_); +ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); #endif /** * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -2667,7 +2880,7 @@ ZENOHC_API void z_internal_bytes_null(struct z_owned_bytes_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result_t *this_); +bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2675,7 +2888,7 @@ bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_chunk_alloc_result_null(struct z_owned_chunk_alloc_result_t *this_); +void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); #endif /** * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. @@ -2798,7 +3011,7 @@ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_); +bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2806,7 +3019,7 @@ bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_memory_layout_null(struct z_owned_memory_layout_t *this_); +void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); #endif /** * Returns ``true`` if mutex is valid, ``false`` otherwise. @@ -2905,7 +3118,7 @@ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_check(const struct z_owned_shm_t *this_); +bool z_internal_shm_check(const z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2913,7 +3126,7 @@ bool z_internal_shm_check(const struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); +bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2921,7 +3134,7 @@ bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); +void z_internal_shm_client_null(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2929,7 +3142,7 @@ void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage_t *this_); +bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2937,7 +3150,7 @@ bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *this_); +void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2945,7 +3158,7 @@ void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); +bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2953,7 +3166,7 @@ bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); +void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2961,7 +3174,7 @@ void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_null(struct z_owned_shm_t *this_); +void z_internal_shm_null(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2969,7 +3182,7 @@ void z_internal_shm_null(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); +bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2977,7 +3190,7 @@ bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_provider_null(struct z_owned_shm_provider_t *this_); +void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); #endif /** * @return ``true`` if slice is not empty, ``false`` otherwise. @@ -2993,7 +3206,7 @@ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); +bool z_internal_source_info_check(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3001,7 +3214,7 @@ bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_internal_source_info_null(struct z_owned_source_info_t *this_); +void z_internal_source_info_null(z_owned_source_info_t *this_); #endif /** * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. @@ -3178,7 +3391,7 @@ enum z_keyexpr_intersection_level_t z_keyexpr_relation_to(const struct z_loaned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); +void z_memory_layout_drop(z_moved_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3186,7 +3399,7 @@ void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, +void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, size_t *out_size, struct z_alloc_alignment_t *out_alignment); #endif @@ -3196,7 +3409,7 @@ void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned_memory_layout_t *this_); +const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3204,7 +3417,7 @@ const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, +z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3260,7 +3473,7 @@ ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); ZENOHC_API z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, struct z_moved_config_t *config, - const struct z_loaned_shm_client_storage_t *shm_clients); + const z_loaned_shm_client_storage_t *shm_clients); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3268,7 +3481,7 @@ z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); +void z_posix_shm_client_new(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3276,8 +3489,8 @@ void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_posix_shm_provider_new(struct z_owned_shm_provider_t *this_, - const struct z_loaned_memory_layout_t *layout); +z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, + const z_loaned_memory_layout_t *layout); #endif /** * Returns the default value of #z_priority_t. @@ -3305,7 +3518,7 @@ ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); +z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); #endif /** * Returns the key expression of the publisher. @@ -3528,7 +3741,7 @@ void z_queryable_drop(struct z_moved_queryable_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); +z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); #endif ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); @@ -3561,7 +3774,7 @@ ZENOHC_API uint8_t z_random_u8(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_ref_shm_client_storage_global(struct z_owned_shm_client_storage_t *this_); +void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3633,7 +3846,7 @@ ZENOHC_API const struct z_loaned_sample_t *z_reply_ok(const struct z_loaned_repl #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API bool z_reply_replier_id(const struct z_loaned_reply_t *this_, - struct z_id_t *out_id); + z_id_t *out_id); #endif /** * Constructs send and recieve ends of the ring channel @@ -3796,7 +4009,7 @@ enum z_reliability_t z_sample_reliability(const struct z_loaned_sample_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); +const z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); #endif /** * Returns the sample timestamp. @@ -3835,7 +4048,7 @@ ZENOHC_API const struct z_loaned_session_t *z_session_loan(const struct z_owned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_drop(struct z_moved_shm_client_t *this_); +void z_shm_client_drop(z_moved_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3843,7 +4056,7 @@ void z_shm_client_drop(struct z_moved_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_new(struct z_owned_shm_client_t *this_, +void z_shm_client_new(z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif @@ -3853,8 +4066,8 @@ void z_shm_client_new(struct z_owned_shm_client_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, - const struct z_loaned_shm_client_storage_t *from); +void z_shm_client_storage_clone(z_owned_shm_client_storage_t *this_, + const z_loaned_shm_client_storage_t *from); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3862,7 +4075,7 @@ void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); +void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3870,15 +4083,15 @@ void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const struct z_owned_shm_client_storage_t *this_); +const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, - const struct zc_loaned_shm_client_list_t *clients, +z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, + const zc_loaned_shm_client_list_t *clients, bool add_default_client_set); #endif /** @@ -3886,7 +4099,7 @@ z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_); +void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3894,8 +4107,8 @@ void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_clone(struct z_owned_shm_t *out, - const struct z_loaned_shm_t *this_); +void z_shm_clone(z_owned_shm_t *out, + const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3903,7 +4116,7 @@ void z_shm_clone(struct z_owned_shm_t *out, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); +const unsigned char *z_shm_data(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3911,7 +4124,7 @@ const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_drop(struct z_moved_shm_t *this_); +void z_shm_drop(z_moved_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3919,8 +4132,8 @@ void z_shm_drop(struct z_moved_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_from_mut(struct z_owned_shm_t *this_, - struct z_moved_shm_mut_t *that); +void z_shm_from_mut(z_owned_shm_t *this_, + z_moved_shm_mut_t *that); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3928,7 +4141,7 @@ void z_shm_from_mut(struct z_owned_shm_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_len(const struct z_loaned_shm_t *this_); +size_t z_shm_len(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3936,13 +4149,13 @@ size_t z_shm_len(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_t *z_shm_loan(const struct z_owned_shm_t *this_); +const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); #endif /** * @brief Mutably borrows ZShm slice. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); +ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3950,7 +4163,7 @@ ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); +const unsigned char *z_shm_mut_data(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3958,7 +4171,7 @@ const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); +unsigned char *z_shm_mut_data_mut(z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3966,7 +4179,7 @@ unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); +void z_shm_mut_drop(z_moved_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3974,7 +4187,7 @@ void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); +size_t z_shm_mut_len(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3982,7 +4195,7 @@ size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t *this_); +const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3990,7 +4203,7 @@ const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); +z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4004,9 +4217,9 @@ struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, - struct z_moved_shm_t *that, - struct z_owned_shm_t *immut); +z_result_t z_shm_mut_try_from_immut(z_owned_shm_mut_t *this_, + z_moved_shm_t *that, + z_owned_shm_t *immut); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4014,7 +4227,7 @@ z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4024,7 +4237,7 @@ void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4034,7 +4247,7 @@ void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4044,7 +4257,7 @@ void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_resu #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment, struct zc_threadsafe_context_t result_context, @@ -4057,7 +4270,7 @@ z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4067,7 +4280,7 @@ void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4076,14 +4289,14 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_available(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_defragment(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4091,14 +4304,14 @@ size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_drop(struct z_moved_shm_provider_t *this_); +void z_shm_provider_drop(z_moved_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4106,15 +4319,15 @@ size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *prov */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_shm_provider_t *this_); +const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_shm_provider_map(z_owned_shm_mut_t *out_result, + const z_loaned_shm_provider_t *provider, struct z_allocated_chunk_t allocated_chunk, size_t len); #endif @@ -4124,7 +4337,7 @@ z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4135,7 +4348,7 @@ void z_shm_provider_new(struct z_owned_shm_provider_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_threadsafe_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_threadsafe_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4146,7 +4359,7 @@ void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4154,7 +4367,7 @@ struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_reloan_mut(struct z_loaned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_reloan_mut(z_loaned_shm_t *this_); #endif /** * Puts current thread to sleep for specified amount of milliseconds. @@ -4227,7 +4440,7 @@ ZENOHC_API const struct z_loaned_slice_t *z_slice_loan(const struct z_owned_slic */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_drop(struct z_moved_source_info_t *this_); +void z_source_info_drop(z_moved_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4235,7 +4448,7 @@ void z_source_info_drop(struct z_moved_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t *this_); +z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4243,7 +4456,7 @@ struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_source_info_t *this_); +const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4251,8 +4464,8 @@ const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_sou */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t z_source_info_new(struct z_owned_source_info_t *this_, - const struct z_entity_global_id_t *source_id, +z_result_t z_source_info_new(z_owned_source_info_t *this_, + const z_entity_global_id_t *source_id, uint32_t source_sn); #endif /** @@ -4261,7 +4474,7 @@ z_result_t z_source_info_new(struct z_owned_source_info_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); +uint32_t z_source_info_sn(const z_loaned_source_info_t *this_); #endif /** * Constructs an owned copy of a string array. @@ -4455,7 +4668,7 @@ const char *z_time_now_as_str(const char *buf, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_timestamp_id(const struct z_timestamp_t *this_); +z_id_t z_timestamp_id(const struct z_timestamp_t *this_); #endif /** * Create uhlc timestamp from session id. @@ -4830,7 +5043,7 @@ void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_s */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t *this_); +bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4838,7 +5051,7 @@ bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_); +void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4846,7 +5059,7 @@ void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener_t *this_); +bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4854,7 +5067,7 @@ bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *this_); +void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4862,7 +5075,7 @@ void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t *this_); +bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4870,7 +5083,7 @@ bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_internal_shm_client_list_null(struct zc_owned_shm_client_list_t *this_); +void zc_internal_shm_client_list_null(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4914,7 +5127,7 @@ z_result_t zc_liveliness_declare_subscriber(struct z_owned_subscriber_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_declare_token(struct zc_owned_liveliness_token_t *this_, +z_result_t zc_liveliness_declare_token(zc_owned_liveliness_token_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, const struct zc_liveliness_declaration_options_t *_options); @@ -4957,7 +5170,7 @@ void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_op */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); +void zc_liveliness_token_drop(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4965,7 +5178,7 @@ void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct zc_owned_liveliness_token_t *this_); +const zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4973,7 +5186,7 @@ const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_undeclare_token(struct zc_moved_liveliness_token_t *this_); +z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5006,7 +5219,7 @@ z_result_t zc_publisher_get_matching_status(const struct z_loaned_publisher_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_publisher_matching_listener_declare(struct zc_owned_matching_listener_t *this_, +z_result_t zc_publisher_matching_listener_declare(zc_owned_matching_listener_t *this_, const struct z_loaned_publisher_t *publisher, struct zc_moved_closure_matching_status_t *callback); #endif @@ -5016,7 +5229,7 @@ z_result_t zc_publisher_matching_listener_declare(struct zc_owned_matching_liste */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *this_); +void zc_publisher_matching_listener_drop(zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5026,7 +5239,7 @@ void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *th */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_publisher_matching_listener_undeclare(struct zc_moved_matching_listener_t *this_); +z_result_t zc_publisher_matching_listener_undeclare(zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5041,9 +5254,9 @@ enum zc_reply_keyexpr_t zc_reply_keyexpr_default(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *this_, +z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, - struct z_moved_shm_client_t *client); + z_moved_shm_client_t *client); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5051,7 +5264,7 @@ z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); +void zc_shm_client_list_drop(zc_moved_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5059,7 +5272,7 @@ void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct zc_owned_shm_client_list_t *this_); +const zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5067,7 +5280,7 @@ const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct z */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_shm_client_list_t *this_); +zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5075,7 +5288,7 @@ struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_new(struct zc_owned_shm_client_list_t *this_); +void zc_shm_client_list_new(zc_owned_shm_client_list_t *this_); #endif /** * Stops all Zenoh tasks and drops all related static variables. @@ -5107,7 +5320,7 @@ void zc_try_init_log_from_env(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_declare_publication_cache(struct ze_owned_publication_cache_t *this_, +z_result_t ze_declare_publication_cache(ze_owned_publication_cache_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, struct ze_publication_cache_options_t *options); @@ -5126,7 +5339,7 @@ z_result_t ze_declare_publication_cache(struct ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_declare_querying_subscriber(struct ze_owned_querying_subscriber_t *this_, +z_result_t ze_declare_querying_subscriber(ze_owned_querying_subscriber_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, struct z_moved_closure_sample_t *callback, @@ -5138,7 +5351,7 @@ z_result_t ze_declare_querying_subscriber(struct ze_owned_querying_subscriber_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache_t *this_); +bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5146,7 +5359,7 @@ bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *this_); +void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5154,13 +5367,13 @@ void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *this_); +bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); #endif /** * Constructs a querying subscriber in a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_subscriber_t *this_); +ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5168,7 +5381,7 @@ ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_su */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); +void ze_publication_cache_drop(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5176,7 +5389,7 @@ void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_loaned_publication_cache_t *this_); +const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const ze_loaned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5184,7 +5397,7 @@ const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_lo */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_publication_cache_t *ze_publication_cache_loan(const struct ze_owned_publication_cache_t *this_); +const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5201,7 +5414,7 @@ void ze_publication_cache_options_default(struct ze_publication_cache_options_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); +void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5211,7 +5424,7 @@ void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber_t *this_, +z_result_t ze_querying_subscriber_get(const ze_loaned_querying_subscriber_t *this_, const struct z_loaned_keyexpr_t *selector, struct z_get_options_t *options); #endif @@ -5221,7 +5434,7 @@ z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *this_); +const ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5238,7 +5451,7 @@ void ze_querying_subscriber_options_default(struct ze_querying_subscriber_option */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *this_); +z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5248,5 +5461,5 @@ z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_querying_subscriber(struct ze_moved_querying_subscriber_t *this_); +z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *this_); #endif diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index d6c3b70f1..08b5243f4 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -4,14 +4,11 @@ #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return (z_moved_alloc_layout_t*)(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return (z_moved_bytes_t*)(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return (z_moved_chunk_alloc_result_t*)(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return (z_moved_closure_hello_t*)(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return (z_moved_closure_query_t*)(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return (z_moved_closure_reply_t*)(x); } static inline z_moved_closure_sample_t* z_closure_sample_move(z_owned_closure_sample_t* x) { return (z_moved_closure_sample_t*)(x); } -static inline z_moved_closure_zid_t* z_closure_zid_move(z_owned_closure_zid_t* x) { return (z_moved_closure_zid_t*)(x); } static inline z_moved_condvar_t* z_condvar_move(z_owned_condvar_t* x) { return (z_moved_condvar_t*)(x); } static inline z_moved_config_t* z_config_move(z_owned_config_t* x) { return (z_moved_config_t*)(x); } static inline z_moved_encoding_t* z_encoding_move(z_owned_encoding_t* x) { return (z_moved_encoding_t*)(x); } @@ -20,7 +17,6 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return (z_moved_fifo_handler_sample_t*)(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return (z_moved_hello_t*)(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return (z_moved_keyexpr_t*)(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return (z_moved_memory_layout_t*)(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return (z_moved_mutex_t*)(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return (z_moved_publisher_t*)(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return (z_moved_query_t*)(x); } @@ -32,36 +28,21 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return (z_moved_ring_handler_sample_t*)(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return (z_moved_sample_t*)(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return (z_moved_session_t*)(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return (z_moved_shm_client_t*)(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return (z_moved_shm_client_storage_t*)(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return (z_moved_shm_t*)(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return (z_moved_shm_mut_t*)(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return (z_moved_shm_provider_t*)(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return (z_moved_slice_t*)(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return (z_moved_source_info_t*)(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return (z_moved_string_array_t*)(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return (z_moved_string_t*)(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return (z_moved_subscriber_t*)(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return (z_moved_task_t*)(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return (zc_moved_closure_log_t*)(x); } -static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return (zc_moved_closure_matching_status_t*)(x); } -static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return (zc_moved_liveliness_token_t*)(x); } -static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return (zc_moved_matching_listener_t*)(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return (zc_moved_shm_client_list_t*)(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return (ze_moved_publication_cache_t*)(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return (ze_moved_querying_subscriber_t*)(x); } #define z_loan(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_loan, \ z_owned_bytes_t : z_bytes_loan, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ z_owned_closure_query_t : z_closure_query_loan, \ z_owned_closure_reply_t : z_closure_reply_loan, \ z_owned_closure_sample_t : z_closure_sample_loan, \ - z_owned_closure_zid_t : z_closure_zid_loan, \ z_owned_condvar_t : z_condvar_loan, \ z_owned_config_t : z_config_loan, \ z_owned_encoding_t : z_encoding_loan, \ @@ -70,7 +51,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan, \ z_owned_hello_t : z_hello_loan, \ z_owned_keyexpr_t : z_keyexpr_loan, \ - z_owned_memory_layout_t : z_memory_layout_loan, \ z_owned_publisher_t : z_publisher_loan, \ z_owned_query_t : z_query_loan, \ z_owned_queryable_t : z_queryable_loan, \ @@ -81,24 +61,14 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_ring_handler_sample_t : z_ring_handler_sample_loan, \ z_owned_sample_t : z_sample_loan, \ z_owned_session_t : z_session_loan, \ - z_owned_shm_client_storage_t : z_shm_client_storage_loan, \ - z_owned_shm_t : z_shm_loan, \ - z_owned_shm_mut_t : z_shm_mut_loan, \ - z_owned_shm_provider_t : z_shm_provider_loan, \ z_owned_slice_t : z_slice_loan, \ - z_owned_source_info_t : z_source_info_loan, \ z_owned_string_array_t : z_string_array_loan, \ z_owned_string_t : z_string_loan, \ z_owned_subscriber_t : z_subscriber_loan, \ z_view_keyexpr_t : z_view_keyexpr_loan, \ z_view_slice_t : z_view_slice_loan, \ z_view_string_t : z_view_string_loan, \ - zc_owned_closure_log_t : zc_closure_log_loan, \ - zc_owned_closure_matching_status_t : zc_closure_matching_status_loan, \ - zc_owned_liveliness_token_t : zc_liveliness_token_loan, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan, \ - ze_owned_publication_cache_t : ze_publication_cache_loan, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_loan \ + zc_owned_closure_log_t : zc_closure_log_loan \ )(&this_) #define z_loan_mut(this_) \ @@ -109,22 +79,16 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_encoding_t : z_encoding_loan_mut, \ z_owned_mutex_t : z_mutex_loan_mut, \ z_owned_publisher_t : z_publisher_loan_mut, \ - z_owned_shm_t : z_shm_loan_mut, \ - z_owned_shm_mut_t : z_shm_mut_loan_mut, \ - z_owned_string_array_t : z_string_array_loan_mut, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut \ + z_owned_string_array_t : z_string_array_loan_mut \ )(&this_) #define z_drop(this_) \ _Generic((this_), \ - z_moved_alloc_layout_t* : z_alloc_layout_drop, \ z_moved_bytes_t* : z_bytes_drop, \ - z_moved_chunk_alloc_result_t* : z_chunk_alloc_result_drop, \ z_moved_closure_hello_t* : z_closure_hello_drop, \ z_moved_closure_query_t* : z_closure_query_drop, \ z_moved_closure_reply_t* : z_closure_reply_drop, \ z_moved_closure_sample_t* : z_closure_sample_drop, \ - z_moved_closure_zid_t* : z_closure_zid_drop, \ z_moved_condvar_t* : z_condvar_drop, \ z_moved_config_t* : z_config_drop, \ z_moved_encoding_t* : z_encoding_drop, \ @@ -133,7 +97,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_moved_fifo_handler_sample_t* : z_fifo_handler_sample_drop, \ z_moved_hello_t* : z_hello_drop, \ z_moved_keyexpr_t* : z_keyexpr_drop, \ - z_moved_memory_layout_t* : z_memory_layout_drop, \ z_moved_mutex_t* : z_mutex_drop, \ z_moved_publisher_t* : z_publisher_drop, \ z_moved_query_t* : z_query_drop, \ @@ -145,36 +108,21 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_moved_ring_handler_sample_t* : z_ring_handler_sample_drop, \ z_moved_sample_t* : z_sample_drop, \ z_moved_session_t* : z_session_drop, \ - z_moved_shm_client_t* : z_shm_client_drop, \ - z_moved_shm_client_storage_t* : z_shm_client_storage_drop, \ - z_moved_shm_t* : z_shm_drop, \ - z_moved_shm_mut_t* : z_shm_mut_drop, \ - z_moved_shm_provider_t* : z_shm_provider_drop, \ z_moved_slice_t* : z_slice_drop, \ - z_moved_source_info_t* : z_source_info_drop, \ z_moved_string_array_t* : z_string_array_drop, \ z_moved_string_t* : z_string_drop, \ z_moved_subscriber_t* : z_subscriber_drop, \ z_moved_task_t* : z_task_drop, \ - zc_moved_closure_log_t* : zc_closure_log_drop, \ - zc_moved_closure_matching_status_t* : zc_closure_matching_status_drop, \ - zc_moved_liveliness_token_t* : zc_liveliness_token_drop, \ - zc_moved_matching_listener_t* : zc_publisher_matching_listener_drop, \ - zc_moved_shm_client_list_t* : zc_shm_client_list_drop, \ - ze_moved_publication_cache_t* : ze_publication_cache_drop, \ - ze_moved_querying_subscriber_t* : ze_querying_subscriber_drop \ + zc_moved_closure_log_t* : zc_closure_log_drop \ )(this_) #define z_move(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_move, \ z_owned_bytes_t : z_bytes_move, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_move, \ z_owned_closure_hello_t : z_closure_hello_move, \ z_owned_closure_query_t : z_closure_query_move, \ z_owned_closure_reply_t : z_closure_reply_move, \ z_owned_closure_sample_t : z_closure_sample_move, \ - z_owned_closure_zid_t : z_closure_zid_move, \ z_owned_condvar_t : z_condvar_move, \ z_owned_config_t : z_config_move, \ z_owned_encoding_t : z_encoding_move, \ @@ -183,7 +131,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_fifo_handler_sample_t : z_fifo_handler_sample_move, \ z_owned_hello_t : z_hello_move, \ z_owned_keyexpr_t : z_keyexpr_move, \ - z_owned_memory_layout_t : z_memory_layout_move, \ z_owned_mutex_t : z_mutex_move, \ z_owned_publisher_t : z_publisher_move, \ z_owned_query_t : z_query_move, \ @@ -195,36 +142,21 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_ring_handler_sample_t : z_ring_handler_sample_move, \ z_owned_sample_t : z_sample_move, \ z_owned_session_t : z_session_move, \ - z_owned_shm_client_t : z_shm_client_move, \ - z_owned_shm_client_storage_t : z_shm_client_storage_move, \ - z_owned_shm_t : z_shm_move, \ - z_owned_shm_mut_t : z_shm_mut_move, \ - z_owned_shm_provider_t : z_shm_provider_move, \ z_owned_slice_t : z_slice_move, \ - z_owned_source_info_t : z_source_info_move, \ z_owned_string_array_t : z_string_array_move, \ z_owned_string_t : z_string_move, \ z_owned_subscriber_t : z_subscriber_move, \ z_owned_task_t : z_task_move, \ - zc_owned_closure_log_t : zc_closure_log_move, \ - zc_owned_closure_matching_status_t : zc_closure_matching_status_move, \ - zc_owned_liveliness_token_t : zc_liveliness_token_move, \ - zc_owned_matching_listener_t : zc_publisher_matching_listener_move, \ - zc_owned_shm_client_list_t : zc_shm_client_list_move, \ - ze_owned_publication_cache_t : ze_publication_cache_move, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_move \ + zc_owned_closure_log_t : zc_closure_log_move \ )(&this_) #define z_internal_null(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_internal_alloc_layout_null, \ z_owned_bytes_t* : z_internal_bytes_null, \ - z_owned_chunk_alloc_result_t* : z_internal_chunk_alloc_result_null, \ z_owned_closure_hello_t* : z_internal_closure_hello_null, \ z_owned_closure_query_t* : z_internal_closure_query_null, \ z_owned_closure_reply_t* : z_internal_closure_reply_null, \ z_owned_closure_sample_t* : z_internal_closure_sample_null, \ - z_owned_closure_zid_t* : z_internal_closure_zid_null, \ z_owned_condvar_t* : z_internal_condvar_null, \ z_owned_config_t* : z_internal_config_null, \ z_owned_encoding_t* : z_internal_encoding_null, \ @@ -233,7 +165,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_fifo_handler_sample_t* : z_internal_fifo_handler_sample_null, \ z_owned_hello_t* : z_internal_hello_null, \ z_owned_keyexpr_t* : z_internal_keyexpr_null, \ - z_owned_memory_layout_t* : z_internal_memory_layout_null, \ z_owned_mutex_t* : z_internal_mutex_null, \ z_owned_publisher_t* : z_internal_publisher_null, \ z_owned_query_t* : z_internal_query_null, \ @@ -245,34 +176,19 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_ring_handler_sample_t* : z_internal_ring_handler_sample_null, \ z_owned_sample_t* : z_internal_sample_null, \ z_owned_session_t* : z_internal_session_null, \ - z_owned_shm_client_t* : z_internal_shm_client_null, \ - z_owned_shm_client_storage_t* : z_internal_shm_client_storage_null, \ - z_owned_shm_mut_t* : z_internal_shm_mut_null, \ - z_owned_shm_t* : z_internal_shm_null, \ - z_owned_shm_provider_t* : z_internal_shm_provider_null, \ z_owned_slice_t* : z_internal_slice_null, \ - z_owned_source_info_t* : z_internal_source_info_null, \ z_owned_string_array_t* : z_internal_string_array_null, \ z_owned_string_t* : z_internal_string_null, \ z_owned_subscriber_t* : z_internal_subscriber_null, \ z_owned_task_t* : z_internal_task_null, \ - zc_owned_closure_log_t* : zc_internal_closure_log_null, \ - zc_owned_closure_matching_status_t* : zc_internal_closure_matching_status_null, \ - zc_owned_liveliness_token_t* : zc_internal_liveliness_token_null, \ - zc_owned_matching_listener_t* : zc_internal_matching_listener_null, \ - zc_owned_shm_client_list_t* : zc_internal_shm_client_list_null, \ - ze_owned_publication_cache_t* : ze_internal_publication_cache_null, \ - ze_owned_querying_subscriber_t* : ze_internal_querying_subscriber_null \ + zc_owned_closure_log_t* : zc_internal_closure_log_null \ )(this_) -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } static inline void z_closure_sample_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { *closure_ = x->_this; z_internal_closure_sample_null(&x->_this); } -static inline void z_closure_zid_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { *closure_ = x->_this; z_internal_closure_zid_null(&x->_this); } static inline void z_condvar_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { *this_ = x->_this; z_internal_condvar_null(&x->_this); } static inline void z_config_take(z_owned_config_t* this_, z_moved_config_t* x) { *this_ = x->_this; z_internal_config_null(&x->_this); } static inline void z_encoding_take(z_owned_encoding_t* this_, z_moved_encoding_t* x) { *this_ = x->_this; z_internal_encoding_null(&x->_this); } @@ -281,7 +197,6 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -293,36 +208,21 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } -static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } -static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } #define z_take(this_, x) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_alloc_layout_take, \ z_owned_bytes_t* : z_bytes_take, \ - z_owned_chunk_alloc_result_t* : z_chunk_alloc_result_take, \ z_owned_closure_hello_t* : z_closure_hello_take, \ z_owned_closure_query_t* : z_closure_query_take, \ z_owned_closure_reply_t* : z_closure_reply_take, \ z_owned_closure_sample_t* : z_closure_sample_take, \ - z_owned_closure_zid_t* : z_closure_zid_take, \ z_owned_condvar_t* : z_condvar_take, \ z_owned_config_t* : z_config_take, \ z_owned_encoding_t* : z_encoding_take, \ @@ -331,7 +231,6 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ z_owned_hello_t* : z_hello_take, \ z_owned_keyexpr_t* : z_keyexpr_take, \ - z_owned_memory_layout_t* : z_memory_layout_take, \ z_owned_mutex_t* : z_mutex_take, \ z_owned_publisher_t* : z_publisher_take, \ z_owned_query_t* : z_query_take, \ @@ -343,36 +242,21 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ z_owned_sample_t* : z_sample_take, \ z_owned_session_t* : z_session_take, \ - z_owned_shm_client_t* : z_shm_client_take, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_take, \ - z_owned_shm_t* : z_shm_take, \ - z_owned_shm_mut_t* : z_shm_mut_take, \ - z_owned_shm_provider_t* : z_shm_provider_take, \ z_owned_slice_t* : z_slice_take, \ - z_owned_source_info_t* : z_source_info_take, \ z_owned_string_array_t* : z_string_array_take, \ z_owned_string_t* : z_string_take, \ z_owned_subscriber_t* : z_subscriber_take, \ z_owned_task_t* : z_task_take, \ - zc_owned_closure_log_t* : zc_closure_log_take, \ - zc_owned_closure_matching_status_t* : zc_closure_matching_status_take, \ - zc_owned_liveliness_token_t* : zc_liveliness_token_take, \ - zc_owned_matching_listener_t* : zc_publisher_matching_listener_take, \ - zc_owned_shm_client_list_t* : zc_shm_client_list_take, \ - ze_owned_publication_cache_t* : ze_publication_cache_take, \ - ze_owned_querying_subscriber_t* : ze_querying_subscriber_take \ + zc_owned_closure_log_t* : zc_closure_log_take \ )(this_, x) #define z_internal_check(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_internal_alloc_layout_check, \ z_owned_bytes_t : z_internal_bytes_check, \ - z_owned_chunk_alloc_result_t : z_internal_chunk_alloc_result_check, \ z_owned_closure_hello_t : z_internal_closure_hello_check, \ z_owned_closure_query_t : z_internal_closure_query_check, \ z_owned_closure_reply_t : z_internal_closure_reply_check, \ z_owned_closure_sample_t : z_internal_closure_sample_check, \ - z_owned_closure_zid_t : z_internal_closure_zid_check, \ z_owned_condvar_t : z_internal_condvar_check, \ z_owned_config_t : z_internal_config_check, \ z_owned_encoding_t : z_internal_encoding_check, \ @@ -381,7 +265,6 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_fifo_handler_sample_t : z_internal_fifo_handler_sample_check, \ z_owned_hello_t : z_internal_hello_check, \ z_owned_keyexpr_t : z_internal_keyexpr_check, \ - z_owned_memory_layout_t : z_internal_memory_layout_check, \ z_owned_mutex_t : z_internal_mutex_check, \ z_owned_publisher_t : z_internal_publisher_check, \ z_owned_query_t : z_internal_query_check, \ @@ -393,24 +276,12 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ z_owned_sample_t : z_internal_sample_check, \ z_owned_session_t : z_internal_session_check, \ - z_owned_shm_t : z_internal_shm_check, \ - z_owned_shm_client_t : z_internal_shm_client_check, \ - z_owned_shm_client_storage_t : z_internal_shm_client_storage_check, \ - z_owned_shm_mut_t : z_internal_shm_mut_check, \ - z_owned_shm_provider_t : z_internal_shm_provider_check, \ z_owned_slice_t : z_internal_slice_check, \ - z_owned_source_info_t : z_internal_source_info_check, \ z_owned_string_array_t : z_internal_string_array_check, \ z_owned_string_t : z_internal_string_check, \ z_owned_subscriber_t : z_internal_subscriber_check, \ z_owned_task_t : z_internal_task_check, \ - zc_owned_closure_log_t : zc_internal_closure_log_check, \ - zc_owned_closure_matching_status_t : zc_internal_closure_matching_status_check, \ - zc_owned_liveliness_token_t : zc_internal_liveliness_token_check, \ - zc_owned_matching_listener_t : zc_internal_matching_listener_check, \ - zc_owned_shm_client_list_t : zc_internal_shm_client_list_check, \ - ze_owned_publication_cache_t : ze_internal_publication_cache_check, \ - ze_owned_querying_subscriber_t : ze_internal_querying_subscriber_check \ + zc_owned_closure_log_t : zc_internal_closure_log_check \ )(&this_) #define z_call(closure, hello) \ @@ -418,9 +289,7 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t const z_loaned_closure_hello_t* : z_closure_hello_call, \ const z_loaned_closure_query_t* : z_closure_query_call, \ const z_loaned_closure_reply_t* : z_closure_reply_call, \ - const z_loaned_closure_sample_t* : z_closure_sample_call, \ - const z_loaned_closure_zid_t* : z_closure_zid_call, \ - const zc_loaned_closure_matching_status_t* : zc_closure_matching_status_call \ + const z_loaned_closure_sample_t* : z_closure_sample_call \ )(closure, hello) #define z_closure(this_, call, drop, context) \ @@ -429,9 +298,7 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_closure_query_t* : z_closure_query, \ z_owned_closure_reply_t* : z_closure_reply, \ z_owned_closure_sample_t* : z_closure_sample, \ - z_owned_closure_zid_t* : z_closure_zid, \ - zc_owned_closure_log_t* : zc_closure_log, \ - zc_owned_closure_matching_status_t* : zc_closure_matching_status \ + zc_owned_closure_log_t* : zc_closure_log \ )(this_, call, drop, context) #define z_try_recv(this_, query) \ @@ -465,8 +332,6 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_reply_t* : z_reply_clone, \ z_owned_reply_err_t* : z_reply_err_clone, \ z_owned_sample_t* : z_sample_clone, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_clone, \ - z_owned_shm_t* : z_shm_clone, \ z_owned_slice_t* : z_slice_clone, \ z_owned_string_array_t* : z_string_array_clone, \ z_owned_string_t* : z_string_clone \ @@ -474,14 +339,11 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t #else // #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return reinterpret_cast(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_sample_t* z_closure_sample_move(z_owned_closure_sample_t* x) { return reinterpret_cast(x); } -static inline z_moved_closure_zid_t* z_closure_zid_move(z_owned_closure_zid_t* x) { return reinterpret_cast(x); } static inline z_moved_condvar_t* z_condvar_move(z_owned_condvar_t* x) { return reinterpret_cast(x); } static inline z_moved_config_t* z_config_move(z_owned_config_t* x) { return reinterpret_cast(x); } static inline z_moved_encoding_t* z_encoding_move(z_owned_encoding_t* x) { return reinterpret_cast(x); } @@ -490,7 +352,6 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return reinterpret_cast(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return reinterpret_cast(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return reinterpret_cast(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return reinterpret_cast(x); } @@ -502,35 +363,20 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return reinterpret_cast(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return reinterpret_cast(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return reinterpret_cast(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return reinterpret_cast(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return reinterpret_cast(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return reinterpret_cast(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return reinterpret_cast(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return reinterpret_cast(x); } -static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return reinterpret_cast(x); } -static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return reinterpret_cast(x); } -static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return reinterpret_cast(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return reinterpret_cast(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return reinterpret_cast(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return reinterpret_cast(x); } -inline const z_loaned_alloc_layout_t* z_loan(const z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan(&this_); }; inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& this_) { return z_bytes_loan(&this_); }; -inline const z_loaned_chunk_alloc_result_t* z_loan(const z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan(&this_); }; inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& closure) { return z_closure_hello_loan(&closure); }; inline const z_loaned_closure_query_t* z_loan(const z_owned_closure_query_t& closure) { return z_closure_query_loan(&closure); }; inline const z_loaned_closure_reply_t* z_loan(const z_owned_closure_reply_t& closure) { return z_closure_reply_loan(&closure); }; inline const z_loaned_closure_sample_t* z_loan(const z_owned_closure_sample_t& closure) { return z_closure_sample_loan(&closure); }; -inline const z_loaned_closure_zid_t* z_loan(const z_owned_closure_zid_t& closure) { return z_closure_zid_loan(&closure); }; inline const z_loaned_condvar_t* z_loan(const z_owned_condvar_t& this_) { return z_condvar_loan(&this_); }; inline const z_loaned_config_t* z_loan(const z_owned_config_t& this_) { return z_config_loan(&this_); }; inline const z_loaned_encoding_t* z_loan(const z_owned_encoding_t& this_) { return z_encoding_loan(&this_); }; @@ -539,7 +385,6 @@ inline const z_loaned_fifo_handler_reply_t* z_loan(const z_owned_fifo_handler_re inline const z_loaned_fifo_handler_sample_t* z_loan(const z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan(&this_); }; inline const z_loaned_hello_t* z_loan(const z_owned_hello_t& this_) { return z_hello_loan(&this_); }; inline const z_loaned_keyexpr_t* z_loan(const z_owned_keyexpr_t& this_) { return z_keyexpr_loan(&this_); }; -inline const z_loaned_memory_layout_t* z_loan(const z_owned_memory_layout_t& this_) { return z_memory_layout_loan(&this_); }; inline const z_loaned_publisher_t* z_loan(const z_owned_publisher_t& this_) { return z_publisher_loan(&this_); }; inline const z_loaned_query_t* z_loan(const z_owned_query_t& this_) { return z_query_loan(&this_); }; inline const z_loaned_queryable_t* z_loan(const z_owned_queryable_t& this_) { return z_queryable_loan(&this_); }; @@ -550,12 +395,7 @@ inline const z_loaned_ring_handler_reply_t* z_loan(const z_owned_ring_handler_re inline const z_loaned_ring_handler_sample_t* z_loan(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan(&this_); }; inline const z_loaned_sample_t* z_loan(const z_owned_sample_t& this_) { return z_sample_loan(&this_); }; inline const z_loaned_session_t* z_loan(const z_owned_session_t& this_) { return z_session_loan(&this_); }; -inline const z_loaned_shm_client_storage_t* z_loan(const z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan(&this_); }; -inline const z_loaned_shm_t* z_loan(const z_owned_shm_t& this_) { return z_shm_loan(&this_); }; -inline const z_loaned_shm_mut_t* z_loan(const z_owned_shm_mut_t& this_) { return z_shm_mut_loan(&this_); }; -inline const z_loaned_shm_provider_t* z_loan(const z_owned_shm_provider_t& this_) { return z_shm_provider_loan(&this_); }; inline const z_loaned_slice_t* z_loan(const z_owned_slice_t& this_) { return z_slice_loan(&this_); }; -inline const z_loaned_source_info_t* z_loan(const z_owned_source_info_t& this_) { return z_source_info_loan(&this_); }; inline const z_loaned_string_array_t* z_loan(const z_owned_string_array_t& this_) { return z_string_array_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_owned_string_t& this_) { return z_string_loan(&this_); }; inline const z_loaned_subscriber_t* z_loan(const z_owned_subscriber_t& this_) { return z_subscriber_loan(&this_); }; @@ -563,11 +403,6 @@ inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& this_) { return inline const z_loaned_slice_t* z_loan(const z_view_slice_t& this_) { return z_view_slice_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_view_string_t& this_) { return z_view_string_loan(&this_); }; inline const zc_loaned_closure_log_t* z_loan(const zc_owned_closure_log_t& closure) { return zc_closure_log_loan(&closure); }; -inline const zc_loaned_closure_matching_status_t* z_loan(const zc_owned_closure_matching_status_t& closure) { return zc_closure_matching_status_loan(&closure); }; -inline const zc_loaned_liveliness_token_t* z_loan(const zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_loan(&this_); }; -inline const zc_loaned_shm_client_list_t* z_loan(const zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan(&this_); }; -inline const ze_loaned_publication_cache_t* z_loan(const ze_owned_publication_cache_t& this_) { return ze_publication_cache_loan(&this_); }; -inline const ze_loaned_querying_subscriber_t* z_loan(const ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_loan(&this_); }; inline z_loaned_bytes_t* z_loan_mut(z_owned_bytes_t& this_) { return z_bytes_loan_mut(&this_); }; @@ -576,20 +411,14 @@ inline z_loaned_config_t* z_loan_mut(z_owned_config_t& this_) { return z_config_ inline z_loaned_encoding_t* z_loan_mut(z_owned_encoding_t& this_) { return z_encoding_loan_mut(&this_); }; inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& this_) { return z_mutex_loan_mut(&this_); }; inline z_loaned_publisher_t* z_loan_mut(z_owned_publisher_t& this_) { return z_publisher_loan_mut(&this_); }; -inline z_loaned_shm_t* z_loan_mut(z_owned_shm_t& this_) { return z_shm_loan_mut(&this_); }; -inline z_loaned_shm_mut_t* z_loan_mut(z_owned_shm_mut_t& this_) { return z_shm_mut_loan_mut(&this_); }; inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { return z_string_array_loan_mut(&this_); }; -inline zc_loaned_shm_client_list_t* z_loan_mut(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan_mut(&this_); }; -inline void z_drop(z_moved_alloc_layout_t* this_) { z_alloc_layout_drop(this_); }; inline void z_drop(z_moved_bytes_t* this_) { z_bytes_drop(this_); }; -inline void z_drop(z_moved_chunk_alloc_result_t* this_) { z_chunk_alloc_result_drop(this_); }; inline void z_drop(z_moved_closure_hello_t* this_) { z_closure_hello_drop(this_); }; inline void z_drop(z_moved_closure_query_t* closure_) { z_closure_query_drop(closure_); }; inline void z_drop(z_moved_closure_reply_t* closure_) { z_closure_reply_drop(closure_); }; inline void z_drop(z_moved_closure_sample_t* closure_) { z_closure_sample_drop(closure_); }; -inline void z_drop(z_moved_closure_zid_t* closure_) { z_closure_zid_drop(closure_); }; inline void z_drop(z_moved_condvar_t* this_) { z_condvar_drop(this_); }; inline void z_drop(z_moved_config_t* this_) { z_config_drop(this_); }; inline void z_drop(z_moved_encoding_t* this_) { z_encoding_drop(this_); }; @@ -598,7 +427,6 @@ inline void z_drop(z_moved_fifo_handler_reply_t* this_) { z_fifo_handler_reply_d inline void z_drop(z_moved_fifo_handler_sample_t* this_) { z_fifo_handler_sample_drop(this_); }; inline void z_drop(z_moved_hello_t* this_) { z_hello_drop(this_); }; inline void z_drop(z_moved_keyexpr_t* this_) { z_keyexpr_drop(this_); }; -inline void z_drop(z_moved_memory_layout_t* this_) { z_memory_layout_drop(this_); }; inline void z_drop(z_moved_mutex_t* this_) { z_mutex_drop(this_); }; inline void z_drop(z_moved_publisher_t* this_) { z_publisher_drop(this_); }; inline void z_drop(z_moved_query_t* this_) { z_query_drop(this_); }; @@ -610,34 +438,19 @@ inline void z_drop(z_moved_ring_handler_reply_t* this_) { z_ring_handler_reply_d inline void z_drop(z_moved_ring_handler_sample_t* this_) { z_ring_handler_sample_drop(this_); }; inline void z_drop(z_moved_sample_t* this_) { z_sample_drop(this_); }; inline void z_drop(z_moved_session_t* this_) { z_session_drop(this_); }; -inline void z_drop(z_moved_shm_client_t* this_) { z_shm_client_drop(this_); }; -inline void z_drop(z_moved_shm_client_storage_t* this_) { z_shm_client_storage_drop(this_); }; -inline void z_drop(z_moved_shm_t* this_) { z_shm_drop(this_); }; -inline void z_drop(z_moved_shm_mut_t* this_) { z_shm_mut_drop(this_); }; -inline void z_drop(z_moved_shm_provider_t* this_) { z_shm_provider_drop(this_); }; inline void z_drop(z_moved_slice_t* this_) { z_slice_drop(this_); }; -inline void z_drop(z_moved_source_info_t* this_) { z_source_info_drop(this_); }; inline void z_drop(z_moved_string_array_t* this_) { z_string_array_drop(this_); }; inline void z_drop(z_moved_string_t* this_) { z_string_drop(this_); }; inline void z_drop(z_moved_subscriber_t* this_) { z_subscriber_drop(this_); }; inline void z_drop(z_moved_task_t* this_) { z_task_drop(this_); }; inline void z_drop(zc_moved_closure_log_t* closure_) { zc_closure_log_drop(closure_); }; -inline void z_drop(zc_moved_closure_matching_status_t* closure_) { zc_closure_matching_status_drop(closure_); }; -inline void z_drop(zc_moved_liveliness_token_t* this_) { zc_liveliness_token_drop(this_); }; -inline void z_drop(zc_moved_matching_listener_t* this_) { zc_publisher_matching_listener_drop(this_); }; -inline void z_drop(zc_moved_shm_client_list_t* this_) { zc_shm_client_list_drop(this_); }; -inline void z_drop(ze_moved_publication_cache_t* this_) { ze_publication_cache_drop(this_); }; -inline void z_drop(ze_moved_querying_subscriber_t* this_) { ze_querying_subscriber_drop(this_); }; -inline z_moved_alloc_layout_t* z_move(z_owned_alloc_layout_t& this_) { return z_alloc_layout_move(&this_); }; inline z_moved_bytes_t* z_move(z_owned_bytes_t& this_) { return z_bytes_move(&this_); }; -inline z_moved_chunk_alloc_result_t* z_move(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_move(&this_); }; inline z_moved_closure_hello_t* z_move(z_owned_closure_hello_t& this_) { return z_closure_hello_move(&this_); }; inline z_moved_closure_query_t* z_move(z_owned_closure_query_t& closure_) { return z_closure_query_move(&closure_); }; inline z_moved_closure_reply_t* z_move(z_owned_closure_reply_t& closure_) { return z_closure_reply_move(&closure_); }; inline z_moved_closure_sample_t* z_move(z_owned_closure_sample_t& closure_) { return z_closure_sample_move(&closure_); }; -inline z_moved_closure_zid_t* z_move(z_owned_closure_zid_t& closure_) { return z_closure_zid_move(&closure_); }; inline z_moved_condvar_t* z_move(z_owned_condvar_t& this_) { return z_condvar_move(&this_); }; inline z_moved_config_t* z_move(z_owned_config_t& this_) { return z_config_move(&this_); }; inline z_moved_encoding_t* z_move(z_owned_encoding_t& this_) { return z_encoding_move(&this_); }; @@ -646,7 +459,6 @@ inline z_moved_fifo_handler_reply_t* z_move(z_owned_fifo_handler_reply_t& this_) inline z_moved_fifo_handler_sample_t* z_move(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_move(&this_); }; inline z_moved_hello_t* z_move(z_owned_hello_t& this_) { return z_hello_move(&this_); }; inline z_moved_keyexpr_t* z_move(z_owned_keyexpr_t& this_) { return z_keyexpr_move(&this_); }; -inline z_moved_memory_layout_t* z_move(z_owned_memory_layout_t& this_) { return z_memory_layout_move(&this_); }; inline z_moved_mutex_t* z_move(z_owned_mutex_t& this_) { return z_mutex_move(&this_); }; inline z_moved_publisher_t* z_move(z_owned_publisher_t& this_) { return z_publisher_move(&this_); }; inline z_moved_query_t* z_move(z_owned_query_t& this_) { return z_query_move(&this_); }; @@ -658,34 +470,19 @@ inline z_moved_ring_handler_reply_t* z_move(z_owned_ring_handler_reply_t& this_) inline z_moved_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_move(&this_); }; inline z_moved_sample_t* z_move(z_owned_sample_t& this_) { return z_sample_move(&this_); }; inline z_moved_session_t* z_move(z_owned_session_t& this_) { return z_session_move(&this_); }; -inline z_moved_shm_client_t* z_move(z_owned_shm_client_t& this_) { return z_shm_client_move(&this_); }; -inline z_moved_shm_client_storage_t* z_move(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_move(&this_); }; -inline z_moved_shm_t* z_move(z_owned_shm_t& this_) { return z_shm_move(&this_); }; -inline z_moved_shm_mut_t* z_move(z_owned_shm_mut_t& this_) { return z_shm_mut_move(&this_); }; -inline z_moved_shm_provider_t* z_move(z_owned_shm_provider_t& this_) { return z_shm_provider_move(&this_); }; inline z_moved_slice_t* z_move(z_owned_slice_t& this_) { return z_slice_move(&this_); }; -inline z_moved_source_info_t* z_move(z_owned_source_info_t& this_) { return z_source_info_move(&this_); }; inline z_moved_string_array_t* z_move(z_owned_string_array_t& this_) { return z_string_array_move(&this_); }; inline z_moved_string_t* z_move(z_owned_string_t& this_) { return z_string_move(&this_); }; inline z_moved_subscriber_t* z_move(z_owned_subscriber_t& this_) { return z_subscriber_move(&this_); }; inline z_moved_task_t* z_move(z_owned_task_t& this_) { return z_task_move(&this_); }; inline zc_moved_closure_log_t* z_move(zc_owned_closure_log_t& closure_) { return zc_closure_log_move(&closure_); }; -inline zc_moved_closure_matching_status_t* z_move(zc_owned_closure_matching_status_t& closure_) { return zc_closure_matching_status_move(&closure_); }; -inline zc_moved_liveliness_token_t* z_move(zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_move(&this_); }; -inline zc_moved_matching_listener_t* z_move(zc_owned_matching_listener_t& this_) { return zc_publisher_matching_listener_move(&this_); }; -inline zc_moved_shm_client_list_t* z_move(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_move(&this_); }; -inline ze_moved_publication_cache_t* z_move(ze_owned_publication_cache_t& this_) { return ze_publication_cache_move(&this_); }; -inline ze_moved_querying_subscriber_t* z_move(ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_move(&this_); }; -inline void z_internal_null(z_owned_alloc_layout_t* this_) { z_internal_alloc_layout_null(this_); }; inline void z_internal_null(z_owned_bytes_t* this_) { z_internal_bytes_null(this_); }; -inline void z_internal_null(z_owned_chunk_alloc_result_t* this_) { z_internal_chunk_alloc_result_null(this_); }; inline void z_internal_null(z_owned_closure_hello_t* this_) { z_internal_closure_hello_null(this_); }; inline void z_internal_null(z_owned_closure_query_t* this_) { z_internal_closure_query_null(this_); }; inline void z_internal_null(z_owned_closure_reply_t* this_) { z_internal_closure_reply_null(this_); }; inline void z_internal_null(z_owned_closure_sample_t* this_) { z_internal_closure_sample_null(this_); }; -inline void z_internal_null(z_owned_closure_zid_t* this_) { z_internal_closure_zid_null(this_); }; inline void z_internal_null(z_owned_condvar_t* this_) { z_internal_condvar_null(this_); }; inline void z_internal_null(z_owned_config_t* this_) { z_internal_config_null(this_); }; inline void z_internal_null(z_owned_encoding_t* this_) { z_internal_encoding_null(this_); }; @@ -694,7 +491,6 @@ inline void z_internal_null(z_owned_fifo_handler_reply_t* this_) { z_internal_fi inline void z_internal_null(z_owned_fifo_handler_sample_t* this_) { z_internal_fifo_handler_sample_null(this_); }; inline void z_internal_null(z_owned_hello_t* this_) { z_internal_hello_null(this_); }; inline void z_internal_null(z_owned_keyexpr_t* this_) { z_internal_keyexpr_null(this_); }; -inline void z_internal_null(z_owned_memory_layout_t* this_) { z_internal_memory_layout_null(this_); }; inline void z_internal_null(z_owned_mutex_t* this_) { z_internal_mutex_null(this_); }; inline void z_internal_null(z_owned_publisher_t* this_) { z_internal_publisher_null(this_); }; inline void z_internal_null(z_owned_query_t* this_) { z_internal_query_null(this_); }; @@ -706,33 +502,18 @@ inline void z_internal_null(z_owned_ring_handler_reply_t* this_) { z_internal_ri inline void z_internal_null(z_owned_ring_handler_sample_t* this_) { z_internal_ring_handler_sample_null(this_); }; inline void z_internal_null(z_owned_sample_t* this_) { z_internal_sample_null(this_); }; inline void z_internal_null(z_owned_session_t* this_) { z_internal_session_null(this_); }; -inline void z_internal_null(z_owned_shm_client_t* this_) { z_internal_shm_client_null(this_); }; -inline void z_internal_null(z_owned_shm_client_storage_t* this_) { z_internal_shm_client_storage_null(this_); }; -inline void z_internal_null(z_owned_shm_mut_t* this_) { z_internal_shm_mut_null(this_); }; -inline void z_internal_null(z_owned_shm_t* this_) { z_internal_shm_null(this_); }; -inline void z_internal_null(z_owned_shm_provider_t* this_) { z_internal_shm_provider_null(this_); }; inline void z_internal_null(z_owned_slice_t* this_) { z_internal_slice_null(this_); }; -inline void z_internal_null(z_owned_source_info_t* this_) { z_internal_source_info_null(this_); }; inline void z_internal_null(z_owned_string_array_t* this_) { z_internal_string_array_null(this_); }; inline void z_internal_null(z_owned_string_t* this_) { z_internal_string_null(this_); }; inline void z_internal_null(z_owned_subscriber_t* this_) { z_internal_subscriber_null(this_); }; inline void z_internal_null(z_owned_task_t* this_) { z_internal_task_null(this_); }; inline void z_internal_null(zc_owned_closure_log_t* this_) { zc_internal_closure_log_null(this_); }; -inline void z_internal_null(zc_owned_closure_matching_status_t* this_) { zc_internal_closure_matching_status_null(this_); }; -inline void z_internal_null(zc_owned_liveliness_token_t* this_) { zc_internal_liveliness_token_null(this_); }; -inline void z_internal_null(zc_owned_matching_listener_t* this_) { zc_internal_matching_listener_null(this_); }; -inline void z_internal_null(zc_owned_shm_client_list_t* this_) { zc_internal_shm_client_list_null(this_); }; -inline void z_internal_null(ze_owned_publication_cache_t* this_) { ze_internal_publication_cache_null(this_); }; -inline void z_internal_null(ze_owned_querying_subscriber_t* this_) { ze_internal_querying_subscriber_null(this_); }; -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } static inline void z_closure_sample_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { *closure_ = x->_this; z_internal_closure_sample_null(&x->_this); } -static inline void z_closure_zid_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { *closure_ = x->_this; z_internal_closure_zid_null(&x->_this); } static inline void z_condvar_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { *this_ = x->_this; z_internal_condvar_null(&x->_this); } static inline void z_config_take(z_owned_config_t* this_, z_moved_config_t* x) { *this_ = x->_this; z_internal_config_null(&x->_this); } static inline void z_encoding_take(z_owned_encoding_t* this_, z_moved_encoding_t* x) { *this_ = x->_this; z_internal_encoding_null(&x->_this); } @@ -741,7 +522,6 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -753,36 +533,18 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } -static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } -static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } -inline void z_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { - z_alloc_layout_take(this_, x); -}; inline void z_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { z_bytes_take(this_, x); }; -inline void z_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { - z_chunk_alloc_result_take(this_, x); -}; inline void z_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { z_closure_hello_take(this_, x); }; @@ -795,9 +557,6 @@ inline void z_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x inline void z_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { z_closure_sample_take(closure_, x); }; -inline void z_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { - z_closure_zid_take(closure_, x); -}; inline void z_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { z_condvar_take(this_, x); }; @@ -822,9 +581,6 @@ inline void z_take(z_owned_hello_t* this_, z_moved_hello_t* x) { inline void z_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { z_keyexpr_take(this_, x); }; -inline void z_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { - z_memory_layout_take(this_, x); -}; inline void z_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { z_mutex_take(this_, x); }; @@ -858,27 +614,9 @@ inline void z_take(z_owned_sample_t* this_, z_moved_sample_t* x) { inline void z_take(z_owned_session_t* this_, z_moved_session_t* x) { z_session_take(this_, x); }; -inline void z_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { - z_shm_client_take(this_, x); -}; -inline void z_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { - z_shm_client_storage_take(this_, x); -}; -inline void z_take(z_owned_shm_t* this_, z_moved_shm_t* x) { - z_shm_take(this_, x); -}; -inline void z_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { - z_shm_mut_take(this_, x); -}; -inline void z_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { - z_shm_provider_take(this_, x); -}; inline void z_take(z_owned_slice_t* this_, z_moved_slice_t* x) { z_slice_take(this_, x); }; -inline void z_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { - z_source_info_take(this_, x); -}; inline void z_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { z_string_array_take(this_, x); }; @@ -894,34 +632,13 @@ inline void z_take(z_owned_task_t* this_, z_moved_task_t* x) { inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { zc_closure_log_take(closure_, x); }; -inline void z_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { - zc_closure_matching_status_take(closure_, x); -}; -inline void z_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { - zc_liveliness_token_take(this_, x); -}; -inline void z_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { - zc_publisher_matching_listener_take(this_, x); -}; -inline void z_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { - zc_shm_client_list_take(this_, x); -}; -inline void z_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { - ze_publication_cache_take(this_, x); -}; -inline void z_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { - ze_querying_subscriber_take(this_, x); -}; -inline bool z_internal_check(const z_owned_alloc_layout_t& this_) { return z_internal_alloc_layout_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; -inline bool z_internal_check(const z_owned_chunk_alloc_result_t& this_) { return z_internal_chunk_alloc_result_check(&this_); }; inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; inline bool z_internal_check(const z_owned_closure_reply_t& this_) { return z_internal_closure_reply_check(&this_); }; inline bool z_internal_check(const z_owned_closure_sample_t& this_) { return z_internal_closure_sample_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_zid_t& this_) { return z_internal_closure_zid_check(&this_); }; inline bool z_internal_check(const z_owned_condvar_t& this_) { return z_internal_condvar_check(&this_); }; inline bool z_internal_check(const z_owned_config_t& this_) { return z_internal_config_check(&this_); }; inline bool z_internal_check(const z_owned_encoding_t& this_) { return z_internal_encoding_check(&this_); }; @@ -930,7 +647,6 @@ inline bool z_internal_check(const z_owned_fifo_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_fifo_handler_sample_t& this_) { return z_internal_fifo_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_hello_check(&this_); }; inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; -inline bool z_internal_check(const z_owned_memory_layout_t& this_) { return z_internal_memory_layout_check(&this_); }; inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; @@ -942,24 +658,12 @@ inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_t& this_) { return z_internal_shm_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_t& this_) { return z_internal_shm_client_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_storage_t& this_) { return z_internal_shm_client_storage_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_mut_t& this_) { return z_internal_shm_mut_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_provider_t& this_) { return z_internal_shm_provider_check(&this_); }; inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; -inline bool z_internal_check(const z_owned_source_info_t& this_) { return z_internal_source_info_check(&this_); }; inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; -inline bool z_internal_check(const zc_owned_closure_matching_status_t& this_) { return zc_internal_closure_matching_status_check(&this_); }; -inline bool z_internal_check(const zc_owned_liveliness_token_t& this_) { return zc_internal_liveliness_token_check(&this_); }; -inline bool z_internal_check(const zc_owned_matching_listener_t& this_) { return zc_internal_matching_listener_check(&this_); }; -inline bool z_internal_check(const zc_owned_shm_client_list_t& this_) { return zc_internal_shm_client_list_check(&this_); }; -inline bool z_internal_check(const ze_owned_publication_cache_t& this_) { return ze_internal_publication_cache_check(&this_); }; -inline bool z_internal_check(const ze_owned_querying_subscriber_t& this_) { return ze_internal_querying_subscriber_check(&this_); }; inline void z_call(const z_loaned_closure_hello_t* closure, z_loaned_hello_t* hello) { @@ -974,21 +678,13 @@ inline void z_call(const z_loaned_closure_reply_t* closure, z_loaned_reply_t* re inline void z_call(const z_loaned_closure_sample_t* closure, z_loaned_sample_t* sample) { z_closure_sample_call(closure, sample); }; -inline void z_call(const z_loaned_closure_zid_t* closure, const z_id_t* z_id) { - z_closure_zid_call(closure, z_id); -}; -inline void z_call(const zc_loaned_closure_matching_status_t* closure, const zc_matching_status_t* mathing_status) { - zc_closure_matching_status_call(closure, mathing_status); -}; extern "C" using z_closure_drop_callback_t = void(void* context); extern "C" using z_closure_hello_callabck_t = void(z_loaned_hello_t *hello, void *context); extern "C" using z_closure_query_callabck_t = void(z_loaned_query_t *query, void *context); extern "C" using z_closure_reply_callabck_t = void(z_loaned_reply_t *reply, void *context); extern "C" using z_closure_sample_callabck_t = void(z_loaned_sample_t *sample, void *context); -extern "C" using z_closure_zid_callabck_t = void(const z_id_t *z_id, void *context); extern "C" using zc_closure_log_callabck_t = void(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); -extern "C" using zc_closure_matching_status_callabck_t = void(const zc_matching_status_t *matching_status, void *context); inline void z_closure(z_owned_closure_hello_t* this_, z_closure_hello_callabck_t* call, z_closure_drop_callback_t* drop, void* context) { @@ -1006,18 +702,10 @@ inline void z_closure(z_owned_closure_sample_t* this_, z_closure_sample_callabck z_closure_drop_callback_t* drop, void* context) { z_closure_sample(this_, call, drop, context); }; -inline void z_closure(z_owned_closure_zid_t* this_, z_closure_zid_callabck_t* call, - z_closure_drop_callback_t* drop, void* context) { - z_closure_zid(this_, call, drop, context); -}; inline void z_closure(zc_owned_closure_log_t* this_, zc_closure_log_callabck_t* call, z_closure_drop_callback_t* drop, void* context) { zc_closure_log(this_, call, drop, context); }; -inline void z_closure(zc_owned_closure_matching_status_t* this_, zc_closure_matching_status_callabck_t* call, - z_closure_drop_callback_t* drop, void* context) { - zc_closure_matching_status(this_, call, drop, context); -}; inline z_result_t z_try_recv(const z_loaned_fifo_handler_query_t* this_, z_owned_query_t* query) { @@ -1087,12 +775,6 @@ inline void z_clone(z_owned_reply_err_t* dst, z_loaned_reply_err_t* this_) { inline void z_clone(z_owned_sample_t* dst, z_loaned_sample_t* this_) { z_sample_clone(dst, this_); }; -inline void z_clone(z_owned_shm_client_storage_t* this_, z_loaned_shm_client_storage_t* from) { - z_shm_client_storage_clone(this_, from); -}; -inline void z_clone(z_owned_shm_t* out, z_loaned_shm_t* this_) { - z_shm_clone(out, this_); -}; inline void z_clone(z_owned_slice_t* dst, z_loaned_slice_t* this_) { z_slice_clone(dst, this_); }; @@ -1105,12 +787,8 @@ inline void z_clone(z_owned_string_t* dst, z_loaned_string_t* this_) { template struct z_loaned_to_owned_type_t {}; template struct z_owned_to_loaned_type_t {}; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_alloc_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_alloc_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_chunk_alloc_result_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_chunk_alloc_result_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_hello_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_query_t type; }; @@ -1119,8 +797,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_reply_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_sample_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_sample_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_zid_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_zid_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_condvar_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_condvar_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_config_t type; }; @@ -1137,8 +813,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_h template<> struct z_owned_to_loaned_type_t { typedef z_loaned_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_keyexpr_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_keyexpr_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_memory_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_memory_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_publisher_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_publisher_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_query_t type; }; @@ -1159,18 +833,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_sample_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_session_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_session_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_client_storage_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_client_storage_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_mut_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_mut_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_provider_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_provider_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_slice_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_slice_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_source_info_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_source_info_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_array_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_string_array_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_t type; }; @@ -1179,16 +843,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_ow template<> struct z_owned_to_loaned_type_t { typedef z_loaned_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_log_t type; }; template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_log_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_matching_status_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_matching_status_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_liveliness_token_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_liveliness_token_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_shm_client_list_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_shm_client_list_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_publication_cache_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_publication_cache_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_querying_subscriber_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_querying_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_mutex_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_mutex_t type; }; #endif // #ifndef __cplusplus diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index d9de76f88..56274e891 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_query_t, z_owned_closure_query_t, z_owned_query_t, }; decl_c_type!( diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index abff70dc6..6c6046997 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_reply_t, z_owned_closure_reply_t, z_owned_reply_t, }; decl_c_type!( diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 492e4cb7e..36a5d3727 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_sample_t, z_owned_closure_sample_t, z_owned_sample_t, }; decl_c_type!( diff --git a/src/collections.rs b/src/collections.rs index 9add10e11..da54925c0 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -25,7 +25,9 @@ use libc::strlen; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, }; pub struct CSlice { diff --git a/src/commons.rs b/src/commons.rs index 9009609bb..c831cf98d 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -37,7 +37,7 @@ use crate::z_id_t; use crate::z_moved_source_info_t; use crate::{ result, - transmute::{CTypeRef, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{CTypeRef, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, }; diff --git a/src/config.rs b/src/config.rs index 930a5c4b9..01eb51ac9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,7 +18,9 @@ use zenoh::config::{Config, WhatAmI}; use crate::{ result::{self, Z_OK}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_internal_string_null, z_owned_string_t, z_string_copy_from_substr, }; @@ -83,7 +85,6 @@ pub extern "C" fn z_config_loan(this_: &'static z_owned_config_t) -> &z_loaned_c #[no_mangle] pub extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loaned_config_t { let this = this_.as_rust_type_mut(); - let this = unsafe { this.as_mut().unwrap_unchecked() }; this.as_loaned_c_type_mut() } @@ -192,7 +193,9 @@ pub unsafe extern "C" fn zc_config_insert_json5_from_substr( value: *const c_char, value_len: usize, ) -> result::z_result_t { - let config = this.as_rust_type_mut(); + let Some(config) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; let key = match from_utf8(from_raw_parts(key as _, key_len)) { Ok(s) => s, Err(e) => { diff --git a/src/encoding.rs b/src/encoding.rs index 19031c37f..5c61582e7 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -26,7 +26,9 @@ use zenoh::bytes::Encoding; pub use crate::opaque_types::{z_loaned_encoding_t, z_owned_encoding_t}; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_moved_encoding_t, z_owned_string_t, z_string_copy_from_substr, }; diff --git a/src/get.rs b/src/get.rs index ac687a347..be98e7474 100644 --- a/src/get.rs +++ b/src/get.rs @@ -24,7 +24,7 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_reply_err_t, z_moved_reply_err_t, z_owned_reply_err_t}; use crate::{ result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_reply_call, z_closure_reply_loan, z_congestion_control_t, z_consolidation_mode_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_sample_t, z_loaned_session_t, z_moved_bytes_t, z_moved_closure_reply_t, z_moved_encoding_t, z_priority_t, @@ -270,10 +270,7 @@ pub unsafe extern "C" fn z_get( let mut owned_response = Some(response); z_closure_reply_call( z_closure_reply_loan(&callback), - owned_response - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut(), + owned_response.as_loaned_c_type_mut(), ) }) .wait() diff --git a/src/info.rs b/src/info.rs index a2437c324..3e7dda602 100644 --- a/src/info.rs +++ b/src/info.rs @@ -18,7 +18,7 @@ use zenoh::{session::ZenohId, Wait}; pub use crate::opaque_types::z_id_t; use crate::{ result, - transmute::{CTypeRef, IntoCType, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{CTypeRef, IntoCType, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_zid_call, z_closure_zid_loan, z_loaned_session_t, z_moved_closure_zid_t, z_owned_string_t, }; diff --git a/src/keyexpr.rs b/src/keyexpr.rs index ba86a5b00..2b9198bfe 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -26,7 +26,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_session_t, z_view_string_from_substr, z_view_string_t, }; diff --git a/src/liveliness.rs b/src/liveliness.rs index 6c89aac0e..7cf4537dc 100644 --- a/src/liveliness.rs +++ b/src/liveliness.rs @@ -19,7 +19,7 @@ use zenoh::{liveliness::LivelinessToken, Wait}; use crate::{ opaque_types::{zc_loaned_liveliness_token_t, zc_owned_liveliness_token_t}, result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_reply_call, z_closure_reply_loan, z_closure_sample_call, z_closure_sample_loan, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_closure_reply_t, z_moved_closure_sample_t, z_owned_subscriber_t, zc_moved_liveliness_token_t, diff --git a/src/payload.rs b/src/payload.rs index 18bf8b7e2..32f1f3287 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -35,7 +35,9 @@ pub use crate::opaque_types::{z_loaned_bytes_t, z_owned_bytes_t}; use crate::result::Z_ENULL; use crate::{ result::{self, z_result_t, Z_EINVAL, Z_EIO, Z_EPARSE, Z_OK}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_slice_t, z_loaned_string_t, z_moved_bytes_t, z_moved_slice_t, z_moved_string_t, z_owned_slice_t, z_owned_string_t, z_view_slice_t, CSlice, CSliceOwned, CSliceView, CString, CStringOwned, diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index 9ef48ee67..be532a256 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -9,7 +9,9 @@ use libc::c_void; pub use crate::opaque_types::{z_loaned_mutex_t, z_moved_mutex_t, z_owned_mutex_t}; use crate::{ result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, }; decl_c_type!( @@ -50,18 +52,16 @@ pub extern "C" fn z_internal_mutex_null(this_: &mut MaybeUninit #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned_mutex_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Locks mutex. If mutex is already locked, blocks the thread until it aquires the lock. /// @return 0 in case of success, negative error code in case of failure. #[no_mangle] pub extern "C" fn z_mutex_lock(this_: &'static mut z_loaned_mutex_t) -> result::z_result_t { - let this = this_.as_rust_type_mut(); + let Some(this) = this_.as_rust_type_mut() else { + return result::Z_ENULL; + }; match this.0.lock() { Ok(new_lock) => { @@ -79,7 +79,9 @@ pub extern "C" fn z_mutex_lock(this_: &'static mut z_loaned_mutex_t) -> result:: /// @return 0 in case of success, negative error code otherwise. #[no_mangle] pub extern "C" fn z_mutex_unlock(this_: &mut z_loaned_mutex_t) -> result::z_result_t { - let this = this_.as_rust_type_mut(); + let Some(this) = this_.as_rust_type_mut() else { + return result::Z_ENULL; + }; if this.1.is_none() { return result::Z_EINVAL_MUTEX; } else { @@ -95,7 +97,9 @@ pub extern "C" fn z_mutex_unlock(this_: &mut z_loaned_mutex_t) -> result::z_resu pub unsafe extern "C" fn z_mutex_try_lock( this: &'static mut z_loaned_mutex_t, ) -> result::z_result_t { - let this = this.as_rust_type_mut(); + let Some(this) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; match this.0.try_lock() { Ok(new_lock) => { let old_lock = this.1.replace(new_lock); @@ -182,7 +186,9 @@ pub unsafe extern "C" fn z_condvar_wait( m: &mut z_loaned_mutex_t, ) -> result::z_result_t { let this = this.as_rust_type_ref(); - let m = m.as_rust_type_mut(); + let Some(m) = m.as_rust_type_mut() else { + return result::Z_ENULL; + }; if m.1.is_none() { return result::Z_EINVAL_MUTEX; // lock was not aquired prior to wait call } diff --git a/src/publication_cache.rs b/src/publication_cache.rs index 494abbb01..dad9a4322 100644 --- a/src/publication_cache.rs +++ b/src/publication_cache.rs @@ -19,7 +19,7 @@ use zenoh_ext::SessionExt; use crate::{ result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_keyexpr_t, z_loaned_session_t, }; #[cfg(feature = "unstable")] diff --git a/src/publisher.rs b/src/publisher.rs index 20761171e..f2e98ea8e 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -28,7 +28,9 @@ use crate::z_moved_source_info_t; use crate::zc_moved_closure_matching_status_t; use crate::{ result::{self}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_congestion_control_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, z_moved_encoding_t, z_priority_t, z_timestamp_t, }; @@ -165,10 +167,7 @@ pub unsafe extern "C" fn z_publisher_loan(this_: &z_owned_publisher_t) -> &z_loa pub unsafe extern "C" fn z_publisher_loan_mut( this: &mut z_owned_publisher_t, ) -> &mut z_loaned_publisher_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Options passed to the `z_publisher_put()` function. diff --git a/src/queryable.rs b/src/queryable.rs index 2b92800ff..a9f90060f 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -26,7 +26,7 @@ use crate::transmute::IntoCType; use crate::{ result, transmute::{ - IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType, + IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType, }, z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, @@ -237,12 +237,10 @@ pub extern "C" fn z_declare_queryable( let queryable = builder .callback(move |query| { let mut owned_query = Some(query); - z_closure_query_call(z_closure_query_loan(&callback), unsafe { - owned_query - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) + z_closure_query_call( + z_closure_query_loan(&callback), + owned_query.as_loaned_c_type_mut(), + ) }) .wait(); match queryable { diff --git a/src/querying_subscriber.rs b/src/querying_subscriber.rs index 1cafa242d..515ab0b81 100644 --- a/src/querying_subscriber.rs +++ b/src/querying_subscriber.rs @@ -20,7 +20,7 @@ use zenoh_ext::*; use crate::{ opaque_types::{ze_loaned_querying_subscriber_t, ze_owned_querying_subscriber_t}, result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_sample_call, z_closure_sample_loan, z_get_options_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_closure_sample_t, z_query_consolidation_none, z_query_consolidation_t, z_query_target_default, z_query_target_t, diff --git a/src/scouting.rs b/src/scouting.rs index e59276c9a..f7da858e2 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -22,7 +22,7 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_hello_t, z_moved_hello_t, z_owned_hello_t}; use crate::{ result::{self, Z_OK}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_hello_call, z_closure_hello_loan, z_moved_closure_hello_t, z_moved_config_t, z_owned_string_array_t, z_view_string_t, CString, CStringView, ZVector, }; @@ -183,9 +183,10 @@ pub extern "C" fn z_scout( let scout = zenoh::scout(what, config) .callback(move |h| { let mut owned_h = Some(h); - z_closure_hello_call(z_closure_hello_loan(&callback), unsafe { - owned_h.as_mut().unwrap_unchecked().as_loaned_c_type_mut() - }) + z_closure_hello_call( + z_closure_hello_loan(&callback), + owned_h.as_loaned_c_type_mut(), + ) }) .await .unwrap(); diff --git a/src/session.rs b/src/session.rs index b64ff9b09..786f5ca95 100644 --- a/src/session.rs +++ b/src/session.rs @@ -21,7 +21,7 @@ use crate::z_loaned_shm_client_storage_t; use crate::{ opaque_types::{z_loaned_session_t, z_owned_session_t}, result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_moved_config_t, z_moved_session_t, }; decl_c_type!( diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 27630c497..438607d00 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -20,7 +20,7 @@ use std::{ use zenoh::shm::{zshm, zshmmut, ZShm}; use crate::{ - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, }; diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index 34d327364..05a5bf89f 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -21,7 +21,7 @@ use zenoh::shm::{zshmmut, ZShmMut}; use crate::{ result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_shm_mut_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_mut_t, z_owned_shm_t, }; diff --git a/src/shm/client/shm_client.rs b/src/shm/client/shm_client.rs index 0e0aa1ede..5bcc28921 100644 --- a/src/shm/client/shm_client.rs +++ b/src/shm/client/shm_client.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{z_moved_shm_client_t, z_owned_shm_client_t}; use crate::{ context::{zc_threadsafe_context_t, DroppableContext, ThreadsafeContext}, shm::common::types::z_segment_id_t, - transmute::{RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{RustTypeMutUninit, RustTypeRef, TakeRustType}, }; /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index bf9584854..e628f787a 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -19,7 +19,7 @@ use zenoh::shm::{ProtocolID, ShmClient, ShmClientStorage, GLOBAL_CLIENT_STORAGE} use super::common::types::z_protocol_id_t; use crate::{ result::{z_result_t, Z_EINVAL, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_shm_client_storage_t, z_moved_shm_client_storage_t, z_moved_shm_client_t, z_owned_shm_client_storage_t, zc_loaned_shm_client_list_t, zc_moved_shm_client_list_t, zc_owned_shm_client_list_t, diff --git a/src/shm/protocol_implementations/posix/posix_shm_client.rs b/src/shm/protocol_implementations/posix/posix_shm_client.rs index b9eae945b..bb9e8d7c0 100644 --- a/src/shm/protocol_implementations/posix/posix_shm_client.rs +++ b/src/shm/protocol_implementations/posix/posix_shm_client.rs @@ -16,7 +16,7 @@ use std::{mem::MaybeUninit, sync::Arc}; use zenoh::shm::{PosixShmClient, ShmClient}; -use crate::{transmute::RustTypeRefUninit, z_owned_shm_client_t}; +use crate::{transmute::RustTypeMutUninit, z_owned_shm_client_t}; /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Creates a new POSIX SHM Client. diff --git a/src/shm/protocol_implementations/posix/posix_shm_provider.rs b/src/shm/protocol_implementations/posix/posix_shm_provider.rs index 4b66eb5d3..4cf9c640e 100644 --- a/src/shm/protocol_implementations/posix/posix_shm_provider.rs +++ b/src/shm/protocol_implementations/posix/posix_shm_provider.rs @@ -25,7 +25,7 @@ use zenoh::{ use crate::{ result::{z_result_t, Z_EINVAL, Z_OK}, shm::provider::shm_provider::CSHMProvider, - transmute::{RustTypeRef, RustTypeRefUninit}, + transmute::{RustTypeMutUninit, RustTypeRef}, z_loaned_memory_layout_t, z_owned_shm_provider_t, }; diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index e141d7776..a4cb327b5 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -28,7 +28,7 @@ use crate::{ context::{zc_threadsafe_context_t, Context, ThreadsafeContext}, result::z_result_t, shm::protocol_implementations::posix::posix_shm_provider::PosixAllocLayout, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_alloc_layout_t, z_loaned_shm_provider_t, z_moved_alloc_layout_t, z_owned_alloc_layout_t, }; diff --git a/src/shm/provider/alloc_layout_impl.rs b/src/shm/provider/alloc_layout_impl.rs index 6ee942077..74932957e 100644 --- a/src/shm/provider/alloc_layout_impl.rs +++ b/src/shm/provider/alloc_layout_impl.rs @@ -31,7 +31,7 @@ use crate::{ context::{zc_threadsafe_context_t, DroppableContext, ThreadsafeContext}, result::{z_result_t, Z_EINVAL, Z_OK}, shm::provider::types::z_buf_alloc_result_t, - transmute::{IntoRustType, RustTypeRef, RustTypeRefUninit}, + transmute::{IntoRustType, RustTypeMutUninit, RustTypeRef}, z_loaned_alloc_layout_t, z_loaned_shm_provider_t, z_owned_alloc_layout_t, }; diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 45b354f93..011459c35 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -37,7 +37,7 @@ use crate::{ protocol_implementations::posix::posix_shm_provider::PosixShmProvider, provider::types::z_buf_layout_alloc_result_t, }, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_shm_provider_t, z_moved_shm_provider_t, z_owned_shm_mut_t, z_owned_shm_provider_t, }; diff --git a/src/shm/provider/shm_provider_impl.rs b/src/shm/provider/shm_provider_impl.rs index 9d4001d29..d94028f9c 100644 --- a/src/shm/provider/shm_provider_impl.rs +++ b/src/shm/provider/shm_provider_impl.rs @@ -31,7 +31,7 @@ use crate::{ context::{Context, DroppableContext, ThreadsafeContext}, result::{z_result_t, Z_EINVAL, Z_OK}, shm::provider::types::z_buf_layout_alloc_result_t, - transmute::{IntoRustType, RustTypeRef, RustTypeRefUninit}, + transmute::{IntoRustType, RustTypeMutUninit, RustTypeRef}, z_loaned_shm_provider_t, z_owned_shm_mut_t, }; diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index 59a1b2ec2..3204bdfe2 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -26,7 +26,7 @@ use super::chunk::z_allocated_chunk_t; use crate::{ result::{z_result_t, Z_EINVAL, Z_OK}, shm::buffer::zshmmut::z_internal_shm_mut_null, - transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{IntoCType, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_chunk_alloc_result_t, z_loaned_memory_layout_t, z_moved_chunk_alloc_result_t, z_moved_memory_layout_t, z_owned_chunk_alloc_result_t, z_owned_memory_layout_t, z_owned_shm_mut_t, diff --git a/src/subscriber.rs b/src/subscriber.rs index c95471b47..686679be8 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -20,7 +20,7 @@ pub use crate::opaque_types::{z_loaned_subscriber_t, z_moved_subscriber_t, z_own use crate::{ keyexpr::*, result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t, }; decl_c_type!( @@ -85,12 +85,10 @@ pub extern "C" fn z_declare_subscriber( .declare_subscriber(key_expr) .callback(move |sample| { let mut owned_sample = Some(sample); - z_closure_sample_call(z_closure_sample_loan(&callback), unsafe { - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) + z_closure_sample_call( + z_closure_sample_loan(&callback), + owned_sample.as_loaned_c_type_mut(), + ) }); match subscriber.wait() { Ok(sub) => { diff --git a/src/transmute.rs b/src/transmute.rs index 195d8780a..39d4bbe91 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -46,10 +46,14 @@ pub(crate) trait ViewCTypeRef: Sized { pub(crate) trait RustTypeRef: Sized { type RustType; fn as_rust_type_ref(&self) -> &Self::RustType; +} +#[allow(dead_code)] +pub(crate) trait RustTypeMut: Sized { + type RustType; fn as_rust_type_mut(&mut self) -> &mut Self::RustType; } #[allow(dead_code)] -pub(crate) trait RustTypeRefUninit: Sized { +pub(crate) trait RustTypeMutUninit: Sized { type RustType; fn as_rust_type_mut_uninit(&mut self) -> &mut MaybeUninit; } @@ -188,11 +192,17 @@ macro_rules! impl_transmute { fn as_rust_type_ref(&self) -> &Self::RustType { unsafe { &*(self as *const Self as *const Self::RustType) } } + } + }; + (as_rust_mut ($c_type:ty, $rust_type:ty)) => { + validate_equivalence!($rust_type, $c_type); + impl $crate::transmute::RustTypeMut for $c_type { + type RustType = $rust_type; fn as_rust_type_mut(&mut self) -> &mut Self::RustType { unsafe { &mut *(self as *mut Self as *mut Self::RustType) } } } - impl $crate::transmute::RustTypeRefUninit for std::mem::MaybeUninit<$c_type> { + impl $crate::transmute::RustTypeMutUninit for std::mem::MaybeUninit<$c_type> { type RustType = $rust_type; fn as_rust_type_mut_uninit(&mut self) -> &mut std::mem::MaybeUninit { unsafe { @@ -239,22 +249,25 @@ macro_rules! impl_transmute { } macro_rules! impl_owned { - (owned $c_owned_type:ty, inner rust option $rust_inner_type:ty) => { + (owned $c_owned_type:ty, rust option $rust_inner_type:ty) => { impl_transmute!(as_c_owned(Option<$rust_inner_type>, $c_owned_type)); impl_transmute!(as_rust($c_owned_type, Option<$rust_inner_type>)); + impl_transmute!(as_rust_mut($c_owned_type, Option<$rust_inner_type>)); impl_transmute!(into_rust($c_owned_type, Option<$rust_inner_type>)); impl_transmute!(into_c(Option<$rust_inner_type>, $c_owned_type)); impl_transmute!(take_rust($c_owned_type, Option<$rust_inner_type>)); }; - (owned $c_owned_type:ty, inner rust option $rust_inner_type:ty) => { + (owned $c_owned_type:ty, rust option $rust_inner_type:ty) => { impl_transmute!(as_c_owned(Option<$rust_inner_type>, $c_owned_type)); impl_transmute!(as_rust($c_owned_type, Option<$rust_inner_type>)); + impl_transmute!(as_rust_mut($c_owned_type, Option<$rust_inner_type>)); impl_transmute!(into_rust($c_owned_type, Option<$rust_inner_type>)); impl_transmute!(take_rust($c_owned_type, Option<$rust_inner_type>)); }; - (owned $c_owned_type:ty, inner rust $rust_owned_type:ty) => { + (owned $c_owned_type:ty, rust $rust_owned_type:ty) => { impl_transmute!(as_c_owned($rust_owned_type, $c_owned_type)); impl_transmute!(as_rust($c_owned_type, $rust_owned_type)); + impl_transmute!(as_rust_mut($c_owned_type, $rust_owned_type)); impl_transmute!(into_rust($c_owned_type, $rust_owned_type)); impl_transmute!(take_rust($c_owned_type, $rust_owned_type)); }; @@ -310,22 +323,20 @@ macro_rules! decl_c_type_inequal { (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { - decl_c_type!( - owned($c_owned_type, option $rust_inner_type), - ); + impl_owned!(owned $c_owned_type, rust option $rust_inner_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); + impl_transmute!(as_rust_mut($c_loaned_type, $rust_loaned_type)); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { - decl_c_type!( - owned($c_owned_type, $rust_owned_type), - ); + impl_owned!(owned $c_owned_type, rust $rust_owned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); + impl_transmute!(as_rust_mut($c_loaned_type, $rust_loaned_type)); }; // @@ -392,16 +403,11 @@ macro_rules! decl_c_type { // (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?) $(,)?) => { - impl_owned!(owned $c_owned_type, inner rust option $rust_inner_type); - }; - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?) - $(,)?) => { - impl_owned!(owned $c_owned_type, inner rust option $rust_inner_type); + impl_owned!(owned $c_owned_type, rust option $rust_inner_type); }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?) $(,)?) => { - impl_owned!(owned $c_owned_type, inner rust $rust_owned_type); + impl_owned!(owned $c_owned_type, rust $rust_owned_type); }; // // Owned with with explicit rust loaned type - rarely used @@ -409,20 +415,20 @@ macro_rules! decl_c_type { (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type, $rust_loaned_type), - ); - validate_equivalence!($c_loaned_type, $c_owned_type); + impl_owned!(owned $c_owned_type, rust option $rust_inner_type); + impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut(Option<$rust_inner_type>, $c_loaned_type)); + impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); + impl_transmute!(as_rust_mut($c_loaned_type, Option<$rust_inner_type>)); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_loaned_type), - ); - validate_equivalence!($c_loaned_type, $c_owned_type); + impl_owned!(owned $c_owned_type, rust $rust_owned_type); + impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut($rust_owned_type, $c_loaned_type)); + impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); + impl_transmute!(as_rust_mut($c_loaned_type, $rust_owned_type)); }; // // Owned with loaned type same as inner type - typical case @@ -450,31 +456,37 @@ macro_rules! decl_c_type { loaned ($c_loaned_type:ty $(,)?), view ($c_view_type:ty, $rust_view_type:ty $(,)?) $(,)?) => { - decl_c_type_inequal!( + decl_c_type!( owned($c_owned_type, option $rust_inner_type), loaned($c_loaned_type), - view($c_view_type, $rust_view_type), ); + impl_transmute!(as_c_view($rust_view_type, $c_view_type)); + impl_transmute!(as_rust($c_view_type, $rust_view_type)); + impl_transmute!(as_rust_mut($c_view_type, $rust_view_type)); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), loaned ($c_loaned_type:ty $(,)?), view ($c_view_type:ty, $rust_view_type:ty $(,)?) $(,)?) => { - decl_c_type_inequal!( + decl_c_type!( owned($c_owned_type, $rust_owned_type), loaned($c_loaned_type, $rust_owned_type), - view($c_view_type, $rust_view_type), ); + impl_transmute!(as_c_view($rust_view_type, $c_view_type)); + impl_transmute!(as_rust($c_view_type, $rust_view_type)); + impl_transmute!(as_rust_mut($c_view_type, $rust_view_type)); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?), view ($c_view_type:ty, $rust_view_type:ty $(,)?) $(,)?) => { - decl_c_type_inequal!( + decl_c_type!( owned($c_owned_type, $rust_owned_type), loaned($c_loaned_type, $rust_loaned_type), - view($c_view_type, $rust_view_type), ); + impl_transmute!(as_c_view($rust_view_type, $c_view_type)); + impl_transmute!(as_rust($c_view_type, $rust_view_type)); + impl_transmute!(as_rust_mut($c_view_type, $rust_view_type)); }; // @@ -501,6 +513,7 @@ macro_rules! decl_c_type { (copy ($c_type:ty, $rust_type:ty $(,)?) $(,)?) => { impl_transmute!(as_c($rust_type, $c_type)); impl_transmute!(as_rust($c_type, $rust_type)); + impl_transmute!(as_rust_mut($c_type, $rust_type)); impl_transmute!(into_c($rust_type, $c_type)); impl_transmute!(into_rust($c_type, $rust_type)); }; @@ -512,5 +525,6 @@ macro_rules! decl_c_type { impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); + impl_transmute!(as_rust_mut($c_loaned_type, $rust_loaned_type)); }; } From cdc06c825d7a0f2254830425d454356be9ea0e47 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 24 Sep 2024 16:22:24 +0400 Subject: [PATCH 04/38] loan_mut added --- Cargo.toml | 2 +- include/zenoh_commons.h | 752 +++++++++++++++++++++++-------- include/zenoh_macros.h | 404 ++--------------- src/closures/hello_closure.rs | 8 + src/closures/query_channel.rs | 24 + src/closures/query_closure.rs | 8 + src/closures/reply_closure.rs | 8 + src/closures/response_channel.rs | 25 + src/closures/sample_channel.rs | 24 + src/closures/sample_closure.rs | 8 + src/closures/zenohid_closure.rs | 6 + src/collections.rs | 18 + src/commons.rs | 18 + src/get.rs | 17 + src/keyexpr.rs | 11 + src/queryable.rs | 25 +- src/scouting.rs | 12 + src/session.rs | 11 + src/shm/client_storage/mod.rs | 13 + src/shm/provider/alloc_layout.rs | 12 + src/shm/provider/shm_provider.rs | 13 + src/shm/provider/types.rs | 26 ++ src/subscriber.rs | 11 + 23 files changed, 903 insertions(+), 553 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0244a649e..3c2c6774b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ spin = "0.9.5" unwrap-infallible = "0.1.5" const_format = "0.2.32" zenoh = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = ["internal"] } -zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", optional = true } +zenoh-ext = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" , optional = true } zenoh-runtime = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } zenoh-util = { version = "1.0.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } flume = "*" diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 0c418b5dd..2ba8356bf 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -16,6 +16,32 @@ #define ALIGN(n) #define ZENOHC_API #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Allocation errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_alloc_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Defragmentation needed. + */ + Z_ALLOC_ERROR_NEED_DEFRAGMENT, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * The provider is out of memory. + */ + Z_ALLOC_ERROR_OUT_OF_MEMORY, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Other error. + */ + Z_ALLOC_ERROR_OTHER, +#endif +} z_alloc_error_t; +#endif typedef enum z_congestion_control_t { /** * Messages are not dropped in case of congestion. @@ -77,6 +103,26 @@ typedef enum z_keyexpr_intersection_level_t { Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3, } z_keyexpr_intersection_level_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Layouting errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_layout_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout arguments are incorrect. + */ + Z_LAYOUT_ERROR_INCORRECT_LAYOUT_ARGS, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout incompatible with provider. + */ + Z_LAYOUT_ERROR_PROVIDER_INCOMPATIBLE_LAYOUT, +#endif +} z_layout_error_t; +#endif /** * The priority of zenoh messages. */ @@ -169,6 +215,52 @@ typedef enum z_whatami_t { Z_WHATAMI_PEER = 2, Z_WHATAMI_CLIENT = 4, } z_whatami_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +} zc_buf_alloc_status_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_layout_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layouting error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_LAYOUT_ERROR = 2, +#endif +} zc_buf_layout_alloc_status_t; +#endif /** * The locality of samples to be received by subscribers or targeted by publishers. */ @@ -237,10 +329,53 @@ typedef enum zc_reply_keyexpr_t { ZC_REPLY_KEYEXPR_MATCHING_QUERY = 1, } zc_reply_keyexpr_t; #endif -typedef struct z_moved_alloc_layout_t { - struct z_owned_alloc_layout_t _this; -} z_moved_alloc_layout_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_alloc_result_t { + enum zc_buf_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t error; +} z_buf_alloc_result_t; +#endif typedef int8_t z_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocAlignment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_alloc_alignment_t { + uint8_t pow; +} z_alloc_alignment_t; +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_data_t { + void *ptr; +} zc_threadsafe_context_data_t; +#endif +/** + * A tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a thread-safe context - the associated callbacks may be executed concurrently with the same + * zc_context_t instance. In other words, all the callbacks associated with this context data MUST be + * thread-safe. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_t { + struct zc_threadsafe_context_data_t context; + void (*delete_fn)(void*); +} zc_threadsafe_context_t; +#endif typedef struct z_moved_bytes_t { struct z_owned_bytes_t _this; } z_moved_bytes_t; @@ -256,15 +391,41 @@ typedef struct z_moved_string_t { typedef struct ALIGN(8) z_bytes_slice_iterator_t { uint8_t _0[24]; } z_bytes_slice_iterator_t; -typedef struct z_moved_shm_t { - struct z_owned_shm_t _this; -} z_moved_shm_t; -typedef struct z_moved_shm_mut_t { - struct z_owned_shm_mut_t _this; -} z_moved_shm_mut_t; -typedef struct z_moved_chunk_alloc_result_t { - struct z_owned_chunk_alloc_result_t _this; -} z_moved_chunk_alloc_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Unique segment identifier. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_segment_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Chunk id within it's segment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_chunk_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A ChunkDescriptor. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_chunk_descriptor_t { + z_segment_id_t segment; + z_chunk_id_t chunk; + size_t len; +} z_chunk_descriptor_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocatedChunk. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_allocated_chunk_t { + struct z_chunk_descriptor_t descriptpr; + void *data; +} z_allocated_chunk_t; +#endif /** * Monotonic clock */ @@ -422,7 +583,7 @@ typedef struct z_owned_closure_zid_t { /** * A callback function. */ - void (*call)(const struct z_id_t *z_id, void *context); + void (*call)(const z_id_t *z_id, void *context); /** * An optional function that will be called upon closure drop. */ @@ -554,9 +715,6 @@ typedef struct z_moved_fifo_handler_sample_t { typedef struct z_query_consolidation_t { enum z_consolidation_mode_t mode; } z_query_consolidation_t; -typedef struct z_moved_source_info_t { - struct z_owned_source_info_t _this; -} z_moved_source_info_t; /** * Options passed to the `z_get()` function. */ @@ -611,7 +769,7 @@ typedef struct z_get_options_t { * * The source info for the query. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * An optional attachment to attach to the query. @@ -628,9 +786,6 @@ typedef struct z_moved_hello_t { typedef struct z_moved_keyexpr_t { struct z_owned_keyexpr_t _this; } z_moved_keyexpr_t; -typedef struct z_moved_memory_layout_t { - struct z_owned_memory_layout_t _this; -} z_moved_memory_layout_t; typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; @@ -671,7 +826,7 @@ typedef struct z_publisher_put_options_t { * * The source info for the publication. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to attach to the publication. @@ -724,7 +879,7 @@ typedef struct z_put_options_t { * * The source info for the message. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this message. @@ -765,7 +920,7 @@ typedef struct z_query_reply_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -799,7 +954,7 @@ typedef struct z_query_reply_del_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -850,15 +1005,46 @@ typedef struct z_scout_options_t { */ enum z_what_t what; } z_scout_options_t; -typedef struct z_moved_shm_client_t { - struct z_owned_shm_client_t _this; -} z_moved_shm_client_t; -typedef struct z_moved_shm_client_storage_t { - struct z_owned_shm_client_storage_t _this; -} z_moved_shm_client_storage_t; -typedef struct z_moved_shm_provider_t { - struct z_owned_shm_provider_t _this; -} z_moved_shm_provider_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_segment_callbacks_t { + uint8_t *(*map_fn)(z_chunk_id_t chunk_id, void *context); +} zc_shm_segment_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_shm_segment_t { + struct zc_threadsafe_context_t context; + struct zc_shm_segment_callbacks_t callbacks; +} z_shm_segment_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callback for ShmClient. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_client_callbacks_t { + bool (*attach_fn)(struct z_shm_segment_t *out_segment, z_segment_id_t segment_id, void *context); +} zc_shm_client_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_layout_alloc_result_t { + enum zc_buf_layout_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t alloc_error; + enum z_layout_error_t layout_error; +} z_buf_layout_alloc_result_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Unique protocol identifier. @@ -868,6 +1054,47 @@ typedef struct z_moved_shm_provider_t { #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) typedef uint32_t z_protocol_id_t; #endif +/** + * A non-tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same + * zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated + * with this context data are not required to be thread-safe. + * + * NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can + * still be executed concurrently. The exact behavior depends on user's application, but we strongly + * discourage our users from pinning to some specific behavior unless they _really_ understand what they + * are doing. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_context_t { + void *context; + void (*delete_fn)(void*); +} zc_context_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmProviderBackend. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_provider_backend_callbacks_t { + void (*alloc_fn)(z_owned_chunk_alloc_result_t *out_result, + const z_loaned_memory_layout_t *layout, + void *context); + void (*free_fn)(const struct z_chunk_descriptor_t *chunk, void *context); + size_t (*defragment_fn)(void *context); + size_t (*available_fn)(void *context); + void (*layout_for_fn)(z_owned_memory_layout_t *layout, void *context); +} zc_shm_provider_backend_callbacks_t; +#endif typedef struct z_moved_string_array_t { struct z_owned_string_array_t _this; } z_moved_string_array_t; @@ -955,6 +1182,15 @@ typedef struct zc_owned_closure_matching_status_t { void (*drop)(void *context); } zc_owned_closure_matching_status_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Loaned closure. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +typedef struct zc_loaned_closure_matching_status_t { + size_t _0[3]; +} zc_loaned_closure_matching_status_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. @@ -991,15 +1227,6 @@ typedef struct zc_liveliness_get_options_t { uint32_t timeout_ms; } zc_liveliness_get_options_t; #endif -typedef struct zc_moved_liveliness_token_t { - struct zc_owned_liveliness_token_t _this; -} zc_moved_liveliness_token_t; -typedef struct zc_moved_matching_listener_t { - struct zc_owned_matching_listener_t _this; -} zc_moved_matching_listener_t; -typedef struct zc_moved_shm_client_list_t { - struct zc_owned_shm_client_list_t _this; -} zc_moved_shm_client_list_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Options passed to the `ze_declare_publication_cache()` function. @@ -1068,19 +1295,6 @@ typedef struct ze_querying_subscriber_options_t { uint64_t query_timeout_ms; } ze_querying_subscriber_options_t; #endif -typedef struct ze_moved_publication_cache_t { - struct ze_owned_publication_cache_t _this; -} ze_moved_publication_cache_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A loaned Zenoh publication cache. - */ -typedef struct ALIGN(8) ze_loaned_publication_cache_t { - uint8_t _0[96]; -} ze_loaned_publication_cache_t; -typedef struct ze_moved_querying_subscriber_t { - struct ze_owned_querying_subscriber_t _this; -} ze_moved_querying_subscriber_t; ZENOHC_API extern const unsigned int Z_ROUTER; ZENOHC_API extern const unsigned int Z_PEER; ZENOHC_API extern const unsigned int Z_CLIENT; @@ -1100,40 +1314,45 @@ ZENOHC_API extern const unsigned int Z_SHM_POSIX_PROTOCOL_ID; #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_blocking(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif /** * Deletes Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_alloc_layout_drop(struct z_moved_alloc_layout_t *this_); +ZENOHC_API void z_alloc_layout_drop(z_moved_alloc_layout_t *this_); #endif /** * Borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_); +#endif +/** + * Mutably borrows Alloc Layout + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(z_owned_alloc_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1141,15 +1360,15 @@ const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_a */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_alloc_layout_new(z_owned_alloc_layout_t *this_, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout, + const z_loaned_alloc_layout_t *layout, struct zc_threadsafe_context_t result_context, void (*result_callback)(void*, struct z_buf_alloc_result_t*)); @@ -1210,7 +1429,7 @@ z_result_t z_bytes_deserialize_into_int8(const struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_loaned_shm(const struct z_loaned_bytes_t *this_, - const struct z_loaned_shm_t **dst); + const z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1222,7 +1441,7 @@ z_result_t z_bytes_deserialize_into_loaned_shm(const struct z_loaned_bytes_t *th #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_mut_loaned_shm(struct z_loaned_bytes_t *this_, - struct z_loaned_shm_t **dst); + z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1234,7 +1453,7 @@ z_result_t z_bytes_deserialize_into_mut_loaned_shm(struct z_loaned_bytes_t *this #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_owned_shm(const struct z_loaned_bytes_t *this_, - struct z_owned_shm_t *dst); + z_owned_shm_t *dst); #endif /** * Deserializes into a pair of `z_owned_bytes_t` objects. @@ -1503,7 +1722,7 @@ ZENOHC_API void z_bytes_serialize_from_int8(struct z_owned_bytes_t *this_, int8_ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_serialize_from_shm(struct z_owned_bytes_t *this_, - struct z_moved_shm_t *shm); + z_moved_shm_t *shm); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1512,7 +1731,7 @@ z_result_t z_bytes_serialize_from_shm(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_serialize_from_shm_mut(struct z_owned_bytes_t *this_, - struct z_moved_shm_mut_t *shm); + z_moved_shm_mut_t *shm); #endif /** * Serializes a slice by copying. @@ -1591,7 +1810,7 @@ z_result_t z_bytes_writer_write_all(struct z_bytes_writer_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); +void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1599,7 +1818,15 @@ void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const struct z_owned_chunk_alloc_result_t *this_); +const z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const z_owned_chunk_alloc_result_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Mutably borrows Chunk Alloc Result. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1607,7 +1834,7 @@ const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const stru */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, +void z_chunk_alloc_result_new_error(z_owned_chunk_alloc_result_t *this_, enum z_alloc_error_t alloc_error); #endif /** @@ -1616,7 +1843,7 @@ void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this_, +z_result_t z_chunk_alloc_result_new_ok(z_owned_chunk_alloc_result_t *this_, struct z_allocated_chunk_t allocated_chunk); #endif /** @@ -1674,6 +1901,11 @@ ZENOHC_API void z_closure_hello_drop(struct z_moved_closure_hello_t *this_); */ ZENOHC_API const struct z_loaned_closure_hello_t *z_closure_hello_loan(const struct z_owned_closure_hello_t *closure); +/** + * Mutably borrows closure. + */ +ZENOHC_API +struct z_loaned_closure_hello_t *z_closure_hello_loan_mut(struct z_owned_closure_hello_t *closure); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -1701,6 +1933,11 @@ ZENOHC_API void z_closure_query_drop(struct z_moved_closure_query_t *closure_); */ ZENOHC_API const struct z_loaned_closure_query_t *z_closure_query_loan(const struct z_owned_closure_query_t *closure); +/** + * Mutably borrows closure. + */ +ZENOHC_API +struct z_loaned_closure_query_t *z_closure_query_loan_mut(struct z_owned_closure_query_t *closure); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -1729,6 +1966,11 @@ void z_closure_reply_drop(struct z_moved_closure_reply_t *closure_); */ ZENOHC_API const struct z_loaned_closure_reply_t *z_closure_reply_loan(const struct z_owned_closure_reply_t *closure); +/** + * Mutably borrows closure. + */ +ZENOHC_API +struct z_loaned_closure_reply_t *z_closure_reply_loan_mut(struct z_owned_closure_reply_t *closure); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -1756,6 +1998,11 @@ ZENOHC_API void z_closure_sample_drop(struct z_moved_closure_sample_t *closure_) */ ZENOHC_API const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_owned_closure_sample_t *closure); +/** + * Borrows closure. + */ +ZENOHC_API +struct z_loaned_closure_sample_t *z_closure_sample_loan_mut(struct z_owned_closure_sample_t *closure); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -1766,7 +2013,7 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid(struct z_owned_closure_zid_t *this_, - void (*call)(const struct z_id_t *z_id, void *context), + void (*call)(const z_id_t *z_id, void *context), void (*drop)(void *context), void *context); #endif @@ -1777,7 +2024,7 @@ void z_closure_zid(struct z_owned_closure_zid_t *this_, #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, - const struct z_id_t *z_id); + const z_id_t *z_id); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1795,6 +2042,14 @@ void z_closure_zid_drop(struct z_moved_closure_zid_t *closure_); ZENOHC_API const struct z_loaned_closure_zid_t *z_closure_zid_loan(const struct z_owned_closure_zid_t *closure); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Borrows closure. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid_t *closure); +#endif /** * Drops conditional variable. */ @@ -2430,7 +2685,7 @@ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_zenoh_uint8(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); +uint32_t z_entity_global_id_eid(const z_entity_global_id_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2438,7 +2693,7 @@ uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_entity_global_id_zid(const struct z_entity_global_id_t *this_); +z_id_t z_entity_global_id_zid(const z_entity_global_id_t *this_); #endif /** * Constructs send and recieve ends of the fifo channel @@ -2470,6 +2725,11 @@ ZENOHC_API void z_fifo_handler_query_drop(struct z_moved_fifo_handler_query_t *t */ ZENOHC_API const struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan(const struct z_owned_fifo_handler_query_t *this_); +/** + * Borrows handler. + */ +ZENOHC_API +struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan_mut(struct z_owned_fifo_handler_query_t *this_); /** * Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until * the channel is dropped (normally when Queryable is dropped). @@ -2496,6 +2756,11 @@ ZENOHC_API void z_fifo_handler_reply_drop(struct z_moved_fifo_handler_reply_t *t */ ZENOHC_API const struct z_loaned_fifo_handler_reply_t *z_fifo_handler_reply_loan(const struct z_owned_fifo_handler_reply_t *this_); +/** + * Mutably borrows handler. + */ +ZENOHC_API +struct z_loaned_fifo_handler_reply_t *z_fifo_handler_reply_loan_mut(struct z_owned_fifo_handler_reply_t *this_); /** * Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until * the channel is dropped (normally when all replies are received). @@ -2521,6 +2786,11 @@ ZENOHC_API void z_fifo_handler_sample_drop(struct z_moved_fifo_handler_sample_t */ ZENOHC_API const struct z_loaned_fifo_handler_sample_t *z_fifo_handler_sample_loan(const struct z_owned_fifo_handler_sample_t *this_); +/** + * Mutably borrows handler. + */ +ZENOHC_API +struct z_loaned_fifo_handler_sample_t *z_fifo_handler_sample_loan_mut(struct z_owned_fifo_handler_sample_t *this_); /** * Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until * the channel is dropped (normally when there are no more samples to receive). @@ -2572,6 +2842,10 @@ ZENOHC_API void z_hello_drop(struct z_moved_hello_t *this_); * Borrows hello message. */ ZENOHC_API const struct z_loaned_hello_t *z_hello_loan(const struct z_owned_hello_t *this_); +/** + * Borrows hello message. + */ +ZENOHC_API struct z_loaned_hello_t *z_hello_loan_mut(struct z_owned_hello_t *this_); /** * Constructs an array of non-owned locators (in the form non-null-terminated strings) of Zenoh entity that sent hello message. * @@ -2590,7 +2864,7 @@ ZENOHC_API enum z_whatami_t z_hello_whatami(const struct z_loaned_hello_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); +z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2598,7 +2872,7 @@ struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_id_to_string(const struct z_id_t *zid, +void z_id_to_string(const z_id_t *zid, struct z_owned_string_t *dst); #endif /** @@ -2639,19 +2913,19 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_info_zid(const struct z_loaned_session_t *session); +z_id_t z_info_zid(const struct z_loaned_session_t *session); #endif /** * Returns ``true`` if `this` is valid. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_internal_alloc_layout_check(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); #endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_internal_alloc_layout_null(struct z_owned_alloc_layout_t *this_); +ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); #endif /** * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -2667,7 +2941,7 @@ ZENOHC_API void z_internal_bytes_null(struct z_owned_bytes_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result_t *this_); +bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2675,7 +2949,7 @@ bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_chunk_alloc_result_null(struct z_owned_chunk_alloc_result_t *this_); +void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); #endif /** * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. @@ -2798,7 +3072,7 @@ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_); +bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2806,7 +3080,7 @@ bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_memory_layout_null(struct z_owned_memory_layout_t *this_); +void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); #endif /** * Returns ``true`` if mutex is valid, ``false`` otherwise. @@ -2905,7 +3179,7 @@ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_check(const struct z_owned_shm_t *this_); +bool z_internal_shm_check(const z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2913,7 +3187,7 @@ bool z_internal_shm_check(const struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); +bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2921,7 +3195,7 @@ bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); +void z_internal_shm_client_null(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2929,7 +3203,7 @@ void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage_t *this_); +bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2937,7 +3211,7 @@ bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *this_); +void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2945,7 +3219,7 @@ void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); +bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2953,7 +3227,7 @@ bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); +void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2961,7 +3235,7 @@ void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_null(struct z_owned_shm_t *this_); +void z_internal_shm_null(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2969,7 +3243,7 @@ void z_internal_shm_null(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); +bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2977,7 +3251,7 @@ bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_provider_null(struct z_owned_shm_provider_t *this_); +void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); #endif /** * @return ``true`` if slice is not empty, ``false`` otherwise. @@ -2993,7 +3267,7 @@ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); +bool z_internal_source_info_check(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3001,7 +3275,7 @@ bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_internal_source_info_null(struct z_owned_source_info_t *this_); +void z_internal_source_info_null(z_owned_source_info_t *this_); #endif /** * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. @@ -3161,6 +3435,10 @@ z_result_t z_keyexpr_join(struct z_owned_keyexpr_t *this_, * Borrows `z_owned_keyexpr_t`. */ ZENOHC_API const struct z_loaned_keyexpr_t *z_keyexpr_loan(const struct z_owned_keyexpr_t *this_); +/** + * Mutably borrows `z_owned_keyexpr_t`. + */ +ZENOHC_API struct z_loaned_keyexpr_t *z_keyexpr_loan_mut(struct z_owned_keyexpr_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Returns the relation between `left` and `right` from `left`'s point of view. @@ -3178,7 +3456,7 @@ enum z_keyexpr_intersection_level_t z_keyexpr_relation_to(const struct z_loaned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); +void z_memory_layout_drop(z_moved_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3186,7 +3464,7 @@ void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, +void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, size_t *out_size, struct z_alloc_alignment_t *out_alignment); #endif @@ -3196,7 +3474,15 @@ void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned_memory_layout_t *this_); +const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Mutably borrows Memory Layout. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_loaned_memory_layout_t *z_memory_layout_loan_mut(z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3204,7 +3490,7 @@ const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, +z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3260,7 +3546,7 @@ ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); ZENOHC_API z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, struct z_moved_config_t *config, - const struct z_loaned_shm_client_storage_t *shm_clients); + const z_loaned_shm_client_storage_t *shm_clients); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3268,7 +3554,7 @@ z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); +void z_posix_shm_client_new(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3276,8 +3562,8 @@ void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_posix_shm_provider_new(struct z_owned_shm_provider_t *this_, - const struct z_loaned_memory_layout_t *layout); +z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, + const z_loaned_memory_layout_t *layout); #endif /** * Returns the default value of #z_priority_t. @@ -3305,7 +3591,7 @@ ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); +z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); #endif /** * Returns the key expression of the publisher. @@ -3431,6 +3717,10 @@ ZENOHC_API const struct z_loaned_keyexpr_t *z_query_keyexpr(const struct z_loane * Borrows the query. */ ZENOHC_API const struct z_loaned_query_t *z_query_loan(const struct z_owned_query_t *this_); +/** + * Mutably borrows the query. + */ +ZENOHC_API struct z_loaned_query_t *z_query_loan_mut(struct z_owned_query_t *this_); /** * Gets query value selector. */ @@ -3528,10 +3818,11 @@ void z_queryable_drop(struct z_moved_queryable_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); +z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); #endif ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); +ZENOHC_API struct z_loaned_queryable_t *z_queryable_loan_mut(struct z_owned_queryable_t *this_); /** * Constructs the default value for `z_query_reply_options_t`. */ @@ -3561,7 +3852,7 @@ ZENOHC_API uint8_t z_random_u8(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_ref_shm_client_storage_global(struct z_owned_shm_client_storage_t *this_); +void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3605,6 +3896,10 @@ const struct z_loaned_encoding_t *z_reply_err_encoding(const struct z_loaned_rep */ ZENOHC_API const struct z_loaned_reply_err_t *z_reply_err_loan(const struct z_owned_reply_err_t *this_); +/** + * Mutably borrows reply error. + */ +ZENOHC_API struct z_loaned_reply_err_t *z_reply_err_loan_mut(struct z_owned_reply_err_t *this_); /** * Returns reply error payload. */ @@ -3619,6 +3914,10 @@ bool z_reply_is_ok(const struct z_loaned_reply_t *this_); * Borrows reply. */ ZENOHC_API const struct z_loaned_reply_t *z_reply_loan(const struct z_owned_reply_t *this_); +/** + * Mutably borrows reply. + */ +ZENOHC_API struct z_loaned_reply_t *z_reply_loan_mut(struct z_owned_reply_t *this_); /** * Yields the contents of the reply by asserting it indicates a success. * @@ -3633,7 +3932,7 @@ ZENOHC_API const struct z_loaned_sample_t *z_reply_ok(const struct z_loaned_repl #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API bool z_reply_replier_id(const struct z_loaned_reply_t *this_, - struct z_id_t *out_id); + z_id_t *out_id); #endif /** * Constructs send and recieve ends of the ring channel @@ -3665,6 +3964,11 @@ ZENOHC_API void z_ring_handler_query_drop(struct z_moved_ring_handler_query_t *t */ ZENOHC_API const struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan(const struct z_owned_ring_handler_query_t *this_); +/** + * Borrows handler. + */ +ZENOHC_API +struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan_mut(struct z_owned_ring_handler_query_t *this_); /** * Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until * the channel is dropped (normally when Queryable is dropped). @@ -3690,6 +3994,11 @@ ZENOHC_API void z_ring_handler_reply_drop(struct z_moved_ring_handler_reply_t *t */ ZENOHC_API const struct z_loaned_ring_handler_reply_t *z_ring_handler_reply_loan(const struct z_owned_ring_handler_reply_t *this_); +/** + * Mutably borrows handler. + */ +ZENOHC_API +struct z_loaned_ring_handler_reply_t *z_ring_handler_reply_loan_mut(struct z_owned_ring_handler_reply_t *this_); /** * Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until * the channel is dropped (normally when all replies are received). @@ -3715,6 +4024,11 @@ ZENOHC_API void z_ring_handler_sample_drop(struct z_moved_ring_handler_sample_t */ ZENOHC_API const struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan(const struct z_owned_ring_handler_sample_t *this_); +/** + * Borrows handler. + */ +ZENOHC_API +struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan_mut(struct z_owned_ring_handler_sample_t *this_); /** * Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until * the channel is dropped (normally when there are no more replies to receive). @@ -3774,6 +4088,10 @@ ZENOHC_API enum z_sample_kind_t z_sample_kind(const struct z_loaned_sample_t *th * Borrows sample. */ ZENOHC_API const struct z_loaned_sample_t *z_sample_loan(const struct z_owned_sample_t *this_); +/** + * Mutably borrows sample. + */ +ZENOHC_API struct z_loaned_sample_t *z_sample_loan_mut(struct z_owned_sample_t *this_); /** * Returns the sample payload data. */ @@ -3796,7 +4114,7 @@ enum z_reliability_t z_sample_reliability(const struct z_loaned_sample_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); +const z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); #endif /** * Returns the sample timestamp. @@ -3829,13 +4147,17 @@ ZENOHC_API void z_session_drop(struct z_moved_session_t *this_); * Borrows session. */ ZENOHC_API const struct z_loaned_session_t *z_session_loan(const struct z_owned_session_t *this_); +/** + * Mutably borrows session. + */ +ZENOHC_API struct z_loaned_session_t *z_session_loan_mut(struct z_owned_session_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes SHM Client. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_drop(struct z_moved_shm_client_t *this_); +void z_shm_client_drop(z_moved_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3843,7 +4165,7 @@ void z_shm_client_drop(struct z_moved_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_new(struct z_owned_shm_client_t *this_, +void z_shm_client_new(z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif @@ -3853,8 +4175,8 @@ void z_shm_client_new(struct z_owned_shm_client_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, - const struct z_loaned_shm_client_storage_t *from); +void z_shm_client_storage_clone(z_owned_shm_client_storage_t *this_, + const z_loaned_shm_client_storage_t *from); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3862,7 +4184,7 @@ void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); +void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3870,15 +4192,23 @@ void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const struct z_owned_shm_client_storage_t *this_); +const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Mutably borrows SHM Client Storage. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, - const struct zc_loaned_shm_client_list_t *clients, +z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(z_owned_shm_client_storage_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, + const zc_loaned_shm_client_list_t *clients, bool add_default_client_set); #endif /** @@ -3886,7 +4216,7 @@ z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_); +void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3894,8 +4224,8 @@ void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_clone(struct z_owned_shm_t *out, - const struct z_loaned_shm_t *this_); +void z_shm_clone(z_owned_shm_t *out, + const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3903,7 +4233,7 @@ void z_shm_clone(struct z_owned_shm_t *out, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); +const unsigned char *z_shm_data(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3911,7 +4241,7 @@ const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_drop(struct z_moved_shm_t *this_); +void z_shm_drop(z_moved_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3919,8 +4249,8 @@ void z_shm_drop(struct z_moved_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_from_mut(struct z_owned_shm_t *this_, - struct z_moved_shm_mut_t *that); +void z_shm_from_mut(z_owned_shm_t *this_, + z_moved_shm_mut_t *that); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3928,7 +4258,7 @@ void z_shm_from_mut(struct z_owned_shm_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_len(const struct z_loaned_shm_t *this_); +size_t z_shm_len(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3936,13 +4266,13 @@ size_t z_shm_len(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_t *z_shm_loan(const struct z_owned_shm_t *this_); +const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); #endif /** * @brief Mutably borrows ZShm slice. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); +ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3950,7 +4280,7 @@ ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); +const unsigned char *z_shm_mut_data(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3958,7 +4288,7 @@ const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); +unsigned char *z_shm_mut_data_mut(z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3966,7 +4296,7 @@ unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); +void z_shm_mut_drop(z_moved_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3974,7 +4304,7 @@ void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); +size_t z_shm_mut_len(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3982,7 +4312,7 @@ size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t *this_); +const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3990,7 +4320,7 @@ const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); +z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4004,9 +4334,9 @@ struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, - struct z_moved_shm_t *that, - struct z_owned_shm_t *immut); +z_result_t z_shm_mut_try_from_immut(z_owned_shm_mut_t *this_, + z_moved_shm_t *that, + z_owned_shm_t *immut); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4014,7 +4344,7 @@ z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4024,7 +4354,7 @@ void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4034,7 +4364,7 @@ void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4044,7 +4374,7 @@ void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_resu #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment, struct zc_threadsafe_context_t result_context, @@ -4057,7 +4387,7 @@ z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4067,7 +4397,7 @@ void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4076,14 +4406,14 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_available(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_defragment(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4091,14 +4421,14 @@ size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_drop(struct z_moved_shm_provider_t *this_); +void z_shm_provider_drop(z_moved_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4106,15 +4436,23 @@ size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *prov */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_shm_provider_t *this_); +const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Mutably borrows SHM Provider. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, - const struct z_loaned_shm_provider_t *provider, +z_loaned_shm_provider_t *z_shm_provider_loan_mut(z_owned_shm_provider_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_result_t z_shm_provider_map(z_owned_shm_mut_t *out_result, + const z_loaned_shm_provider_t *provider, struct z_allocated_chunk_t allocated_chunk, size_t len); #endif @@ -4124,7 +4462,7 @@ z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4135,7 +4473,7 @@ void z_shm_provider_new(struct z_owned_shm_provider_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_threadsafe_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_threadsafe_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4146,7 +4484,7 @@ void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4154,7 +4492,7 @@ struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_reloan_mut(struct z_loaned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_reloan_mut(z_loaned_shm_t *this_); #endif /** * Puts current thread to sleep for specified amount of milliseconds. @@ -4221,13 +4559,17 @@ ZENOHC_API size_t z_slice_len(const struct z_loaned_slice_t *this_); * Borrows slice. */ ZENOHC_API const struct z_loaned_slice_t *z_slice_loan(const struct z_owned_slice_t *this_); +/** + * Mutably borrows slice. + */ +ZENOHC_API struct z_loaned_slice_t *z_slice_loan_mut(struct z_owned_slice_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_drop(struct z_moved_source_info_t *this_); +void z_source_info_drop(z_moved_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4235,7 +4577,15 @@ void z_source_info_drop(struct z_moved_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t *this_); +z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Borrows source info. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4243,7 +4593,7 @@ struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_source_info_t *this_); +const z_loaned_source_info_t *z_source_info_loan_mut(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4251,8 +4601,8 @@ const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_sou */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t z_source_info_new(struct z_owned_source_info_t *this_, - const struct z_entity_global_id_t *source_id, +z_result_t z_source_info_new(z_owned_source_info_t *this_, + const z_entity_global_id_t *source_id, uint32_t source_sn); #endif /** @@ -4261,7 +4611,7 @@ z_result_t z_source_info_new(struct z_owned_source_info_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); +uint32_t z_source_info_sn(const z_loaned_source_info_t *this_); #endif /** * Constructs an owned copy of a string array. @@ -4378,6 +4728,10 @@ ZENOHC_API size_t z_string_len(const struct z_loaned_string_t *this_); * Borrows string. */ ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_string_t *this_); +/** + * Mutably borrows string. + */ +ZENOHC_API struct z_loaned_string_t *z_string_loan_mut(struct z_owned_string_t *this_); /** * Drops subscriber and resets it to its gravestone state. * The callback closure is not dropped and still keeps receiving and processing samples until the corresponding session is closed. @@ -4394,6 +4748,10 @@ const struct z_loaned_keyexpr_t *z_subscriber_keyexpr(const struct z_loaned_subs */ ZENOHC_API const struct z_loaned_subscriber_t *z_subscriber_loan(const struct z_owned_subscriber_t *this_); +/** + * Mutably borrows subscriber. + */ +ZENOHC_API struct z_loaned_subscriber_t *z_subscriber_loan_mut(struct z_owned_subscriber_t *this_); /** * Constructs the default value for `z_subscriber_options_t`. */ @@ -4455,7 +4813,7 @@ const char *z_time_now_as_str(const char *buf, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_timestamp_id(const struct z_timestamp_t *this_); +z_id_t z_timestamp_id(const struct z_timestamp_t *this_); #endif /** * Create uhlc timestamp from session id. @@ -4830,7 +5188,7 @@ void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_s */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t *this_); +bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4838,7 +5196,7 @@ bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_); +void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4846,7 +5204,7 @@ void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener_t *this_); +bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4854,7 +5212,7 @@ bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *this_); +void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4862,7 +5220,7 @@ void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t *this_); +bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4870,7 +5228,7 @@ bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_internal_shm_client_list_null(struct zc_owned_shm_client_list_t *this_); +void zc_internal_shm_client_list_null(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4914,7 +5272,7 @@ z_result_t zc_liveliness_declare_subscriber(struct z_owned_subscriber_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_declare_token(struct zc_owned_liveliness_token_t *this_, +z_result_t zc_liveliness_declare_token(zc_owned_liveliness_token_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, const struct zc_liveliness_declaration_options_t *_options); @@ -4957,7 +5315,7 @@ void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_op */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); +void zc_liveliness_token_drop(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4965,7 +5323,7 @@ void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct zc_owned_liveliness_token_t *this_); +const zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4973,7 +5331,7 @@ const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_undeclare_token(struct zc_moved_liveliness_token_t *this_); +z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5006,7 +5364,7 @@ z_result_t zc_publisher_get_matching_status(const struct z_loaned_publisher_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_publisher_matching_listener_declare(struct zc_owned_matching_listener_t *this_, +z_result_t zc_publisher_matching_listener_declare(zc_owned_matching_listener_t *this_, const struct z_loaned_publisher_t *publisher, struct zc_moved_closure_matching_status_t *callback); #endif @@ -5016,7 +5374,7 @@ z_result_t zc_publisher_matching_listener_declare(struct zc_owned_matching_liste */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *this_); +void zc_publisher_matching_listener_drop(zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5026,7 +5384,7 @@ void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *th */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_publisher_matching_listener_undeclare(struct zc_moved_matching_listener_t *this_); +z_result_t zc_publisher_matching_listener_undeclare(zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5041,9 +5399,9 @@ enum zc_reply_keyexpr_t zc_reply_keyexpr_default(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *this_, +z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, - struct z_moved_shm_client_t *client); + z_moved_shm_client_t *client); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5051,7 +5409,7 @@ z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); +void zc_shm_client_list_drop(zc_moved_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5059,7 +5417,7 @@ void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct zc_owned_shm_client_list_t *this_); +const zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5067,7 +5425,7 @@ const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct z */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_shm_client_list_t *this_); +zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5075,7 +5433,7 @@ struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_new(struct zc_owned_shm_client_list_t *this_); +void zc_shm_client_list_new(zc_owned_shm_client_list_t *this_); #endif /** * Stops all Zenoh tasks and drops all related static variables. @@ -5107,7 +5465,7 @@ void zc_try_init_log_from_env(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_declare_publication_cache(struct ze_owned_publication_cache_t *this_, +z_result_t ze_declare_publication_cache(ze_owned_publication_cache_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, struct ze_publication_cache_options_t *options); @@ -5126,7 +5484,7 @@ z_result_t ze_declare_publication_cache(struct ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_declare_querying_subscriber(struct ze_owned_querying_subscriber_t *this_, +z_result_t ze_declare_querying_subscriber(ze_owned_querying_subscriber_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, struct z_moved_closure_sample_t *callback, @@ -5138,7 +5496,7 @@ z_result_t ze_declare_querying_subscriber(struct ze_owned_querying_subscriber_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache_t *this_); +bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5146,7 +5504,7 @@ bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *this_); +void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5154,13 +5512,13 @@ void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *this_); +bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); #endif /** * Constructs a querying subscriber in a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_subscriber_t *this_); +ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5168,7 +5526,7 @@ ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_su */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); +void ze_publication_cache_drop(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5176,7 +5534,7 @@ void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_loaned_publication_cache_t *this_); +const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const ze_loaned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5184,7 +5542,7 @@ const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_lo */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_publication_cache_t *ze_publication_cache_loan(const struct ze_owned_publication_cache_t *this_); +const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5201,7 +5559,7 @@ void ze_publication_cache_options_default(struct ze_publication_cache_options_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); +void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5211,7 +5569,7 @@ void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber_t *this_, +z_result_t ze_querying_subscriber_get(const ze_loaned_querying_subscriber_t *this_, const struct z_loaned_keyexpr_t *selector, struct z_get_options_t *options); #endif @@ -5221,7 +5579,7 @@ z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *this_); +const ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5238,7 +5596,7 @@ void ze_querying_subscriber_options_default(struct ze_querying_subscriber_option */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *this_); +z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5248,5 +5606,5 @@ z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_querying_subscriber(struct ze_moved_querying_subscriber_t *this_); +z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *this_); #endif diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index d6c3b70f1..0e3af2731 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -4,14 +4,11 @@ #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return (z_moved_alloc_layout_t*)(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return (z_moved_bytes_t*)(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return (z_moved_chunk_alloc_result_t*)(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return (z_moved_closure_hello_t*)(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return (z_moved_closure_query_t*)(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return (z_moved_closure_reply_t*)(x); } static inline z_moved_closure_sample_t* z_closure_sample_move(z_owned_closure_sample_t* x) { return (z_moved_closure_sample_t*)(x); } -static inline z_moved_closure_zid_t* z_closure_zid_move(z_owned_closure_zid_t* x) { return (z_moved_closure_zid_t*)(x); } static inline z_moved_condvar_t* z_condvar_move(z_owned_condvar_t* x) { return (z_moved_condvar_t*)(x); } static inline z_moved_config_t* z_config_move(z_owned_config_t* x) { return (z_moved_config_t*)(x); } static inline z_moved_encoding_t* z_encoding_move(z_owned_encoding_t* x) { return (z_moved_encoding_t*)(x); } @@ -20,7 +17,6 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return (z_moved_fifo_handler_sample_t*)(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return (z_moved_hello_t*)(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return (z_moved_keyexpr_t*)(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return (z_moved_memory_layout_t*)(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return (z_moved_mutex_t*)(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return (z_moved_publisher_t*)(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return (z_moved_query_t*)(x); } @@ -32,36 +28,21 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return (z_moved_ring_handler_sample_t*)(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return (z_moved_sample_t*)(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return (z_moved_session_t*)(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return (z_moved_shm_client_t*)(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return (z_moved_shm_client_storage_t*)(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return (z_moved_shm_t*)(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return (z_moved_shm_mut_t*)(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return (z_moved_shm_provider_t*)(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return (z_moved_slice_t*)(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return (z_moved_source_info_t*)(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return (z_moved_string_array_t*)(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return (z_moved_string_t*)(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return (z_moved_subscriber_t*)(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return (z_moved_task_t*)(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return (zc_moved_closure_log_t*)(x); } -static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return (zc_moved_closure_matching_status_t*)(x); } -static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return (zc_moved_liveliness_token_t*)(x); } -static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return (zc_moved_matching_listener_t*)(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return (zc_moved_shm_client_list_t*)(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return (ze_moved_publication_cache_t*)(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return (ze_moved_querying_subscriber_t*)(x); } #define z_loan(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_loan, \ z_owned_bytes_t : z_bytes_loan, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ z_owned_closure_query_t : z_closure_query_loan, \ z_owned_closure_reply_t : z_closure_reply_loan, \ z_owned_closure_sample_t : z_closure_sample_loan, \ - z_owned_closure_zid_t : z_closure_zid_loan, \ z_owned_condvar_t : z_condvar_loan, \ z_owned_config_t : z_config_loan, \ z_owned_encoding_t : z_encoding_loan, \ @@ -70,7 +51,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan, \ z_owned_hello_t : z_hello_loan, \ z_owned_keyexpr_t : z_keyexpr_loan, \ - z_owned_memory_layout_t : z_memory_layout_loan, \ z_owned_publisher_t : z_publisher_loan, \ z_owned_query_t : z_query_loan, \ z_owned_queryable_t : z_queryable_loan, \ @@ -81,50 +61,55 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_ring_handler_sample_t : z_ring_handler_sample_loan, \ z_owned_sample_t : z_sample_loan, \ z_owned_session_t : z_session_loan, \ - z_owned_shm_client_storage_t : z_shm_client_storage_loan, \ - z_owned_shm_t : z_shm_loan, \ - z_owned_shm_mut_t : z_shm_mut_loan, \ - z_owned_shm_provider_t : z_shm_provider_loan, \ z_owned_slice_t : z_slice_loan, \ - z_owned_source_info_t : z_source_info_loan, \ z_owned_string_array_t : z_string_array_loan, \ z_owned_string_t : z_string_loan, \ z_owned_subscriber_t : z_subscriber_loan, \ z_view_keyexpr_t : z_view_keyexpr_loan, \ z_view_slice_t : z_view_slice_loan, \ z_view_string_t : z_view_string_loan, \ - zc_owned_closure_log_t : zc_closure_log_loan, \ - zc_owned_closure_matching_status_t : zc_closure_matching_status_loan, \ - zc_owned_liveliness_token_t : zc_liveliness_token_loan, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan, \ - ze_owned_publication_cache_t : ze_publication_cache_loan, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_loan \ + zc_owned_closure_log_t : zc_closure_log_loan \ )(&this_) #define z_loan_mut(this_) \ _Generic((this_), \ z_owned_bytes_t : z_bytes_loan_mut, \ + z_owned_closure_hello_t : z_closure_hello_loan_mut, \ + z_owned_closure_query_t : z_closure_query_loan_mut, \ + z_owned_closure_reply_t : z_closure_reply_loan_mut, \ + z_owned_closure_sample_t : z_closure_sample_loan_mut, \ z_owned_condvar_t : z_condvar_loan_mut, \ z_owned_config_t : z_config_loan_mut, \ z_owned_encoding_t : z_encoding_loan_mut, \ + z_owned_fifo_handler_query_t : z_fifo_handler_query_loan_mut, \ + z_owned_fifo_handler_reply_t : z_fifo_handler_reply_loan_mut, \ + z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan_mut, \ + z_owned_hello_t : z_hello_loan_mut, \ + z_owned_keyexpr_t : z_keyexpr_loan_mut, \ z_owned_mutex_t : z_mutex_loan_mut, \ z_owned_publisher_t : z_publisher_loan_mut, \ - z_owned_shm_t : z_shm_loan_mut, \ - z_owned_shm_mut_t : z_shm_mut_loan_mut, \ + z_owned_query_t : z_query_loan_mut, \ + z_owned_queryable_t : z_queryable_loan_mut, \ + z_owned_reply_err_t : z_reply_err_loan_mut, \ + z_owned_reply_t : z_reply_loan_mut, \ + z_owned_ring_handler_query_t : z_ring_handler_query_loan_mut, \ + z_owned_ring_handler_reply_t : z_ring_handler_reply_loan_mut, \ + z_owned_ring_handler_sample_t : z_ring_handler_sample_loan_mut, \ + z_owned_sample_t : z_sample_loan_mut, \ + z_owned_session_t : z_session_loan_mut, \ + z_owned_slice_t : z_slice_loan_mut, \ z_owned_string_array_t : z_string_array_loan_mut, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut \ + z_owned_string_t : z_string_loan_mut, \ + z_owned_subscriber_t : z_subscriber_loan_mut \ )(&this_) #define z_drop(this_) \ _Generic((this_), \ - z_moved_alloc_layout_t* : z_alloc_layout_drop, \ z_moved_bytes_t* : z_bytes_drop, \ - z_moved_chunk_alloc_result_t* : z_chunk_alloc_result_drop, \ z_moved_closure_hello_t* : z_closure_hello_drop, \ z_moved_closure_query_t* : z_closure_query_drop, \ z_moved_closure_reply_t* : z_closure_reply_drop, \ z_moved_closure_sample_t* : z_closure_sample_drop, \ - z_moved_closure_zid_t* : z_closure_zid_drop, \ z_moved_condvar_t* : z_condvar_drop, \ z_moved_config_t* : z_config_drop, \ z_moved_encoding_t* : z_encoding_drop, \ @@ -133,7 +118,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_moved_fifo_handler_sample_t* : z_fifo_handler_sample_drop, \ z_moved_hello_t* : z_hello_drop, \ z_moved_keyexpr_t* : z_keyexpr_drop, \ - z_moved_memory_layout_t* : z_memory_layout_drop, \ z_moved_mutex_t* : z_mutex_drop, \ z_moved_publisher_t* : z_publisher_drop, \ z_moved_query_t* : z_query_drop, \ @@ -145,36 +129,21 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_moved_ring_handler_sample_t* : z_ring_handler_sample_drop, \ z_moved_sample_t* : z_sample_drop, \ z_moved_session_t* : z_session_drop, \ - z_moved_shm_client_t* : z_shm_client_drop, \ - z_moved_shm_client_storage_t* : z_shm_client_storage_drop, \ - z_moved_shm_t* : z_shm_drop, \ - z_moved_shm_mut_t* : z_shm_mut_drop, \ - z_moved_shm_provider_t* : z_shm_provider_drop, \ z_moved_slice_t* : z_slice_drop, \ - z_moved_source_info_t* : z_source_info_drop, \ z_moved_string_array_t* : z_string_array_drop, \ z_moved_string_t* : z_string_drop, \ z_moved_subscriber_t* : z_subscriber_drop, \ z_moved_task_t* : z_task_drop, \ - zc_moved_closure_log_t* : zc_closure_log_drop, \ - zc_moved_closure_matching_status_t* : zc_closure_matching_status_drop, \ - zc_moved_liveliness_token_t* : zc_liveliness_token_drop, \ - zc_moved_matching_listener_t* : zc_publisher_matching_listener_drop, \ - zc_moved_shm_client_list_t* : zc_shm_client_list_drop, \ - ze_moved_publication_cache_t* : ze_publication_cache_drop, \ - ze_moved_querying_subscriber_t* : ze_querying_subscriber_drop \ + zc_moved_closure_log_t* : zc_closure_log_drop \ )(this_) #define z_move(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_move, \ z_owned_bytes_t : z_bytes_move, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_move, \ z_owned_closure_hello_t : z_closure_hello_move, \ z_owned_closure_query_t : z_closure_query_move, \ z_owned_closure_reply_t : z_closure_reply_move, \ z_owned_closure_sample_t : z_closure_sample_move, \ - z_owned_closure_zid_t : z_closure_zid_move, \ z_owned_condvar_t : z_condvar_move, \ z_owned_config_t : z_config_move, \ z_owned_encoding_t : z_encoding_move, \ @@ -183,7 +152,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_fifo_handler_sample_t : z_fifo_handler_sample_move, \ z_owned_hello_t : z_hello_move, \ z_owned_keyexpr_t : z_keyexpr_move, \ - z_owned_memory_layout_t : z_memory_layout_move, \ z_owned_mutex_t : z_mutex_move, \ z_owned_publisher_t : z_publisher_move, \ z_owned_query_t : z_query_move, \ @@ -195,36 +163,21 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_ring_handler_sample_t : z_ring_handler_sample_move, \ z_owned_sample_t : z_sample_move, \ z_owned_session_t : z_session_move, \ - z_owned_shm_client_t : z_shm_client_move, \ - z_owned_shm_client_storage_t : z_shm_client_storage_move, \ - z_owned_shm_t : z_shm_move, \ - z_owned_shm_mut_t : z_shm_mut_move, \ - z_owned_shm_provider_t : z_shm_provider_move, \ z_owned_slice_t : z_slice_move, \ - z_owned_source_info_t : z_source_info_move, \ z_owned_string_array_t : z_string_array_move, \ z_owned_string_t : z_string_move, \ z_owned_subscriber_t : z_subscriber_move, \ z_owned_task_t : z_task_move, \ - zc_owned_closure_log_t : zc_closure_log_move, \ - zc_owned_closure_matching_status_t : zc_closure_matching_status_move, \ - zc_owned_liveliness_token_t : zc_liveliness_token_move, \ - zc_owned_matching_listener_t : zc_publisher_matching_listener_move, \ - zc_owned_shm_client_list_t : zc_shm_client_list_move, \ - ze_owned_publication_cache_t : ze_publication_cache_move, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_move \ + zc_owned_closure_log_t : zc_closure_log_move \ )(&this_) #define z_internal_null(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_internal_alloc_layout_null, \ z_owned_bytes_t* : z_internal_bytes_null, \ - z_owned_chunk_alloc_result_t* : z_internal_chunk_alloc_result_null, \ z_owned_closure_hello_t* : z_internal_closure_hello_null, \ z_owned_closure_query_t* : z_internal_closure_query_null, \ z_owned_closure_reply_t* : z_internal_closure_reply_null, \ z_owned_closure_sample_t* : z_internal_closure_sample_null, \ - z_owned_closure_zid_t* : z_internal_closure_zid_null, \ z_owned_condvar_t* : z_internal_condvar_null, \ z_owned_config_t* : z_internal_config_null, \ z_owned_encoding_t* : z_internal_encoding_null, \ @@ -233,7 +186,6 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_fifo_handler_sample_t* : z_internal_fifo_handler_sample_null, \ z_owned_hello_t* : z_internal_hello_null, \ z_owned_keyexpr_t* : z_internal_keyexpr_null, \ - z_owned_memory_layout_t* : z_internal_memory_layout_null, \ z_owned_mutex_t* : z_internal_mutex_null, \ z_owned_publisher_t* : z_internal_publisher_null, \ z_owned_query_t* : z_internal_query_null, \ @@ -245,34 +197,19 @@ static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_own z_owned_ring_handler_sample_t* : z_internal_ring_handler_sample_null, \ z_owned_sample_t* : z_internal_sample_null, \ z_owned_session_t* : z_internal_session_null, \ - z_owned_shm_client_t* : z_internal_shm_client_null, \ - z_owned_shm_client_storage_t* : z_internal_shm_client_storage_null, \ - z_owned_shm_mut_t* : z_internal_shm_mut_null, \ - z_owned_shm_t* : z_internal_shm_null, \ - z_owned_shm_provider_t* : z_internal_shm_provider_null, \ z_owned_slice_t* : z_internal_slice_null, \ - z_owned_source_info_t* : z_internal_source_info_null, \ z_owned_string_array_t* : z_internal_string_array_null, \ z_owned_string_t* : z_internal_string_null, \ z_owned_subscriber_t* : z_internal_subscriber_null, \ z_owned_task_t* : z_internal_task_null, \ - zc_owned_closure_log_t* : zc_internal_closure_log_null, \ - zc_owned_closure_matching_status_t* : zc_internal_closure_matching_status_null, \ - zc_owned_liveliness_token_t* : zc_internal_liveliness_token_null, \ - zc_owned_matching_listener_t* : zc_internal_matching_listener_null, \ - zc_owned_shm_client_list_t* : zc_internal_shm_client_list_null, \ - ze_owned_publication_cache_t* : ze_internal_publication_cache_null, \ - ze_owned_querying_subscriber_t* : ze_internal_querying_subscriber_null \ + zc_owned_closure_log_t* : zc_internal_closure_log_null \ )(this_) -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } static inline void z_closure_sample_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { *closure_ = x->_this; z_internal_closure_sample_null(&x->_this); } -static inline void z_closure_zid_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { *closure_ = x->_this; z_internal_closure_zid_null(&x->_this); } static inline void z_condvar_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { *this_ = x->_this; z_internal_condvar_null(&x->_this); } static inline void z_config_take(z_owned_config_t* this_, z_moved_config_t* x) { *this_ = x->_this; z_internal_config_null(&x->_this); } static inline void z_encoding_take(z_owned_encoding_t* this_, z_moved_encoding_t* x) { *this_ = x->_this; z_internal_encoding_null(&x->_this); } @@ -281,7 +218,6 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -293,36 +229,21 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } -static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } -static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } #define z_take(this_, x) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_alloc_layout_take, \ z_owned_bytes_t* : z_bytes_take, \ - z_owned_chunk_alloc_result_t* : z_chunk_alloc_result_take, \ z_owned_closure_hello_t* : z_closure_hello_take, \ z_owned_closure_query_t* : z_closure_query_take, \ z_owned_closure_reply_t* : z_closure_reply_take, \ z_owned_closure_sample_t* : z_closure_sample_take, \ - z_owned_closure_zid_t* : z_closure_zid_take, \ z_owned_condvar_t* : z_condvar_take, \ z_owned_config_t* : z_config_take, \ z_owned_encoding_t* : z_encoding_take, \ @@ -331,7 +252,6 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ z_owned_hello_t* : z_hello_take, \ z_owned_keyexpr_t* : z_keyexpr_take, \ - z_owned_memory_layout_t* : z_memory_layout_take, \ z_owned_mutex_t* : z_mutex_take, \ z_owned_publisher_t* : z_publisher_take, \ z_owned_query_t* : z_query_take, \ @@ -343,36 +263,21 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ z_owned_sample_t* : z_sample_take, \ z_owned_session_t* : z_session_take, \ - z_owned_shm_client_t* : z_shm_client_take, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_take, \ - z_owned_shm_t* : z_shm_take, \ - z_owned_shm_mut_t* : z_shm_mut_take, \ - z_owned_shm_provider_t* : z_shm_provider_take, \ z_owned_slice_t* : z_slice_take, \ - z_owned_source_info_t* : z_source_info_take, \ z_owned_string_array_t* : z_string_array_take, \ z_owned_string_t* : z_string_take, \ z_owned_subscriber_t* : z_subscriber_take, \ z_owned_task_t* : z_task_take, \ - zc_owned_closure_log_t* : zc_closure_log_take, \ - zc_owned_closure_matching_status_t* : zc_closure_matching_status_take, \ - zc_owned_liveliness_token_t* : zc_liveliness_token_take, \ - zc_owned_matching_listener_t* : zc_publisher_matching_listener_take, \ - zc_owned_shm_client_list_t* : zc_shm_client_list_take, \ - ze_owned_publication_cache_t* : ze_publication_cache_take, \ - ze_owned_querying_subscriber_t* : ze_querying_subscriber_take \ + zc_owned_closure_log_t* : zc_closure_log_take \ )(this_, x) #define z_internal_check(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_internal_alloc_layout_check, \ z_owned_bytes_t : z_internal_bytes_check, \ - z_owned_chunk_alloc_result_t : z_internal_chunk_alloc_result_check, \ z_owned_closure_hello_t : z_internal_closure_hello_check, \ z_owned_closure_query_t : z_internal_closure_query_check, \ z_owned_closure_reply_t : z_internal_closure_reply_check, \ z_owned_closure_sample_t : z_internal_closure_sample_check, \ - z_owned_closure_zid_t : z_internal_closure_zid_check, \ z_owned_condvar_t : z_internal_condvar_check, \ z_owned_config_t : z_internal_config_check, \ z_owned_encoding_t : z_internal_encoding_check, \ @@ -381,7 +286,6 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_fifo_handler_sample_t : z_internal_fifo_handler_sample_check, \ z_owned_hello_t : z_internal_hello_check, \ z_owned_keyexpr_t : z_internal_keyexpr_check, \ - z_owned_memory_layout_t : z_internal_memory_layout_check, \ z_owned_mutex_t : z_internal_mutex_check, \ z_owned_publisher_t : z_internal_publisher_check, \ z_owned_query_t : z_internal_query_check, \ @@ -393,24 +297,12 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ z_owned_sample_t : z_internal_sample_check, \ z_owned_session_t : z_internal_session_check, \ - z_owned_shm_t : z_internal_shm_check, \ - z_owned_shm_client_t : z_internal_shm_client_check, \ - z_owned_shm_client_storage_t : z_internal_shm_client_storage_check, \ - z_owned_shm_mut_t : z_internal_shm_mut_check, \ - z_owned_shm_provider_t : z_internal_shm_provider_check, \ z_owned_slice_t : z_internal_slice_check, \ - z_owned_source_info_t : z_internal_source_info_check, \ z_owned_string_array_t : z_internal_string_array_check, \ z_owned_string_t : z_internal_string_check, \ z_owned_subscriber_t : z_internal_subscriber_check, \ z_owned_task_t : z_internal_task_check, \ - zc_owned_closure_log_t : zc_internal_closure_log_check, \ - zc_owned_closure_matching_status_t : zc_internal_closure_matching_status_check, \ - zc_owned_liveliness_token_t : zc_internal_liveliness_token_check, \ - zc_owned_matching_listener_t : zc_internal_matching_listener_check, \ - zc_owned_shm_client_list_t : zc_internal_shm_client_list_check, \ - ze_owned_publication_cache_t : ze_internal_publication_cache_check, \ - ze_owned_querying_subscriber_t : ze_internal_querying_subscriber_check \ + zc_owned_closure_log_t : zc_internal_closure_log_check \ )(&this_) #define z_call(closure, hello) \ @@ -418,9 +310,7 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t const z_loaned_closure_hello_t* : z_closure_hello_call, \ const z_loaned_closure_query_t* : z_closure_query_call, \ const z_loaned_closure_reply_t* : z_closure_reply_call, \ - const z_loaned_closure_sample_t* : z_closure_sample_call, \ - const z_loaned_closure_zid_t* : z_closure_zid_call, \ - const zc_loaned_closure_matching_status_t* : zc_closure_matching_status_call \ + const z_loaned_closure_sample_t* : z_closure_sample_call \ )(closure, hello) #define z_closure(this_, call, drop, context) \ @@ -429,9 +319,7 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_closure_query_t* : z_closure_query, \ z_owned_closure_reply_t* : z_closure_reply, \ z_owned_closure_sample_t* : z_closure_sample, \ - z_owned_closure_zid_t* : z_closure_zid, \ - zc_owned_closure_log_t* : zc_closure_log, \ - zc_owned_closure_matching_status_t* : zc_closure_matching_status \ + zc_owned_closure_log_t* : zc_closure_log \ )(this_, call, drop, context) #define z_try_recv(this_, query) \ @@ -465,8 +353,6 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t z_owned_reply_t* : z_reply_clone, \ z_owned_reply_err_t* : z_reply_err_clone, \ z_owned_sample_t* : z_sample_clone, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_clone, \ - z_owned_shm_t* : z_shm_clone, \ z_owned_slice_t* : z_slice_clone, \ z_owned_string_array_t* : z_string_array_clone, \ z_owned_string_t* : z_string_clone \ @@ -474,14 +360,11 @@ static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* t #else // #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return reinterpret_cast(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_sample_t* z_closure_sample_move(z_owned_closure_sample_t* x) { return reinterpret_cast(x); } -static inline z_moved_closure_zid_t* z_closure_zid_move(z_owned_closure_zid_t* x) { return reinterpret_cast(x); } static inline z_moved_condvar_t* z_condvar_move(z_owned_condvar_t* x) { return reinterpret_cast(x); } static inline z_moved_config_t* z_config_move(z_owned_config_t* x) { return reinterpret_cast(x); } static inline z_moved_encoding_t* z_encoding_move(z_owned_encoding_t* x) { return reinterpret_cast(x); } @@ -490,7 +373,6 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return reinterpret_cast(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return reinterpret_cast(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return reinterpret_cast(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return reinterpret_cast(x); } @@ -502,35 +384,20 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return reinterpret_cast(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return reinterpret_cast(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return reinterpret_cast(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return reinterpret_cast(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return reinterpret_cast(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return reinterpret_cast(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return reinterpret_cast(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return reinterpret_cast(x); } -static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return reinterpret_cast(x); } -static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return reinterpret_cast(x); } -static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return reinterpret_cast(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return reinterpret_cast(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return reinterpret_cast(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return reinterpret_cast(x); } -inline const z_loaned_alloc_layout_t* z_loan(const z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan(&this_); }; inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& this_) { return z_bytes_loan(&this_); }; -inline const z_loaned_chunk_alloc_result_t* z_loan(const z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan(&this_); }; inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& closure) { return z_closure_hello_loan(&closure); }; inline const z_loaned_closure_query_t* z_loan(const z_owned_closure_query_t& closure) { return z_closure_query_loan(&closure); }; inline const z_loaned_closure_reply_t* z_loan(const z_owned_closure_reply_t& closure) { return z_closure_reply_loan(&closure); }; inline const z_loaned_closure_sample_t* z_loan(const z_owned_closure_sample_t& closure) { return z_closure_sample_loan(&closure); }; -inline const z_loaned_closure_zid_t* z_loan(const z_owned_closure_zid_t& closure) { return z_closure_zid_loan(&closure); }; inline const z_loaned_condvar_t* z_loan(const z_owned_condvar_t& this_) { return z_condvar_loan(&this_); }; inline const z_loaned_config_t* z_loan(const z_owned_config_t& this_) { return z_config_loan(&this_); }; inline const z_loaned_encoding_t* z_loan(const z_owned_encoding_t& this_) { return z_encoding_loan(&this_); }; @@ -539,7 +406,6 @@ inline const z_loaned_fifo_handler_reply_t* z_loan(const z_owned_fifo_handler_re inline const z_loaned_fifo_handler_sample_t* z_loan(const z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan(&this_); }; inline const z_loaned_hello_t* z_loan(const z_owned_hello_t& this_) { return z_hello_loan(&this_); }; inline const z_loaned_keyexpr_t* z_loan(const z_owned_keyexpr_t& this_) { return z_keyexpr_loan(&this_); }; -inline const z_loaned_memory_layout_t* z_loan(const z_owned_memory_layout_t& this_) { return z_memory_layout_loan(&this_); }; inline const z_loaned_publisher_t* z_loan(const z_owned_publisher_t& this_) { return z_publisher_loan(&this_); }; inline const z_loaned_query_t* z_loan(const z_owned_query_t& this_) { return z_query_loan(&this_); }; inline const z_loaned_queryable_t* z_loan(const z_owned_queryable_t& this_) { return z_queryable_loan(&this_); }; @@ -550,12 +416,7 @@ inline const z_loaned_ring_handler_reply_t* z_loan(const z_owned_ring_handler_re inline const z_loaned_ring_handler_sample_t* z_loan(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan(&this_); }; inline const z_loaned_sample_t* z_loan(const z_owned_sample_t& this_) { return z_sample_loan(&this_); }; inline const z_loaned_session_t* z_loan(const z_owned_session_t& this_) { return z_session_loan(&this_); }; -inline const z_loaned_shm_client_storage_t* z_loan(const z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan(&this_); }; -inline const z_loaned_shm_t* z_loan(const z_owned_shm_t& this_) { return z_shm_loan(&this_); }; -inline const z_loaned_shm_mut_t* z_loan(const z_owned_shm_mut_t& this_) { return z_shm_mut_loan(&this_); }; -inline const z_loaned_shm_provider_t* z_loan(const z_owned_shm_provider_t& this_) { return z_shm_provider_loan(&this_); }; inline const z_loaned_slice_t* z_loan(const z_owned_slice_t& this_) { return z_slice_loan(&this_); }; -inline const z_loaned_source_info_t* z_loan(const z_owned_source_info_t& this_) { return z_source_info_loan(&this_); }; inline const z_loaned_string_array_t* z_loan(const z_owned_string_array_t& this_) { return z_string_array_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_owned_string_t& this_) { return z_string_loan(&this_); }; inline const z_loaned_subscriber_t* z_loan(const z_owned_subscriber_t& this_) { return z_subscriber_loan(&this_); }; @@ -563,33 +424,43 @@ inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& this_) { return inline const z_loaned_slice_t* z_loan(const z_view_slice_t& this_) { return z_view_slice_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_view_string_t& this_) { return z_view_string_loan(&this_); }; inline const zc_loaned_closure_log_t* z_loan(const zc_owned_closure_log_t& closure) { return zc_closure_log_loan(&closure); }; -inline const zc_loaned_closure_matching_status_t* z_loan(const zc_owned_closure_matching_status_t& closure) { return zc_closure_matching_status_loan(&closure); }; -inline const zc_loaned_liveliness_token_t* z_loan(const zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_loan(&this_); }; -inline const zc_loaned_shm_client_list_t* z_loan(const zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan(&this_); }; -inline const ze_loaned_publication_cache_t* z_loan(const ze_owned_publication_cache_t& this_) { return ze_publication_cache_loan(&this_); }; -inline const ze_loaned_querying_subscriber_t* z_loan(const ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_loan(&this_); }; inline z_loaned_bytes_t* z_loan_mut(z_owned_bytes_t& this_) { return z_bytes_loan_mut(&this_); }; +inline z_loaned_closure_hello_t* z_loan_mut(z_owned_closure_hello_t& closure) { return z_closure_hello_loan_mut(&closure); }; +inline z_loaned_closure_query_t* z_loan_mut(z_owned_closure_query_t& closure) { return z_closure_query_loan_mut(&closure); }; +inline z_loaned_closure_reply_t* z_loan_mut(z_owned_closure_reply_t& closure) { return z_closure_reply_loan_mut(&closure); }; +inline z_loaned_closure_sample_t* z_loan_mut(z_owned_closure_sample_t& closure) { return z_closure_sample_loan_mut(&closure); }; inline z_loaned_condvar_t* z_loan_mut(z_owned_condvar_t& this_) { return z_condvar_loan_mut(&this_); }; inline z_loaned_config_t* z_loan_mut(z_owned_config_t& this_) { return z_config_loan_mut(&this_); }; inline z_loaned_encoding_t* z_loan_mut(z_owned_encoding_t& this_) { return z_encoding_loan_mut(&this_); }; +inline z_loaned_fifo_handler_query_t* z_loan_mut(z_owned_fifo_handler_query_t& this_) { return z_fifo_handler_query_loan_mut(&this_); }; +inline z_loaned_fifo_handler_reply_t* z_loan_mut(z_owned_fifo_handler_reply_t& this_) { return z_fifo_handler_reply_loan_mut(&this_); }; +inline z_loaned_fifo_handler_sample_t* z_loan_mut(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan_mut(&this_); }; +inline z_loaned_hello_t* z_loan_mut(z_owned_hello_t& this_) { return z_hello_loan_mut(&this_); }; +inline z_loaned_keyexpr_t* z_loan_mut(z_owned_keyexpr_t& this_) { return z_keyexpr_loan_mut(&this_); }; inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& this_) { return z_mutex_loan_mut(&this_); }; inline z_loaned_publisher_t* z_loan_mut(z_owned_publisher_t& this_) { return z_publisher_loan_mut(&this_); }; -inline z_loaned_shm_t* z_loan_mut(z_owned_shm_t& this_) { return z_shm_loan_mut(&this_); }; -inline z_loaned_shm_mut_t* z_loan_mut(z_owned_shm_mut_t& this_) { return z_shm_mut_loan_mut(&this_); }; +inline z_loaned_query_t* z_loan_mut(z_owned_query_t& this_) { return z_query_loan_mut(&this_); }; +inline z_loaned_queryable_t* z_loan_mut(z_owned_queryable_t& this_) { return z_queryable_loan_mut(&this_); }; +inline z_loaned_reply_err_t* z_loan_mut(z_owned_reply_err_t& this_) { return z_reply_err_loan_mut(&this_); }; +inline z_loaned_reply_t* z_loan_mut(z_owned_reply_t& this_) { return z_reply_loan_mut(&this_); }; +inline z_loaned_ring_handler_query_t* z_loan_mut(z_owned_ring_handler_query_t& this_) { return z_ring_handler_query_loan_mut(&this_); }; +inline z_loaned_ring_handler_reply_t* z_loan_mut(z_owned_ring_handler_reply_t& this_) { return z_ring_handler_reply_loan_mut(&this_); }; +inline z_loaned_ring_handler_sample_t* z_loan_mut(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan_mut(&this_); }; +inline z_loaned_sample_t* z_loan_mut(z_owned_sample_t& this_) { return z_sample_loan_mut(&this_); }; +inline z_loaned_session_t* z_loan_mut(z_owned_session_t& this_) { return z_session_loan_mut(&this_); }; +inline z_loaned_slice_t* z_loan_mut(z_owned_slice_t& this_) { return z_slice_loan_mut(&this_); }; inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { return z_string_array_loan_mut(&this_); }; -inline zc_loaned_shm_client_list_t* z_loan_mut(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan_mut(&this_); }; +inline z_loaned_string_t* z_loan_mut(z_owned_string_t& this_) { return z_string_loan_mut(&this_); }; +inline z_loaned_subscriber_t* z_loan_mut(z_owned_subscriber_t& this_) { return z_subscriber_loan_mut(&this_); }; -inline void z_drop(z_moved_alloc_layout_t* this_) { z_alloc_layout_drop(this_); }; inline void z_drop(z_moved_bytes_t* this_) { z_bytes_drop(this_); }; -inline void z_drop(z_moved_chunk_alloc_result_t* this_) { z_chunk_alloc_result_drop(this_); }; inline void z_drop(z_moved_closure_hello_t* this_) { z_closure_hello_drop(this_); }; inline void z_drop(z_moved_closure_query_t* closure_) { z_closure_query_drop(closure_); }; inline void z_drop(z_moved_closure_reply_t* closure_) { z_closure_reply_drop(closure_); }; inline void z_drop(z_moved_closure_sample_t* closure_) { z_closure_sample_drop(closure_); }; -inline void z_drop(z_moved_closure_zid_t* closure_) { z_closure_zid_drop(closure_); }; inline void z_drop(z_moved_condvar_t* this_) { z_condvar_drop(this_); }; inline void z_drop(z_moved_config_t* this_) { z_config_drop(this_); }; inline void z_drop(z_moved_encoding_t* this_) { z_encoding_drop(this_); }; @@ -598,7 +469,6 @@ inline void z_drop(z_moved_fifo_handler_reply_t* this_) { z_fifo_handler_reply_d inline void z_drop(z_moved_fifo_handler_sample_t* this_) { z_fifo_handler_sample_drop(this_); }; inline void z_drop(z_moved_hello_t* this_) { z_hello_drop(this_); }; inline void z_drop(z_moved_keyexpr_t* this_) { z_keyexpr_drop(this_); }; -inline void z_drop(z_moved_memory_layout_t* this_) { z_memory_layout_drop(this_); }; inline void z_drop(z_moved_mutex_t* this_) { z_mutex_drop(this_); }; inline void z_drop(z_moved_publisher_t* this_) { z_publisher_drop(this_); }; inline void z_drop(z_moved_query_t* this_) { z_query_drop(this_); }; @@ -610,34 +480,19 @@ inline void z_drop(z_moved_ring_handler_reply_t* this_) { z_ring_handler_reply_d inline void z_drop(z_moved_ring_handler_sample_t* this_) { z_ring_handler_sample_drop(this_); }; inline void z_drop(z_moved_sample_t* this_) { z_sample_drop(this_); }; inline void z_drop(z_moved_session_t* this_) { z_session_drop(this_); }; -inline void z_drop(z_moved_shm_client_t* this_) { z_shm_client_drop(this_); }; -inline void z_drop(z_moved_shm_client_storage_t* this_) { z_shm_client_storage_drop(this_); }; -inline void z_drop(z_moved_shm_t* this_) { z_shm_drop(this_); }; -inline void z_drop(z_moved_shm_mut_t* this_) { z_shm_mut_drop(this_); }; -inline void z_drop(z_moved_shm_provider_t* this_) { z_shm_provider_drop(this_); }; inline void z_drop(z_moved_slice_t* this_) { z_slice_drop(this_); }; -inline void z_drop(z_moved_source_info_t* this_) { z_source_info_drop(this_); }; inline void z_drop(z_moved_string_array_t* this_) { z_string_array_drop(this_); }; inline void z_drop(z_moved_string_t* this_) { z_string_drop(this_); }; inline void z_drop(z_moved_subscriber_t* this_) { z_subscriber_drop(this_); }; inline void z_drop(z_moved_task_t* this_) { z_task_drop(this_); }; inline void z_drop(zc_moved_closure_log_t* closure_) { zc_closure_log_drop(closure_); }; -inline void z_drop(zc_moved_closure_matching_status_t* closure_) { zc_closure_matching_status_drop(closure_); }; -inline void z_drop(zc_moved_liveliness_token_t* this_) { zc_liveliness_token_drop(this_); }; -inline void z_drop(zc_moved_matching_listener_t* this_) { zc_publisher_matching_listener_drop(this_); }; -inline void z_drop(zc_moved_shm_client_list_t* this_) { zc_shm_client_list_drop(this_); }; -inline void z_drop(ze_moved_publication_cache_t* this_) { ze_publication_cache_drop(this_); }; -inline void z_drop(ze_moved_querying_subscriber_t* this_) { ze_querying_subscriber_drop(this_); }; -inline z_moved_alloc_layout_t* z_move(z_owned_alloc_layout_t& this_) { return z_alloc_layout_move(&this_); }; inline z_moved_bytes_t* z_move(z_owned_bytes_t& this_) { return z_bytes_move(&this_); }; -inline z_moved_chunk_alloc_result_t* z_move(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_move(&this_); }; inline z_moved_closure_hello_t* z_move(z_owned_closure_hello_t& this_) { return z_closure_hello_move(&this_); }; inline z_moved_closure_query_t* z_move(z_owned_closure_query_t& closure_) { return z_closure_query_move(&closure_); }; inline z_moved_closure_reply_t* z_move(z_owned_closure_reply_t& closure_) { return z_closure_reply_move(&closure_); }; inline z_moved_closure_sample_t* z_move(z_owned_closure_sample_t& closure_) { return z_closure_sample_move(&closure_); }; -inline z_moved_closure_zid_t* z_move(z_owned_closure_zid_t& closure_) { return z_closure_zid_move(&closure_); }; inline z_moved_condvar_t* z_move(z_owned_condvar_t& this_) { return z_condvar_move(&this_); }; inline z_moved_config_t* z_move(z_owned_config_t& this_) { return z_config_move(&this_); }; inline z_moved_encoding_t* z_move(z_owned_encoding_t& this_) { return z_encoding_move(&this_); }; @@ -646,7 +501,6 @@ inline z_moved_fifo_handler_reply_t* z_move(z_owned_fifo_handler_reply_t& this_) inline z_moved_fifo_handler_sample_t* z_move(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_move(&this_); }; inline z_moved_hello_t* z_move(z_owned_hello_t& this_) { return z_hello_move(&this_); }; inline z_moved_keyexpr_t* z_move(z_owned_keyexpr_t& this_) { return z_keyexpr_move(&this_); }; -inline z_moved_memory_layout_t* z_move(z_owned_memory_layout_t& this_) { return z_memory_layout_move(&this_); }; inline z_moved_mutex_t* z_move(z_owned_mutex_t& this_) { return z_mutex_move(&this_); }; inline z_moved_publisher_t* z_move(z_owned_publisher_t& this_) { return z_publisher_move(&this_); }; inline z_moved_query_t* z_move(z_owned_query_t& this_) { return z_query_move(&this_); }; @@ -658,34 +512,19 @@ inline z_moved_ring_handler_reply_t* z_move(z_owned_ring_handler_reply_t& this_) inline z_moved_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_move(&this_); }; inline z_moved_sample_t* z_move(z_owned_sample_t& this_) { return z_sample_move(&this_); }; inline z_moved_session_t* z_move(z_owned_session_t& this_) { return z_session_move(&this_); }; -inline z_moved_shm_client_t* z_move(z_owned_shm_client_t& this_) { return z_shm_client_move(&this_); }; -inline z_moved_shm_client_storage_t* z_move(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_move(&this_); }; -inline z_moved_shm_t* z_move(z_owned_shm_t& this_) { return z_shm_move(&this_); }; -inline z_moved_shm_mut_t* z_move(z_owned_shm_mut_t& this_) { return z_shm_mut_move(&this_); }; -inline z_moved_shm_provider_t* z_move(z_owned_shm_provider_t& this_) { return z_shm_provider_move(&this_); }; inline z_moved_slice_t* z_move(z_owned_slice_t& this_) { return z_slice_move(&this_); }; -inline z_moved_source_info_t* z_move(z_owned_source_info_t& this_) { return z_source_info_move(&this_); }; inline z_moved_string_array_t* z_move(z_owned_string_array_t& this_) { return z_string_array_move(&this_); }; inline z_moved_string_t* z_move(z_owned_string_t& this_) { return z_string_move(&this_); }; inline z_moved_subscriber_t* z_move(z_owned_subscriber_t& this_) { return z_subscriber_move(&this_); }; inline z_moved_task_t* z_move(z_owned_task_t& this_) { return z_task_move(&this_); }; inline zc_moved_closure_log_t* z_move(zc_owned_closure_log_t& closure_) { return zc_closure_log_move(&closure_); }; -inline zc_moved_closure_matching_status_t* z_move(zc_owned_closure_matching_status_t& closure_) { return zc_closure_matching_status_move(&closure_); }; -inline zc_moved_liveliness_token_t* z_move(zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_move(&this_); }; -inline zc_moved_matching_listener_t* z_move(zc_owned_matching_listener_t& this_) { return zc_publisher_matching_listener_move(&this_); }; -inline zc_moved_shm_client_list_t* z_move(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_move(&this_); }; -inline ze_moved_publication_cache_t* z_move(ze_owned_publication_cache_t& this_) { return ze_publication_cache_move(&this_); }; -inline ze_moved_querying_subscriber_t* z_move(ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_move(&this_); }; -inline void z_internal_null(z_owned_alloc_layout_t* this_) { z_internal_alloc_layout_null(this_); }; inline void z_internal_null(z_owned_bytes_t* this_) { z_internal_bytes_null(this_); }; -inline void z_internal_null(z_owned_chunk_alloc_result_t* this_) { z_internal_chunk_alloc_result_null(this_); }; inline void z_internal_null(z_owned_closure_hello_t* this_) { z_internal_closure_hello_null(this_); }; inline void z_internal_null(z_owned_closure_query_t* this_) { z_internal_closure_query_null(this_); }; inline void z_internal_null(z_owned_closure_reply_t* this_) { z_internal_closure_reply_null(this_); }; inline void z_internal_null(z_owned_closure_sample_t* this_) { z_internal_closure_sample_null(this_); }; -inline void z_internal_null(z_owned_closure_zid_t* this_) { z_internal_closure_zid_null(this_); }; inline void z_internal_null(z_owned_condvar_t* this_) { z_internal_condvar_null(this_); }; inline void z_internal_null(z_owned_config_t* this_) { z_internal_config_null(this_); }; inline void z_internal_null(z_owned_encoding_t* this_) { z_internal_encoding_null(this_); }; @@ -694,7 +533,6 @@ inline void z_internal_null(z_owned_fifo_handler_reply_t* this_) { z_internal_fi inline void z_internal_null(z_owned_fifo_handler_sample_t* this_) { z_internal_fifo_handler_sample_null(this_); }; inline void z_internal_null(z_owned_hello_t* this_) { z_internal_hello_null(this_); }; inline void z_internal_null(z_owned_keyexpr_t* this_) { z_internal_keyexpr_null(this_); }; -inline void z_internal_null(z_owned_memory_layout_t* this_) { z_internal_memory_layout_null(this_); }; inline void z_internal_null(z_owned_mutex_t* this_) { z_internal_mutex_null(this_); }; inline void z_internal_null(z_owned_publisher_t* this_) { z_internal_publisher_null(this_); }; inline void z_internal_null(z_owned_query_t* this_) { z_internal_query_null(this_); }; @@ -706,33 +544,18 @@ inline void z_internal_null(z_owned_ring_handler_reply_t* this_) { z_internal_ri inline void z_internal_null(z_owned_ring_handler_sample_t* this_) { z_internal_ring_handler_sample_null(this_); }; inline void z_internal_null(z_owned_sample_t* this_) { z_internal_sample_null(this_); }; inline void z_internal_null(z_owned_session_t* this_) { z_internal_session_null(this_); }; -inline void z_internal_null(z_owned_shm_client_t* this_) { z_internal_shm_client_null(this_); }; -inline void z_internal_null(z_owned_shm_client_storage_t* this_) { z_internal_shm_client_storage_null(this_); }; -inline void z_internal_null(z_owned_shm_mut_t* this_) { z_internal_shm_mut_null(this_); }; -inline void z_internal_null(z_owned_shm_t* this_) { z_internal_shm_null(this_); }; -inline void z_internal_null(z_owned_shm_provider_t* this_) { z_internal_shm_provider_null(this_); }; inline void z_internal_null(z_owned_slice_t* this_) { z_internal_slice_null(this_); }; -inline void z_internal_null(z_owned_source_info_t* this_) { z_internal_source_info_null(this_); }; inline void z_internal_null(z_owned_string_array_t* this_) { z_internal_string_array_null(this_); }; inline void z_internal_null(z_owned_string_t* this_) { z_internal_string_null(this_); }; inline void z_internal_null(z_owned_subscriber_t* this_) { z_internal_subscriber_null(this_); }; inline void z_internal_null(z_owned_task_t* this_) { z_internal_task_null(this_); }; inline void z_internal_null(zc_owned_closure_log_t* this_) { zc_internal_closure_log_null(this_); }; -inline void z_internal_null(zc_owned_closure_matching_status_t* this_) { zc_internal_closure_matching_status_null(this_); }; -inline void z_internal_null(zc_owned_liveliness_token_t* this_) { zc_internal_liveliness_token_null(this_); }; -inline void z_internal_null(zc_owned_matching_listener_t* this_) { zc_internal_matching_listener_null(this_); }; -inline void z_internal_null(zc_owned_shm_client_list_t* this_) { zc_internal_shm_client_list_null(this_); }; -inline void z_internal_null(ze_owned_publication_cache_t* this_) { ze_internal_publication_cache_null(this_); }; -inline void z_internal_null(ze_owned_querying_subscriber_t* this_) { ze_internal_querying_subscriber_null(this_); }; -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } static inline void z_closure_sample_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { *closure_ = x->_this; z_internal_closure_sample_null(&x->_this); } -static inline void z_closure_zid_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { *closure_ = x->_this; z_internal_closure_zid_null(&x->_this); } static inline void z_condvar_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { *this_ = x->_this; z_internal_condvar_null(&x->_this); } static inline void z_config_take(z_owned_config_t* this_, z_moved_config_t* x) { *this_ = x->_this; z_internal_config_null(&x->_this); } static inline void z_encoding_take(z_owned_encoding_t* this_, z_moved_encoding_t* x) { *this_ = x->_this; z_internal_encoding_null(&x->_this); } @@ -741,7 +564,6 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -753,36 +575,18 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } -static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } -static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } -inline void z_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { - z_alloc_layout_take(this_, x); -}; inline void z_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { z_bytes_take(this_, x); }; -inline void z_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { - z_chunk_alloc_result_take(this_, x); -}; inline void z_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { z_closure_hello_take(this_, x); }; @@ -795,9 +599,6 @@ inline void z_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x inline void z_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { z_closure_sample_take(closure_, x); }; -inline void z_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { - z_closure_zid_take(closure_, x); -}; inline void z_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { z_condvar_take(this_, x); }; @@ -822,9 +623,6 @@ inline void z_take(z_owned_hello_t* this_, z_moved_hello_t* x) { inline void z_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { z_keyexpr_take(this_, x); }; -inline void z_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { - z_memory_layout_take(this_, x); -}; inline void z_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { z_mutex_take(this_, x); }; @@ -858,27 +656,9 @@ inline void z_take(z_owned_sample_t* this_, z_moved_sample_t* x) { inline void z_take(z_owned_session_t* this_, z_moved_session_t* x) { z_session_take(this_, x); }; -inline void z_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { - z_shm_client_take(this_, x); -}; -inline void z_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { - z_shm_client_storage_take(this_, x); -}; -inline void z_take(z_owned_shm_t* this_, z_moved_shm_t* x) { - z_shm_take(this_, x); -}; -inline void z_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { - z_shm_mut_take(this_, x); -}; -inline void z_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { - z_shm_provider_take(this_, x); -}; inline void z_take(z_owned_slice_t* this_, z_moved_slice_t* x) { z_slice_take(this_, x); }; -inline void z_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { - z_source_info_take(this_, x); -}; inline void z_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { z_string_array_take(this_, x); }; @@ -894,34 +674,13 @@ inline void z_take(z_owned_task_t* this_, z_moved_task_t* x) { inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { zc_closure_log_take(closure_, x); }; -inline void z_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { - zc_closure_matching_status_take(closure_, x); -}; -inline void z_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { - zc_liveliness_token_take(this_, x); -}; -inline void z_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { - zc_publisher_matching_listener_take(this_, x); -}; -inline void z_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { - zc_shm_client_list_take(this_, x); -}; -inline void z_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { - ze_publication_cache_take(this_, x); -}; -inline void z_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { - ze_querying_subscriber_take(this_, x); -}; -inline bool z_internal_check(const z_owned_alloc_layout_t& this_) { return z_internal_alloc_layout_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; -inline bool z_internal_check(const z_owned_chunk_alloc_result_t& this_) { return z_internal_chunk_alloc_result_check(&this_); }; inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; inline bool z_internal_check(const z_owned_closure_reply_t& this_) { return z_internal_closure_reply_check(&this_); }; inline bool z_internal_check(const z_owned_closure_sample_t& this_) { return z_internal_closure_sample_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_zid_t& this_) { return z_internal_closure_zid_check(&this_); }; inline bool z_internal_check(const z_owned_condvar_t& this_) { return z_internal_condvar_check(&this_); }; inline bool z_internal_check(const z_owned_config_t& this_) { return z_internal_config_check(&this_); }; inline bool z_internal_check(const z_owned_encoding_t& this_) { return z_internal_encoding_check(&this_); }; @@ -930,7 +689,6 @@ inline bool z_internal_check(const z_owned_fifo_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_fifo_handler_sample_t& this_) { return z_internal_fifo_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_hello_check(&this_); }; inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; -inline bool z_internal_check(const z_owned_memory_layout_t& this_) { return z_internal_memory_layout_check(&this_); }; inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; @@ -942,24 +700,12 @@ inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_t& this_) { return z_internal_shm_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_t& this_) { return z_internal_shm_client_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_storage_t& this_) { return z_internal_shm_client_storage_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_mut_t& this_) { return z_internal_shm_mut_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_provider_t& this_) { return z_internal_shm_provider_check(&this_); }; inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; -inline bool z_internal_check(const z_owned_source_info_t& this_) { return z_internal_source_info_check(&this_); }; inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; -inline bool z_internal_check(const zc_owned_closure_matching_status_t& this_) { return zc_internal_closure_matching_status_check(&this_); }; -inline bool z_internal_check(const zc_owned_liveliness_token_t& this_) { return zc_internal_liveliness_token_check(&this_); }; -inline bool z_internal_check(const zc_owned_matching_listener_t& this_) { return zc_internal_matching_listener_check(&this_); }; -inline bool z_internal_check(const zc_owned_shm_client_list_t& this_) { return zc_internal_shm_client_list_check(&this_); }; -inline bool z_internal_check(const ze_owned_publication_cache_t& this_) { return ze_internal_publication_cache_check(&this_); }; -inline bool z_internal_check(const ze_owned_querying_subscriber_t& this_) { return ze_internal_querying_subscriber_check(&this_); }; inline void z_call(const z_loaned_closure_hello_t* closure, z_loaned_hello_t* hello) { @@ -974,21 +720,13 @@ inline void z_call(const z_loaned_closure_reply_t* closure, z_loaned_reply_t* re inline void z_call(const z_loaned_closure_sample_t* closure, z_loaned_sample_t* sample) { z_closure_sample_call(closure, sample); }; -inline void z_call(const z_loaned_closure_zid_t* closure, const z_id_t* z_id) { - z_closure_zid_call(closure, z_id); -}; -inline void z_call(const zc_loaned_closure_matching_status_t* closure, const zc_matching_status_t* mathing_status) { - zc_closure_matching_status_call(closure, mathing_status); -}; extern "C" using z_closure_drop_callback_t = void(void* context); extern "C" using z_closure_hello_callabck_t = void(z_loaned_hello_t *hello, void *context); extern "C" using z_closure_query_callabck_t = void(z_loaned_query_t *query, void *context); extern "C" using z_closure_reply_callabck_t = void(z_loaned_reply_t *reply, void *context); extern "C" using z_closure_sample_callabck_t = void(z_loaned_sample_t *sample, void *context); -extern "C" using z_closure_zid_callabck_t = void(const z_id_t *z_id, void *context); extern "C" using zc_closure_log_callabck_t = void(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); -extern "C" using zc_closure_matching_status_callabck_t = void(const zc_matching_status_t *matching_status, void *context); inline void z_closure(z_owned_closure_hello_t* this_, z_closure_hello_callabck_t* call, z_closure_drop_callback_t* drop, void* context) { @@ -1006,18 +744,10 @@ inline void z_closure(z_owned_closure_sample_t* this_, z_closure_sample_callabck z_closure_drop_callback_t* drop, void* context) { z_closure_sample(this_, call, drop, context); }; -inline void z_closure(z_owned_closure_zid_t* this_, z_closure_zid_callabck_t* call, - z_closure_drop_callback_t* drop, void* context) { - z_closure_zid(this_, call, drop, context); -}; inline void z_closure(zc_owned_closure_log_t* this_, zc_closure_log_callabck_t* call, z_closure_drop_callback_t* drop, void* context) { zc_closure_log(this_, call, drop, context); }; -inline void z_closure(zc_owned_closure_matching_status_t* this_, zc_closure_matching_status_callabck_t* call, - z_closure_drop_callback_t* drop, void* context) { - zc_closure_matching_status(this_, call, drop, context); -}; inline z_result_t z_try_recv(const z_loaned_fifo_handler_query_t* this_, z_owned_query_t* query) { @@ -1087,12 +817,6 @@ inline void z_clone(z_owned_reply_err_t* dst, z_loaned_reply_err_t* this_) { inline void z_clone(z_owned_sample_t* dst, z_loaned_sample_t* this_) { z_sample_clone(dst, this_); }; -inline void z_clone(z_owned_shm_client_storage_t* this_, z_loaned_shm_client_storage_t* from) { - z_shm_client_storage_clone(this_, from); -}; -inline void z_clone(z_owned_shm_t* out, z_loaned_shm_t* this_) { - z_shm_clone(out, this_); -}; inline void z_clone(z_owned_slice_t* dst, z_loaned_slice_t* this_) { z_slice_clone(dst, this_); }; @@ -1105,12 +829,8 @@ inline void z_clone(z_owned_string_t* dst, z_loaned_string_t* this_) { template struct z_loaned_to_owned_type_t {}; template struct z_owned_to_loaned_type_t {}; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_alloc_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_alloc_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_chunk_alloc_result_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_chunk_alloc_result_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_hello_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_query_t type; }; @@ -1119,8 +839,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_reply_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_sample_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_sample_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_zid_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_zid_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_condvar_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_condvar_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_config_t type; }; @@ -1137,8 +855,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_h template<> struct z_owned_to_loaned_type_t { typedef z_loaned_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_keyexpr_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_keyexpr_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_memory_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_memory_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_publisher_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_publisher_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_query_t type; }; @@ -1159,18 +875,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_sample_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_session_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_session_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_client_storage_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_client_storage_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_mut_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_mut_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_provider_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_provider_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_slice_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_slice_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_source_info_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_source_info_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_array_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_string_array_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_t type; }; @@ -1179,16 +885,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_ow template<> struct z_owned_to_loaned_type_t { typedef z_loaned_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_log_t type; }; template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_log_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_matching_status_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_matching_status_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_liveliness_token_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_liveliness_token_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_shm_client_list_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_shm_client_list_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_publication_cache_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_publication_cache_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_querying_subscriber_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_querying_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_mutex_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_mutex_t type; }; #endif // #ifndef __cplusplus diff --git a/src/closures/hello_closure.rs b/src/closures/hello_closure.rs index 016e81275..33161d001 100644 --- a/src/closures/hello_closure.rs +++ b/src/closures/hello_closure.rs @@ -143,6 +143,14 @@ pub extern "C" fn z_closure_hello_loan( closure.as_loaned_c_type_ref() } +/// Mutably borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_hello_loan_mut( + closure: &mut z_owned_closure_hello_t, +) -> &mut z_loaned_closure_hello_t { + closure.as_loaned_c_type_mut() +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index d9de76f88..ece303634 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -103,6 +103,18 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan( .as_loaned_c_type_ref() } +/// Borrows handler. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_fifo_handler_query_loan_mut( + this: &mut z_owned_fifo_handler_query_t, +) -> &mut z_loaned_fifo_handler_query_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -211,6 +223,18 @@ pub unsafe extern "C" fn z_ring_handler_query_loan( .as_loaned_c_type_ref() } +/// Borrows handler. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_ring_handler_query_loan_mut( + this: &mut z_owned_ring_handler_query_t, +) -> &mut z_loaned_ring_handler_query_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state). diff --git a/src/closures/query_closure.rs b/src/closures/query_closure.rs index 35e355c35..09b9ece82 100644 --- a/src/closures/query_closure.rs +++ b/src/closures/query_closure.rs @@ -142,6 +142,14 @@ pub extern "C" fn z_closure_query_loan( closure.as_loaned_c_type_ref() } +/// Mutably borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_query_loan_mut( + closure: &mut z_owned_closure_query_t, +) -> &mut z_loaned_closure_query_t { + closure.as_loaned_c_type_mut() +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/reply_closure.rs b/src/closures/reply_closure.rs index 1fd5908d6..149d7b754 100644 --- a/src/closures/reply_closure.rs +++ b/src/closures/reply_closure.rs @@ -145,6 +145,14 @@ pub extern "C" fn z_closure_reply_loan( closure.as_loaned_c_type_ref() } +/// Mutably borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_reply_loan_mut( + closure: &mut z_owned_closure_reply_t, +) -> &mut z_loaned_closure_reply_t { + closure.as_loaned_c_type_mut() +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index abff70dc6..6c9d83d37 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -103,6 +103,19 @@ pub unsafe extern "C" fn z_fifo_handler_reply_loan( .as_loaned_c_type_ref() } +/// Mutably borrows handler. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_fifo_handler_reply_loan_mut( + this: &mut z_owned_fifo_handler_reply_t, +) -> &mut z_loaned_fifo_handler_reply_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + + /// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). @@ -207,6 +220,18 @@ pub unsafe extern "C" fn z_ring_handler_reply_loan( .as_loaned_c_type_ref() } +/// Mutably borrows handler. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_ring_handler_reply_loan_mut( + this: &mut z_owned_ring_handler_reply_t, +) -> &mut z_loaned_ring_handler_reply_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 492e4cb7e..2742ef899 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -103,6 +103,18 @@ pub unsafe extern "C" fn z_fifo_handler_sample_loan( .as_loaned_c_type_ref() } +/// Mutably borrows handler. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_fifo_handler_sample_loan_mut( + this: &mut z_owned_fifo_handler_sample_t, +) -> &mut z_loaned_fifo_handler_sample_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more samples to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). @@ -211,6 +223,18 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan( .as_loaned_c_type_ref() } +/// Borrows handler. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_ring_handler_sample_loan_mut( + this: &mut z_owned_ring_handler_sample_t, +) -> &mut z_loaned_ring_handler_sample_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more replies to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). diff --git a/src/closures/sample_closure.rs b/src/closures/sample_closure.rs index 4fed39c36..07e0ec53e 100644 --- a/src/closures/sample_closure.rs +++ b/src/closures/sample_closure.rs @@ -144,6 +144,14 @@ pub extern "C" fn z_closure_sample_loan( closure.as_loaned_c_type_ref() } +/// Borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_sample_loan_mut( + closure: &mut z_owned_closure_sample_t, +) -> &mut z_loaned_closure_sample_t { + closure.as_loaned_c_type_mut() +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index ee7565873..1c5629613 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -146,6 +146,12 @@ impl From for z_owned_closure_zid_t { pub extern "C" fn z_closure_zid_loan(closure: &z_owned_closure_zid_t) -> &z_loaned_closure_zid_t { closure.as_loaned_c_type_ref() } +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_zid_loan_mut(closure: &mut z_owned_closure_zid_t) -> &mut z_loaned_closure_zid_t { + closure.as_loaned_c_type_mut() +} /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. diff --git a/src/collections.rs b/src/collections.rs index 624dfb55b..568027d97 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -339,6 +339,12 @@ pub extern "C" fn z_slice_loan(this_: &z_owned_slice_t) -> &z_loaned_slice_t { this_.as_rust_type_ref().as_loaned_c_type_ref() } +/// Mutably borrows slice. +#[no_mangle] +pub extern "C" fn z_slice_loan_mut(this_: &mut z_owned_slice_t) -> &mut z_loaned_slice_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() +} + /// Constructs an owned copy of a slice. #[no_mangle] pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: &z_loaned_slice_t) { @@ -483,6 +489,12 @@ impl Deref for CStringOwned { } } +impl DerefMut for CStringOwned { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + impl Deref for CStringView { type Target = CString; fn deref(&self) -> &Self::Target { @@ -584,6 +596,12 @@ pub extern "C" fn z_string_loan(this_: &z_owned_string_t) -> &z_loaned_string_t this_.as_rust_type_ref().as_loaned_c_type_ref() } +/// Mutably borrows string. +#[no_mangle] +pub extern "C" fn z_string_loan_mut(this_: &mut z_owned_string_t) -> &mut z_loaned_string_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() +} + /// Borrows view string. #[no_mangle] pub extern "C" fn z_view_string_loan(this_: &z_view_string_t) -> &z_loaned_string_t { diff --git a/src/commons.rs b/src/commons.rs index 9009609bb..d6372887a 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -214,6 +214,17 @@ pub unsafe extern "C" fn z_sample_loan(this_: &z_owned_sample_t) -> &z_loaned_sa .as_loaned_c_type_ref() } +/// Mutably borrows sample. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loaned_sample_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Frees the memory and invalidates the sample, resetting it to a gravestone state. #[no_mangle] pub extern "C" fn z_sample_drop(this_: &mut z_moved_sample_t) { @@ -600,6 +611,13 @@ pub extern "C" fn z_source_info_loan(this_: &z_owned_source_info_t) -> &z_loaned this_.as_rust_type_ref().as_loaned_c_type_ref() } +#[cfg(feature = "unstable")] +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Borrows source info. +#[no_mangle] +pub extern "C" fn z_source_info_loan_mut(this_: &z_owned_source_info_t) -> &z_loaned_source_info_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() +} #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. diff --git a/src/get.rs b/src/get.rs index 2069e1af4..ad99354e3 100644 --- a/src/get.rs +++ b/src/get.rs @@ -71,6 +71,12 @@ pub extern "C" fn z_reply_err_loan(this_: &z_owned_reply_err_t) -> &z_loaned_rep this_.as_rust_type_ref().as_loaned_c_type_ref() } +/// Mutably borrows reply error. +#[no_mangle] +pub extern "C" fn z_reply_err_loan_mut(this_: &mut z_owned_reply_err_t) -> &mut z_loaned_reply_err_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() +} + /// Frees the memory and resets the reply error it to its default value. #[no_mangle] pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { @@ -309,6 +315,17 @@ pub unsafe extern "C" fn z_reply_loan(this_: &z_owned_reply_t) -> &z_loaned_repl .as_loaned_c_type_ref() } +/// Mutably borrows reply. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned_reply_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// The replies consolidation strategy to apply on replies to a `z_get()`. #[repr(C)] #[derive(Clone, Copy)] diff --git a/src/keyexpr.rs b/src/keyexpr.rs index ba86a5b00..6b65a646c 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -134,6 +134,17 @@ pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_ .as_loaned_c_type_ref() } +/// Mutably borrows `z_owned_keyexpr_t`. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_keyexpr_loan_mut(this_: &mut z_owned_keyexpr_t) -> &mut z_loaned_keyexpr_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Borrows `z_view_keyexpr_t`. #[no_mangle] #[allow(clippy::missing_safety_doc)] diff --git a/src/queryable.rs b/src/queryable.rs index dc934e2d1..c29bfe3fe 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -55,6 +55,17 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa .as_loaned_c_type_ref() } +// Mutably borrows Queryable +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_queryable_loan_mut(this_: &mut z_owned_queryable_t) -> &mut z_loaned_queryable_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; decl_c_type!( owned(z_owned_query_t, option Query), @@ -74,13 +85,25 @@ pub extern "C" fn z_internal_query_check(query: &z_owned_query_t) -> bool { /// Borrows the query. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_query_loan(this_: &'static z_owned_query_t) -> &z_loaned_query_t { +pub unsafe extern "C" fn z_query_loan(this_: &z_owned_query_t) -> &z_loaned_query_t { this_ .as_rust_type_ref() .as_ref() .unwrap_unchecked() .as_loaned_c_type_ref() } + +/// Mutably borrows the query. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_query_loan_mut(this_: &mut z_owned_query_t) -> &mut z_loaned_query_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Destroys the query resetting it to its gravestone value. #[no_mangle] pub extern "C" fn z_query_drop(this_: &mut z_moved_query_t) { diff --git a/src/scouting.rs b/src/scouting.rs index 4b9dca2bf..421e86955 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -51,6 +51,18 @@ pub unsafe extern "C" fn z_hello_loan(this_: &z_owned_hello_t) -> &z_loaned_hell .as_loaned_c_type_ref() } +/// Borrows hello message. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap() + .as_loaned_c_type_mut() +} + + /// Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. #[no_mangle] pub extern "C" fn z_internal_hello_check(this_: &z_owned_hello_t) -> bool { diff --git a/src/session.rs b/src/session.rs index b64ff9b09..e9fd5ff6e 100644 --- a/src/session.rs +++ b/src/session.rs @@ -40,6 +40,17 @@ pub unsafe extern "C" fn z_session_loan(this_: &z_owned_session_t) -> &z_loaned_ .as_loaned_c_type_ref() } +/// Mutably borrows session. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_session_loan_mut(this_: &mut z_owned_session_t) -> &mut z_loaned_session_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Constructs a Zenoh session in its gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index bf9584854..fc166421f 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -198,3 +198,16 @@ pub unsafe extern "C" fn z_shm_client_storage_loan( .unwrap_unchecked() .as_loaned_c_type_ref() } + +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Mutably borrows SHM Client Storage. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_shm_client_storage_loan_mut( + this: &mut z_owned_shm_client_storage_t, +) -> &mut z_loaned_shm_client_storage_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index e141d7776..f93935291 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -86,6 +86,18 @@ pub unsafe extern "C" fn z_alloc_layout_loan( .as_loaned_c_type_ref() } +/// Mutably borrows Alloc Layout +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_alloc_layout_loan_mut( + this: &mut z_owned_alloc_layout_t, +) -> &mut z_loaned_alloc_layout_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Deletes Alloc Layout #[no_mangle] pub extern "C" fn z_alloc_layout_drop(this_: &mut z_moved_alloc_layout_t) { diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 45b354f93..af608162b 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -122,6 +122,19 @@ pub unsafe extern "C" fn z_shm_provider_loan( .as_loaned_c_type_ref() } +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Mutably borrows SHM Provider. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_shm_provider_loan_mut( + this: &mut z_owned_shm_provider_t, +) -> &mut z_loaned_shm_provider_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes SHM Provider. #[no_mangle] diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index 59a1b2ec2..92cb6337b 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -172,6 +172,19 @@ pub unsafe extern "C" fn z_memory_layout_loan( .as_loaned_c_type_ref() } +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Mutably borrows Memory Layout. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_memory_layout_loan_mut( + this: &mut z_owned_memory_layout_t, +) -> &mut z_loaned_memory_layout_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes Memory Layout. #[no_mangle] @@ -255,6 +268,19 @@ pub unsafe extern "C" fn z_chunk_alloc_result_loan( .as_loaned_c_type_ref() } +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Mutably borrows Chunk Alloc Result. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_chunk_alloc_result_loan_mut( + this: &mut z_owned_chunk_alloc_result_t, +) -> &mut z_loaned_chunk_alloc_result_t { + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes Chunk Alloc Result. #[no_mangle] diff --git a/src/subscriber.rs b/src/subscriber.rs index 6cf5bb401..ad062253d 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -45,6 +45,17 @@ pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_l .as_loaned_c_type_ref() } +/// Mutably borrows subscriber. +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_subscriber_loan_mut(this_: &mut z_owned_subscriber_t) -> &mut z_loaned_subscriber_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() +} + /// Options passed to the `z_declare_subscriber()` function. #[allow(non_camel_case_types)] #[repr(C)] From 0e02579b78c37a7a23b37fc49153f94a896c083c Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 24 Sep 2024 18:28:28 +0400 Subject: [PATCH 05/38] move, loan, etc operations documented --- docs/concepts.rst | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/docs/concepts.rst b/docs/concepts.rst index ec5c3c747..0b8436177 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -147,6 +147,79 @@ Examples include `z_timestamp_t`, `z_priority_t`, etc. z_timestamp_new(&ts, z_loan(session)); z_timestamp_t ts1 = ts; +Common operations +================= + +The transition between "owned", "loaned" and "moved" structures above is performed by corresponding functions. +The following operations are available: move, loan, mutable loan, take, check, and drop. They are performed for +"xxx" entity by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take_moved`, `z_xxx_take_loaned`, +`z_xxx_check`, and `z_xxx_drop`. +The generic macros `z_move`, `z_loan`, `z_loan_mut`, `z_take`, `z_check`, and `z_drop` are also provided. + +Loan operation +-------------- + +Function `z_xxx_loan` accepts `const z_owned_xxx_t*` and returns pointer `const z_loaned_xxx_t*` which gives read only +access to `z_owned_xxx_t` entity. + +`z_loan` macro accepts variable of `z_owned_xxx_t` type and calls corresponding `z_xxx_loan` function. + +Mutable loan operation +---------------------- + +Function `z_xxx_loan_mut` accepts `z_owned_xxx_t*` and +returns pointer `z_xxx_loaned_t*` which allows to +read and modify `z_owned_xxx_t` entity and if supported by the type take ownership on it (see "take" operation) + +`z_loan_mut` macro accepts variable of `z_owned_xxx_t` type and calls corresponding `z_xxx_loan_mut` function. + +Move operation +-------------- + +Function `z_xxx_move` accepts `z_owned_xxx_t*` and +returns pointer `z_moved_xxx_t*` which only allows to take +ownership of `z_owned_xxx_t`. The agreement is that the function which accepts `z_moved_xxx_t*` parameter +is obliged to take ownership on it (see "take" operation) + +`z_move` macro accepts varible of `z_owned_xxx_t` type anc calls corresponding `z_move_xxx` function + +Take operation +-------------- + +Functions `z_xxx_take_moved` and `z_xxx_take_loaned` accepts pointer +to unitialized `z_owned_xxx_t` destination structure and + `z_moved_xxx_t*` and `z_loaned_xxx_t*` source pointers correspondingly. + +These functions moves data from source `z_owned_xxx_t` structure into destination one. The source +structure is set to empty "gravestone" state (see "check" operation) + +`z_take` macro accepts `z_moved_xxx_t*` and `z_loaned_xxx_t*` pointers and calls corresponding +`z_xxx_take_moved` and `z_xxx_take_loaned` functions. + +Check operation +--------------- + +When owned object is dropped or taken it's set to so-called "gravestone" state which is safe to +double drop. No operations except "check" and "drop" are normally allowed on dropped/taken object. + +Function `z_xxx_check` returns true if object is in valid state, e.g. if all operations +on the object are allowed. + +There is small catch: for some objects the gravestone state is still valid state. +Examples are `z_owned_bytes_t` which is set to "empty" state by the drop and `z_owned_encoding_t` +which becomes `ZENOH_BYTES`. For such objects the `z_check` always returns true, even after "drop" or "take" +operation. + +`z_check` macro accepts `const z_owned_xxx_t*` and calls corresponding `z_xxx_check` function + +Drop operation +-------------- + +Function `z_xxx_drop` accepts `z_moved_xxx_t*` pointer. It frees all resources hold by corresponding +`z_owned_xxx_t` object and sets this object to gravestone state, safe to double drop. + +`z_drop` macro accepts `z_moved_xxx_t*` and calls corresponding `z_xxx_drop` function + Name Prefixes `z_`, `zc_`, `ze_` ================================ From 8a229e4d2474663bf86b90ceb9256387c0c82556 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 27 Sep 2024 13:51:19 +0200 Subject: [PATCH 06/38] take functions added --- include/zenoh_commons.h | 836 ++++++++++++++++--------------- include/zenoh_macros.h | 376 +++++++++++++- src/closures/hello_closure.rs | 11 +- src/closures/query_channel.rs | 24 +- src/closures/query_closure.rs | 11 +- src/closures/reply_closure.rs | 11 +- src/closures/response_channel.rs | 23 +- src/closures/sample_channel.rs | 24 +- src/closures/sample_closure.rs | 11 +- src/closures/zenohid_closure.rs | 9 + src/collections.rs | 21 + src/commons.rs | 22 +- src/config.rs | 9 + src/encoding.rs | 9 + src/get.rs | 23 +- src/keyexpr.rs | 13 +- src/payload.rs | 9 + src/platform/synchronization.rs | 9 + src/publisher.rs | 9 + src/queryable.rs | 24 +- src/scouting.rs | 12 +- src/session.rs | 13 +- src/shm/buffer/zshm.rs | 23 +- src/shm/buffer/zshmmut.rs | 9 + src/shm/client_storage/mod.rs | 11 + src/shm/provider/alloc_layout.rs | 9 + src/shm/provider/shm_provider.rs | 9 + src/shm/provider/types.rs | 18 + src/subscriber.rs | 13 +- 29 files changed, 1125 insertions(+), 476 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 2ba8356bf..bb3f06f56 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -16,32 +16,6 @@ #define ALIGN(n) #define ZENOHC_API #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Allocation errors - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef enum z_alloc_error_t { -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Defragmentation needed. - */ - Z_ALLOC_ERROR_NEED_DEFRAGMENT, -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * The provider is out of memory. - */ - Z_ALLOC_ERROR_OUT_OF_MEMORY, -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Other error. - */ - Z_ALLOC_ERROR_OTHER, -#endif -} z_alloc_error_t; -#endif typedef enum z_congestion_control_t { /** * Messages are not dropped in case of congestion. @@ -103,26 +77,6 @@ typedef enum z_keyexpr_intersection_level_t { Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3, } z_keyexpr_intersection_level_t; #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Layouting errors - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef enum z_layout_error_t { -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Layout arguments are incorrect. - */ - Z_LAYOUT_ERROR_INCORRECT_LAYOUT_ARGS, -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Layout incompatible with provider. - */ - Z_LAYOUT_ERROR_PROVIDER_INCOMPATIBLE_LAYOUT, -#endif -} z_layout_error_t; -#endif /** * The priority of zenoh messages. */ @@ -215,52 +169,6 @@ typedef enum z_whatami_t { Z_WHATAMI_PEER = 2, Z_WHATAMI_CLIENT = 4, } z_whatami_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Status of SHM buffer allocation operation. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef enum zc_buf_alloc_status_t { -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Allocation ok - */ - ZC_BUF_ALLOC_STATUS_OK = 0, -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Allocation error - */ - ZC_BUF_ALLOC_STATUS_ALLOC_ERROR = 1, -#endif -} zc_buf_alloc_status_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Status of SHM buffer layouting + allocation operation. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef enum zc_buf_layout_alloc_status_t { -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Allocation ok - */ - ZC_BUF_LAYOUT_ALLOC_STATUS_OK = 0, -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Allocation error - */ - ZC_BUF_LAYOUT_ALLOC_STATUS_ALLOC_ERROR = 1, -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) - /** - * Layouting error - */ - ZC_BUF_LAYOUT_ALLOC_STATUS_LAYOUT_ERROR = 2, -#endif -} zc_buf_layout_alloc_status_t; -#endif /** * The locality of samples to be received by subscribers or targeted by publishers. */ @@ -329,53 +237,10 @@ typedef enum zc_reply_keyexpr_t { ZC_REPLY_KEYEXPR_MATCHING_QUERY = 1, } zc_reply_keyexpr_t; #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A result of SHM buffer allocation operation. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct z_buf_alloc_result_t { - enum zc_buf_alloc_status_t status; - z_owned_shm_mut_t buf; - enum z_alloc_error_t error; -} z_buf_alloc_result_t; -#endif +typedef struct z_moved_alloc_layout_t { + struct z_owned_alloc_layout_t _this; +} z_moved_alloc_layout_t; typedef int8_t z_result_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief An AllocAlignment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct z_alloc_alignment_t { - uint8_t pow; -} z_alloc_alignment_t; -#endif -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct zc_threadsafe_context_data_t { - void *ptr; -} zc_threadsafe_context_data_t; -#endif -/** - * A tread-safe droppable context. - * Contexts are idiomatically used in C together with callback interfaces to deliver associated state - * information to each callback. - * - * This is a thread-safe context - the associated callbacks may be executed concurrently with the same - * zc_context_t instance. In other words, all the callbacks associated with this context data MUST be - * thread-safe. - * - * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The - * delete_fn is guaranteed to be executed only once at some point of time after the last associated - * callback call returns. - * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't - * be executed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct zc_threadsafe_context_t { - struct zc_threadsafe_context_data_t context; - void (*delete_fn)(void*); -} zc_threadsafe_context_t; -#endif typedef struct z_moved_bytes_t { struct z_owned_bytes_t _this; } z_moved_bytes_t; @@ -391,41 +256,15 @@ typedef struct z_moved_string_t { typedef struct ALIGN(8) z_bytes_slice_iterator_t { uint8_t _0[24]; } z_bytes_slice_iterator_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Unique segment identifier. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef uint32_t z_segment_id_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Chunk id within it's segment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef uint32_t z_chunk_id_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A ChunkDescriptor. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct z_chunk_descriptor_t { - z_segment_id_t segment; - z_chunk_id_t chunk; - size_t len; -} z_chunk_descriptor_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief An AllocatedChunk. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct z_allocated_chunk_t { - struct z_chunk_descriptor_t descriptpr; - void *data; -} z_allocated_chunk_t; -#endif +typedef struct z_moved_shm_t { + struct z_owned_shm_t _this; +} z_moved_shm_t; +typedef struct z_moved_shm_mut_t { + struct z_owned_shm_mut_t _this; +} z_moved_shm_mut_t; +typedef struct z_moved_chunk_alloc_result_t { + struct z_owned_chunk_alloc_result_t _this; +} z_moved_chunk_alloc_result_t; /** * Monotonic clock */ @@ -583,7 +422,7 @@ typedef struct z_owned_closure_zid_t { /** * A callback function. */ - void (*call)(const z_id_t *z_id, void *context); + void (*call)(const struct z_id_t *z_id, void *context); /** * An optional function that will be called upon closure drop. */ @@ -715,6 +554,9 @@ typedef struct z_moved_fifo_handler_sample_t { typedef struct z_query_consolidation_t { enum z_consolidation_mode_t mode; } z_query_consolidation_t; +typedef struct z_moved_source_info_t { + struct z_owned_source_info_t _this; +} z_moved_source_info_t; /** * Options passed to the `z_get()` function. */ @@ -769,7 +611,7 @@ typedef struct z_get_options_t { * * The source info for the query. */ - z_moved_source_info_t *source_info; + struct z_moved_source_info_t *source_info; #endif /** * An optional attachment to attach to the query. @@ -786,6 +628,9 @@ typedef struct z_moved_hello_t { typedef struct z_moved_keyexpr_t { struct z_owned_keyexpr_t _this; } z_moved_keyexpr_t; +typedef struct z_moved_memory_layout_t { + struct z_owned_memory_layout_t _this; +} z_moved_memory_layout_t; typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; @@ -826,7 +671,7 @@ typedef struct z_publisher_put_options_t { * * The source info for the publication. */ - z_moved_source_info_t *source_info; + struct z_moved_source_info_t *source_info; #endif /** * The attachment to attach to the publication. @@ -879,7 +724,7 @@ typedef struct z_put_options_t { * * The source info for the message. */ - z_moved_source_info_t *source_info; + struct z_moved_source_info_t *source_info; #endif /** * The attachment to this message. @@ -920,7 +765,7 @@ typedef struct z_query_reply_options_t { * * The source info for the reply. */ - z_moved_source_info_t *source_info; + struct z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -954,7 +799,7 @@ typedef struct z_query_reply_del_options_t { * * The source info for the reply. */ - z_moved_source_info_t *source_info; + struct z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -1005,46 +850,15 @@ typedef struct z_scout_options_t { */ enum z_what_t what; } z_scout_options_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Callbacks for ShmSegment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct zc_shm_segment_callbacks_t { - uint8_t *(*map_fn)(z_chunk_id_t chunk_id, void *context); -} zc_shm_segment_callbacks_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief An ShmSegment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct z_shm_segment_t { - struct zc_threadsafe_context_t context; - struct zc_shm_segment_callbacks_t callbacks; -} z_shm_segment_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Callback for ShmClient. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct zc_shm_client_callbacks_t { - bool (*attach_fn)(struct z_shm_segment_t *out_segment, z_segment_id_t segment_id, void *context); -} zc_shm_client_callbacks_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A result of SHM buffer layouting + allocation operation. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct z_buf_layout_alloc_result_t { - enum zc_buf_layout_alloc_status_t status; - z_owned_shm_mut_t buf; - enum z_alloc_error_t alloc_error; - enum z_layout_error_t layout_error; -} z_buf_layout_alloc_result_t; -#endif +typedef struct z_moved_shm_client_t { + struct z_owned_shm_client_t _this; +} z_moved_shm_client_t; +typedef struct z_moved_shm_client_storage_t { + struct z_owned_shm_client_storage_t _this; +} z_moved_shm_client_storage_t; +typedef struct z_moved_shm_provider_t { + struct z_owned_shm_provider_t _this; +} z_moved_shm_provider_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Unique protocol identifier. @@ -1054,47 +868,6 @@ typedef struct z_buf_layout_alloc_result_t { #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) typedef uint32_t z_protocol_id_t; #endif -/** - * A non-tread-safe droppable context. - * Contexts are idiomatically used in C together with callback interfaces to deliver associated state - * information to each callback. - * - * This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same - * zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated - * with this context data are not required to be thread-safe. - * - * NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can - * still be executed concurrently. The exact behavior depends on user's application, but we strongly - * discourage our users from pinning to some specific behavior unless they _really_ understand what they - * are doing. - * - * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The - * delete_fn is guaranteed to be executed only once at some point of time after the last associated - * callback call returns. - * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't - * be executed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct zc_context_t { - void *context; - void (*delete_fn)(void*); -} zc_context_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Callbacks for ShmProviderBackend. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -typedef struct zc_shm_provider_backend_callbacks_t { - void (*alloc_fn)(z_owned_chunk_alloc_result_t *out_result, - const z_loaned_memory_layout_t *layout, - void *context); - void (*free_fn)(const struct z_chunk_descriptor_t *chunk, void *context); - size_t (*defragment_fn)(void *context); - size_t (*available_fn)(void *context); - void (*layout_for_fn)(z_owned_memory_layout_t *layout, void *context); -} zc_shm_provider_backend_callbacks_t; -#endif typedef struct z_moved_string_array_t { struct z_owned_string_array_t _this; } z_moved_string_array_t; @@ -1182,15 +955,6 @@ typedef struct zc_owned_closure_matching_status_t { void (*drop)(void *context); } zc_owned_closure_matching_status_t; #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Loaned closure. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct zc_loaned_closure_matching_status_t { - size_t _0[3]; -} zc_loaned_closure_matching_status_t; -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. @@ -1227,6 +991,15 @@ typedef struct zc_liveliness_get_options_t { uint32_t timeout_ms; } zc_liveliness_get_options_t; #endif +typedef struct zc_moved_liveliness_token_t { + struct zc_owned_liveliness_token_t _this; +} zc_moved_liveliness_token_t; +typedef struct zc_moved_matching_listener_t { + struct zc_owned_matching_listener_t _this; +} zc_moved_matching_listener_t; +typedef struct zc_moved_shm_client_list_t { + struct zc_owned_shm_client_list_t _this; +} zc_moved_shm_client_list_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Options passed to the `ze_declare_publication_cache()` function. @@ -1295,6 +1068,19 @@ typedef struct ze_querying_subscriber_options_t { uint64_t query_timeout_ms; } ze_querying_subscriber_options_t; #endif +typedef struct ze_moved_publication_cache_t { + struct ze_owned_publication_cache_t _this; +} ze_moved_publication_cache_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A loaned Zenoh publication cache. + */ +typedef struct ALIGN(8) ze_loaned_publication_cache_t { + uint8_t _0[96]; +} ze_loaned_publication_cache_t; +typedef struct ze_moved_querying_subscriber_t { + struct ze_owned_querying_subscriber_t _this; +} ze_moved_querying_subscriber_t; ZENOHC_API extern const unsigned int Z_ROUTER; ZENOHC_API extern const unsigned int Z_PEER; ZENOHC_API extern const unsigned int Z_CLIENT; @@ -1314,45 +1100,47 @@ ZENOHC_API extern const unsigned int Z_SHM_POSIX_PROTOCOL_ID; #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc(struct z_buf_alloc_result_t *out_result, - const z_loaned_alloc_layout_t *layout); + const struct z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc(struct z_buf_alloc_result_t *out_result, - const z_loaned_alloc_layout_t *layout); + const struct z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag(struct z_buf_alloc_result_t *out_result, - const z_loaned_alloc_layout_t *layout); + const struct z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_blocking(struct z_buf_alloc_result_t *out_result, - const z_loaned_alloc_layout_t *layout); + const struct z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, - const z_loaned_alloc_layout_t *layout); + const struct z_loaned_alloc_layout_t *layout); #endif /** * Deletes Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_alloc_layout_drop(z_moved_alloc_layout_t *this_); +ZENOHC_API void z_alloc_layout_drop(struct z_moved_alloc_layout_t *this_); #endif /** * Borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_); +ZENOHC_API +const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_alloc_layout_t *this_); #endif /** * Mutably borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(z_owned_alloc_layout_t *this_); +ZENOHC_API +struct z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(struct z_owned_alloc_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1360,15 +1148,23 @@ ZENOHC_API z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(z_owned_alloc_layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_alloc_layout_new(z_owned_alloc_layout_t *this_, - const z_loaned_shm_provider_t *provider, +z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif +/** + * Takes ownership of the mutably borrowed Alloc Layout + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +void z_alloc_layout_take_loaned(struct z_owned_alloc_layout_t *dst, + struct z_loaned_alloc_layout_t *src); +#endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, - const z_loaned_alloc_layout_t *layout, + const struct z_loaned_alloc_layout_t *layout, struct zc_threadsafe_context_t result_context, void (*result_callback)(void*, struct z_buf_alloc_result_t*)); @@ -1429,7 +1225,7 @@ z_result_t z_bytes_deserialize_into_int8(const struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_loaned_shm(const struct z_loaned_bytes_t *this_, - const z_loaned_shm_t **dst); + const struct z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1441,7 +1237,7 @@ z_result_t z_bytes_deserialize_into_loaned_shm(const struct z_loaned_bytes_t *th #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_mut_loaned_shm(struct z_loaned_bytes_t *this_, - z_loaned_shm_t **dst); + struct z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1453,7 +1249,7 @@ z_result_t z_bytes_deserialize_into_mut_loaned_shm(struct z_loaned_bytes_t *this #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_deserialize_into_owned_shm(const struct z_loaned_bytes_t *this_, - z_owned_shm_t *dst); + struct z_owned_shm_t *dst); #endif /** * Deserializes into a pair of `z_owned_bytes_t` objects. @@ -1722,7 +1518,7 @@ ZENOHC_API void z_bytes_serialize_from_int8(struct z_owned_bytes_t *this_, int8_ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_serialize_from_shm(struct z_owned_bytes_t *this_, - z_moved_shm_t *shm); + struct z_moved_shm_t *shm); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1731,7 +1527,7 @@ z_result_t z_bytes_serialize_from_shm(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_serialize_from_shm_mut(struct z_owned_bytes_t *this_, - z_moved_shm_mut_t *shm); + struct z_moved_shm_mut_t *shm); #endif /** * Serializes a slice by copying. @@ -1777,6 +1573,10 @@ ZENOHC_API void z_bytes_serialize_from_uint8(struct z_owned_bytes_t *this_, uint ZENOHC_API bool z_bytes_slice_iterator_next(struct z_bytes_slice_iterator_t *this_, struct z_view_slice_t *slice); +/** + * Takes ownership of the mutably borrowed bytes + */ +ZENOHC_API void z_bytes_take_loaned(struct z_owned_bytes_t *dst, struct z_loaned_bytes_t *src); /** * Appends bytes. * This allows to compose a serialized data out of multiple `z_owned_bytes_t` that may point to different memory regions. @@ -1810,7 +1610,7 @@ z_result_t z_bytes_writer_write_all(struct z_bytes_writer_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); +void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1818,7 +1618,7 @@ void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const z_owned_chunk_alloc_result_t *this_); +const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const struct z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1826,7 +1626,7 @@ const z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const z_owned_chu */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(z_owned_chunk_alloc_result_t *this_); +struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(struct z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1834,7 +1634,7 @@ z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(z_owned_chunk_alloc */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_new_error(z_owned_chunk_alloc_result_t *this_, +void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, enum z_alloc_error_t alloc_error); #endif /** @@ -1843,9 +1643,17 @@ void z_chunk_alloc_result_new_error(z_owned_chunk_alloc_result_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_chunk_alloc_result_new_ok(z_owned_chunk_alloc_result_t *this_, +z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this_, struct z_allocated_chunk_t allocated_chunk); #endif +/** + * Takes ownership of the mutably borrowed Chunk Alloc Result. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +void z_chunk_alloc_result_take_loaned(struct z_owned_chunk_alloc_result_t *dst, + struct z_loaned_chunk_alloc_result_t *src); +#endif /** * Get number of milliseconds passed since creation of `time`. */ @@ -1906,6 +1714,12 @@ const struct z_loaned_closure_hello_t *z_closure_hello_loan(const struct z_owned */ ZENOHC_API struct z_loaned_closure_hello_t *z_closure_hello_loan_mut(struct z_owned_closure_hello_t *closure); +/** + * Takes ownership of the mutably borrowed closure + */ +ZENOHC_API +void z_closure_hello_take_loaned(struct z_owned_closure_hello_t *dst, + struct z_loaned_closure_hello_t *src); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -1938,6 +1752,12 @@ const struct z_loaned_closure_query_t *z_closure_query_loan(const struct z_owned */ ZENOHC_API struct z_loaned_closure_query_t *z_closure_query_loan_mut(struct z_owned_closure_query_t *closure); +/** + * Takes ownership of the mutably borrowed closure + */ +ZENOHC_API +void z_closure_query_take_loaned(struct z_owned_closure_query_t *dst, + struct z_loaned_closure_query_t *src); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -1971,6 +1791,12 @@ const struct z_loaned_closure_reply_t *z_closure_reply_loan(const struct z_owned */ ZENOHC_API struct z_loaned_closure_reply_t *z_closure_reply_loan_mut(struct z_owned_closure_reply_t *closure); +/** + * Takes ownership of the mutably borrowed closure + */ +ZENOHC_API +void z_closure_reply_take_loaned(struct z_owned_closure_reply_t *dst, + struct z_loaned_closure_reply_t *src); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -2003,6 +1829,12 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own */ ZENOHC_API struct z_loaned_closure_sample_t *z_closure_sample_loan_mut(struct z_owned_closure_sample_t *closure); +/** + * Takes ownership of the mutably borrowed closure + */ +ZENOHC_API +void z_closure_sample_take_loaned(struct z_owned_closure_sample_t *dst, + struct z_loaned_closure_sample_t *src); /** * @brief Constructs closure. * @param this_: uninitialized memory location where new closure will be constructed. @@ -2013,7 +1845,7 @@ struct z_loaned_closure_sample_t *z_closure_sample_loan_mut(struct z_owned_closu #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid(struct z_owned_closure_zid_t *this_, - void (*call)(const z_id_t *z_id, void *context), + void (*call)(const struct z_id_t *z_id, void *context), void (*drop)(void *context), void *context); #endif @@ -2024,7 +1856,7 @@ void z_closure_zid(struct z_owned_closure_zid_t *this_, #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, - const z_id_t *z_id); + const struct z_id_t *z_id); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2050,6 +1882,14 @@ const struct z_loaned_closure_zid_t *z_closure_zid_loan(const struct z_owned_clo ZENOHC_API struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid_t *closure); #endif +/** + * Takes ownership of the mutably borrowed closure + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +void z_closure_zid_take_loaned(struct z_owned_closure_zid_t *dst, + struct z_loaned_closure_zid_t *src); +#endif /** * Drops conditional variable. */ @@ -2101,6 +1941,10 @@ ZENOHC_API const struct z_loaned_config_t *z_config_loan(const struct z_owned_co * Mutably borrows config. */ ZENOHC_API struct z_loaned_config_t *z_config_loan_mut(struct z_owned_config_t *this_); +/** + * Takes ownership of the mutably borrowed config. + */ +ZENOHC_API void z_config_take_loaned(struct z_owned_config_t *dst, struct z_loaned_config_t *src); /** * Constructs and declares a key expression on the network. This reduces key key expression to a numerical id, * which allows to save the bandwith, when passing key expression between Zenoh entities. @@ -2422,6 +2266,12 @@ ZENOHC_API z_result_t z_encoding_set_schema_from_substr(struct z_loaned_encoding_t *this_, const char *s, size_t len); +/** + * Takes ownership of the mutably borrowed encoding + */ +ZENOHC_API +void z_encoding_take_loaned(struct z_owned_encoding_t *dst, + struct z_loaned_encoding_t *src); /** * A CSS file. * @@ -2685,7 +2535,7 @@ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_zenoh_uint8(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_entity_global_id_eid(const z_entity_global_id_t *this_); +uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2693,7 +2543,7 @@ uint32_t z_entity_global_id_eid(const z_entity_global_id_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_id_t z_entity_global_id_zid(const z_entity_global_id_t *this_); +struct z_id_t z_entity_global_id_zid(const struct z_entity_global_id_t *this_); #endif /** * Constructs send and recieve ends of the fifo channel @@ -2739,6 +2589,12 @@ struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan_mut(struct z_own ZENOHC_API z_result_t z_fifo_handler_query_recv(const struct z_loaned_fifo_handler_query_t *this_, struct z_owned_query_t *query); +/** + * Takes ownership of the mutably borrowed handler + */ +ZENOHC_API +void z_fifo_handler_query_take_loaned(struct z_owned_fifo_handler_query_t *dst, + struct z_loaned_fifo_handler_query_t *src); /** * Returns query from the fifo buffer. If there are no more pending queries will return immediately (with query set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -2769,6 +2625,12 @@ struct z_loaned_fifo_handler_reply_t *z_fifo_handler_reply_loan_mut(struct z_own ZENOHC_API z_result_t z_fifo_handler_reply_recv(const struct z_loaned_fifo_handler_reply_t *this_, struct z_owned_reply_t *reply); +/** + * Takes ownership of the mutably borrowed handler + */ +ZENOHC_API +void z_fifo_handler_reply_take_loaned(struct z_owned_fifo_handler_reply_t *dst, + struct z_loaned_fifo_handler_reply_t *src); /** * Returns reply from the fifo buffer. If there are no more pending replies will return immediately (with reply set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state), @@ -2799,6 +2661,12 @@ struct z_loaned_fifo_handler_sample_t *z_fifo_handler_sample_loan_mut(struct z_o ZENOHC_API z_result_t z_fifo_handler_sample_recv(const struct z_loaned_fifo_handler_sample_t *this_, struct z_owned_sample_t *sample); +/** + * Takes ownership of the mutably borrowed fifo_handler_sample + */ +ZENOHC_API +void z_fifo_handler_sample_take_loaned(struct z_owned_fifo_handler_sample_t *dst, + struct z_loaned_fifo_handler_sample_t *src); /** * Returns sample from the fifo buffer. * If there are no more pending replies will return immediately (with sample set to its gravestone state). @@ -2854,6 +2722,10 @@ ZENOHC_API struct z_loaned_hello_t *z_hello_loan_mut(struct z_owned_hello_t *thi ZENOHC_API void z_hello_locators(const struct z_loaned_hello_t *this_, struct z_owned_string_array_t *locators_out); +/** + * Takes ownership of the mutably borrowed hello + */ +ZENOHC_API void z_hello_take_loaned(struct z_owned_hello_t *dst, struct z_loaned_hello_t *src); /** * Returns type of Zenoh entity that transmitted hello message. */ @@ -2864,7 +2736,7 @@ ZENOHC_API enum z_whatami_t z_hello_whatami(const struct z_loaned_hello_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); +struct z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2872,7 +2744,7 @@ z_id_t z_hello_zid(const struct z_loaned_hello_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_id_to_string(const z_id_t *zid, +void z_id_to_string(const struct z_id_t *zid, struct z_owned_string_t *dst); #endif /** @@ -2913,19 +2785,19 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_id_t z_info_zid(const struct z_loaned_session_t *session); +struct z_id_t z_info_zid(const struct z_loaned_session_t *session); #endif /** * Returns ``true`` if `this` is valid. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); +ZENOHC_API bool z_internal_alloc_layout_check(const struct z_owned_alloc_layout_t *this_); #endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); +ZENOHC_API void z_internal_alloc_layout_null(struct z_owned_alloc_layout_t *this_); #endif /** * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -2941,7 +2813,7 @@ ZENOHC_API void z_internal_bytes_null(struct z_owned_bytes_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); +bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2949,7 +2821,7 @@ bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); +void z_internal_chunk_alloc_result_null(struct z_owned_chunk_alloc_result_t *this_); #endif /** * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. @@ -3072,7 +2944,7 @@ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); +bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3080,7 +2952,7 @@ bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); +void z_internal_memory_layout_null(struct z_owned_memory_layout_t *this_); #endif /** * Returns ``true`` if mutex is valid, ``false`` otherwise. @@ -3179,7 +3051,7 @@ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_check(const z_owned_shm_t *this_); +bool z_internal_shm_check(const struct z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3187,7 +3059,7 @@ bool z_internal_shm_check(const z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); +bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3195,7 +3067,7 @@ bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_null(z_owned_shm_client_t *this_); +void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3203,7 +3075,7 @@ void z_internal_shm_client_null(z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); +bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3211,7 +3083,7 @@ bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); +void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3219,7 +3091,7 @@ void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); +bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3227,7 +3099,7 @@ bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); +void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3235,7 +3107,7 @@ void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_null(z_owned_shm_t *this_); +void z_internal_shm_null(struct z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3243,7 +3115,7 @@ void z_internal_shm_null(z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); +bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3251,7 +3123,7 @@ bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); +void z_internal_shm_provider_null(struct z_owned_shm_provider_t *this_); #endif /** * @return ``true`` if slice is not empty, ``false`` otherwise. @@ -3267,7 +3139,7 @@ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool z_internal_source_info_check(const z_owned_source_info_t *this_); +bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3275,7 +3147,7 @@ bool z_internal_source_info_check(const z_owned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_internal_source_info_null(z_owned_source_info_t *this_); +void z_internal_source_info_null(struct z_owned_source_info_t *this_); #endif /** * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. @@ -3450,13 +3322,19 @@ ZENOHC_API enum z_keyexpr_intersection_level_t z_keyexpr_relation_to(const struct z_loaned_keyexpr_t *left, const struct z_loaned_keyexpr_t *right); #endif +/** + * Takes ownership of the mutably borrowed keyexpr + */ +ZENOHC_API +void z_keyexpr_take_loaned(struct z_owned_keyexpr_t *dst, + struct z_loaned_keyexpr_t *src); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes Memory Layout. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_drop(z_moved_memory_layout_t *this_); +void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3464,7 +3342,7 @@ void z_memory_layout_drop(z_moved_memory_layout_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, +void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, size_t *out_size, struct z_alloc_alignment_t *out_alignment); #endif @@ -3474,7 +3352,7 @@ void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout_t *this_); +const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3482,7 +3360,7 @@ const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_memory_layout_t *z_memory_layout_loan_mut(z_owned_memory_layout_t *this_); +struct z_loaned_memory_layout_t *z_memory_layout_loan_mut(struct z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3490,10 +3368,18 @@ z_loaned_memory_layout_t *z_memory_layout_loan_mut(z_owned_memory_layout_t *this */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, +z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif +/** + * Takes ownership of the mutably borrowed Memory Layout. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +void z_memory_layout_take_loaned(struct z_owned_memory_layout_t *dst, + struct z_loaned_memory_layout_t *src); +#endif /** * Drops mutex and resets it to its gravestone state. */ @@ -3512,6 +3398,10 @@ ZENOHC_API struct z_loaned_mutex_t *z_mutex_loan_mut(struct z_owned_mutex_t *thi * @return 0 in case of success, negative error code in case of failure. */ ZENOHC_API z_result_t z_mutex_lock(struct z_loaned_mutex_t *this_); +/** + * Takes ownership of the mutably borrowed mutex + */ +ZENOHC_API void z_mutex_take_loaned(struct z_owned_mutex_t *dst, struct z_loaned_mutex_t *src); /** * Tries to lock mutex. If mutex is already locked, return immediately. * @return 0 in case of success, negative value if failed to aquire the lock. @@ -3546,7 +3436,7 @@ ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); ZENOHC_API z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, struct z_moved_config_t *config, - const z_loaned_shm_client_storage_t *shm_clients); + const struct z_loaned_shm_client_storage_t *shm_clients); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3554,7 +3444,7 @@ z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_posix_shm_client_new(z_owned_shm_client_t *this_); +void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3562,8 +3452,8 @@ void z_posix_shm_client_new(z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, - const z_loaned_memory_layout_t *layout); +z_result_t z_posix_shm_provider_new(struct z_owned_shm_provider_t *this_, + const struct z_loaned_memory_layout_t *layout); #endif /** * Returns the default value of #z_priority_t. @@ -3591,7 +3481,7 @@ ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); +struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); #endif /** * Returns the key expression of the publisher. @@ -3632,6 +3522,12 @@ z_result_t z_publisher_put(const struct z_loaned_publisher_t *this_, * Constructs the default value for `z_publisher_put_options_t`. */ ZENOHC_API void z_publisher_put_options_default(struct z_publisher_put_options_t *this_); +/** + * Takes ownership of the mutably borrowed publisher + */ +ZENOHC_API +void z_publisher_take_loaned(struct z_owned_publisher_t *dst, + struct z_loaned_publisher_t *src); /** * Publishes data on specified key expression. * @@ -3802,6 +3698,10 @@ ZENOHC_API void z_query_reply_err_options_default(struct z_query_reply_err_optio * Constructs the default value for `z_query_reply_options_t`. */ ZENOHC_API void z_query_reply_options_default(struct z_query_reply_options_t *this_); +/** + * Takes ownership of the mutably borrowed query + */ +ZENOHC_API void z_query_take_loaned(struct z_owned_query_t *dst, struct z_loaned_query_t *src); /** * Create a default `z_query_target_t`. */ @@ -3818,7 +3718,7 @@ void z_queryable_drop(struct z_moved_queryable_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); +struct z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); #endif ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); @@ -3827,6 +3727,12 @@ ZENOHC_API struct z_loaned_queryable_t *z_queryable_loan_mut(struct z_owned_quer * Constructs the default value for `z_query_reply_options_t`. */ ZENOHC_API void z_queryable_options_default(struct z_queryable_options_t *this_); +/** + * Takes ownership of the mutably borrowed queryable + */ +ZENOHC_API +void z_queryable_take_loaned(struct z_owned_queryable_t *dst, + struct z_loaned_queryable_t *src); /** * Fills buffer with random data. */ @@ -3852,7 +3758,7 @@ ZENOHC_API uint8_t z_random_u8(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); +void z_ref_shm_client_storage_global(struct z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3905,6 +3811,12 @@ ZENOHC_API struct z_loaned_reply_err_t *z_reply_err_loan_mut(struct z_owned_repl */ ZENOHC_API const struct z_loaned_bytes_t *z_reply_err_payload(const struct z_loaned_reply_err_t *this_); +/** + * Takes ownership of the mutably borrowed reply error + */ +ZENOHC_API +void z_reply_err_take_loaned(struct z_owned_reply_err_t *dst, + struct z_loaned_reply_err_t *src); /** * Returns ``true`` if reply contains a valid response, ``false`` otherwise (in this case it contains a errror value). */ @@ -3932,8 +3844,12 @@ ZENOHC_API const struct z_loaned_sample_t *z_reply_ok(const struct z_loaned_repl #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API bool z_reply_replier_id(const struct z_loaned_reply_t *this_, - z_id_t *out_id); + struct z_id_t *out_id); #endif +/** + * Takes ownership of the mutably borrowed reply + */ +ZENOHC_API void z_reply_take_loaned(struct z_owned_reply_t *dst, struct z_loaned_reply_t *src); /** * Constructs send and recieve ends of the ring channel */ @@ -3977,6 +3893,12 @@ struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan_mut(struct z_own ZENOHC_API z_result_t z_ring_handler_query_recv(const struct z_loaned_ring_handler_query_t *this_, struct z_owned_query_t *query); +/** + * Takes ownership of the mutably borrowed handler + */ +ZENOHC_API +void z_ring_handler_query_take_loaned(struct z_owned_ring_handler_query_t *dst, + struct z_loaned_ring_handler_query_t *src); /** * Returns query from the ring buffer. If there are no more pending queries will return immediately (with query set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -4007,6 +3929,12 @@ struct z_loaned_ring_handler_reply_t *z_ring_handler_reply_loan_mut(struct z_own ZENOHC_API z_result_t z_ring_handler_reply_recv(const struct z_loaned_ring_handler_reply_t *this_, struct z_owned_reply_t *reply); +/** + * Takes ownership of the mutably borrowed handler + */ +ZENOHC_API +void z_ring_handler_reply_take_loaned(struct z_owned_ring_handler_reply_t *dst, + struct z_loaned_ring_handler_reply_t *src); /** * Returns reply from the ring buffer. If there are no more pending replies will return immediately (with reply set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state), @@ -4037,6 +3965,12 @@ struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan_mut(struct z_o ZENOHC_API z_result_t z_ring_handler_sample_recv(const struct z_loaned_ring_handler_sample_t *this_, struct z_owned_sample_t *sample); +/** + * Takes ownership of the mutably borrowed handler + */ +ZENOHC_API +void z_ring_handler_sample_take_loaned(struct z_owned_ring_handler_sample_t *dst, + struct z_loaned_ring_handler_sample_t *src); /** * Returns sample from the ring buffer. If there are no more pending replies will return immediately (with sample set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state), @@ -4114,8 +4048,12 @@ enum z_reliability_t z_sample_reliability(const struct z_loaned_sample_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); +const struct z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); #endif +/** + * Takes ownership of the mutably borrowed sample. + */ +ZENOHC_API void z_sample_take_loaned(struct z_owned_sample_t *dst, struct z_loaned_sample_t *src); /** * Returns the sample timestamp. * @@ -4151,13 +4089,19 @@ ZENOHC_API const struct z_loaned_session_t *z_session_loan(const struct z_owned_ * Mutably borrows session. */ ZENOHC_API struct z_loaned_session_t *z_session_loan_mut(struct z_owned_session_t *this_); +/** + * Takes ownership of the mutably borrowed session + */ +ZENOHC_API +void z_session_take_loaned(struct z_owned_session_t *dst, + struct z_loaned_session_t *src); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes SHM Client. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_drop(z_moved_shm_client_t *this_); +void z_shm_client_drop(struct z_moved_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4165,7 +4109,7 @@ void z_shm_client_drop(z_moved_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_new(z_owned_shm_client_t *this_, +void z_shm_client_new(struct z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif @@ -4175,8 +4119,8 @@ void z_shm_client_new(z_owned_shm_client_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_clone(z_owned_shm_client_storage_t *this_, - const z_loaned_shm_client_storage_t *from); +void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, + const struct z_loaned_shm_client_storage_t *from); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4184,7 +4128,7 @@ void z_shm_client_storage_clone(z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); +void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4192,7 +4136,7 @@ void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm_client_storage_t *this_); +const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const struct z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4200,15 +4144,15 @@ const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(z_owned_shm_client_storage_t *this_); +struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(struct z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, - const zc_loaned_shm_client_list_t *clients, +z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, + const struct zc_loaned_shm_client_list_t *clients, bool add_default_client_set); #endif /** @@ -4216,7 +4160,16 @@ z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); +void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Takes ownership of the mutably borrowed SHM Client Storage. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +void z_shm_client_storage_take_loaned(struct z_owned_shm_client_storage_t *dst, + struct z_loaned_shm_client_storage_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4224,8 +4177,8 @@ void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_clone(z_owned_shm_t *out, - const z_loaned_shm_t *this_); +void z_shm_clone(struct z_owned_shm_t *out, + const struct z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4233,7 +4186,7 @@ void z_shm_clone(z_owned_shm_t *out, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_data(const z_loaned_shm_t *this_); +const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4241,7 +4194,7 @@ const unsigned char *z_shm_data(const z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_drop(z_moved_shm_t *this_); +void z_shm_drop(struct z_moved_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4249,8 +4202,8 @@ void z_shm_drop(z_moved_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_from_mut(z_owned_shm_t *this_, - z_moved_shm_mut_t *that); +void z_shm_from_mut(struct z_owned_shm_t *this_, + struct z_moved_shm_mut_t *that); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4258,7 +4211,7 @@ void z_shm_from_mut(z_owned_shm_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_len(const z_loaned_shm_t *this_); +size_t z_shm_len(const struct z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4266,13 +4219,13 @@ size_t z_shm_len(const z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); +const struct z_loaned_shm_t *z_shm_loan(const struct z_owned_shm_t *this_); #endif /** * @brief Mutably borrows ZShm slice. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); +ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4280,7 +4233,7 @@ ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_mut_data(const z_loaned_shm_mut_t *this_); +const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4288,7 +4241,7 @@ const unsigned char *z_shm_mut_data(const z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -unsigned char *z_shm_mut_data_mut(z_loaned_shm_mut_t *this_); +unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4296,7 +4249,7 @@ unsigned char *z_shm_mut_data_mut(z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_mut_drop(z_moved_shm_mut_t *this_); +void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4304,7 +4257,7 @@ void z_shm_mut_drop(z_moved_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_mut_len(const z_loaned_shm_mut_t *this_); +size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4312,7 +4265,7 @@ size_t z_shm_mut_len(const z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); +const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4320,7 +4273,15 @@ const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); +struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); +#endif +/** + * Takes ownership of the mutably borrowed shm_mut + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +void z_shm_mut_take_loaned(struct z_owned_shm_mut_t *dst, + struct z_loaned_shm_mut_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4334,9 +4295,9 @@ z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_mut_try_from_immut(z_owned_shm_mut_t *this_, - z_moved_shm_t *that, - z_owned_shm_t *immut); +z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, + struct z_moved_shm_t *that, + struct z_owned_shm_t *immut); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4344,7 +4305,7 @@ z_result_t z_shm_mut_try_from_immut(z_owned_shm_mut_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, - const z_loaned_shm_provider_t *provider, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4354,7 +4315,7 @@ void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, - const z_loaned_shm_provider_t *provider, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4364,7 +4325,7 @@ void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_result, - const z_loaned_shm_provider_t *provider, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4374,7 +4335,7 @@ void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_resu #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result_t *out_result, - const z_loaned_shm_provider_t *provider, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment, struct zc_threadsafe_context_t result_context, @@ -4387,7 +4348,7 @@ z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t *out_result, - const z_loaned_shm_provider_t *provider, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4397,7 +4358,7 @@ void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t *out_result, - const z_loaned_shm_provider_t *provider, + const struct z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4406,14 +4367,14 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); +size_t z_shm_provider_available(const struct z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_defragment(const z_loaned_shm_provider_t *provider); +size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4421,14 +4382,14 @@ size_t z_shm_provider_defragment(const z_loaned_shm_provider_t *provider); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_drop(z_moved_shm_provider_t *this_); +void z_shm_provider_drop(struct z_moved_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); +size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4436,7 +4397,7 @@ size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t *this_); +const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4444,15 +4405,15 @@ const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_shm_provider_t *z_shm_provider_loan_mut(z_owned_shm_provider_t *this_); +struct z_loaned_shm_provider_t *z_shm_provider_loan_mut(struct z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_provider_map(z_owned_shm_mut_t *out_result, - const z_loaned_shm_provider_t *provider, +z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, + const struct z_loaned_shm_provider_t *provider, struct z_allocated_chunk_t allocated_chunk, size_t len); #endif @@ -4462,29 +4423,43 @@ z_result_t z_shm_provider_map(z_owned_shm_mut_t *out_result, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_new(z_owned_shm_provider_t *this_, +void z_shm_provider_new(struct z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); #endif +/** + * Takes ownership of the mutably borrowed SHM Provider + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +void z_shm_provider_take_loaned(struct z_owned_shm_provider_t *dst, + struct z_loaned_shm_provider_t *src); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Creates a new threadsafe SHM Provider. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_threadsafe_new(z_owned_shm_provider_t *this_, +void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_threadsafe_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); #endif +/** + * Takes ownership of the mutably borrowed shm + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API void z_shm_take_loaned(struct z_owned_shm_t *dst, struct z_loaned_shm_t *src); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_shm_mut_t *z_shm_try_mut(z_owned_shm_t *this_); +struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4492,7 +4467,7 @@ z_loaned_shm_mut_t *z_shm_try_mut(z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_loaned_shm_mut_t *z_shm_try_reloan_mut(z_loaned_shm_t *this_); +struct z_loaned_shm_mut_t *z_shm_try_reloan_mut(struct z_loaned_shm_t *this_); #endif /** * Puts current thread to sleep for specified amount of milliseconds. @@ -4563,13 +4538,17 @@ ZENOHC_API const struct z_loaned_slice_t *z_slice_loan(const struct z_owned_slic * Mutably borrows slice. */ ZENOHC_API struct z_loaned_slice_t *z_slice_loan_mut(struct z_owned_slice_t *this_); +/** + * Takes ownership of mutably borrowed slice + */ +ZENOHC_API void z_slice_take_loaned(struct z_owned_slice_t *dst, struct z_loaned_slice_t *src); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_drop(z_moved_source_info_t *this_); +void z_source_info_drop(struct z_moved_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4577,7 +4556,7 @@ void z_source_info_drop(z_moved_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); +struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4585,7 +4564,7 @@ z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *this_); +const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4593,7 +4572,7 @@ const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *th */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const z_loaned_source_info_t *z_source_info_loan_mut(const z_owned_source_info_t *this_); +const struct z_loaned_source_info_t *z_source_info_loan_mut(const struct z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4601,8 +4580,8 @@ const z_loaned_source_info_t *z_source_info_loan_mut(const z_owned_source_info_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t z_source_info_new(z_owned_source_info_t *this_, - const z_entity_global_id_t *source_id, +z_result_t z_source_info_new(struct z_owned_source_info_t *this_, + const struct z_entity_global_id_t *source_id, uint32_t source_sn); #endif /** @@ -4611,7 +4590,16 @@ z_result_t z_source_info_new(z_owned_source_info_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_source_info_sn(const z_loaned_source_info_t *this_); +uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Takes ownership of the mutably borrowed source info. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +void z_source_info_take_loaned(struct z_owned_source_info_t *dst, + struct z_loaned_source_info_t *src); #endif /** * Constructs an owned copy of a string array. @@ -4669,6 +4657,12 @@ size_t z_string_array_push_by_alias(struct z_loaned_string_array_t *this_, ZENOHC_API size_t z_string_array_push_by_copy(struct z_loaned_string_array_t *this_, const struct z_loaned_string_t *value); +/** + * Takes ownership of mutably borrowed string array. + */ +ZENOHC_API +void z_string_array_take_loaned(struct z_owned_string_array_t *dst, + struct z_loaned_string_array_t *src); ZENOHC_API const struct z_loaned_slice_t *z_string_as_slice(const struct z_loaned_string_t *this_); /** * Constructs an owned copy of a string. @@ -4732,6 +4726,10 @@ ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_st * Mutably borrows string. */ ZENOHC_API struct z_loaned_string_t *z_string_loan_mut(struct z_owned_string_t *this_); +/** + * Takes ownership of mutably borrowed string. + */ +ZENOHC_API void z_string_take_loaned(struct z_owned_string_t *dst, struct z_loaned_string_t *src); /** * Drops subscriber and resets it to its gravestone state. * The callback closure is not dropped and still keeps receiving and processing samples until the corresponding session is closed. @@ -4756,6 +4754,12 @@ ZENOHC_API struct z_loaned_subscriber_t *z_subscriber_loan_mut(struct z_owned_su * Constructs the default value for `z_subscriber_options_t`. */ ZENOHC_API void z_subscriber_options_default(struct z_subscriber_options_t *this_); +/** + * Takes ownership of the mutably borrowed subscriber + */ +ZENOHC_API +void z_subscriber_take_loaned(struct z_owned_subscriber_t *dst, + struct z_loaned_subscriber_t *src); /** * Detaches the task and releases all allocated resources. */ @@ -4813,7 +4817,7 @@ const char *z_time_now_as_str(const char *buf, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_id_t z_timestamp_id(const struct z_timestamp_t *this_); +struct z_id_t z_timestamp_id(const struct z_timestamp_t *this_); #endif /** * Create uhlc timestamp from session id. @@ -5188,7 +5192,7 @@ void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_s */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); +bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5196,7 +5200,7 @@ bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); +void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5204,7 +5208,7 @@ void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); +bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5212,7 +5216,7 @@ bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); +void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5220,7 +5224,7 @@ void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); +bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5228,7 +5232,7 @@ bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_internal_shm_client_list_null(zc_owned_shm_client_list_t *this_); +void zc_internal_shm_client_list_null(struct zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5272,7 +5276,7 @@ z_result_t zc_liveliness_declare_subscriber(struct z_owned_subscriber_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_declare_token(zc_owned_liveliness_token_t *this_, +z_result_t zc_liveliness_declare_token(struct zc_owned_liveliness_token_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, const struct zc_liveliness_declaration_options_t *_options); @@ -5315,7 +5319,7 @@ void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_op */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_liveliness_token_drop(zc_moved_liveliness_token_t *this_); +void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5323,7 +5327,7 @@ void zc_liveliness_token_drop(zc_moved_liveliness_token_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const zc_owned_liveliness_token_t *this_); +const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5331,7 +5335,7 @@ const zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const zc_owned_live */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); +z_result_t zc_liveliness_undeclare_token(struct zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5364,7 +5368,7 @@ z_result_t zc_publisher_get_matching_status(const struct z_loaned_publisher_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_publisher_matching_listener_declare(zc_owned_matching_listener_t *this_, +z_result_t zc_publisher_matching_listener_declare(struct zc_owned_matching_listener_t *this_, const struct z_loaned_publisher_t *publisher, struct zc_moved_closure_matching_status_t *callback); #endif @@ -5374,7 +5378,7 @@ z_result_t zc_publisher_matching_listener_declare(zc_owned_matching_listener_t * */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_publisher_matching_listener_drop(zc_moved_matching_listener_t *this_); +void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5384,7 +5388,7 @@ void zc_publisher_matching_listener_drop(zc_moved_matching_listener_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_publisher_matching_listener_undeclare(zc_moved_matching_listener_t *this_); +z_result_t zc_publisher_matching_listener_undeclare(struct zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5399,9 +5403,9 @@ enum zc_reply_keyexpr_t zc_reply_keyexpr_default(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, +z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, - z_moved_shm_client_t *client); + struct z_moved_shm_client_t *client); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5409,7 +5413,7 @@ z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_drop(zc_moved_shm_client_list_t *this_); +void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5417,7 +5421,7 @@ void zc_shm_client_list_drop(zc_moved_shm_client_list_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const zc_owned_shm_client_list_t *this_); +const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5425,7 +5429,7 @@ const zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const zc_owned_shm_cl */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(zc_owned_shm_client_list_t *this_); +struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5433,7 +5437,7 @@ zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(zc_owned_shm_client_lis */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_new(zc_owned_shm_client_list_t *this_); +void zc_shm_client_list_new(struct zc_owned_shm_client_list_t *this_); #endif /** * Stops all Zenoh tasks and drops all related static variables. @@ -5465,7 +5469,7 @@ void zc_try_init_log_from_env(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_declare_publication_cache(ze_owned_publication_cache_t *this_, +z_result_t ze_declare_publication_cache(struct ze_owned_publication_cache_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, struct ze_publication_cache_options_t *options); @@ -5484,7 +5488,7 @@ z_result_t ze_declare_publication_cache(ze_owned_publication_cache_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_declare_querying_subscriber(ze_owned_querying_subscriber_t *this_, +z_result_t ze_declare_querying_subscriber(struct ze_owned_querying_subscriber_t *this_, const struct z_loaned_session_t *session, const struct z_loaned_keyexpr_t *key_expr, struct z_moved_closure_sample_t *callback, @@ -5496,7 +5500,7 @@ z_result_t ze_declare_querying_subscriber(ze_owned_querying_subscriber_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); +bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5504,7 +5508,7 @@ bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); +void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5512,13 +5516,13 @@ void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); +bool ze_internal_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *this_); #endif /** * Constructs a querying subscriber in a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); +ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5526,7 +5530,7 @@ ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscribe */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_publication_cache_drop(ze_moved_publication_cache_t *this_); +void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5534,7 +5538,7 @@ void ze_publication_cache_drop(ze_moved_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const ze_loaned_publication_cache_t *this_); +const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_loaned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5542,7 +5546,7 @@ const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const ze_loaned_pu */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_publication_cache_t *this_); +const struct ze_loaned_publication_cache_t *ze_publication_cache_loan(const struct ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5559,7 +5563,7 @@ void ze_publication_cache_options_default(struct ze_publication_cache_options_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_); +void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5569,7 +5573,7 @@ void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_querying_subscriber_get(const ze_loaned_querying_subscriber_t *this_, +z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber_t *this_, const struct z_loaned_keyexpr_t *selector, struct z_get_options_t *options); #endif @@ -5579,7 +5583,7 @@ z_result_t ze_querying_subscriber_get(const ze_loaned_querying_subscriber_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const ze_owned_querying_subscriber_t *this_); +const struct ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5596,7 +5600,7 @@ void ze_querying_subscriber_options_default(struct ze_querying_subscriber_option */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_t *this_); +z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5606,5 +5610,5 @@ z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *this_); +z_result_t ze_undeclare_querying_subscriber(struct ze_moved_querying_subscriber_t *this_); #endif diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 0e3af2731..5213602ca 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -4,11 +4,14 @@ #ifndef __cplusplus +static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return (z_moved_alloc_layout_t*)(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return (z_moved_bytes_t*)(x); } +static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return (z_moved_chunk_alloc_result_t*)(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return (z_moved_closure_hello_t*)(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return (z_moved_closure_query_t*)(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return (z_moved_closure_reply_t*)(x); } static inline z_moved_closure_sample_t* z_closure_sample_move(z_owned_closure_sample_t* x) { return (z_moved_closure_sample_t*)(x); } +static inline z_moved_closure_zid_t* z_closure_zid_move(z_owned_closure_zid_t* x) { return (z_moved_closure_zid_t*)(x); } static inline z_moved_condvar_t* z_condvar_move(z_owned_condvar_t* x) { return (z_moved_condvar_t*)(x); } static inline z_moved_config_t* z_config_move(z_owned_config_t* x) { return (z_moved_config_t*)(x); } static inline z_moved_encoding_t* z_encoding_move(z_owned_encoding_t* x) { return (z_moved_encoding_t*)(x); } @@ -17,6 +20,7 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return (z_moved_fifo_handler_sample_t*)(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return (z_moved_hello_t*)(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return (z_moved_keyexpr_t*)(x); } +static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return (z_moved_memory_layout_t*)(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return (z_moved_mutex_t*)(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return (z_moved_publisher_t*)(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return (z_moved_query_t*)(x); } @@ -28,21 +32,36 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return (z_moved_ring_handler_sample_t*)(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return (z_moved_sample_t*)(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return (z_moved_session_t*)(x); } +static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return (z_moved_shm_client_t*)(x); } +static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return (z_moved_shm_client_storage_t*)(x); } +static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return (z_moved_shm_t*)(x); } +static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return (z_moved_shm_mut_t*)(x); } +static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return (z_moved_shm_provider_t*)(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return (z_moved_slice_t*)(x); } +static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return (z_moved_source_info_t*)(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return (z_moved_string_array_t*)(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return (z_moved_string_t*)(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return (z_moved_subscriber_t*)(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return (z_moved_task_t*)(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return (zc_moved_closure_log_t*)(x); } +static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return (zc_moved_closure_matching_status_t*)(x); } +static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return (zc_moved_liveliness_token_t*)(x); } +static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return (zc_moved_matching_listener_t*)(x); } +static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return (zc_moved_shm_client_list_t*)(x); } +static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return (ze_moved_publication_cache_t*)(x); } +static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return (ze_moved_querying_subscriber_t*)(x); } #define z_loan(this_) \ _Generic((this_), \ + z_owned_alloc_layout_t : z_alloc_layout_loan, \ z_owned_bytes_t : z_bytes_loan, \ + z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ z_owned_closure_query_t : z_closure_query_loan, \ z_owned_closure_reply_t : z_closure_reply_loan, \ z_owned_closure_sample_t : z_closure_sample_loan, \ + z_owned_closure_zid_t : z_closure_zid_loan, \ z_owned_condvar_t : z_condvar_loan, \ z_owned_config_t : z_config_loan, \ z_owned_encoding_t : z_encoding_loan, \ @@ -51,6 +70,7 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan, \ z_owned_hello_t : z_hello_loan, \ z_owned_keyexpr_t : z_keyexpr_loan, \ + z_owned_memory_layout_t : z_memory_layout_loan, \ z_owned_publisher_t : z_publisher_loan, \ z_owned_query_t : z_query_loan, \ z_owned_queryable_t : z_queryable_loan, \ @@ -61,23 +81,36 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_ring_handler_sample_t : z_ring_handler_sample_loan, \ z_owned_sample_t : z_sample_loan, \ z_owned_session_t : z_session_loan, \ + z_owned_shm_client_storage_t : z_shm_client_storage_loan, \ + z_owned_shm_t : z_shm_loan, \ + z_owned_shm_mut_t : z_shm_mut_loan, \ + z_owned_shm_provider_t : z_shm_provider_loan, \ z_owned_slice_t : z_slice_loan, \ + z_owned_source_info_t : z_source_info_loan, \ z_owned_string_array_t : z_string_array_loan, \ z_owned_string_t : z_string_loan, \ z_owned_subscriber_t : z_subscriber_loan, \ z_view_keyexpr_t : z_view_keyexpr_loan, \ z_view_slice_t : z_view_slice_loan, \ z_view_string_t : z_view_string_loan, \ - zc_owned_closure_log_t : zc_closure_log_loan \ + zc_owned_closure_log_t : zc_closure_log_loan, \ + zc_owned_closure_matching_status_t : zc_closure_matching_status_loan, \ + zc_owned_liveliness_token_t : zc_liveliness_token_loan, \ + zc_owned_shm_client_list_t : zc_shm_client_list_loan, \ + ze_owned_publication_cache_t : ze_publication_cache_loan, \ + ze_owned_querying_subscriber_t : ze_querying_subscriber_loan \ )(&this_) #define z_loan_mut(this_) \ _Generic((this_), \ + z_owned_alloc_layout_t : z_alloc_layout_loan_mut, \ z_owned_bytes_t : z_bytes_loan_mut, \ + z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan_mut, \ z_owned_closure_hello_t : z_closure_hello_loan_mut, \ z_owned_closure_query_t : z_closure_query_loan_mut, \ z_owned_closure_reply_t : z_closure_reply_loan_mut, \ z_owned_closure_sample_t : z_closure_sample_loan_mut, \ + z_owned_closure_zid_t : z_closure_zid_loan_mut, \ z_owned_condvar_t : z_condvar_loan_mut, \ z_owned_config_t : z_config_loan_mut, \ z_owned_encoding_t : z_encoding_loan_mut, \ @@ -86,6 +119,7 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan_mut, \ z_owned_hello_t : z_hello_loan_mut, \ z_owned_keyexpr_t : z_keyexpr_loan_mut, \ + z_owned_memory_layout_t : z_memory_layout_loan_mut, \ z_owned_mutex_t : z_mutex_loan_mut, \ z_owned_publisher_t : z_publisher_loan_mut, \ z_owned_query_t : z_query_loan_mut, \ @@ -97,19 +131,27 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_ring_handler_sample_t : z_ring_handler_sample_loan_mut, \ z_owned_sample_t : z_sample_loan_mut, \ z_owned_session_t : z_session_loan_mut, \ + z_owned_shm_client_storage_t : z_shm_client_storage_loan_mut, \ + z_owned_shm_t : z_shm_loan_mut, \ + z_owned_shm_mut_t : z_shm_mut_loan_mut, \ + z_owned_shm_provider_t : z_shm_provider_loan_mut, \ z_owned_slice_t : z_slice_loan_mut, \ z_owned_string_array_t : z_string_array_loan_mut, \ z_owned_string_t : z_string_loan_mut, \ - z_owned_subscriber_t : z_subscriber_loan_mut \ + z_owned_subscriber_t : z_subscriber_loan_mut, \ + zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut \ )(&this_) #define z_drop(this_) \ _Generic((this_), \ + z_moved_alloc_layout_t* : z_alloc_layout_drop, \ z_moved_bytes_t* : z_bytes_drop, \ + z_moved_chunk_alloc_result_t* : z_chunk_alloc_result_drop, \ z_moved_closure_hello_t* : z_closure_hello_drop, \ z_moved_closure_query_t* : z_closure_query_drop, \ z_moved_closure_reply_t* : z_closure_reply_drop, \ z_moved_closure_sample_t* : z_closure_sample_drop, \ + z_moved_closure_zid_t* : z_closure_zid_drop, \ z_moved_condvar_t* : z_condvar_drop, \ z_moved_config_t* : z_config_drop, \ z_moved_encoding_t* : z_encoding_drop, \ @@ -118,6 +160,7 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_moved_fifo_handler_sample_t* : z_fifo_handler_sample_drop, \ z_moved_hello_t* : z_hello_drop, \ z_moved_keyexpr_t* : z_keyexpr_drop, \ + z_moved_memory_layout_t* : z_memory_layout_drop, \ z_moved_mutex_t* : z_mutex_drop, \ z_moved_publisher_t* : z_publisher_drop, \ z_moved_query_t* : z_query_drop, \ @@ -129,21 +172,36 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_moved_ring_handler_sample_t* : z_ring_handler_sample_drop, \ z_moved_sample_t* : z_sample_drop, \ z_moved_session_t* : z_session_drop, \ + z_moved_shm_client_t* : z_shm_client_drop, \ + z_moved_shm_client_storage_t* : z_shm_client_storage_drop, \ + z_moved_shm_t* : z_shm_drop, \ + z_moved_shm_mut_t* : z_shm_mut_drop, \ + z_moved_shm_provider_t* : z_shm_provider_drop, \ z_moved_slice_t* : z_slice_drop, \ + z_moved_source_info_t* : z_source_info_drop, \ z_moved_string_array_t* : z_string_array_drop, \ z_moved_string_t* : z_string_drop, \ z_moved_subscriber_t* : z_subscriber_drop, \ z_moved_task_t* : z_task_drop, \ - zc_moved_closure_log_t* : zc_closure_log_drop \ + zc_moved_closure_log_t* : zc_closure_log_drop, \ + zc_moved_closure_matching_status_t* : zc_closure_matching_status_drop, \ + zc_moved_liveliness_token_t* : zc_liveliness_token_drop, \ + zc_moved_matching_listener_t* : zc_publisher_matching_listener_drop, \ + zc_moved_shm_client_list_t* : zc_shm_client_list_drop, \ + ze_moved_publication_cache_t* : ze_publication_cache_drop, \ + ze_moved_querying_subscriber_t* : ze_querying_subscriber_drop \ )(this_) #define z_move(this_) \ _Generic((this_), \ + z_owned_alloc_layout_t : z_alloc_layout_move, \ z_owned_bytes_t : z_bytes_move, \ + z_owned_chunk_alloc_result_t : z_chunk_alloc_result_move, \ z_owned_closure_hello_t : z_closure_hello_move, \ z_owned_closure_query_t : z_closure_query_move, \ z_owned_closure_reply_t : z_closure_reply_move, \ z_owned_closure_sample_t : z_closure_sample_move, \ + z_owned_closure_zid_t : z_closure_zid_move, \ z_owned_condvar_t : z_condvar_move, \ z_owned_config_t : z_config_move, \ z_owned_encoding_t : z_encoding_move, \ @@ -152,6 +210,7 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_fifo_handler_sample_t : z_fifo_handler_sample_move, \ z_owned_hello_t : z_hello_move, \ z_owned_keyexpr_t : z_keyexpr_move, \ + z_owned_memory_layout_t : z_memory_layout_move, \ z_owned_mutex_t : z_mutex_move, \ z_owned_publisher_t : z_publisher_move, \ z_owned_query_t : z_query_move, \ @@ -163,21 +222,36 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_ring_handler_sample_t : z_ring_handler_sample_move, \ z_owned_sample_t : z_sample_move, \ z_owned_session_t : z_session_move, \ + z_owned_shm_client_t : z_shm_client_move, \ + z_owned_shm_client_storage_t : z_shm_client_storage_move, \ + z_owned_shm_t : z_shm_move, \ + z_owned_shm_mut_t : z_shm_mut_move, \ + z_owned_shm_provider_t : z_shm_provider_move, \ z_owned_slice_t : z_slice_move, \ + z_owned_source_info_t : z_source_info_move, \ z_owned_string_array_t : z_string_array_move, \ z_owned_string_t : z_string_move, \ z_owned_subscriber_t : z_subscriber_move, \ z_owned_task_t : z_task_move, \ - zc_owned_closure_log_t : zc_closure_log_move \ + zc_owned_closure_log_t : zc_closure_log_move, \ + zc_owned_closure_matching_status_t : zc_closure_matching_status_move, \ + zc_owned_liveliness_token_t : zc_liveliness_token_move, \ + zc_owned_matching_listener_t : zc_publisher_matching_listener_move, \ + zc_owned_shm_client_list_t : zc_shm_client_list_move, \ + ze_owned_publication_cache_t : ze_publication_cache_move, \ + ze_owned_querying_subscriber_t : ze_querying_subscriber_move \ )(&this_) #define z_internal_null(this_) \ _Generic((this_), \ + z_owned_alloc_layout_t* : z_internal_alloc_layout_null, \ z_owned_bytes_t* : z_internal_bytes_null, \ + z_owned_chunk_alloc_result_t* : z_internal_chunk_alloc_result_null, \ z_owned_closure_hello_t* : z_internal_closure_hello_null, \ z_owned_closure_query_t* : z_internal_closure_query_null, \ z_owned_closure_reply_t* : z_internal_closure_reply_null, \ z_owned_closure_sample_t* : z_internal_closure_sample_null, \ + z_owned_closure_zid_t* : z_internal_closure_zid_null, \ z_owned_condvar_t* : z_internal_condvar_null, \ z_owned_config_t* : z_internal_config_null, \ z_owned_encoding_t* : z_internal_encoding_null, \ @@ -186,6 +260,7 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_fifo_handler_sample_t* : z_internal_fifo_handler_sample_null, \ z_owned_hello_t* : z_internal_hello_null, \ z_owned_keyexpr_t* : z_internal_keyexpr_null, \ + z_owned_memory_layout_t* : z_internal_memory_layout_null, \ z_owned_mutex_t* : z_internal_mutex_null, \ z_owned_publisher_t* : z_internal_publisher_null, \ z_owned_query_t* : z_internal_query_null, \ @@ -197,19 +272,34 @@ static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t z_owned_ring_handler_sample_t* : z_internal_ring_handler_sample_null, \ z_owned_sample_t* : z_internal_sample_null, \ z_owned_session_t* : z_internal_session_null, \ + z_owned_shm_client_t* : z_internal_shm_client_null, \ + z_owned_shm_client_storage_t* : z_internal_shm_client_storage_null, \ + z_owned_shm_mut_t* : z_internal_shm_mut_null, \ + z_owned_shm_t* : z_internal_shm_null, \ + z_owned_shm_provider_t* : z_internal_shm_provider_null, \ z_owned_slice_t* : z_internal_slice_null, \ + z_owned_source_info_t* : z_internal_source_info_null, \ z_owned_string_array_t* : z_internal_string_array_null, \ z_owned_string_t* : z_internal_string_null, \ z_owned_subscriber_t* : z_internal_subscriber_null, \ z_owned_task_t* : z_internal_task_null, \ - zc_owned_closure_log_t* : zc_internal_closure_log_null \ + zc_owned_closure_log_t* : zc_internal_closure_log_null, \ + zc_owned_closure_matching_status_t* : zc_internal_closure_matching_status_null, \ + zc_owned_liveliness_token_t* : zc_internal_liveliness_token_null, \ + zc_owned_matching_listener_t* : zc_internal_matching_listener_null, \ + zc_owned_shm_client_list_t* : zc_internal_shm_client_list_null, \ + ze_owned_publication_cache_t* : ze_internal_publication_cache_null, \ + ze_owned_querying_subscriber_t* : ze_internal_querying_subscriber_null \ )(this_) +static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } +static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } static inline void z_closure_sample_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { *closure_ = x->_this; z_internal_closure_sample_null(&x->_this); } +static inline void z_closure_zid_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { *closure_ = x->_this; z_internal_closure_zid_null(&x->_this); } static inline void z_condvar_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { *this_ = x->_this; z_internal_condvar_null(&x->_this); } static inline void z_config_take(z_owned_config_t* this_, z_moved_config_t* x) { *this_ = x->_this; z_internal_config_null(&x->_this); } static inline void z_encoding_take(z_owned_encoding_t* this_, z_moved_encoding_t* x) { *this_ = x->_this; z_internal_encoding_null(&x->_this); } @@ -218,6 +308,7 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } +static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -229,21 +320,36 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } +static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } +static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } +static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } +static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } +static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } +static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } +static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } +static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } +static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } +static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } +static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } +static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } #define z_take(this_, x) \ _Generic((this_), \ + z_owned_alloc_layout_t* : z_alloc_layout_take, \ z_owned_bytes_t* : z_bytes_take, \ + z_owned_chunk_alloc_result_t* : z_chunk_alloc_result_take, \ z_owned_closure_hello_t* : z_closure_hello_take, \ z_owned_closure_query_t* : z_closure_query_take, \ z_owned_closure_reply_t* : z_closure_reply_take, \ z_owned_closure_sample_t* : z_closure_sample_take, \ + z_owned_closure_zid_t* : z_closure_zid_take, \ z_owned_condvar_t* : z_condvar_take, \ z_owned_config_t* : z_config_take, \ z_owned_encoding_t* : z_encoding_take, \ @@ -252,6 +358,7 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move z_owned_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ z_owned_hello_t* : z_hello_take, \ z_owned_keyexpr_t* : z_keyexpr_take, \ + z_owned_memory_layout_t* : z_memory_layout_take, \ z_owned_mutex_t* : z_mutex_take, \ z_owned_publisher_t* : z_publisher_take, \ z_owned_query_t* : z_query_take, \ @@ -263,21 +370,36 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ z_owned_sample_t* : z_sample_take, \ z_owned_session_t* : z_session_take, \ + z_owned_shm_client_t* : z_shm_client_take, \ + z_owned_shm_client_storage_t* : z_shm_client_storage_take, \ + z_owned_shm_t* : z_shm_take, \ + z_owned_shm_mut_t* : z_shm_mut_take, \ + z_owned_shm_provider_t* : z_shm_provider_take, \ z_owned_slice_t* : z_slice_take, \ + z_owned_source_info_t* : z_source_info_take, \ z_owned_string_array_t* : z_string_array_take, \ z_owned_string_t* : z_string_take, \ z_owned_subscriber_t* : z_subscriber_take, \ z_owned_task_t* : z_task_take, \ - zc_owned_closure_log_t* : zc_closure_log_take \ + zc_owned_closure_log_t* : zc_closure_log_take, \ + zc_owned_closure_matching_status_t* : zc_closure_matching_status_take, \ + zc_owned_liveliness_token_t* : zc_liveliness_token_take, \ + zc_owned_matching_listener_t* : zc_publisher_matching_listener_take, \ + zc_owned_shm_client_list_t* : zc_shm_client_list_take, \ + ze_owned_publication_cache_t* : ze_publication_cache_take, \ + ze_owned_querying_subscriber_t* : ze_querying_subscriber_take \ )(this_, x) #define z_internal_check(this_) \ _Generic((this_), \ + z_owned_alloc_layout_t : z_internal_alloc_layout_check, \ z_owned_bytes_t : z_internal_bytes_check, \ + z_owned_chunk_alloc_result_t : z_internal_chunk_alloc_result_check, \ z_owned_closure_hello_t : z_internal_closure_hello_check, \ z_owned_closure_query_t : z_internal_closure_query_check, \ z_owned_closure_reply_t : z_internal_closure_reply_check, \ z_owned_closure_sample_t : z_internal_closure_sample_check, \ + z_owned_closure_zid_t : z_internal_closure_zid_check, \ z_owned_condvar_t : z_internal_condvar_check, \ z_owned_config_t : z_internal_config_check, \ z_owned_encoding_t : z_internal_encoding_check, \ @@ -286,6 +408,7 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move z_owned_fifo_handler_sample_t : z_internal_fifo_handler_sample_check, \ z_owned_hello_t : z_internal_hello_check, \ z_owned_keyexpr_t : z_internal_keyexpr_check, \ + z_owned_memory_layout_t : z_internal_memory_layout_check, \ z_owned_mutex_t : z_internal_mutex_check, \ z_owned_publisher_t : z_internal_publisher_check, \ z_owned_query_t : z_internal_query_check, \ @@ -297,12 +420,24 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ z_owned_sample_t : z_internal_sample_check, \ z_owned_session_t : z_internal_session_check, \ + z_owned_shm_t : z_internal_shm_check, \ + z_owned_shm_client_t : z_internal_shm_client_check, \ + z_owned_shm_client_storage_t : z_internal_shm_client_storage_check, \ + z_owned_shm_mut_t : z_internal_shm_mut_check, \ + z_owned_shm_provider_t : z_internal_shm_provider_check, \ z_owned_slice_t : z_internal_slice_check, \ + z_owned_source_info_t : z_internal_source_info_check, \ z_owned_string_array_t : z_internal_string_array_check, \ z_owned_string_t : z_internal_string_check, \ z_owned_subscriber_t : z_internal_subscriber_check, \ z_owned_task_t : z_internal_task_check, \ - zc_owned_closure_log_t : zc_internal_closure_log_check \ + zc_owned_closure_log_t : zc_internal_closure_log_check, \ + zc_owned_closure_matching_status_t : zc_internal_closure_matching_status_check, \ + zc_owned_liveliness_token_t : zc_internal_liveliness_token_check, \ + zc_owned_matching_listener_t : zc_internal_matching_listener_check, \ + zc_owned_shm_client_list_t : zc_internal_shm_client_list_check, \ + ze_owned_publication_cache_t : ze_internal_publication_cache_check, \ + ze_owned_querying_subscriber_t : ze_internal_querying_subscriber_check \ )(&this_) #define z_call(closure, hello) \ @@ -310,7 +445,9 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move const z_loaned_closure_hello_t* : z_closure_hello_call, \ const z_loaned_closure_query_t* : z_closure_query_call, \ const z_loaned_closure_reply_t* : z_closure_reply_call, \ - const z_loaned_closure_sample_t* : z_closure_sample_call \ + const z_loaned_closure_sample_t* : z_closure_sample_call, \ + const z_loaned_closure_zid_t* : z_closure_zid_call, \ + const zc_loaned_closure_matching_status_t* : zc_closure_matching_status_call \ )(closure, hello) #define z_closure(this_, call, drop, context) \ @@ -319,7 +456,9 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move z_owned_closure_query_t* : z_closure_query, \ z_owned_closure_reply_t* : z_closure_reply, \ z_owned_closure_sample_t* : z_closure_sample, \ - zc_owned_closure_log_t* : zc_closure_log \ + z_owned_closure_zid_t* : z_closure_zid, \ + zc_owned_closure_log_t* : zc_closure_log, \ + zc_owned_closure_matching_status_t* : zc_closure_matching_status \ )(this_, call, drop, context) #define z_try_recv(this_, query) \ @@ -353,6 +492,8 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move z_owned_reply_t* : z_reply_clone, \ z_owned_reply_err_t* : z_reply_err_clone, \ z_owned_sample_t* : z_sample_clone, \ + z_owned_shm_client_storage_t* : z_shm_client_storage_clone, \ + z_owned_shm_t* : z_shm_clone, \ z_owned_slice_t* : z_slice_clone, \ z_owned_string_array_t* : z_string_array_clone, \ z_owned_string_t* : z_string_clone \ @@ -360,11 +501,14 @@ static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_move #else // #ifndef __cplusplus +static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return reinterpret_cast(x); } +static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_sample_t* z_closure_sample_move(z_owned_closure_sample_t* x) { return reinterpret_cast(x); } +static inline z_moved_closure_zid_t* z_closure_zid_move(z_owned_closure_zid_t* x) { return reinterpret_cast(x); } static inline z_moved_condvar_t* z_condvar_move(z_owned_condvar_t* x) { return reinterpret_cast(x); } static inline z_moved_config_t* z_config_move(z_owned_config_t* x) { return reinterpret_cast(x); } static inline z_moved_encoding_t* z_encoding_move(z_owned_encoding_t* x) { return reinterpret_cast(x); } @@ -373,6 +517,7 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return reinterpret_cast(x); } +static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return reinterpret_cast(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return reinterpret_cast(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return reinterpret_cast(x); } @@ -384,20 +529,35 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return reinterpret_cast(x); } +static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return reinterpret_cast(x); } +static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return reinterpret_cast(x); } +static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return reinterpret_cast(x); } +static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return reinterpret_cast(x); } +static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return reinterpret_cast(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return reinterpret_cast(x); } +static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return reinterpret_cast(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return reinterpret_cast(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return reinterpret_cast(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return reinterpret_cast(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return reinterpret_cast(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return reinterpret_cast(x); } +static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return reinterpret_cast(x); } +static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return reinterpret_cast(x); } +static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return reinterpret_cast(x); } +static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return reinterpret_cast(x); } +static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return reinterpret_cast(x); } +static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return reinterpret_cast(x); } +inline const z_loaned_alloc_layout_t* z_loan(const z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan(&this_); }; inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& this_) { return z_bytes_loan(&this_); }; +inline const z_loaned_chunk_alloc_result_t* z_loan(const z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan(&this_); }; inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& closure) { return z_closure_hello_loan(&closure); }; inline const z_loaned_closure_query_t* z_loan(const z_owned_closure_query_t& closure) { return z_closure_query_loan(&closure); }; inline const z_loaned_closure_reply_t* z_loan(const z_owned_closure_reply_t& closure) { return z_closure_reply_loan(&closure); }; inline const z_loaned_closure_sample_t* z_loan(const z_owned_closure_sample_t& closure) { return z_closure_sample_loan(&closure); }; +inline const z_loaned_closure_zid_t* z_loan(const z_owned_closure_zid_t& closure) { return z_closure_zid_loan(&closure); }; inline const z_loaned_condvar_t* z_loan(const z_owned_condvar_t& this_) { return z_condvar_loan(&this_); }; inline const z_loaned_config_t* z_loan(const z_owned_config_t& this_) { return z_config_loan(&this_); }; inline const z_loaned_encoding_t* z_loan(const z_owned_encoding_t& this_) { return z_encoding_loan(&this_); }; @@ -406,6 +566,7 @@ inline const z_loaned_fifo_handler_reply_t* z_loan(const z_owned_fifo_handler_re inline const z_loaned_fifo_handler_sample_t* z_loan(const z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan(&this_); }; inline const z_loaned_hello_t* z_loan(const z_owned_hello_t& this_) { return z_hello_loan(&this_); }; inline const z_loaned_keyexpr_t* z_loan(const z_owned_keyexpr_t& this_) { return z_keyexpr_loan(&this_); }; +inline const z_loaned_memory_layout_t* z_loan(const z_owned_memory_layout_t& this_) { return z_memory_layout_loan(&this_); }; inline const z_loaned_publisher_t* z_loan(const z_owned_publisher_t& this_) { return z_publisher_loan(&this_); }; inline const z_loaned_query_t* z_loan(const z_owned_query_t& this_) { return z_query_loan(&this_); }; inline const z_loaned_queryable_t* z_loan(const z_owned_queryable_t& this_) { return z_queryable_loan(&this_); }; @@ -416,7 +577,12 @@ inline const z_loaned_ring_handler_reply_t* z_loan(const z_owned_ring_handler_re inline const z_loaned_ring_handler_sample_t* z_loan(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan(&this_); }; inline const z_loaned_sample_t* z_loan(const z_owned_sample_t& this_) { return z_sample_loan(&this_); }; inline const z_loaned_session_t* z_loan(const z_owned_session_t& this_) { return z_session_loan(&this_); }; +inline const z_loaned_shm_client_storage_t* z_loan(const z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan(&this_); }; +inline const z_loaned_shm_t* z_loan(const z_owned_shm_t& this_) { return z_shm_loan(&this_); }; +inline const z_loaned_shm_mut_t* z_loan(const z_owned_shm_mut_t& this_) { return z_shm_mut_loan(&this_); }; +inline const z_loaned_shm_provider_t* z_loan(const z_owned_shm_provider_t& this_) { return z_shm_provider_loan(&this_); }; inline const z_loaned_slice_t* z_loan(const z_owned_slice_t& this_) { return z_slice_loan(&this_); }; +inline const z_loaned_source_info_t* z_loan(const z_owned_source_info_t& this_) { return z_source_info_loan(&this_); }; inline const z_loaned_string_array_t* z_loan(const z_owned_string_array_t& this_) { return z_string_array_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_owned_string_t& this_) { return z_string_loan(&this_); }; inline const z_loaned_subscriber_t* z_loan(const z_owned_subscriber_t& this_) { return z_subscriber_loan(&this_); }; @@ -424,13 +590,21 @@ inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& this_) { return inline const z_loaned_slice_t* z_loan(const z_view_slice_t& this_) { return z_view_slice_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_view_string_t& this_) { return z_view_string_loan(&this_); }; inline const zc_loaned_closure_log_t* z_loan(const zc_owned_closure_log_t& closure) { return zc_closure_log_loan(&closure); }; +inline const zc_loaned_closure_matching_status_t* z_loan(const zc_owned_closure_matching_status_t& closure) { return zc_closure_matching_status_loan(&closure); }; +inline const zc_loaned_liveliness_token_t* z_loan(const zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_loan(&this_); }; +inline const zc_loaned_shm_client_list_t* z_loan(const zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan(&this_); }; +inline const ze_loaned_publication_cache_t* z_loan(const ze_owned_publication_cache_t& this_) { return ze_publication_cache_loan(&this_); }; +inline const ze_loaned_querying_subscriber_t* z_loan(const ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_loan(&this_); }; +inline z_loaned_alloc_layout_t* z_loan_mut(z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan_mut(&this_); }; inline z_loaned_bytes_t* z_loan_mut(z_owned_bytes_t& this_) { return z_bytes_loan_mut(&this_); }; +inline z_loaned_chunk_alloc_result_t* z_loan_mut(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan_mut(&this_); }; inline z_loaned_closure_hello_t* z_loan_mut(z_owned_closure_hello_t& closure) { return z_closure_hello_loan_mut(&closure); }; inline z_loaned_closure_query_t* z_loan_mut(z_owned_closure_query_t& closure) { return z_closure_query_loan_mut(&closure); }; inline z_loaned_closure_reply_t* z_loan_mut(z_owned_closure_reply_t& closure) { return z_closure_reply_loan_mut(&closure); }; inline z_loaned_closure_sample_t* z_loan_mut(z_owned_closure_sample_t& closure) { return z_closure_sample_loan_mut(&closure); }; +inline z_loaned_closure_zid_t* z_loan_mut(z_owned_closure_zid_t& closure) { return z_closure_zid_loan_mut(&closure); }; inline z_loaned_condvar_t* z_loan_mut(z_owned_condvar_t& this_) { return z_condvar_loan_mut(&this_); }; inline z_loaned_config_t* z_loan_mut(z_owned_config_t& this_) { return z_config_loan_mut(&this_); }; inline z_loaned_encoding_t* z_loan_mut(z_owned_encoding_t& this_) { return z_encoding_loan_mut(&this_); }; @@ -439,6 +613,7 @@ inline z_loaned_fifo_handler_reply_t* z_loan_mut(z_owned_fifo_handler_reply_t& t inline z_loaned_fifo_handler_sample_t* z_loan_mut(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan_mut(&this_); }; inline z_loaned_hello_t* z_loan_mut(z_owned_hello_t& this_) { return z_hello_loan_mut(&this_); }; inline z_loaned_keyexpr_t* z_loan_mut(z_owned_keyexpr_t& this_) { return z_keyexpr_loan_mut(&this_); }; +inline z_loaned_memory_layout_t* z_loan_mut(z_owned_memory_layout_t& this_) { return z_memory_layout_loan_mut(&this_); }; inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& this_) { return z_mutex_loan_mut(&this_); }; inline z_loaned_publisher_t* z_loan_mut(z_owned_publisher_t& this_) { return z_publisher_loan_mut(&this_); }; inline z_loaned_query_t* z_loan_mut(z_owned_query_t& this_) { return z_query_loan_mut(&this_); }; @@ -450,17 +625,25 @@ inline z_loaned_ring_handler_reply_t* z_loan_mut(z_owned_ring_handler_reply_t& t inline z_loaned_ring_handler_sample_t* z_loan_mut(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan_mut(&this_); }; inline z_loaned_sample_t* z_loan_mut(z_owned_sample_t& this_) { return z_sample_loan_mut(&this_); }; inline z_loaned_session_t* z_loan_mut(z_owned_session_t& this_) { return z_session_loan_mut(&this_); }; +inline z_loaned_shm_client_storage_t* z_loan_mut(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan_mut(&this_); }; +inline z_loaned_shm_t* z_loan_mut(z_owned_shm_t& this_) { return z_shm_loan_mut(&this_); }; +inline z_loaned_shm_mut_t* z_loan_mut(z_owned_shm_mut_t& this_) { return z_shm_mut_loan_mut(&this_); }; +inline z_loaned_shm_provider_t* z_loan_mut(z_owned_shm_provider_t& this_) { return z_shm_provider_loan_mut(&this_); }; inline z_loaned_slice_t* z_loan_mut(z_owned_slice_t& this_) { return z_slice_loan_mut(&this_); }; inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { return z_string_array_loan_mut(&this_); }; inline z_loaned_string_t* z_loan_mut(z_owned_string_t& this_) { return z_string_loan_mut(&this_); }; inline z_loaned_subscriber_t* z_loan_mut(z_owned_subscriber_t& this_) { return z_subscriber_loan_mut(&this_); }; +inline zc_loaned_shm_client_list_t* z_loan_mut(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan_mut(&this_); }; +inline void z_drop(z_moved_alloc_layout_t* this_) { z_alloc_layout_drop(this_); }; inline void z_drop(z_moved_bytes_t* this_) { z_bytes_drop(this_); }; +inline void z_drop(z_moved_chunk_alloc_result_t* this_) { z_chunk_alloc_result_drop(this_); }; inline void z_drop(z_moved_closure_hello_t* this_) { z_closure_hello_drop(this_); }; inline void z_drop(z_moved_closure_query_t* closure_) { z_closure_query_drop(closure_); }; inline void z_drop(z_moved_closure_reply_t* closure_) { z_closure_reply_drop(closure_); }; inline void z_drop(z_moved_closure_sample_t* closure_) { z_closure_sample_drop(closure_); }; +inline void z_drop(z_moved_closure_zid_t* closure_) { z_closure_zid_drop(closure_); }; inline void z_drop(z_moved_condvar_t* this_) { z_condvar_drop(this_); }; inline void z_drop(z_moved_config_t* this_) { z_config_drop(this_); }; inline void z_drop(z_moved_encoding_t* this_) { z_encoding_drop(this_); }; @@ -469,6 +652,7 @@ inline void z_drop(z_moved_fifo_handler_reply_t* this_) { z_fifo_handler_reply_d inline void z_drop(z_moved_fifo_handler_sample_t* this_) { z_fifo_handler_sample_drop(this_); }; inline void z_drop(z_moved_hello_t* this_) { z_hello_drop(this_); }; inline void z_drop(z_moved_keyexpr_t* this_) { z_keyexpr_drop(this_); }; +inline void z_drop(z_moved_memory_layout_t* this_) { z_memory_layout_drop(this_); }; inline void z_drop(z_moved_mutex_t* this_) { z_mutex_drop(this_); }; inline void z_drop(z_moved_publisher_t* this_) { z_publisher_drop(this_); }; inline void z_drop(z_moved_query_t* this_) { z_query_drop(this_); }; @@ -480,19 +664,34 @@ inline void z_drop(z_moved_ring_handler_reply_t* this_) { z_ring_handler_reply_d inline void z_drop(z_moved_ring_handler_sample_t* this_) { z_ring_handler_sample_drop(this_); }; inline void z_drop(z_moved_sample_t* this_) { z_sample_drop(this_); }; inline void z_drop(z_moved_session_t* this_) { z_session_drop(this_); }; +inline void z_drop(z_moved_shm_client_t* this_) { z_shm_client_drop(this_); }; +inline void z_drop(z_moved_shm_client_storage_t* this_) { z_shm_client_storage_drop(this_); }; +inline void z_drop(z_moved_shm_t* this_) { z_shm_drop(this_); }; +inline void z_drop(z_moved_shm_mut_t* this_) { z_shm_mut_drop(this_); }; +inline void z_drop(z_moved_shm_provider_t* this_) { z_shm_provider_drop(this_); }; inline void z_drop(z_moved_slice_t* this_) { z_slice_drop(this_); }; +inline void z_drop(z_moved_source_info_t* this_) { z_source_info_drop(this_); }; inline void z_drop(z_moved_string_array_t* this_) { z_string_array_drop(this_); }; inline void z_drop(z_moved_string_t* this_) { z_string_drop(this_); }; inline void z_drop(z_moved_subscriber_t* this_) { z_subscriber_drop(this_); }; inline void z_drop(z_moved_task_t* this_) { z_task_drop(this_); }; inline void z_drop(zc_moved_closure_log_t* closure_) { zc_closure_log_drop(closure_); }; +inline void z_drop(zc_moved_closure_matching_status_t* closure_) { zc_closure_matching_status_drop(closure_); }; +inline void z_drop(zc_moved_liveliness_token_t* this_) { zc_liveliness_token_drop(this_); }; +inline void z_drop(zc_moved_matching_listener_t* this_) { zc_publisher_matching_listener_drop(this_); }; +inline void z_drop(zc_moved_shm_client_list_t* this_) { zc_shm_client_list_drop(this_); }; +inline void z_drop(ze_moved_publication_cache_t* this_) { ze_publication_cache_drop(this_); }; +inline void z_drop(ze_moved_querying_subscriber_t* this_) { ze_querying_subscriber_drop(this_); }; +inline z_moved_alloc_layout_t* z_move(z_owned_alloc_layout_t& this_) { return z_alloc_layout_move(&this_); }; inline z_moved_bytes_t* z_move(z_owned_bytes_t& this_) { return z_bytes_move(&this_); }; +inline z_moved_chunk_alloc_result_t* z_move(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_move(&this_); }; inline z_moved_closure_hello_t* z_move(z_owned_closure_hello_t& this_) { return z_closure_hello_move(&this_); }; inline z_moved_closure_query_t* z_move(z_owned_closure_query_t& closure_) { return z_closure_query_move(&closure_); }; inline z_moved_closure_reply_t* z_move(z_owned_closure_reply_t& closure_) { return z_closure_reply_move(&closure_); }; inline z_moved_closure_sample_t* z_move(z_owned_closure_sample_t& closure_) { return z_closure_sample_move(&closure_); }; +inline z_moved_closure_zid_t* z_move(z_owned_closure_zid_t& closure_) { return z_closure_zid_move(&closure_); }; inline z_moved_condvar_t* z_move(z_owned_condvar_t& this_) { return z_condvar_move(&this_); }; inline z_moved_config_t* z_move(z_owned_config_t& this_) { return z_config_move(&this_); }; inline z_moved_encoding_t* z_move(z_owned_encoding_t& this_) { return z_encoding_move(&this_); }; @@ -501,6 +700,7 @@ inline z_moved_fifo_handler_reply_t* z_move(z_owned_fifo_handler_reply_t& this_) inline z_moved_fifo_handler_sample_t* z_move(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_move(&this_); }; inline z_moved_hello_t* z_move(z_owned_hello_t& this_) { return z_hello_move(&this_); }; inline z_moved_keyexpr_t* z_move(z_owned_keyexpr_t& this_) { return z_keyexpr_move(&this_); }; +inline z_moved_memory_layout_t* z_move(z_owned_memory_layout_t& this_) { return z_memory_layout_move(&this_); }; inline z_moved_mutex_t* z_move(z_owned_mutex_t& this_) { return z_mutex_move(&this_); }; inline z_moved_publisher_t* z_move(z_owned_publisher_t& this_) { return z_publisher_move(&this_); }; inline z_moved_query_t* z_move(z_owned_query_t& this_) { return z_query_move(&this_); }; @@ -512,19 +712,34 @@ inline z_moved_ring_handler_reply_t* z_move(z_owned_ring_handler_reply_t& this_) inline z_moved_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_move(&this_); }; inline z_moved_sample_t* z_move(z_owned_sample_t& this_) { return z_sample_move(&this_); }; inline z_moved_session_t* z_move(z_owned_session_t& this_) { return z_session_move(&this_); }; +inline z_moved_shm_client_t* z_move(z_owned_shm_client_t& this_) { return z_shm_client_move(&this_); }; +inline z_moved_shm_client_storage_t* z_move(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_move(&this_); }; +inline z_moved_shm_t* z_move(z_owned_shm_t& this_) { return z_shm_move(&this_); }; +inline z_moved_shm_mut_t* z_move(z_owned_shm_mut_t& this_) { return z_shm_mut_move(&this_); }; +inline z_moved_shm_provider_t* z_move(z_owned_shm_provider_t& this_) { return z_shm_provider_move(&this_); }; inline z_moved_slice_t* z_move(z_owned_slice_t& this_) { return z_slice_move(&this_); }; +inline z_moved_source_info_t* z_move(z_owned_source_info_t& this_) { return z_source_info_move(&this_); }; inline z_moved_string_array_t* z_move(z_owned_string_array_t& this_) { return z_string_array_move(&this_); }; inline z_moved_string_t* z_move(z_owned_string_t& this_) { return z_string_move(&this_); }; inline z_moved_subscriber_t* z_move(z_owned_subscriber_t& this_) { return z_subscriber_move(&this_); }; inline z_moved_task_t* z_move(z_owned_task_t& this_) { return z_task_move(&this_); }; inline zc_moved_closure_log_t* z_move(zc_owned_closure_log_t& closure_) { return zc_closure_log_move(&closure_); }; +inline zc_moved_closure_matching_status_t* z_move(zc_owned_closure_matching_status_t& closure_) { return zc_closure_matching_status_move(&closure_); }; +inline zc_moved_liveliness_token_t* z_move(zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_move(&this_); }; +inline zc_moved_matching_listener_t* z_move(zc_owned_matching_listener_t& this_) { return zc_publisher_matching_listener_move(&this_); }; +inline zc_moved_shm_client_list_t* z_move(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_move(&this_); }; +inline ze_moved_publication_cache_t* z_move(ze_owned_publication_cache_t& this_) { return ze_publication_cache_move(&this_); }; +inline ze_moved_querying_subscriber_t* z_move(ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_move(&this_); }; +inline void z_internal_null(z_owned_alloc_layout_t* this_) { z_internal_alloc_layout_null(this_); }; inline void z_internal_null(z_owned_bytes_t* this_) { z_internal_bytes_null(this_); }; +inline void z_internal_null(z_owned_chunk_alloc_result_t* this_) { z_internal_chunk_alloc_result_null(this_); }; inline void z_internal_null(z_owned_closure_hello_t* this_) { z_internal_closure_hello_null(this_); }; inline void z_internal_null(z_owned_closure_query_t* this_) { z_internal_closure_query_null(this_); }; inline void z_internal_null(z_owned_closure_reply_t* this_) { z_internal_closure_reply_null(this_); }; inline void z_internal_null(z_owned_closure_sample_t* this_) { z_internal_closure_sample_null(this_); }; +inline void z_internal_null(z_owned_closure_zid_t* this_) { z_internal_closure_zid_null(this_); }; inline void z_internal_null(z_owned_condvar_t* this_) { z_internal_condvar_null(this_); }; inline void z_internal_null(z_owned_config_t* this_) { z_internal_config_null(this_); }; inline void z_internal_null(z_owned_encoding_t* this_) { z_internal_encoding_null(this_); }; @@ -533,6 +748,7 @@ inline void z_internal_null(z_owned_fifo_handler_reply_t* this_) { z_internal_fi inline void z_internal_null(z_owned_fifo_handler_sample_t* this_) { z_internal_fifo_handler_sample_null(this_); }; inline void z_internal_null(z_owned_hello_t* this_) { z_internal_hello_null(this_); }; inline void z_internal_null(z_owned_keyexpr_t* this_) { z_internal_keyexpr_null(this_); }; +inline void z_internal_null(z_owned_memory_layout_t* this_) { z_internal_memory_layout_null(this_); }; inline void z_internal_null(z_owned_mutex_t* this_) { z_internal_mutex_null(this_); }; inline void z_internal_null(z_owned_publisher_t* this_) { z_internal_publisher_null(this_); }; inline void z_internal_null(z_owned_query_t* this_) { z_internal_query_null(this_); }; @@ -544,18 +760,33 @@ inline void z_internal_null(z_owned_ring_handler_reply_t* this_) { z_internal_ri inline void z_internal_null(z_owned_ring_handler_sample_t* this_) { z_internal_ring_handler_sample_null(this_); }; inline void z_internal_null(z_owned_sample_t* this_) { z_internal_sample_null(this_); }; inline void z_internal_null(z_owned_session_t* this_) { z_internal_session_null(this_); }; +inline void z_internal_null(z_owned_shm_client_t* this_) { z_internal_shm_client_null(this_); }; +inline void z_internal_null(z_owned_shm_client_storage_t* this_) { z_internal_shm_client_storage_null(this_); }; +inline void z_internal_null(z_owned_shm_mut_t* this_) { z_internal_shm_mut_null(this_); }; +inline void z_internal_null(z_owned_shm_t* this_) { z_internal_shm_null(this_); }; +inline void z_internal_null(z_owned_shm_provider_t* this_) { z_internal_shm_provider_null(this_); }; inline void z_internal_null(z_owned_slice_t* this_) { z_internal_slice_null(this_); }; +inline void z_internal_null(z_owned_source_info_t* this_) { z_internal_source_info_null(this_); }; inline void z_internal_null(z_owned_string_array_t* this_) { z_internal_string_array_null(this_); }; inline void z_internal_null(z_owned_string_t* this_) { z_internal_string_null(this_); }; inline void z_internal_null(z_owned_subscriber_t* this_) { z_internal_subscriber_null(this_); }; inline void z_internal_null(z_owned_task_t* this_) { z_internal_task_null(this_); }; inline void z_internal_null(zc_owned_closure_log_t* this_) { zc_internal_closure_log_null(this_); }; +inline void z_internal_null(zc_owned_closure_matching_status_t* this_) { zc_internal_closure_matching_status_null(this_); }; +inline void z_internal_null(zc_owned_liveliness_token_t* this_) { zc_internal_liveliness_token_null(this_); }; +inline void z_internal_null(zc_owned_matching_listener_t* this_) { zc_internal_matching_listener_null(this_); }; +inline void z_internal_null(zc_owned_shm_client_list_t* this_) { zc_internal_shm_client_list_null(this_); }; +inline void z_internal_null(ze_owned_publication_cache_t* this_) { ze_internal_publication_cache_null(this_); }; +inline void z_internal_null(ze_owned_querying_subscriber_t* this_) { ze_internal_querying_subscriber_null(this_); }; +static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } +static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } static inline void z_closure_sample_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { *closure_ = x->_this; z_internal_closure_sample_null(&x->_this); } +static inline void z_closure_zid_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { *closure_ = x->_this; z_internal_closure_zid_null(&x->_this); } static inline void z_condvar_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { *this_ = x->_this; z_internal_condvar_null(&x->_this); } static inline void z_config_take(z_owned_config_t* this_, z_moved_config_t* x) { *this_ = x->_this; z_internal_config_null(&x->_this); } static inline void z_encoding_take(z_owned_encoding_t* this_, z_moved_encoding_t* x) { *this_ = x->_this; z_internal_encoding_null(&x->_this); } @@ -564,6 +795,7 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } +static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -575,18 +807,36 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } +static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } +static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } +static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } +static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } +static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } +static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } +static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } +static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } +static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } +static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } +static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } +static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } +inline void z_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { + z_alloc_layout_take(this_, x); +}; inline void z_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { z_bytes_take(this_, x); }; +inline void z_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { + z_chunk_alloc_result_take(this_, x); +}; inline void z_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { z_closure_hello_take(this_, x); }; @@ -599,6 +849,9 @@ inline void z_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x inline void z_take(z_owned_closure_sample_t* closure_, z_moved_closure_sample_t* x) { z_closure_sample_take(closure_, x); }; +inline void z_take(z_owned_closure_zid_t* closure_, z_moved_closure_zid_t* x) { + z_closure_zid_take(closure_, x); +}; inline void z_take(z_owned_condvar_t* this_, z_moved_condvar_t* x) { z_condvar_take(this_, x); }; @@ -623,6 +876,9 @@ inline void z_take(z_owned_hello_t* this_, z_moved_hello_t* x) { inline void z_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { z_keyexpr_take(this_, x); }; +inline void z_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { + z_memory_layout_take(this_, x); +}; inline void z_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { z_mutex_take(this_, x); }; @@ -656,9 +912,27 @@ inline void z_take(z_owned_sample_t* this_, z_moved_sample_t* x) { inline void z_take(z_owned_session_t* this_, z_moved_session_t* x) { z_session_take(this_, x); }; +inline void z_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { + z_shm_client_take(this_, x); +}; +inline void z_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { + z_shm_client_storage_take(this_, x); +}; +inline void z_take(z_owned_shm_t* this_, z_moved_shm_t* x) { + z_shm_take(this_, x); +}; +inline void z_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { + z_shm_mut_take(this_, x); +}; +inline void z_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { + z_shm_provider_take(this_, x); +}; inline void z_take(z_owned_slice_t* this_, z_moved_slice_t* x) { z_slice_take(this_, x); }; +inline void z_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { + z_source_info_take(this_, x); +}; inline void z_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { z_string_array_take(this_, x); }; @@ -674,13 +948,34 @@ inline void z_take(z_owned_task_t* this_, z_moved_task_t* x) { inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { zc_closure_log_take(closure_, x); }; +inline void z_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { + zc_closure_matching_status_take(closure_, x); +}; +inline void z_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { + zc_liveliness_token_take(this_, x); +}; +inline void z_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { + zc_publisher_matching_listener_take(this_, x); +}; +inline void z_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { + zc_shm_client_list_take(this_, x); +}; +inline void z_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { + ze_publication_cache_take(this_, x); +}; +inline void z_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { + ze_querying_subscriber_take(this_, x); +}; +inline bool z_internal_check(const z_owned_alloc_layout_t& this_) { return z_internal_alloc_layout_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; +inline bool z_internal_check(const z_owned_chunk_alloc_result_t& this_) { return z_internal_chunk_alloc_result_check(&this_); }; inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; inline bool z_internal_check(const z_owned_closure_reply_t& this_) { return z_internal_closure_reply_check(&this_); }; inline bool z_internal_check(const z_owned_closure_sample_t& this_) { return z_internal_closure_sample_check(&this_); }; +inline bool z_internal_check(const z_owned_closure_zid_t& this_) { return z_internal_closure_zid_check(&this_); }; inline bool z_internal_check(const z_owned_condvar_t& this_) { return z_internal_condvar_check(&this_); }; inline bool z_internal_check(const z_owned_config_t& this_) { return z_internal_config_check(&this_); }; inline bool z_internal_check(const z_owned_encoding_t& this_) { return z_internal_encoding_check(&this_); }; @@ -689,6 +984,7 @@ inline bool z_internal_check(const z_owned_fifo_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_fifo_handler_sample_t& this_) { return z_internal_fifo_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_hello_check(&this_); }; inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; +inline bool z_internal_check(const z_owned_memory_layout_t& this_) { return z_internal_memory_layout_check(&this_); }; inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; @@ -700,12 +996,24 @@ inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; +inline bool z_internal_check(const z_owned_shm_t& this_) { return z_internal_shm_check(&this_); }; +inline bool z_internal_check(const z_owned_shm_client_t& this_) { return z_internal_shm_client_check(&this_); }; +inline bool z_internal_check(const z_owned_shm_client_storage_t& this_) { return z_internal_shm_client_storage_check(&this_); }; +inline bool z_internal_check(const z_owned_shm_mut_t& this_) { return z_internal_shm_mut_check(&this_); }; +inline bool z_internal_check(const z_owned_shm_provider_t& this_) { return z_internal_shm_provider_check(&this_); }; inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; +inline bool z_internal_check(const z_owned_source_info_t& this_) { return z_internal_source_info_check(&this_); }; inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; +inline bool z_internal_check(const zc_owned_closure_matching_status_t& this_) { return zc_internal_closure_matching_status_check(&this_); }; +inline bool z_internal_check(const zc_owned_liveliness_token_t& this_) { return zc_internal_liveliness_token_check(&this_); }; +inline bool z_internal_check(const zc_owned_matching_listener_t& this_) { return zc_internal_matching_listener_check(&this_); }; +inline bool z_internal_check(const zc_owned_shm_client_list_t& this_) { return zc_internal_shm_client_list_check(&this_); }; +inline bool z_internal_check(const ze_owned_publication_cache_t& this_) { return ze_internal_publication_cache_check(&this_); }; +inline bool z_internal_check(const ze_owned_querying_subscriber_t& this_) { return ze_internal_querying_subscriber_check(&this_); }; inline void z_call(const z_loaned_closure_hello_t* closure, z_loaned_hello_t* hello) { @@ -720,13 +1028,21 @@ inline void z_call(const z_loaned_closure_reply_t* closure, z_loaned_reply_t* re inline void z_call(const z_loaned_closure_sample_t* closure, z_loaned_sample_t* sample) { z_closure_sample_call(closure, sample); }; +inline void z_call(const z_loaned_closure_zid_t* closure, const z_id_t* z_id) { + z_closure_zid_call(closure, z_id); +}; +inline void z_call(const zc_loaned_closure_matching_status_t* closure, const zc_matching_status_t* mathing_status) { + zc_closure_matching_status_call(closure, mathing_status); +}; extern "C" using z_closure_drop_callback_t = void(void* context); extern "C" using z_closure_hello_callabck_t = void(z_loaned_hello_t *hello, void *context); extern "C" using z_closure_query_callabck_t = void(z_loaned_query_t *query, void *context); extern "C" using z_closure_reply_callabck_t = void(z_loaned_reply_t *reply, void *context); extern "C" using z_closure_sample_callabck_t = void(z_loaned_sample_t *sample, void *context); +extern "C" using z_closure_zid_callabck_t = void(const z_id_t *z_id, void *context); extern "C" using zc_closure_log_callabck_t = void(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); +extern "C" using zc_closure_matching_status_callabck_t = void(const zc_matching_status_t *matching_status, void *context); inline void z_closure(z_owned_closure_hello_t* this_, z_closure_hello_callabck_t* call, z_closure_drop_callback_t* drop, void* context) { @@ -744,10 +1060,18 @@ inline void z_closure(z_owned_closure_sample_t* this_, z_closure_sample_callabck z_closure_drop_callback_t* drop, void* context) { z_closure_sample(this_, call, drop, context); }; +inline void z_closure(z_owned_closure_zid_t* this_, z_closure_zid_callabck_t* call, + z_closure_drop_callback_t* drop, void* context) { + z_closure_zid(this_, call, drop, context); +}; inline void z_closure(zc_owned_closure_log_t* this_, zc_closure_log_callabck_t* call, z_closure_drop_callback_t* drop, void* context) { zc_closure_log(this_, call, drop, context); }; +inline void z_closure(zc_owned_closure_matching_status_t* this_, zc_closure_matching_status_callabck_t* call, + z_closure_drop_callback_t* drop, void* context) { + zc_closure_matching_status(this_, call, drop, context); +}; inline z_result_t z_try_recv(const z_loaned_fifo_handler_query_t* this_, z_owned_query_t* query) { @@ -817,6 +1141,12 @@ inline void z_clone(z_owned_reply_err_t* dst, z_loaned_reply_err_t* this_) { inline void z_clone(z_owned_sample_t* dst, z_loaned_sample_t* this_) { z_sample_clone(dst, this_); }; +inline void z_clone(z_owned_shm_client_storage_t* this_, z_loaned_shm_client_storage_t* from) { + z_shm_client_storage_clone(this_, from); +}; +inline void z_clone(z_owned_shm_t* out, z_loaned_shm_t* this_) { + z_shm_clone(out, this_); +}; inline void z_clone(z_owned_slice_t* dst, z_loaned_slice_t* this_) { z_slice_clone(dst, this_); }; @@ -829,8 +1159,12 @@ inline void z_clone(z_owned_string_t* dst, z_loaned_string_t* this_) { template struct z_loaned_to_owned_type_t {}; template struct z_owned_to_loaned_type_t {}; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_alloc_layout_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_alloc_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_chunk_alloc_result_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_chunk_alloc_result_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_hello_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_query_t type; }; @@ -839,6 +1173,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_reply_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_sample_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_sample_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_zid_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_zid_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_condvar_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_condvar_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_config_t type; }; @@ -855,6 +1191,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_h template<> struct z_owned_to_loaned_type_t { typedef z_loaned_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_keyexpr_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_keyexpr_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_memory_layout_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_memory_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_publisher_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_publisher_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_query_t type; }; @@ -875,8 +1213,18 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_sample_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_session_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_session_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_client_storage_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_client_storage_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_mut_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_mut_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_provider_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_provider_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_slice_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_slice_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef z_owned_source_info_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef z_loaned_source_info_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_array_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_string_array_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_t type; }; @@ -885,6 +1233,16 @@ template<> struct z_loaned_to_owned_type_t { typedef z_ow template<> struct z_owned_to_loaned_type_t { typedef z_loaned_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_log_t type; }; template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_log_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_matching_status_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_matching_status_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef zc_owned_liveliness_token_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_liveliness_token_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef zc_owned_shm_client_list_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_shm_client_list_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef ze_owned_publication_cache_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_publication_cache_t type; }; +template<> struct z_loaned_to_owned_type_t { typedef ze_owned_querying_subscriber_t type; }; +template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_querying_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_mutex_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_mutex_t type; }; #endif // #ifndef __cplusplus diff --git a/src/closures/hello_closure.rs b/src/closures/hello_closure.rs index 33161d001..581ef486f 100644 --- a/src/closures/hello_closure.rs +++ b/src/closures/hello_closure.rs @@ -17,7 +17,7 @@ use std::mem::MaybeUninit; use libc::c_void; use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, z_loaned_hello_t, }; /// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: @@ -151,6 +151,15 @@ pub extern "C" fn z_closure_hello_loan_mut( closure.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed closure +#[no_mangle] +pub extern "C" fn z_closure_hello_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_closure_hello_t, +) { + dst.write(std::mem::take(src.as_owned_c_type_mut())); +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 4d0f62807..09e58b4da 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_query_t, z_owned_closure_query_t, z_owned_query_t, }; decl_c_type!( @@ -110,11 +110,18 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan_mut( this: &mut z_owned_fifo_handler_query_t, ) -> &mut z_loaned_fifo_handler_query_t { this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed handler +#[no_mangle] +pub extern "C" fn z_fifo_handler_query_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_fifo_handler_query_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -230,11 +237,18 @@ pub unsafe extern "C" fn z_ring_handler_query_loan_mut( this: &mut z_owned_ring_handler_query_t, ) -> &mut z_loaned_ring_handler_query_t { this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed handler +#[no_mangle] +pub extern "C" fn z_ring_handler_query_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_ring_handler_query_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state). diff --git a/src/closures/query_closure.rs b/src/closures/query_closure.rs index 09b9ece82..ec830ac61 100644 --- a/src/closures/query_closure.rs +++ b/src/closures/query_closure.rs @@ -17,7 +17,7 @@ use std::mem::MaybeUninit; use libc::c_void; use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, z_loaned_query_t, }; /// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: @@ -150,6 +150,15 @@ pub extern "C" fn z_closure_query_loan_mut( closure.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed closure +#[no_mangle] +pub extern "C" fn z_closure_query_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_closure_query_t, +) { + dst.write(std::mem::take(src.as_owned_c_type_mut())); +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/reply_closure.rs b/src/closures/reply_closure.rs index 149d7b754..13b15d725 100644 --- a/src/closures/reply_closure.rs +++ b/src/closures/reply_closure.rs @@ -17,7 +17,7 @@ use std::mem::MaybeUninit; use libc::c_void; use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, z_loaned_reply_t, }; /// A structure that contains all the elements for stateful, memory-leak-free callbacks. @@ -153,6 +153,15 @@ pub extern "C" fn z_closure_reply_loan_mut( closure.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed closure +#[no_mangle] +pub extern "C" fn z_closure_reply_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_closure_reply_t, +) { + dst.write(std::mem::take(src.as_owned_c_type_mut())); +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index 29d417caa..3ad41da88 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_reply_t, z_owned_closure_reply_t, z_owned_reply_t, }; decl_c_type!( @@ -110,11 +110,17 @@ pub unsafe extern "C" fn z_fifo_handler_reply_loan_mut( this: &mut z_owned_fifo_handler_reply_t, ) -> &mut z_loaned_fifo_handler_reply_t { this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed handler +#[no_mangle] +pub extern "C" fn z_fifo_handler_reply_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_fifo_handler_reply_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} /// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). @@ -227,11 +233,18 @@ pub unsafe extern "C" fn z_ring_handler_reply_loan_mut( this: &mut z_owned_ring_handler_reply_t, ) -> &mut z_loaned_ring_handler_reply_t { this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed handler +#[no_mangle] +pub extern "C" fn z_ring_handler_reply_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_ring_handler_reply_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index d8a43e5be..b997164ad 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -25,7 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_sample_t, z_owned_closure_sample_t, z_owned_sample_t, }; decl_c_type!( @@ -110,11 +110,18 @@ pub unsafe extern "C" fn z_fifo_handler_sample_loan_mut( this: &mut z_owned_fifo_handler_sample_t, ) -> &mut z_loaned_fifo_handler_sample_t { this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed fifo_handler_sample +#[no_mangle] +pub extern "C" fn z_fifo_handler_sample_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_fifo_handler_sample_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more samples to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). @@ -230,11 +237,18 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan_mut( this: &mut z_owned_ring_handler_sample_t, ) -> &mut z_loaned_ring_handler_sample_t { this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed handler +#[no_mangle] +pub extern "C" fn z_ring_handler_sample_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_ring_handler_sample_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more replies to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). diff --git a/src/closures/sample_closure.rs b/src/closures/sample_closure.rs index 07e0ec53e..80a3dcfc2 100644 --- a/src/closures/sample_closure.rs +++ b/src/closures/sample_closure.rs @@ -17,7 +17,7 @@ use std::mem::MaybeUninit; use libc::c_void; use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, z_loaned_sample_t, }; /// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. @@ -152,6 +152,15 @@ pub extern "C" fn z_closure_sample_loan_mut( closure.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed closure +#[no_mangle] +pub extern "C" fn z_closure_sample_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_closure_sample_t, +) { + dst.write(std::mem::take(src.as_owned_c_type_mut())); +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index 1c5629613..421e4e041 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -153,6 +153,15 @@ pub extern "C" fn z_closure_zid_loan_mut(closure: &mut z_owned_closure_zid_t) -> closure.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed closure +#[no_mangle] +pub extern "C" fn z_closure_zid_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_closure_zid_t, +) { + dst.write(std::mem::take(src.as_owned_c_type_mut())); +} + /// @brief Constructs closure. /// @param this_: uninitialized memory location where new closure will be constructed. /// @param call: a closure body. diff --git a/src/collections.rs b/src/collections.rs index cf8c9bdd3..3d775e2f3 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -347,6 +347,12 @@ pub extern "C" fn z_slice_loan_mut(this_: &mut z_owned_slice_t) -> &mut z_loaned this_.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of mutably borrowed slice +#[no_mangle] +pub extern "C" fn z_slice_take_loaned(dst: &mut MaybeUninit, src: &mut z_loaned_slice_t) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Constructs an owned copy of a slice. #[no_mangle] pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: &z_loaned_slice_t) { @@ -604,6 +610,12 @@ pub extern "C" fn z_string_loan_mut(this_: &mut z_owned_string_t) -> &mut z_loan this_.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of mutably borrowed string. +#[no_mangle] +pub extern "C" fn z_string_take_loaned(dst: &mut MaybeUninit, src: &mut z_loaned_string_t) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Borrows view string. #[no_mangle] pub extern "C" fn z_view_string_loan(this_: &z_view_string_t) -> &z_loaned_string_t { @@ -803,6 +815,15 @@ pub unsafe extern "C" fn z_string_array_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of mutably borrowed string array. +#[no_mangle] +pub extern "C" fn z_string_array_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_string_array_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// @return number of elements in the array. #[no_mangle] pub extern "C" fn z_string_array_len(this_: &z_loaned_string_array_t) -> usize { diff --git a/src/commons.rs b/src/commons.rs index 74fd5fa68..3c2ce0d1c 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -37,7 +37,7 @@ use crate::z_id_t; use crate::z_moved_source_info_t; use crate::{ result, - transmute::{CTypeRef, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{CTypeRef, LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, }; @@ -220,11 +220,15 @@ pub unsafe extern "C" fn z_sample_loan(this_: &z_owned_sample_t) -> &z_loaned_sa pub unsafe extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loaned_sample_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed sample. +#[no_mangle] +pub extern "C" fn z_sample_take_loaned(dst: &mut MaybeUninit, src: &mut z_loaned_sample_t) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Frees the memory and invalidates the sample, resetting it to a gravestone state. #[no_mangle] pub extern "C" fn z_sample_drop(this_: &mut z_moved_sample_t) { @@ -618,6 +622,18 @@ pub extern "C" fn z_source_info_loan(this_: &z_owned_source_info_t) -> &z_loaned pub extern "C" fn z_source_info_loan_mut(this_: &z_owned_source_info_t) -> &z_loaned_source_info_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } + +#[cfg(feature = "unstable")] +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Takes ownership of the mutably borrowed source info. +#[no_mangle] +pub extern "C" fn z_source_info_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_source_info_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. diff --git a/src/config.rs b/src/config.rs index 01eb51ac9..e4832029b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -88,6 +88,15 @@ pub extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loan this.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed config. +#[no_mangle] +pub extern "C" fn z_config_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_config_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Constructs a new empty configuration. #[no_mangle] pub extern "C" fn z_config_default( diff --git a/src/encoding.rs b/src/encoding.rs index 5c61582e7..c8e65b71d 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -168,6 +168,15 @@ pub extern "C" fn z_encoding_loan_mut(this_: &mut z_owned_encoding_t) -> &mut z_ this_.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed encoding +#[no_mangle] +pub extern "C" fn z_encoding_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_encoding_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Constructs an owned copy of the encoding in provided uninitilized memory location. #[no_mangle] pub extern "C" fn z_encoding_clone( diff --git a/src/get.rs b/src/get.rs index bbb34fbb8..2e5376af0 100644 --- a/src/get.rs +++ b/src/get.rs @@ -24,7 +24,7 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_reply_err_t, z_moved_reply_err_t, z_owned_reply_err_t}; use crate::{ result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_reply_call, z_closure_reply_loan, z_congestion_control_t, z_consolidation_mode_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_sample_t, z_loaned_session_t, z_moved_bytes_t, z_moved_closure_reply_t, z_moved_encoding_t, z_priority_t, @@ -77,6 +77,16 @@ pub extern "C" fn z_reply_err_loan_mut(this_: &mut z_owned_reply_err_t) -> &mut this_.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed reply error +#[no_mangle] +pub extern "C" fn z_reply_err_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_reply_err_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + + /// Frees the memory and resets the reply error it to its default value. #[no_mangle] pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { @@ -318,11 +328,18 @@ pub unsafe extern "C" fn z_reply_loan(this_: &z_owned_reply_t) -> &z_loaned_repl pub unsafe extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned_reply_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed reply +#[no_mangle] +pub extern "C" fn z_reply_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_reply_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// The replies consolidation strategy to apply on replies to a `z_get()`. #[repr(C)] #[derive(Clone, Copy)] diff --git a/src/keyexpr.rs b/src/keyexpr.rs index 7e0faddf8..e9a74e4ce 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -26,7 +26,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_session_t, z_view_string_from_substr, z_view_string_t, }; @@ -140,11 +140,18 @@ pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_ pub unsafe extern "C" fn z_keyexpr_loan_mut(this_: &mut z_owned_keyexpr_t) -> &mut z_loaned_keyexpr_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed keyexpr +#[no_mangle] +pub extern "C" fn z_keyexpr_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_keyexpr_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Borrows `z_view_keyexpr_t`. #[no_mangle] #[allow(clippy::missing_safety_doc)] diff --git a/src/payload.rs b/src/payload.rs index 32f1f3287..8642cf442 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -86,6 +86,15 @@ extern "C" fn z_bytes_loan_mut(this: &mut z_owned_bytes_t) -> &mut z_loaned_byte this.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed bytes +#[no_mangle] +pub extern "C" fn z_bytes_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_bytes_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Returns ``true`` if `this_` is empty, ``false`` otherwise. #[no_mangle] extern "C" fn z_bytes_is_empty(this: &z_loaned_bytes_t) -> bool { diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index be532a256..f832cf4f0 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -55,6 +55,15 @@ pub unsafe extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z this_.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed mutex +#[no_mangle] +pub extern "C" fn z_mutex_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_mutex_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Locks mutex. If mutex is already locked, blocks the thread until it aquires the lock. /// @return 0 in case of success, negative error code in case of failure. #[no_mangle] diff --git a/src/publisher.rs b/src/publisher.rs index f2e98ea8e..94ac5b4f5 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -170,6 +170,15 @@ pub unsafe extern "C" fn z_publisher_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed publisher +#[no_mangle] +pub extern "C" fn z_publisher_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_publisher_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Options passed to the `z_publisher_put()` function. #[repr(C)] pub struct z_publisher_put_options_t { diff --git a/src/queryable.rs b/src/queryable.rs index 072be8add..ace043944 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -26,7 +26,7 @@ use crate::transmute::IntoCType; use crate::{ result, transmute::{ - IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType, + IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType }, z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, @@ -63,11 +63,18 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa pub unsafe extern "C" fn z_queryable_loan_mut(this_: &mut z_owned_queryable_t) -> &mut z_loaned_queryable_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed queryable +#[no_mangle] +pub extern "C" fn z_queryable_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_queryable_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; decl_c_type!( owned(z_owned_query_t, option Query), @@ -101,11 +108,18 @@ pub unsafe extern "C" fn z_query_loan(this_: &z_owned_query_t) -> &z_loaned_quer pub unsafe extern "C" fn z_query_loan_mut(this_: &mut z_owned_query_t) -> &mut z_loaned_query_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed query +#[no_mangle] +pub extern "C" fn z_query_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_query_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Destroys the query resetting it to its gravestone value. #[no_mangle] pub extern "C" fn z_query_drop(this_: &mut z_moved_query_t) { diff --git a/src/scouting.rs b/src/scouting.rs index 69cdd51b5..c5cf32f67 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -22,7 +22,7 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_hello_t, z_moved_hello_t, z_owned_hello_t}; use crate::{ result::{self, Z_OK}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_hello_call, z_closure_hello_loan, z_moved_closure_hello_t, z_moved_config_t, z_owned_string_array_t, z_view_string_t, CString, CStringView, ZVector, }; @@ -57,11 +57,17 @@ pub unsafe extern "C" fn z_hello_loan(this_: &z_owned_hello_t) -> &z_loaned_hell pub unsafe extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed hello +#[no_mangle] +pub extern "C" fn z_hello_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_hello_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} /// Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. #[no_mangle] diff --git a/src/session.rs b/src/session.rs index 5bb14d6db..596fe0847 100644 --- a/src/session.rs +++ b/src/session.rs @@ -21,7 +21,7 @@ use crate::z_loaned_shm_client_storage_t; use crate::{ opaque_types::{z_loaned_session_t, z_owned_session_t}, result, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_moved_config_t, z_moved_session_t, }; decl_c_type!( @@ -46,11 +46,18 @@ pub unsafe extern "C" fn z_session_loan(this_: &z_owned_session_t) -> &z_loaned_ pub unsafe extern "C" fn z_session_loan_mut(this_: &mut z_owned_session_t) -> &mut z_loaned_session_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed session +#[no_mangle] +pub extern "C" fn z_session_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_session_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Constructs a Zenoh session in its gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 438607d00..f74ef22c7 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -20,7 +20,7 @@ use std::{ use zenoh::shm::{zshm, zshmmut, ZShm}; use crate::{ - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, }; @@ -80,26 +80,31 @@ pub unsafe extern "C" fn z_shm_loan(this_: &z_owned_shm_t) -> &z_loaned_shm_t { #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_t { - let this: &mut zshm = this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .borrow_mut(); - this.as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() +} + +/// Takes ownership of the mutably borrowed shm +#[no_mangle] +pub extern "C" fn z_shm_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_shm_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> *mut z_loaned_shm_mut_t { +pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_mut_t { let this = this_.as_rust_type_mut(); let this: &mut ZShm = this.as_mut().unwrap_unchecked(); let shm: &mut zshm = this.borrow_mut(); match shm.try_into() { Ok(val) => { let v: &mut zshmmut = val; - v.as_loaned_c_type_mut() + v.as + // v.as_loaned_c_type_mut() } Err(_) => std::ptr::null_mut(), } diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index 05a5bf89f..86d5c6da0 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -101,6 +101,15 @@ pub unsafe extern "C" fn z_shm_mut_loan_mut( shmmut.as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed shm_mut +#[no_mangle] +pub extern "C" fn z_shm_mut_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_shm_mut_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes ZShmMut slice. #[no_mangle] diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 279cc50a3..9f088dfa0 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -211,3 +211,14 @@ pub unsafe extern "C" fn z_shm_client_storage_loan_mut( .unwrap_unchecked() .as_loaned_c_type_mut() } + +/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. +/// @brief Takes ownership of the mutably borrowed SHM Client Storage. +#[no_mangle] +pub extern "C" fn z_shm_client_storage_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_shm_client_storage_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index 319b6ec9e..2b5faff54 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -98,6 +98,15 @@ pub unsafe extern "C" fn z_alloc_layout_loan_mut( .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed Alloc Layout +#[no_mangle] +pub extern "C" fn z_alloc_layout_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_alloc_layout_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Deletes Alloc Layout #[no_mangle] pub extern "C" fn z_alloc_layout_drop(this_: &mut z_moved_alloc_layout_t) { diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 06dc3ce80..5519ec209 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -135,6 +135,15 @@ pub unsafe extern "C" fn z_shm_provider_loan_mut( .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed SHM Provider +#[no_mangle] +pub extern "C" fn z_shm_provider_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_shm_provider_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes SHM Provider. #[no_mangle] diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index 29e3afd75..1bd0c25a5 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -185,6 +185,15 @@ pub unsafe extern "C" fn z_memory_layout_loan_mut( .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed Memory Layout. +#[no_mangle] +pub extern "C" fn z_memory_layout_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_memory_layout_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes Memory Layout. #[no_mangle] @@ -281,6 +290,15 @@ pub unsafe extern "C" fn z_chunk_alloc_result_loan_mut( .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed Chunk Alloc Result. +#[no_mangle] +pub extern "C" fn z_chunk_alloc_result_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_chunk_alloc_result_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes Chunk Alloc Result. #[no_mangle] diff --git a/src/subscriber.rs b/src/subscriber.rs index 0e8836021..5277da5b4 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -20,7 +20,7 @@ pub use crate::opaque_types::{z_loaned_subscriber_t, z_moved_subscriber_t, z_own use crate::{ keyexpr::*, result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t, }; decl_c_type!( @@ -51,11 +51,18 @@ pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_l pub unsafe extern "C" fn z_subscriber_loan_mut(this_: &mut z_owned_subscriber_t) -> &mut z_loaned_subscriber_t { this_ .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() .as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed subscriber +#[no_mangle] +pub extern "C" fn z_subscriber_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_subscriber_t, +) { + dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +} + /// Options passed to the `z_declare_subscriber()` function. #[allow(non_camel_case_types)] #[repr(C)] From 18d1161d7f23aa12de0e92574233610df4eba995 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Mon, 21 Oct 2024 12:19:26 +0200 Subject: [PATCH 07/38] syntax error fixes --- include/zenoh_commons.h | 79 +++++++++++++++++++++++++++++++++-------- include/zenoh_macros.h | 5 ++- src/queryable.rs | 3 +- src/shm/buffer/zshm.rs | 3 +- 4 files changed, 70 insertions(+), 20 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 1a97b73fb..1d50d35fe 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1265,6 +1265,60 @@ bool z_bytes_slice_iterator_next(struct z_bytes_slice_iterator_t *this_, * Takes ownership of the mutably borrowed bytes */ ZENOHC_API void z_bytes_take_loaned(struct z_owned_bytes_t *dst, struct z_loaned_bytes_t *src); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Converts data into a loaned SHM buffer. + * + * @param this_: Data to convert. + * @param dst: An uninitialized memory location where to construct an SHM buffer. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_result_t z_bytes_to_loaned_shm(const struct z_loaned_bytes_t *this_, + const struct z_loaned_shm_t **dst); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Converts data into a mutably loaned SHM buffer. + * + * @param this_: Data to convert. + * @param dst: An uninitialized memory location where to construct an SHM buffer. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_result_t z_bytes_to_mut_loaned_shm(struct z_loaned_bytes_t *this_, + struct z_loaned_shm_t **dst); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Converts data into an owned SHM buffer by copying it's shared reference. + * + * @param this_: Data to convert. + * @param dst: An uninitialized memory location where to construct an SHM buffer. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +z_result_t z_bytes_to_owned_shm(const struct z_loaned_bytes_t *this_, + struct z_owned_shm_t *dst); +#endif +/** + * Converts data into an owned slice. + * + * @param this_: Data to convert. + * @param dst: An uninitialized memory location where to construct a slice. + */ +ZENOHC_API +z_result_t z_bytes_to_slice(const struct z_loaned_bytes_t *this_, + struct z_owned_slice_t *dst); +/** + * Converts data into an owned non-null-terminated string. + * + * @param this_: Data to convert. + * @param dst: An uninitialized memory location where to construct a string. + */ +ZENOHC_API +z_result_t z_bytes_to_string(const struct z_loaned_bytes_t *this_, + struct z_owned_string_t *dst); /** * Appends bytes. * This allows to compose a serialized data out of multiple `z_owned_bytes_t` that may point to different memory regions. @@ -1563,7 +1617,7 @@ ZENOHC_API void z_closure_sample_drop(struct z_moved_closure_sample_t *closure_) ZENOHC_API const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_owned_closure_sample_t *closure); /** - * Borrows closure. + * Mutably borrows closure. */ ZENOHC_API struct z_loaned_closure_sample_t *z_closure_sample_loan_mut(struct z_owned_closure_sample_t *closure); @@ -1608,27 +1662,23 @@ void z_closure_zid_drop(struct z_moved_closure_zid_t *closure_); */ ZENOHC_API const struct z_loaned_closure_zid_t *z_closure_zid_loan(const struct z_owned_closure_zid_t *closure); -/** - * @brief Mutably borrows closure. - */ -ZENOHC_API -const struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(const struct z_owned_closure_zid_t *closure); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Borrows closure. */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid_t *closure); -#endif +/** + * @brief Mutably borrows closure. + */ +ZENOHC_API +const struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(const struct z_owned_closure_zid_t *closure); /** * Takes ownership of the mutably borrowed closure */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void z_closure_zid_take_loaned(struct z_owned_closure_zid_t *dst, struct z_loaned_closure_zid_t *src); -#endif /** * Drops conditional variable. */ @@ -1685,8 +1735,8 @@ ZENOHC_API struct z_loaned_config_t *z_config_loan_mut(struct z_owned_config_t * */ ZENOHC_API void z_config_take_loaned(struct z_owned_config_t *dst, struct z_loaned_config_t *src); /** - * Constructs and declares a key expression on the network. This reduces key key expression to a numerical id, - * which allows to save the bandwith, when passing key expression between Zenoh entities. + * Declares a background queryable for a given keyexpr. The queryable callback will be be called + * to proccess incoming queries until the corresponding session is closed or dropped. * * @param session: The zenoh session. * @param key_expr: The key expression the Queryable will reply to. @@ -3743,7 +3793,6 @@ ZENOHC_API bool z_session_is_closed(const struct z_loaned_session_t *session); * Borrows session. */ ZENOHC_API const struct z_loaned_session_t *z_session_loan(const struct z_owned_session_t *this_); -ZENOHC_API struct z_loaned_session_t *z_session_loan_mut(struct z_owned_session_t *this_); /** * Mutably borrows session. */ @@ -4390,8 +4439,8 @@ ZENOHC_API struct z_loaned_string_t *z_string_loan_mut(struct z_owned_string_t * */ ZENOHC_API void z_string_take_loaned(struct z_owned_string_t *dst, struct z_loaned_string_t *src); /** - * Drops subscriber and resets it to its gravestone state. - * The callback closure is not dropped and still keeps receiving and processing samples until the corresponding session is closed. + * Undeclares subscriber callback and resets it to its gravestone state. + * This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value. */ ZENOHC_API void z_subscriber_drop(struct z_moved_subscriber_t *this_); /** diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index ad6b17d8a..9fa81b136 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -109,6 +109,7 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x _Generic((this_), \ z_owned_alloc_layout_t : z_alloc_layout_loan_mut, \ z_owned_bytes_t : z_bytes_loan_mut, \ + z_owned_bytes_writer_t : z_bytes_writer_loan_mut, \ z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan_mut, \ z_owned_closure_hello_t : z_closure_hello_loan_mut, \ z_owned_closure_query_t : z_closure_query_loan_mut, \ @@ -143,7 +144,8 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_string_array_t : z_string_array_loan_mut, \ z_owned_string_t : z_string_loan_mut, \ z_owned_subscriber_t : z_subscriber_loan_mut, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut \ + zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut, \ + ze_owned_serializer_t : ze_serializer_loan_mut \ )(&this_) #define z_drop(this_) \ @@ -628,6 +630,7 @@ inline const ze_loaned_serializer_t* z_loan(const ze_owned_serializer_t& this_) inline z_loaned_alloc_layout_t* z_loan_mut(z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan_mut(&this_); }; inline z_loaned_bytes_t* z_loan_mut(z_owned_bytes_t& this_) { return z_bytes_loan_mut(&this_); }; +inline z_loaned_bytes_writer_t* z_loan_mut(z_owned_bytes_writer_t& this_) { return z_bytes_writer_loan_mut(&this_); }; inline z_loaned_chunk_alloc_result_t* z_loan_mut(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan_mut(&this_); }; inline z_loaned_closure_hello_t* z_loan_mut(z_owned_closure_hello_t& closure) { return z_closure_hello_loan_mut(&closure); }; inline z_loaned_closure_query_t* z_loan_mut(z_owned_closure_query_t& closure) { return z_closure_query_loan_mut(&closure); }; diff --git a/src/queryable.rs b/src/queryable.rs index 70256e703..0a69ec12b 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -266,8 +266,7 @@ fn _declare_queryable_inner<'a, 'b>( z_closure_query_loan(&callback), owned_query.as_loaned_c_type_mut(), ) - }) - }); + }); queryable } diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index f74ef22c7..2bceecddb 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -103,8 +103,7 @@ pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> &mut z_loan match shm.try_into() { Ok(val) => { let v: &mut zshmmut = val; - v.as - // v.as_loaned_c_type_mut() + v.as_loaned_c_type_mut() } Err(_) => std::ptr::null_mut(), } From 56b1f4d2942c8b8d129f673f9ca8bd25aab2811d Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Tue, 22 Oct 2024 14:24:48 +0200 Subject: [PATCH 08/38] build errors fixed --- include/zenoh_commons.h | 640 ++++++++++++++++++++----------- include/zenoh_macros.h | 331 +--------------- src/closures/query_channel.rs | 16 +- src/closures/response_channel.rs | 16 +- src/closures/sample_channel.rs | 16 +- src/closures/zenohid_closure.rs | 14 +- src/collections.rs | 19 +- src/commons.rs | 20 +- src/config.rs | 3 +- src/encoding.rs | 3 +- src/get.rs | 19 +- src/keyexpr.rs | 15 +- src/platform/synchronization.rs | 3 +- src/publisher.rs | 3 +- src/queryable.rs | 36 +- src/scouting.rs | 12 +- src/serialization.rs | 99 ++--- src/session.rs | 19 +- src/shm/buffer/zshm.rs | 7 +- src/shm/buffer/zshmmut.rs | 3 +- src/shm/client_storage/mod.rs | 4 +- src/shm/provider/alloc_layout.rs | 3 +- src/shm/provider/shm_provider.rs | 3 +- src/shm/provider/types.rs | 6 +- src/subscriber.rs | 15 +- src/zbytes.rs | 22 +- 26 files changed, 640 insertions(+), 707 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 1d50d35fe..f8c64d9f1 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -16,6 +16,32 @@ #define ALIGN(n) #define ZENOHC_API #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Allocation errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_alloc_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Defragmentation needed. + */ + Z_ALLOC_ERROR_NEED_DEFRAGMENT, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * The provider is out of memory. + */ + Z_ALLOC_ERROR_OUT_OF_MEMORY, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Other error. + */ + Z_ALLOC_ERROR_OTHER, +#endif +} z_alloc_error_t; +#endif typedef enum z_congestion_control_t { /** * Messages are not dropped in case of congestion. @@ -77,6 +103,26 @@ typedef enum z_keyexpr_intersection_level_t { Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3, } z_keyexpr_intersection_level_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Layouting errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_layout_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout arguments are incorrect. + */ + Z_LAYOUT_ERROR_INCORRECT_LAYOUT_ARGS, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout incompatible with provider. + */ + Z_LAYOUT_ERROR_PROVIDER_INCOMPATIBLE_LAYOUT, +#endif +} z_layout_error_t; +#endif /** * The priority of zenoh messages. */ @@ -169,6 +215,52 @@ typedef enum z_whatami_t { Z_WHATAMI_PEER = 2, Z_WHATAMI_CLIENT = 4, } z_whatami_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +} zc_buf_alloc_status_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_layout_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layouting error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_LAYOUT_ERROR = 2, +#endif +} zc_buf_layout_alloc_status_t; +#endif /** * The locality of samples to be received by subscribers or targeted by publishers. */ @@ -237,19 +329,56 @@ typedef enum zc_reply_keyexpr_t { ZC_REPLY_KEYEXPR_MATCHING_QUERY = 1, } zc_reply_keyexpr_t; #endif -typedef struct z_moved_alloc_layout_t { - struct z_owned_alloc_layout_t _this; -} z_moved_alloc_layout_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_alloc_result_t { + enum zc_buf_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t error; +} z_buf_alloc_result_t; +#endif typedef int8_t z_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocAlignment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_alloc_alignment_t { + uint8_t pow; +} z_alloc_alignment_t; +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_data_t { + void *ptr; +} zc_threadsafe_context_data_t; +#endif +/** + * A tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a thread-safe context - the associated callbacks may be executed concurrently with the same + * zc_context_t instance. In other words, all the callbacks associated with this context data MUST be + * thread-safe. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_t { + struct zc_threadsafe_context_data_t context; + void (*delete_fn)(void*); +} zc_threadsafe_context_t; +#endif typedef struct z_moved_bytes_t { struct z_owned_bytes_t _this; } z_moved_bytes_t; -typedef struct z_moved_shm_t { - struct z_owned_shm_t _this; -} z_moved_shm_t; -typedef struct z_moved_shm_mut_t { - struct z_owned_shm_mut_t _this; -} z_moved_shm_mut_t; typedef struct z_moved_slice_t { struct z_owned_slice_t _this; } z_moved_slice_t; @@ -265,9 +394,41 @@ typedef struct ALIGN(8) z_bytes_slice_iterator_t { typedef struct z_moved_bytes_writer_t { struct z_owned_bytes_writer_t _this; } z_moved_bytes_writer_t; -typedef struct z_moved_chunk_alloc_result_t { - struct z_owned_chunk_alloc_result_t _this; -} z_moved_chunk_alloc_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Unique segment identifier. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_segment_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Chunk id within it's segment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_chunk_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A ChunkDescriptor. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_chunk_descriptor_t { + z_segment_id_t segment; + z_chunk_id_t chunk; + size_t len; +} z_chunk_descriptor_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocatedChunk. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_allocated_chunk_t { + struct z_chunk_descriptor_t descriptpr; + void *data; +} z_allocated_chunk_t; +#endif /** * Monotonic clock */ @@ -477,9 +638,6 @@ typedef struct z_moved_fifo_handler_sample_t { typedef struct z_query_consolidation_t { enum z_consolidation_mode_t mode; } z_query_consolidation_t; -typedef struct z_moved_source_info_t { - struct z_owned_source_info_t _this; -} z_moved_source_info_t; /** * Options passed to the `z_get()` function. */ @@ -534,7 +692,7 @@ typedef struct z_get_options_t { * * The source info for the query. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * An optional attachment to attach to the query. @@ -551,9 +709,6 @@ typedef struct z_moved_hello_t { typedef struct z_moved_keyexpr_t { struct z_owned_keyexpr_t _this; } z_moved_keyexpr_t; -typedef struct z_moved_memory_layout_t { - struct z_owned_memory_layout_t _this; -} z_moved_memory_layout_t; typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; @@ -594,7 +749,7 @@ typedef struct z_publisher_put_options_t { * * The source info for the publication. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to attach to the publication. @@ -647,7 +802,7 @@ typedef struct z_put_options_t { * * The source info for the message. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this message. @@ -688,7 +843,7 @@ typedef struct z_query_reply_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -722,7 +877,7 @@ typedef struct z_query_reply_del_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -776,15 +931,46 @@ typedef struct z_scout_options_t { typedef struct z_moved_session_t { struct z_owned_session_t _this; } z_moved_session_t; -typedef struct z_moved_shm_client_t { - struct z_owned_shm_client_t _this; -} z_moved_shm_client_t; -typedef struct z_moved_shm_client_storage_t { - struct z_owned_shm_client_storage_t _this; -} z_moved_shm_client_storage_t; -typedef struct z_moved_shm_provider_t { - struct z_owned_shm_provider_t _this; -} z_moved_shm_provider_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_segment_callbacks_t { + uint8_t *(*map_fn)(z_chunk_id_t chunk_id, void *context); +} zc_shm_segment_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_shm_segment_t { + struct zc_threadsafe_context_t context; + struct zc_shm_segment_callbacks_t callbacks; +} z_shm_segment_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callback for ShmClient. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_client_callbacks_t { + bool (*attach_fn)(struct z_shm_segment_t *out_segment, z_segment_id_t segment_id, void *context); +} zc_shm_client_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_layout_alloc_result_t { + enum zc_buf_layout_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t alloc_error; + enum z_layout_error_t layout_error; +} z_buf_layout_alloc_result_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Unique protocol identifier. @@ -794,6 +980,47 @@ typedef struct z_moved_shm_provider_t { #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) typedef uint32_t z_protocol_id_t; #endif +/** + * A non-tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same + * zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated + * with this context data are not required to be thread-safe. + * + * NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can + * still be executed concurrently. The exact behavior depends on user's application, but we strongly + * discourage our users from pinning to some specific behavior unless they _really_ understand what they + * are doing. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_context_t { + void *context; + void (*delete_fn)(void*); +} zc_context_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmProviderBackend. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_provider_backend_callbacks_t { + void (*alloc_fn)(z_owned_chunk_alloc_result_t *out_result, + const z_loaned_memory_layout_t *layout, + void *context); + void (*free_fn)(const struct z_chunk_descriptor_t *chunk, void *context); + size_t (*defragment_fn)(void *context); + size_t (*available_fn)(void *context); + void (*layout_for_fn)(z_owned_memory_layout_t *layout, void *context); +} zc_shm_provider_backend_callbacks_t; +#endif typedef struct z_moved_string_array_t { struct z_owned_string_array_t _this; } z_moved_string_array_t; @@ -853,6 +1080,15 @@ typedef struct zc_owned_closure_matching_status_t { void (*_drop)(void *context); } zc_owned_closure_matching_status_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Loaned closure. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +typedef struct zc_loaned_closure_matching_status_t { + size_t _0[3]; +} zc_loaned_closure_matching_status_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. @@ -889,15 +1125,6 @@ typedef struct zc_liveliness_get_options_t { uint32_t timeout_ms; } zc_liveliness_get_options_t; #endif -typedef struct zc_moved_liveliness_token_t { - struct zc_owned_liveliness_token_t _this; -} zc_moved_liveliness_token_t; -typedef struct zc_moved_matching_listener_t { - struct zc_owned_matching_listener_t _this; -} zc_moved_matching_listener_t; -typedef struct zc_moved_shm_client_list_t { - struct zc_owned_shm_client_list_t _this; -} zc_moved_shm_client_list_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Options passed to the `ze_declare_publication_cache()` function. @@ -966,19 +1193,6 @@ typedef struct ze_querying_subscriber_options_t { uint64_t query_timeout_ms; } ze_querying_subscriber_options_t; #endif -typedef struct ze_moved_publication_cache_t { - struct ze_owned_publication_cache_t _this; -} ze_moved_publication_cache_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A loaned Zenoh publication cache. - */ -typedef struct ALIGN(8) ze_loaned_publication_cache_t { - uint8_t _0[96]; -} ze_loaned_publication_cache_t; -typedef struct ze_moved_querying_subscriber_t { - struct ze_owned_querying_subscriber_t _this; -} ze_moved_querying_subscriber_t; typedef struct ze_moved_serializer_t { struct ze_owned_serializer_t _this; } ze_moved_serializer_t; @@ -1001,47 +1215,45 @@ ZENOHC_API extern const unsigned int Z_SHM_POSIX_PROTOCOL_ID; #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_blocking(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif /** * Deletes Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_alloc_layout_drop(struct z_moved_alloc_layout_t *this_); +ZENOHC_API void z_alloc_layout_drop(z_moved_alloc_layout_t *this_); #endif /** * Borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_); #endif /** * Mutably borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(struct z_owned_alloc_layout_t *this_); +ZENOHC_API z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(z_owned_alloc_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1049,8 +1261,8 @@ struct z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(struct z_owned_alloc_lay */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_alloc_layout_new(z_owned_alloc_layout_t *this_, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -1059,13 +1271,13 @@ z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_alloc_layout_take_loaned(struct z_owned_alloc_layout_t *dst, - struct z_loaned_alloc_layout_t *src); +void z_alloc_layout_take_loaned(z_owned_alloc_layout_t *dst, + z_loaned_alloc_layout_t *src); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout, + const z_loaned_alloc_layout_t *layout, struct zc_threadsafe_context_t result_context, void (*result_callback)(void*, struct z_buf_alloc_result_t*)); @@ -1135,7 +1347,7 @@ z_result_t z_bytes_from_buf(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_from_shm(struct z_owned_bytes_t *this_, - struct z_moved_shm_t *shm); + z_moved_shm_t *shm); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1144,7 +1356,7 @@ z_result_t z_bytes_from_shm(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_from_shm_mut(struct z_owned_bytes_t *this_, - struct z_moved_shm_mut_t *shm); + z_moved_shm_mut_t *shm); #endif /** * Converts a slice into `z_owned_bytes_t`. @@ -1275,7 +1487,7 @@ ZENOHC_API void z_bytes_take_loaned(struct z_owned_bytes_t *dst, struct z_loaned #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_to_loaned_shm(const struct z_loaned_bytes_t *this_, - const struct z_loaned_shm_t **dst); + const z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1287,7 +1499,7 @@ z_result_t z_bytes_to_loaned_shm(const struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_to_mut_loaned_shm(struct z_loaned_bytes_t *this_, - struct z_loaned_shm_t **dst); + z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1299,7 +1511,7 @@ z_result_t z_bytes_to_mut_loaned_shm(struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_to_owned_shm(const struct z_loaned_bytes_t *this_, - struct z_owned_shm_t *dst); + z_owned_shm_t *dst); #endif /** * Converts data into an owned slice. @@ -1372,7 +1584,7 @@ z_result_t z_bytes_writer_write_all(struct z_loaned_bytes_writer_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); +void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1380,7 +1592,7 @@ void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const struct z_owned_chunk_alloc_result_t *this_); +const z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1388,7 +1600,7 @@ const struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const stru */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(struct z_owned_chunk_alloc_result_t *this_); +z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1396,7 +1608,7 @@ struct z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(struct z_own */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, +void z_chunk_alloc_result_new_error(z_owned_chunk_alloc_result_t *this_, enum z_alloc_error_t alloc_error); #endif /** @@ -1405,7 +1617,7 @@ void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this_, +z_result_t z_chunk_alloc_result_new_ok(z_owned_chunk_alloc_result_t *this_, struct z_allocated_chunk_t allocated_chunk); #endif /** @@ -1413,8 +1625,8 @@ z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_take_loaned(struct z_owned_chunk_alloc_result_t *dst, - struct z_loaned_chunk_alloc_result_t *src); +void z_chunk_alloc_result_take_loaned(z_owned_chunk_alloc_result_t *dst, + z_loaned_chunk_alloc_result_t *src); #endif /** * Get number of milliseconds passed since creation of `time`. @@ -1662,17 +1874,11 @@ void z_closure_zid_drop(struct z_moved_closure_zid_t *closure_); */ ZENOHC_API const struct z_loaned_closure_zid_t *z_closure_zid_loan(const struct z_owned_closure_zid_t *closure); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows closure. - */ -ZENOHC_API -struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid_t *closure); /** * @brief Mutably borrows closure. */ ZENOHC_API -const struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(const struct z_owned_closure_zid_t *closure); +struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid_t *closure); /** * Takes ownership of the mutably borrowed closure */ @@ -2257,7 +2463,7 @@ const struct z_loaned_encoding_t *z_encoding_zenoh_string(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); +uint32_t z_entity_global_id_eid(const z_entity_global_id_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2265,7 +2471,7 @@ uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_entity_global_id_zid(const struct z_entity_global_id_t *this_); +struct z_id_t z_entity_global_id_zid(const z_entity_global_id_t *this_); #endif /** * Constructs send and recieve ends of the fifo channel @@ -2494,13 +2700,13 @@ ZENOHC_API struct z_id_t z_info_zid(const struct z_loaned_session_t *session); * Returns ``true`` if `this` is valid. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_internal_alloc_layout_check(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); #endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_internal_alloc_layout_null(struct z_owned_alloc_layout_t *this_); +ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); #endif /** * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -2524,7 +2730,7 @@ ZENOHC_API void z_internal_bytes_writer_null(struct z_owned_bytes_writer_t *this */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result_t *this_); +bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2532,7 +2738,7 @@ bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_chunk_alloc_result_null(struct z_owned_chunk_alloc_result_t *this_); +void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); #endif /** * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. @@ -2647,7 +2853,7 @@ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_); +bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2655,7 +2861,7 @@ bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_memory_layout_null(struct z_owned_memory_layout_t *this_); +void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); #endif /** * Returns ``true`` if mutex is valid, ``false`` otherwise. @@ -2754,7 +2960,7 @@ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_check(const struct z_owned_shm_t *this_); +bool z_internal_shm_check(const z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2762,7 +2968,7 @@ bool z_internal_shm_check(const struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); +bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2770,7 +2976,7 @@ bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); +void z_internal_shm_client_null(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2778,7 +2984,7 @@ void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage_t *this_); +bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2786,7 +2992,7 @@ bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *this_); +void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2794,7 +3000,7 @@ void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); +bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2802,7 +3008,7 @@ bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); +void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2810,7 +3016,7 @@ void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_null(struct z_owned_shm_t *this_); +void z_internal_shm_null(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2818,7 +3024,7 @@ void z_internal_shm_null(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); +bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2826,7 +3032,7 @@ bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_provider_null(struct z_owned_shm_provider_t *this_); +void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); #endif /** * @return ``true`` if slice is not empty, ``false`` otherwise. @@ -2842,7 +3048,7 @@ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); +bool z_internal_source_info_check(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2850,7 +3056,7 @@ bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_internal_source_info_null(struct z_owned_source_info_t *this_); +void z_internal_source_info_null(z_owned_source_info_t *this_); #endif /** * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. @@ -3037,7 +3243,7 @@ void z_keyexpr_take_loaned(struct z_owned_keyexpr_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); +void z_memory_layout_drop(z_moved_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3045,7 +3251,7 @@ void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, +void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, size_t *out_size, struct z_alloc_alignment_t *out_alignment); #endif @@ -3055,7 +3261,7 @@ void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned_memory_layout_t *this_); +const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3063,7 +3269,7 @@ const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_memory_layout_t *z_memory_layout_loan_mut(struct z_owned_memory_layout_t *this_); +z_loaned_memory_layout_t *z_memory_layout_loan_mut(z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3071,7 +3277,7 @@ struct z_loaned_memory_layout_t *z_memory_layout_loan_mut(struct z_owned_memory_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, +z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3080,8 +3286,8 @@ z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_take_loaned(struct z_owned_memory_layout_t *dst, - struct z_loaned_memory_layout_t *src); +void z_memory_layout_take_loaned(z_owned_memory_layout_t *dst, + z_loaned_memory_layout_t *src); #endif /** * Drops mutex and resets it to its gravestone state. @@ -3139,7 +3345,7 @@ ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); ZENOHC_API z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, struct z_moved_config_t *config, - const struct z_loaned_shm_client_storage_t *shm_clients); + const z_loaned_shm_client_storage_t *shm_clients); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3147,7 +3353,7 @@ z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); +void z_posix_shm_client_new(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3155,8 +3361,8 @@ void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_posix_shm_provider_new(struct z_owned_shm_provider_t *this_, - const struct z_loaned_memory_layout_t *layout); +z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, + const z_loaned_memory_layout_t *layout); #endif /** * Returns the default value of #z_priority_t. @@ -3185,7 +3391,7 @@ ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); +z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); #endif /** * Returns the key expression of the publisher. @@ -3420,7 +3626,7 @@ ZENOHC_API void z_queryable_drop(struct z_moved_queryable_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); +z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); #endif ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); @@ -3460,7 +3666,7 @@ ZENOHC_API uint8_t z_random_u8(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_ref_shm_client_storage_global(struct z_owned_shm_client_storage_t *this_); +void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3750,7 +3956,7 @@ enum z_reliability_t z_sample_reliability(const struct z_loaned_sample_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); +const z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); #endif /** * Takes ownership of the mutably borrowed sample. @@ -3809,7 +4015,7 @@ void z_session_take_loaned(struct z_owned_session_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_drop(struct z_moved_shm_client_t *this_); +void z_shm_client_drop(z_moved_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3817,7 +4023,7 @@ void z_shm_client_drop(struct z_moved_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_new(struct z_owned_shm_client_t *this_, +void z_shm_client_new(z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif @@ -3827,8 +4033,8 @@ void z_shm_client_new(struct z_owned_shm_client_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, - const struct z_loaned_shm_client_storage_t *from); +void z_shm_client_storage_clone(z_owned_shm_client_storage_t *this_, + const z_loaned_shm_client_storage_t *from); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3836,7 +4042,7 @@ void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); +void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3844,7 +4050,7 @@ void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const struct z_owned_shm_client_storage_t *this_); +const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3852,15 +4058,15 @@ const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const stru */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(struct z_owned_shm_client_storage_t *this_); +z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, - const struct zc_loaned_shm_client_list_t *clients, +z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, + const zc_loaned_shm_client_list_t *clients, bool add_default_client_set); #endif /** @@ -3868,7 +4074,7 @@ z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_); +void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3876,8 +4082,8 @@ void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_take_loaned(struct z_owned_shm_client_storage_t *dst, - struct z_loaned_shm_client_storage_t *src); +void z_shm_client_storage_take_loaned(z_owned_shm_client_storage_t *dst, + z_loaned_shm_client_storage_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3885,8 +4091,8 @@ void z_shm_client_storage_take_loaned(struct z_owned_shm_client_storage_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_clone(struct z_owned_shm_t *out, - const struct z_loaned_shm_t *this_); +void z_shm_clone(z_owned_shm_t *out, + const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3894,7 +4100,7 @@ void z_shm_clone(struct z_owned_shm_t *out, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); +const unsigned char *z_shm_data(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3902,7 +4108,7 @@ const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_drop(struct z_moved_shm_t *this_); +void z_shm_drop(z_moved_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3910,8 +4116,8 @@ void z_shm_drop(struct z_moved_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_from_mut(struct z_owned_shm_t *this_, - struct z_moved_shm_mut_t *that); +void z_shm_from_mut(z_owned_shm_t *this_, + z_moved_shm_mut_t *that); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3919,7 +4125,7 @@ void z_shm_from_mut(struct z_owned_shm_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_len(const struct z_loaned_shm_t *this_); +size_t z_shm_len(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3927,13 +4133,13 @@ size_t z_shm_len(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_t *z_shm_loan(const struct z_owned_shm_t *this_); +const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); #endif /** * @brief Mutably borrows ZShm slice. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); +ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3941,7 +4147,7 @@ ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); +const unsigned char *z_shm_mut_data(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3949,7 +4155,7 @@ const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); +unsigned char *z_shm_mut_data_mut(z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3957,7 +4163,7 @@ unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); +void z_shm_mut_drop(z_moved_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3965,7 +4171,7 @@ void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); +size_t z_shm_mut_len(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3973,7 +4179,7 @@ size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t *this_); +const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3981,15 +4187,13 @@ const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); +z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); #endif /** * Takes ownership of the mutably borrowed shm_mut */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_mut_take_loaned(struct z_owned_shm_mut_t *dst, - struct z_loaned_shm_mut_t *src); +ZENOHC_API void z_shm_mut_take_loaned(z_owned_shm_mut_t *dst, z_loaned_shm_mut_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4003,9 +4207,9 @@ void z_shm_mut_take_loaned(struct z_owned_shm_mut_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, - struct z_moved_shm_t *that, - struct z_owned_shm_t *immut); +z_result_t z_shm_mut_try_from_immut(z_owned_shm_mut_t *this_, + z_moved_shm_t *that, + z_owned_shm_t *immut); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4013,7 +4217,7 @@ z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4023,7 +4227,7 @@ void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4033,7 +4237,7 @@ void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4043,7 +4247,7 @@ void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_resu #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment, struct zc_threadsafe_context_t result_context, @@ -4056,7 +4260,7 @@ z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4066,7 +4270,7 @@ void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4075,14 +4279,14 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_available(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_defragment(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4090,14 +4294,14 @@ size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_drop(struct z_moved_shm_provider_t *this_); +void z_shm_provider_drop(z_moved_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4105,7 +4309,7 @@ size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *prov */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_shm_provider_t *this_); +const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4113,15 +4317,15 @@ const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_s */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_provider_t *z_shm_provider_loan_mut(struct z_owned_shm_provider_t *this_); +z_loaned_shm_provider_t *z_shm_provider_loan_mut(z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_shm_provider_map(z_owned_shm_mut_t *out_result, + const z_loaned_shm_provider_t *provider, struct z_allocated_chunk_t allocated_chunk, size_t len); #endif @@ -4131,7 +4335,7 @@ z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4141,8 +4345,8 @@ void z_shm_provider_new(struct z_owned_shm_provider_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_take_loaned(struct z_owned_shm_provider_t *dst, - struct z_loaned_shm_provider_t *src); +void z_shm_provider_take_loaned(z_owned_shm_provider_t *dst, + z_loaned_shm_provider_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4150,7 +4354,7 @@ void z_shm_provider_take_loaned(struct z_owned_shm_provider_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_threadsafe_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_threadsafe_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4159,7 +4363,7 @@ void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, * Takes ownership of the mutably borrowed shm */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_shm_take_loaned(struct z_owned_shm_t *dst, struct z_loaned_shm_t *src); +ZENOHC_API void z_shm_take_loaned(z_owned_shm_t *dst, z_loaned_shm_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4167,7 +4371,7 @@ ZENOHC_API void z_shm_take_loaned(struct z_owned_shm_t *dst, struct z_loaned_shm */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4175,7 +4379,7 @@ struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_reloan_mut(struct z_loaned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_reloan_mut(z_loaned_shm_t *this_); #endif /** * Puts current thread to sleep for specified amount of milliseconds. @@ -4256,7 +4460,7 @@ ZENOHC_API void z_slice_take_loaned(struct z_owned_slice_t *dst, struct z_loaned */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_drop(struct z_moved_source_info_t *this_); +void z_source_info_drop(z_moved_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4264,7 +4468,7 @@ void z_source_info_drop(struct z_moved_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t *this_); +z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4272,7 +4476,7 @@ struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_source_info_t *this_); +const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4280,7 +4484,7 @@ const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_sou */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_source_info_loan_mut(const struct z_owned_source_info_t *this_); +const z_loaned_source_info_t *z_source_info_loan_mut(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4288,8 +4492,8 @@ const struct z_loaned_source_info_t *z_source_info_loan_mut(const struct z_owned */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t z_source_info_new(struct z_owned_source_info_t *this_, - const struct z_entity_global_id_t *source_id, +z_result_t z_source_info_new(z_owned_source_info_t *this_, + const z_entity_global_id_t *source_id, uint32_t source_sn); #endif /** @@ -4298,7 +4502,7 @@ z_result_t z_source_info_new(struct z_owned_source_info_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); +uint32_t z_source_info_sn(const z_loaned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4306,8 +4510,8 @@ uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_take_loaned(struct z_owned_source_info_t *dst, - struct z_loaned_source_info_t *src); +void z_source_info_take_loaned(z_owned_source_info_t *dst, + z_loaned_source_info_t *src); #endif /** * Constructs an owned copy of a string array. @@ -4925,7 +5129,7 @@ void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_s */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t *this_); +bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4933,7 +5137,7 @@ bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_); +void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4941,7 +5145,7 @@ void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener_t *this_); +bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4949,7 +5153,7 @@ bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *this_); +void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4957,7 +5161,7 @@ void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t *this_); +bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4965,7 +5169,7 @@ bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_internal_shm_client_list_null(struct zc_owned_shm_client_list_t *this_); +void zc_internal_shm_client_list_null(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5028,7 +5232,7 @@ z_result_t zc_liveliness_declare_subscriber(const struct z_loaned_session_t *ses #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t zc_liveliness_declare_token(const struct z_loaned_session_t *session, - struct zc_owned_liveliness_token_t *token, + zc_owned_liveliness_token_t *token, const struct z_loaned_keyexpr_t *key_expr, const struct zc_liveliness_declaration_options_t *_options); #endif @@ -5070,7 +5274,7 @@ void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_op */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); +void zc_liveliness_token_drop(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5078,7 +5282,7 @@ void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct zc_owned_liveliness_token_t *this_); +const zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5086,7 +5290,7 @@ const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_undeclare_token(struct zc_moved_liveliness_token_t *this_); +z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5124,7 +5328,7 @@ z_result_t zc_publisher_declare_background_matching_listener(const struct z_loan #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t zc_publisher_declare_matching_listener(const struct z_loaned_publisher_t *publisher, - struct zc_owned_matching_listener_t *matching_listener, + zc_owned_matching_listener_t *matching_listener, struct zc_moved_closure_matching_status_t *callback); #endif /** @@ -5144,7 +5348,7 @@ z_result_t zc_publisher_get_matching_status(const struct z_loaned_publisher_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *this_); +void zc_publisher_matching_listener_drop(zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5159,9 +5363,9 @@ enum zc_reply_keyexpr_t zc_reply_keyexpr_default(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *this_, +z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, - struct z_moved_shm_client_t *client); + z_moved_shm_client_t *client); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5169,7 +5373,7 @@ z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); +void zc_shm_client_list_drop(zc_moved_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5177,7 +5381,7 @@ void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct zc_owned_shm_client_list_t *this_); +const zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5185,7 +5389,7 @@ const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct z */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_shm_client_list_t *this_); +zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5193,7 +5397,7 @@ struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_new(struct zc_owned_shm_client_list_t *this_); +void zc_shm_client_list_new(zc_owned_shm_client_list_t *this_); #endif /** * Stops all Zenoh tasks and drops all related static variables. @@ -5261,7 +5465,7 @@ z_result_t ze_declare_background_querying_subscriber(const struct z_loaned_sessi #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t ze_declare_publication_cache(const struct z_loaned_session_t *session, - struct ze_owned_publication_cache_t *pub_cache, + ze_owned_publication_cache_t *pub_cache, const struct z_loaned_keyexpr_t *key_expr, struct ze_publication_cache_options_t *options); #endif @@ -5280,7 +5484,7 @@ z_result_t ze_declare_publication_cache(const struct z_loaned_session_t *session #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t ze_declare_querying_subscriber(const struct z_loaned_session_t *session, - struct ze_owned_querying_subscriber_t *querying_subscriber, + ze_owned_querying_subscriber_t *querying_subscriber, const struct z_loaned_keyexpr_t *key_expr, struct z_moved_closure_sample_t *callback, struct ze_querying_subscriber_options_t *options); @@ -5464,7 +5668,7 @@ ZENOHC_API bool ze_deserializer_is_done(const struct ze_deserializer_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache_t *this_); +bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5472,7 +5676,7 @@ bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *this_); +void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5480,13 +5684,13 @@ void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *this_); +bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); #endif /** * Constructs a querying subscriber in a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_subscriber_t *this_); +ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); #endif /** * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -5503,7 +5707,7 @@ ZENOHC_API void ze_internal_serializer_null(struct ze_owned_serializer_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); +void ze_publication_cache_drop(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5511,7 +5715,7 @@ void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_loaned_publication_cache_t *this_); +const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const ze_loaned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5519,7 +5723,7 @@ const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_lo */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_publication_cache_t *ze_publication_cache_loan(const struct ze_owned_publication_cache_t *this_); +const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5536,7 +5740,7 @@ void ze_publication_cache_options_default(struct ze_publication_cache_options_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); +void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5546,7 +5750,7 @@ void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber_t *this_, +z_result_t ze_querying_subscriber_get(const ze_loaned_querying_subscriber_t *this_, const struct z_loaned_keyexpr_t *selector, struct z_get_options_t *options); #endif @@ -5556,7 +5760,7 @@ z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *this_); +const ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5801,7 +6005,7 @@ z_result_t ze_serializer_serialize_uint8(struct ze_loaned_serializer_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *this_); +z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5811,5 +6015,5 @@ z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_querying_subscriber(struct ze_moved_querying_subscriber_t *this_); +z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *this_); #endif diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 9fa81b136..7c0725f67 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -4,10 +4,8 @@ #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return (z_moved_alloc_layout_t*)(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return (z_moved_bytes_t*)(x); } static inline z_moved_bytes_writer_t* z_bytes_writer_move(z_owned_bytes_writer_t* x) { return (z_moved_bytes_writer_t*)(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return (z_moved_chunk_alloc_result_t*)(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return (z_moved_closure_hello_t*)(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return (z_moved_closure_query_t*)(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return (z_moved_closure_reply_t*)(x); } @@ -21,7 +19,6 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return (z_moved_fifo_handler_sample_t*)(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return (z_moved_hello_t*)(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return (z_moved_keyexpr_t*)(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return (z_moved_memory_layout_t*)(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return (z_moved_mutex_t*)(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return (z_moved_publisher_t*)(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return (z_moved_query_t*)(x); } @@ -33,33 +30,19 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return (z_moved_ring_handler_sample_t*)(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return (z_moved_sample_t*)(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return (z_moved_session_t*)(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return (z_moved_shm_client_t*)(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return (z_moved_shm_client_storage_t*)(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return (z_moved_shm_t*)(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return (z_moved_shm_mut_t*)(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return (z_moved_shm_provider_t*)(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return (z_moved_slice_t*)(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return (z_moved_source_info_t*)(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return (z_moved_string_array_t*)(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return (z_moved_string_t*)(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return (z_moved_subscriber_t*)(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return (z_moved_task_t*)(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return (zc_moved_closure_log_t*)(x); } -static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return (zc_moved_closure_matching_status_t*)(x); } -static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return (zc_moved_liveliness_token_t*)(x); } -static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return (zc_moved_matching_listener_t*)(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return (zc_moved_shm_client_list_t*)(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return (ze_moved_publication_cache_t*)(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return (ze_moved_querying_subscriber_t*)(x); } static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x) { return (ze_moved_serializer_t*)(x); } #define z_loan(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_loan, \ z_owned_bytes_t : z_bytes_loan, \ z_owned_bytes_writer_t : z_bytes_writer_loan, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ z_owned_closure_query_t : z_closure_query_loan, \ z_owned_closure_reply_t : z_closure_reply_loan, \ @@ -73,7 +56,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan, \ z_owned_hello_t : z_hello_loan, \ z_owned_keyexpr_t : z_keyexpr_loan, \ - z_owned_memory_layout_t : z_memory_layout_loan, \ z_owned_publisher_t : z_publisher_loan, \ z_owned_query_t : z_query_loan, \ z_owned_queryable_t : z_queryable_loan, \ @@ -84,12 +66,7 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t : z_ring_handler_sample_loan, \ z_owned_sample_t : z_sample_loan, \ z_owned_session_t : z_session_loan, \ - z_owned_shm_client_storage_t : z_shm_client_storage_loan, \ - z_owned_shm_t : z_shm_loan, \ - z_owned_shm_mut_t : z_shm_mut_loan, \ - z_owned_shm_provider_t : z_shm_provider_loan, \ z_owned_slice_t : z_slice_loan, \ - z_owned_source_info_t : z_source_info_loan, \ z_owned_string_array_t : z_string_array_loan, \ z_owned_string_t : z_string_loan, \ z_owned_subscriber_t : z_subscriber_loan, \ @@ -97,20 +74,13 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_view_slice_t : z_view_slice_loan, \ z_view_string_t : z_view_string_loan, \ zc_owned_closure_log_t : zc_closure_log_loan, \ - zc_owned_closure_matching_status_t : zc_closure_matching_status_loan, \ - zc_owned_liveliness_token_t : zc_liveliness_token_loan, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan, \ - ze_owned_publication_cache_t : ze_publication_cache_loan, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_loan, \ ze_owned_serializer_t : ze_serializer_loan \ )(&this_) #define z_loan_mut(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_loan_mut, \ z_owned_bytes_t : z_bytes_loan_mut, \ z_owned_bytes_writer_t : z_bytes_writer_loan_mut, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_loan_mut, \ z_owned_closure_hello_t : z_closure_hello_loan_mut, \ z_owned_closure_query_t : z_closure_query_loan_mut, \ z_owned_closure_reply_t : z_closure_reply_loan_mut, \ @@ -124,7 +94,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan_mut, \ z_owned_hello_t : z_hello_loan_mut, \ z_owned_keyexpr_t : z_keyexpr_loan_mut, \ - z_owned_memory_layout_t : z_memory_layout_loan_mut, \ z_owned_mutex_t : z_mutex_loan_mut, \ z_owned_publisher_t : z_publisher_loan_mut, \ z_owned_query_t : z_query_loan_mut, \ @@ -136,24 +105,17 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t : z_ring_handler_sample_loan_mut, \ z_owned_sample_t : z_sample_loan_mut, \ z_owned_session_t : z_session_loan_mut, \ - z_owned_shm_client_storage_t : z_shm_client_storage_loan_mut, \ - z_owned_shm_t : z_shm_loan_mut, \ - z_owned_shm_mut_t : z_shm_mut_loan_mut, \ - z_owned_shm_provider_t : z_shm_provider_loan_mut, \ z_owned_slice_t : z_slice_loan_mut, \ z_owned_string_array_t : z_string_array_loan_mut, \ z_owned_string_t : z_string_loan_mut, \ z_owned_subscriber_t : z_subscriber_loan_mut, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut, \ ze_owned_serializer_t : ze_serializer_loan_mut \ )(&this_) #define z_drop(this_) \ _Generic((this_), \ - z_moved_alloc_layout_t* : z_alloc_layout_drop, \ z_moved_bytes_t* : z_bytes_drop, \ z_moved_bytes_writer_t* : z_bytes_writer_drop, \ - z_moved_chunk_alloc_result_t* : z_chunk_alloc_result_drop, \ z_moved_closure_hello_t* : z_closure_hello_drop, \ z_moved_closure_query_t* : z_closure_query_drop, \ z_moved_closure_reply_t* : z_closure_reply_drop, \ @@ -167,7 +129,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_moved_fifo_handler_sample_t* : z_fifo_handler_sample_drop, \ z_moved_hello_t* : z_hello_drop, \ z_moved_keyexpr_t* : z_keyexpr_drop, \ - z_moved_memory_layout_t* : z_memory_layout_drop, \ z_moved_mutex_t* : z_mutex_drop, \ z_moved_publisher_t* : z_publisher_drop, \ z_moved_query_t* : z_query_drop, \ @@ -179,33 +140,19 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_moved_ring_handler_sample_t* : z_ring_handler_sample_drop, \ z_moved_sample_t* : z_sample_drop, \ z_moved_session_t* : z_session_drop, \ - z_moved_shm_client_t* : z_shm_client_drop, \ - z_moved_shm_client_storage_t* : z_shm_client_storage_drop, \ - z_moved_shm_t* : z_shm_drop, \ - z_moved_shm_mut_t* : z_shm_mut_drop, \ - z_moved_shm_provider_t* : z_shm_provider_drop, \ z_moved_slice_t* : z_slice_drop, \ - z_moved_source_info_t* : z_source_info_drop, \ z_moved_string_array_t* : z_string_array_drop, \ z_moved_string_t* : z_string_drop, \ z_moved_subscriber_t* : z_subscriber_drop, \ z_moved_task_t* : z_task_drop, \ zc_moved_closure_log_t* : zc_closure_log_drop, \ - zc_moved_closure_matching_status_t* : zc_closure_matching_status_drop, \ - zc_moved_liveliness_token_t* : zc_liveliness_token_drop, \ - zc_moved_matching_listener_t* : zc_publisher_matching_listener_drop, \ - zc_moved_shm_client_list_t* : zc_shm_client_list_drop, \ - ze_moved_publication_cache_t* : ze_publication_cache_drop, \ - ze_moved_querying_subscriber_t* : ze_querying_subscriber_drop, \ ze_moved_serializer_t* : ze_serializer_drop \ )(this_) #define z_move(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_move, \ z_owned_bytes_t : z_bytes_move, \ z_owned_bytes_writer_t : z_bytes_writer_move, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_move, \ z_owned_closure_hello_t : z_closure_hello_move, \ z_owned_closure_query_t : z_closure_query_move, \ z_owned_closure_reply_t : z_closure_reply_move, \ @@ -219,7 +166,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_fifo_handler_sample_t : z_fifo_handler_sample_move, \ z_owned_hello_t : z_hello_move, \ z_owned_keyexpr_t : z_keyexpr_move, \ - z_owned_memory_layout_t : z_memory_layout_move, \ z_owned_mutex_t : z_mutex_move, \ z_owned_publisher_t : z_publisher_move, \ z_owned_query_t : z_query_move, \ @@ -231,33 +177,19 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t : z_ring_handler_sample_move, \ z_owned_sample_t : z_sample_move, \ z_owned_session_t : z_session_move, \ - z_owned_shm_client_t : z_shm_client_move, \ - z_owned_shm_client_storage_t : z_shm_client_storage_move, \ - z_owned_shm_t : z_shm_move, \ - z_owned_shm_mut_t : z_shm_mut_move, \ - z_owned_shm_provider_t : z_shm_provider_move, \ z_owned_slice_t : z_slice_move, \ - z_owned_source_info_t : z_source_info_move, \ z_owned_string_array_t : z_string_array_move, \ z_owned_string_t : z_string_move, \ z_owned_subscriber_t : z_subscriber_move, \ z_owned_task_t : z_task_move, \ zc_owned_closure_log_t : zc_closure_log_move, \ - zc_owned_closure_matching_status_t : zc_closure_matching_status_move, \ - zc_owned_liveliness_token_t : zc_liveliness_token_move, \ - zc_owned_matching_listener_t : zc_publisher_matching_listener_move, \ - zc_owned_shm_client_list_t : zc_shm_client_list_move, \ - ze_owned_publication_cache_t : ze_publication_cache_move, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_move, \ ze_owned_serializer_t : ze_serializer_move \ )(&this_) #define z_internal_null(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_internal_alloc_layout_null, \ z_owned_bytes_t* : z_internal_bytes_null, \ z_owned_bytes_writer_t* : z_internal_bytes_writer_null, \ - z_owned_chunk_alloc_result_t* : z_internal_chunk_alloc_result_null, \ z_owned_closure_hello_t* : z_internal_closure_hello_null, \ z_owned_closure_query_t* : z_internal_closure_query_null, \ z_owned_closure_reply_t* : z_internal_closure_reply_null, \ @@ -271,7 +203,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_fifo_handler_sample_t* : z_internal_fifo_handler_sample_null, \ z_owned_hello_t* : z_internal_hello_null, \ z_owned_keyexpr_t* : z_internal_keyexpr_null, \ - z_owned_memory_layout_t* : z_internal_memory_layout_null, \ z_owned_mutex_t* : z_internal_mutex_null, \ z_owned_publisher_t* : z_internal_publisher_null, \ z_owned_query_t* : z_internal_query_null, \ @@ -283,31 +214,17 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t* : z_internal_ring_handler_sample_null, \ z_owned_sample_t* : z_internal_sample_null, \ z_owned_session_t* : z_internal_session_null, \ - z_owned_shm_client_t* : z_internal_shm_client_null, \ - z_owned_shm_client_storage_t* : z_internal_shm_client_storage_null, \ - z_owned_shm_mut_t* : z_internal_shm_mut_null, \ - z_owned_shm_t* : z_internal_shm_null, \ - z_owned_shm_provider_t* : z_internal_shm_provider_null, \ z_owned_slice_t* : z_internal_slice_null, \ - z_owned_source_info_t* : z_internal_source_info_null, \ z_owned_string_array_t* : z_internal_string_array_null, \ z_owned_string_t* : z_internal_string_null, \ z_owned_subscriber_t* : z_internal_subscriber_null, \ z_owned_task_t* : z_internal_task_null, \ zc_owned_closure_log_t* : zc_internal_closure_log_null, \ - zc_owned_closure_matching_status_t* : zc_internal_closure_matching_status_null, \ - zc_owned_liveliness_token_t* : zc_internal_liveliness_token_null, \ - zc_owned_matching_listener_t* : zc_internal_matching_listener_null, \ - zc_owned_shm_client_list_t* : zc_internal_shm_client_list_null, \ - ze_owned_publication_cache_t* : ze_internal_publication_cache_null, \ - ze_owned_querying_subscriber_t* : ze_internal_querying_subscriber_null, \ ze_owned_serializer_t* : ze_internal_serializer_null \ )(this_) -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } static inline void z_bytes_writer_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* x) { *this_ = x->_this; z_internal_bytes_writer_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } @@ -321,7 +238,6 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -333,33 +249,19 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } -static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } -static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { *this_ = x->_this; ze_internal_serializer_null(&x->_this); } #define z_take(this_, x) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_alloc_layout_take, \ z_owned_bytes_t* : z_bytes_take, \ z_owned_bytes_writer_t* : z_bytes_writer_take, \ - z_owned_chunk_alloc_result_t* : z_chunk_alloc_result_take, \ z_owned_closure_hello_t* : z_closure_hello_take, \ z_owned_closure_query_t* : z_closure_query_take, \ z_owned_closure_reply_t* : z_closure_reply_take, \ @@ -373,7 +275,6 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ z_owned_hello_t* : z_hello_take, \ z_owned_keyexpr_t* : z_keyexpr_take, \ - z_owned_memory_layout_t* : z_memory_layout_take, \ z_owned_mutex_t* : z_mutex_take, \ z_owned_publisher_t* : z_publisher_take, \ z_owned_query_t* : z_query_take, \ @@ -385,33 +286,19 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ z_owned_sample_t* : z_sample_take, \ z_owned_session_t* : z_session_take, \ - z_owned_shm_client_t* : z_shm_client_take, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_take, \ - z_owned_shm_t* : z_shm_take, \ - z_owned_shm_mut_t* : z_shm_mut_take, \ - z_owned_shm_provider_t* : z_shm_provider_take, \ z_owned_slice_t* : z_slice_take, \ - z_owned_source_info_t* : z_source_info_take, \ z_owned_string_array_t* : z_string_array_take, \ z_owned_string_t* : z_string_take, \ z_owned_subscriber_t* : z_subscriber_take, \ z_owned_task_t* : z_task_take, \ zc_owned_closure_log_t* : zc_closure_log_take, \ - zc_owned_closure_matching_status_t* : zc_closure_matching_status_take, \ - zc_owned_liveliness_token_t* : zc_liveliness_token_take, \ - zc_owned_matching_listener_t* : zc_publisher_matching_listener_take, \ - zc_owned_shm_client_list_t* : zc_shm_client_list_take, \ - ze_owned_publication_cache_t* : ze_publication_cache_take, \ - ze_owned_querying_subscriber_t* : ze_querying_subscriber_take, \ ze_owned_serializer_t* : ze_serializer_take \ )(this_, x) #define z_internal_check(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_internal_alloc_layout_check, \ z_owned_bytes_t : z_internal_bytes_check, \ z_owned_bytes_writer_t : z_internal_bytes_writer_check, \ - z_owned_chunk_alloc_result_t : z_internal_chunk_alloc_result_check, \ z_owned_closure_hello_t : z_internal_closure_hello_check, \ z_owned_closure_query_t : z_internal_closure_query_check, \ z_owned_closure_reply_t : z_internal_closure_reply_check, \ @@ -425,7 +312,6 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_fifo_handler_sample_t : z_internal_fifo_handler_sample_check, \ z_owned_hello_t : z_internal_hello_check, \ z_owned_keyexpr_t : z_internal_keyexpr_check, \ - z_owned_memory_layout_t : z_internal_memory_layout_check, \ z_owned_mutex_t : z_internal_mutex_check, \ z_owned_publisher_t : z_internal_publisher_check, \ z_owned_query_t : z_internal_query_check, \ @@ -437,24 +323,12 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ z_owned_sample_t : z_internal_sample_check, \ z_owned_session_t : z_internal_session_check, \ - z_owned_shm_t : z_internal_shm_check, \ - z_owned_shm_client_t : z_internal_shm_client_check, \ - z_owned_shm_client_storage_t : z_internal_shm_client_storage_check, \ - z_owned_shm_mut_t : z_internal_shm_mut_check, \ - z_owned_shm_provider_t : z_internal_shm_provider_check, \ z_owned_slice_t : z_internal_slice_check, \ - z_owned_source_info_t : z_internal_source_info_check, \ z_owned_string_array_t : z_internal_string_array_check, \ z_owned_string_t : z_internal_string_check, \ z_owned_subscriber_t : z_internal_subscriber_check, \ z_owned_task_t : z_internal_task_check, \ zc_owned_closure_log_t : zc_internal_closure_log_check, \ - zc_owned_closure_matching_status_t : zc_internal_closure_matching_status_check, \ - zc_owned_liveliness_token_t : zc_internal_liveliness_token_check, \ - zc_owned_matching_listener_t : zc_internal_matching_listener_check, \ - zc_owned_shm_client_list_t : zc_internal_shm_client_list_check, \ - ze_owned_publication_cache_t : ze_internal_publication_cache_check, \ - ze_owned_querying_subscriber_t : ze_internal_querying_subscriber_check, \ ze_owned_serializer_t : ze_internal_serializer_check \ )(&this_) @@ -464,8 +338,7 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser const z_loaned_closure_query_t* : z_closure_query_call, \ const z_loaned_closure_reply_t* : z_closure_reply_call, \ const z_loaned_closure_sample_t* : z_closure_sample_call, \ - const z_loaned_closure_zid_t* : z_closure_zid_call, \ - const zc_loaned_closure_matching_status_t* : zc_closure_matching_status_call \ + const z_loaned_closure_zid_t* : z_closure_zid_call \ )(closure, hello) typedef void(*z_closure_drop_callback_t)(void *context); @@ -475,7 +348,6 @@ typedef void(*z_closure_reply_callback_t)(z_loaned_reply_t *reply, void *context typedef void(*z_closure_sample_callback_t)(z_loaned_sample_t *sample, void *context); typedef void(*z_closure_zid_callback_t)(const z_id_t *z_id, void *context); typedef void(*zc_closure_log_callback_t)(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); -typedef void(*zc_closure_matching_status_callback_t)(const zc_matching_status_t *matching_status, void *context); #define z_closure(this_, call, drop, context) \ _Generic((this_), \ @@ -484,8 +356,7 @@ typedef void(*zc_closure_matching_status_callback_t)(const zc_matching_status_t z_owned_closure_reply_t* : z_closure_reply, \ z_owned_closure_sample_t* : z_closure_sample, \ z_owned_closure_zid_t* : z_closure_zid, \ - zc_owned_closure_log_t* : zc_closure_log, \ - zc_owned_closure_matching_status_t* : zc_closure_matching_status \ + zc_owned_closure_log_t* : zc_closure_log \ )(this_, call, drop, context) #define z_try_recv(this_, query) \ @@ -519,8 +390,6 @@ typedef void(*zc_closure_matching_status_callback_t)(const zc_matching_status_t z_owned_reply_t* : z_reply_clone, \ z_owned_reply_err_t* : z_reply_err_clone, \ z_owned_sample_t* : z_sample_clone, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_clone, \ - z_owned_shm_t* : z_shm_clone, \ z_owned_slice_t* : z_slice_clone, \ z_owned_string_array_t* : z_string_array_clone, \ z_owned_string_t* : z_string_clone \ @@ -528,10 +397,8 @@ typedef void(*zc_closure_matching_status_callback_t)(const zc_matching_status_t #else // #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_writer_t* z_bytes_writer_move(z_owned_bytes_writer_t* x) { return reinterpret_cast(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_reply_t* z_closure_reply_move(z_owned_closure_reply_t* x) { return reinterpret_cast(x); } @@ -545,7 +412,6 @@ static inline z_moved_fifo_handler_reply_t* z_fifo_handler_reply_move(z_owned_fi static inline z_moved_fifo_handler_sample_t* z_fifo_handler_sample_move(z_owned_fifo_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return reinterpret_cast(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return reinterpret_cast(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return reinterpret_cast(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return reinterpret_cast(x); } @@ -557,32 +423,18 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return reinterpret_cast(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return reinterpret_cast(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return reinterpret_cast(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return reinterpret_cast(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return reinterpret_cast(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return reinterpret_cast(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return reinterpret_cast(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return reinterpret_cast(x); } -static inline zc_moved_closure_matching_status_t* zc_closure_matching_status_move(zc_owned_closure_matching_status_t* x) { return reinterpret_cast(x); } -static inline zc_moved_liveliness_token_t* zc_liveliness_token_move(zc_owned_liveliness_token_t* x) { return reinterpret_cast(x); } -static inline zc_moved_matching_listener_t* zc_publisher_matching_listener_move(zc_owned_matching_listener_t* x) { return reinterpret_cast(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return reinterpret_cast(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return reinterpret_cast(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return reinterpret_cast(x); } static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x) { return reinterpret_cast(x); } -inline const z_loaned_alloc_layout_t* z_loan(const z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan(&this_); }; inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& this_) { return z_bytes_loan(&this_); }; inline const z_loaned_bytes_writer_t* z_loan(const z_owned_bytes_writer_t& this_) { return z_bytes_writer_loan(&this_); }; -inline const z_loaned_chunk_alloc_result_t* z_loan(const z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan(&this_); }; inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& closure) { return z_closure_hello_loan(&closure); }; inline const z_loaned_closure_query_t* z_loan(const z_owned_closure_query_t& closure) { return z_closure_query_loan(&closure); }; inline const z_loaned_closure_reply_t* z_loan(const z_owned_closure_reply_t& closure) { return z_closure_reply_loan(&closure); }; @@ -596,7 +448,6 @@ inline const z_loaned_fifo_handler_reply_t* z_loan(const z_owned_fifo_handler_re inline const z_loaned_fifo_handler_sample_t* z_loan(const z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan(&this_); }; inline const z_loaned_hello_t* z_loan(const z_owned_hello_t& this_) { return z_hello_loan(&this_); }; inline const z_loaned_keyexpr_t* z_loan(const z_owned_keyexpr_t& this_) { return z_keyexpr_loan(&this_); }; -inline const z_loaned_memory_layout_t* z_loan(const z_owned_memory_layout_t& this_) { return z_memory_layout_loan(&this_); }; inline const z_loaned_publisher_t* z_loan(const z_owned_publisher_t& this_) { return z_publisher_loan(&this_); }; inline const z_loaned_query_t* z_loan(const z_owned_query_t& this_) { return z_query_loan(&this_); }; inline const z_loaned_queryable_t* z_loan(const z_owned_queryable_t& this_) { return z_queryable_loan(&this_); }; @@ -607,12 +458,7 @@ inline const z_loaned_ring_handler_reply_t* z_loan(const z_owned_ring_handler_re inline const z_loaned_ring_handler_sample_t* z_loan(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan(&this_); }; inline const z_loaned_sample_t* z_loan(const z_owned_sample_t& this_) { return z_sample_loan(&this_); }; inline const z_loaned_session_t* z_loan(const z_owned_session_t& this_) { return z_session_loan(&this_); }; -inline const z_loaned_shm_client_storage_t* z_loan(const z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan(&this_); }; -inline const z_loaned_shm_t* z_loan(const z_owned_shm_t& this_) { return z_shm_loan(&this_); }; -inline const z_loaned_shm_mut_t* z_loan(const z_owned_shm_mut_t& this_) { return z_shm_mut_loan(&this_); }; -inline const z_loaned_shm_provider_t* z_loan(const z_owned_shm_provider_t& this_) { return z_shm_provider_loan(&this_); }; inline const z_loaned_slice_t* z_loan(const z_owned_slice_t& this_) { return z_slice_loan(&this_); }; -inline const z_loaned_source_info_t* z_loan(const z_owned_source_info_t& this_) { return z_source_info_loan(&this_); }; inline const z_loaned_string_array_t* z_loan(const z_owned_string_array_t& this_) { return z_string_array_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_owned_string_t& this_) { return z_string_loan(&this_); }; inline const z_loaned_subscriber_t* z_loan(const z_owned_subscriber_t& this_) { return z_subscriber_loan(&this_); }; @@ -620,18 +466,11 @@ inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& this_) { return inline const z_loaned_slice_t* z_loan(const z_view_slice_t& this_) { return z_view_slice_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_view_string_t& this_) { return z_view_string_loan(&this_); }; inline const zc_loaned_closure_log_t* z_loan(const zc_owned_closure_log_t& closure) { return zc_closure_log_loan(&closure); }; -inline const zc_loaned_closure_matching_status_t* z_loan(const zc_owned_closure_matching_status_t& closure) { return zc_closure_matching_status_loan(&closure); }; -inline const zc_loaned_liveliness_token_t* z_loan(const zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_loan(&this_); }; -inline const zc_loaned_shm_client_list_t* z_loan(const zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan(&this_); }; -inline const ze_loaned_publication_cache_t* z_loan(const ze_owned_publication_cache_t& this_) { return ze_publication_cache_loan(&this_); }; -inline const ze_loaned_querying_subscriber_t* z_loan(const ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_loan(&this_); }; inline const ze_loaned_serializer_t* z_loan(const ze_owned_serializer_t& this_) { return ze_serializer_loan(&this_); }; -inline z_loaned_alloc_layout_t* z_loan_mut(z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan_mut(&this_); }; inline z_loaned_bytes_t* z_loan_mut(z_owned_bytes_t& this_) { return z_bytes_loan_mut(&this_); }; inline z_loaned_bytes_writer_t* z_loan_mut(z_owned_bytes_writer_t& this_) { return z_bytes_writer_loan_mut(&this_); }; -inline z_loaned_chunk_alloc_result_t* z_loan_mut(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_loan_mut(&this_); }; inline z_loaned_closure_hello_t* z_loan_mut(z_owned_closure_hello_t& closure) { return z_closure_hello_loan_mut(&closure); }; inline z_loaned_closure_query_t* z_loan_mut(z_owned_closure_query_t& closure) { return z_closure_query_loan_mut(&closure); }; inline z_loaned_closure_reply_t* z_loan_mut(z_owned_closure_reply_t& closure) { return z_closure_reply_loan_mut(&closure); }; @@ -645,7 +484,6 @@ inline z_loaned_fifo_handler_reply_t* z_loan_mut(z_owned_fifo_handler_reply_t& t inline z_loaned_fifo_handler_sample_t* z_loan_mut(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan_mut(&this_); }; inline z_loaned_hello_t* z_loan_mut(z_owned_hello_t& this_) { return z_hello_loan_mut(&this_); }; inline z_loaned_keyexpr_t* z_loan_mut(z_owned_keyexpr_t& this_) { return z_keyexpr_loan_mut(&this_); }; -inline z_loaned_memory_layout_t* z_loan_mut(z_owned_memory_layout_t& this_) { return z_memory_layout_loan_mut(&this_); }; inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& this_) { return z_mutex_loan_mut(&this_); }; inline z_loaned_publisher_t* z_loan_mut(z_owned_publisher_t& this_) { return z_publisher_loan_mut(&this_); }; inline z_loaned_query_t* z_loan_mut(z_owned_query_t& this_) { return z_query_loan_mut(&this_); }; @@ -657,22 +495,15 @@ inline z_loaned_ring_handler_reply_t* z_loan_mut(z_owned_ring_handler_reply_t& t inline z_loaned_ring_handler_sample_t* z_loan_mut(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan_mut(&this_); }; inline z_loaned_sample_t* z_loan_mut(z_owned_sample_t& this_) { return z_sample_loan_mut(&this_); }; inline z_loaned_session_t* z_loan_mut(z_owned_session_t& this_) { return z_session_loan_mut(&this_); }; -inline z_loaned_shm_client_storage_t* z_loan_mut(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan_mut(&this_); }; -inline z_loaned_shm_t* z_loan_mut(z_owned_shm_t& this_) { return z_shm_loan_mut(&this_); }; -inline z_loaned_shm_mut_t* z_loan_mut(z_owned_shm_mut_t& this_) { return z_shm_mut_loan_mut(&this_); }; -inline z_loaned_shm_provider_t* z_loan_mut(z_owned_shm_provider_t& this_) { return z_shm_provider_loan_mut(&this_); }; inline z_loaned_slice_t* z_loan_mut(z_owned_slice_t& this_) { return z_slice_loan_mut(&this_); }; inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { return z_string_array_loan_mut(&this_); }; inline z_loaned_string_t* z_loan_mut(z_owned_string_t& this_) { return z_string_loan_mut(&this_); }; inline z_loaned_subscriber_t* z_loan_mut(z_owned_subscriber_t& this_) { return z_subscriber_loan_mut(&this_); }; -inline zc_loaned_shm_client_list_t* z_loan_mut(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan_mut(&this_); }; inline ze_loaned_serializer_t* z_loan_mut(ze_owned_serializer_t& this_) { return ze_serializer_loan_mut(&this_); }; -inline void z_drop(z_moved_alloc_layout_t* this_) { z_alloc_layout_drop(this_); }; inline void z_drop(z_moved_bytes_t* this_) { z_bytes_drop(this_); }; inline void z_drop(z_moved_bytes_writer_t* this_) { z_bytes_writer_drop(this_); }; -inline void z_drop(z_moved_chunk_alloc_result_t* this_) { z_chunk_alloc_result_drop(this_); }; inline void z_drop(z_moved_closure_hello_t* this_) { z_closure_hello_drop(this_); }; inline void z_drop(z_moved_closure_query_t* closure_) { z_closure_query_drop(closure_); }; inline void z_drop(z_moved_closure_reply_t* closure_) { z_closure_reply_drop(closure_); }; @@ -686,7 +517,6 @@ inline void z_drop(z_moved_fifo_handler_reply_t* this_) { z_fifo_handler_reply_d inline void z_drop(z_moved_fifo_handler_sample_t* this_) { z_fifo_handler_sample_drop(this_); }; inline void z_drop(z_moved_hello_t* this_) { z_hello_drop(this_); }; inline void z_drop(z_moved_keyexpr_t* this_) { z_keyexpr_drop(this_); }; -inline void z_drop(z_moved_memory_layout_t* this_) { z_memory_layout_drop(this_); }; inline void z_drop(z_moved_mutex_t* this_) { z_mutex_drop(this_); }; inline void z_drop(z_moved_publisher_t* this_) { z_publisher_drop(this_); }; inline void z_drop(z_moved_query_t* this_) { z_query_drop(this_); }; @@ -698,31 +528,17 @@ inline void z_drop(z_moved_ring_handler_reply_t* this_) { z_ring_handler_reply_d inline void z_drop(z_moved_ring_handler_sample_t* this_) { z_ring_handler_sample_drop(this_); }; inline void z_drop(z_moved_sample_t* this_) { z_sample_drop(this_); }; inline void z_drop(z_moved_session_t* this_) { z_session_drop(this_); }; -inline void z_drop(z_moved_shm_client_t* this_) { z_shm_client_drop(this_); }; -inline void z_drop(z_moved_shm_client_storage_t* this_) { z_shm_client_storage_drop(this_); }; -inline void z_drop(z_moved_shm_t* this_) { z_shm_drop(this_); }; -inline void z_drop(z_moved_shm_mut_t* this_) { z_shm_mut_drop(this_); }; -inline void z_drop(z_moved_shm_provider_t* this_) { z_shm_provider_drop(this_); }; inline void z_drop(z_moved_slice_t* this_) { z_slice_drop(this_); }; -inline void z_drop(z_moved_source_info_t* this_) { z_source_info_drop(this_); }; inline void z_drop(z_moved_string_array_t* this_) { z_string_array_drop(this_); }; inline void z_drop(z_moved_string_t* this_) { z_string_drop(this_); }; inline void z_drop(z_moved_subscriber_t* this_) { z_subscriber_drop(this_); }; inline void z_drop(z_moved_task_t* this_) { z_task_drop(this_); }; inline void z_drop(zc_moved_closure_log_t* closure_) { zc_closure_log_drop(closure_); }; -inline void z_drop(zc_moved_closure_matching_status_t* closure_) { zc_closure_matching_status_drop(closure_); }; -inline void z_drop(zc_moved_liveliness_token_t* this_) { zc_liveliness_token_drop(this_); }; -inline void z_drop(zc_moved_matching_listener_t* this_) { zc_publisher_matching_listener_drop(this_); }; -inline void z_drop(zc_moved_shm_client_list_t* this_) { zc_shm_client_list_drop(this_); }; -inline void z_drop(ze_moved_publication_cache_t* this_) { ze_publication_cache_drop(this_); }; -inline void z_drop(ze_moved_querying_subscriber_t* this_) { ze_querying_subscriber_drop(this_); }; inline void z_drop(ze_moved_serializer_t* this_) { ze_serializer_drop(this_); }; -inline z_moved_alloc_layout_t* z_move(z_owned_alloc_layout_t& this_) { return z_alloc_layout_move(&this_); }; inline z_moved_bytes_t* z_move(z_owned_bytes_t& this_) { return z_bytes_move(&this_); }; inline z_moved_bytes_writer_t* z_move(z_owned_bytes_writer_t& this_) { return z_bytes_writer_move(&this_); }; -inline z_moved_chunk_alloc_result_t* z_move(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_move(&this_); }; inline z_moved_closure_hello_t* z_move(z_owned_closure_hello_t& this_) { return z_closure_hello_move(&this_); }; inline z_moved_closure_query_t* z_move(z_owned_closure_query_t& closure_) { return z_closure_query_move(&closure_); }; inline z_moved_closure_reply_t* z_move(z_owned_closure_reply_t& closure_) { return z_closure_reply_move(&closure_); }; @@ -736,7 +552,6 @@ inline z_moved_fifo_handler_reply_t* z_move(z_owned_fifo_handler_reply_t& this_) inline z_moved_fifo_handler_sample_t* z_move(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_move(&this_); }; inline z_moved_hello_t* z_move(z_owned_hello_t& this_) { return z_hello_move(&this_); }; inline z_moved_keyexpr_t* z_move(z_owned_keyexpr_t& this_) { return z_keyexpr_move(&this_); }; -inline z_moved_memory_layout_t* z_move(z_owned_memory_layout_t& this_) { return z_memory_layout_move(&this_); }; inline z_moved_mutex_t* z_move(z_owned_mutex_t& this_) { return z_mutex_move(&this_); }; inline z_moved_publisher_t* z_move(z_owned_publisher_t& this_) { return z_publisher_move(&this_); }; inline z_moved_query_t* z_move(z_owned_query_t& this_) { return z_query_move(&this_); }; @@ -748,31 +563,17 @@ inline z_moved_ring_handler_reply_t* z_move(z_owned_ring_handler_reply_t& this_) inline z_moved_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_move(&this_); }; inline z_moved_sample_t* z_move(z_owned_sample_t& this_) { return z_sample_move(&this_); }; inline z_moved_session_t* z_move(z_owned_session_t& this_) { return z_session_move(&this_); }; -inline z_moved_shm_client_t* z_move(z_owned_shm_client_t& this_) { return z_shm_client_move(&this_); }; -inline z_moved_shm_client_storage_t* z_move(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_move(&this_); }; -inline z_moved_shm_t* z_move(z_owned_shm_t& this_) { return z_shm_move(&this_); }; -inline z_moved_shm_mut_t* z_move(z_owned_shm_mut_t& this_) { return z_shm_mut_move(&this_); }; -inline z_moved_shm_provider_t* z_move(z_owned_shm_provider_t& this_) { return z_shm_provider_move(&this_); }; inline z_moved_slice_t* z_move(z_owned_slice_t& this_) { return z_slice_move(&this_); }; -inline z_moved_source_info_t* z_move(z_owned_source_info_t& this_) { return z_source_info_move(&this_); }; inline z_moved_string_array_t* z_move(z_owned_string_array_t& this_) { return z_string_array_move(&this_); }; inline z_moved_string_t* z_move(z_owned_string_t& this_) { return z_string_move(&this_); }; inline z_moved_subscriber_t* z_move(z_owned_subscriber_t& this_) { return z_subscriber_move(&this_); }; inline z_moved_task_t* z_move(z_owned_task_t& this_) { return z_task_move(&this_); }; inline zc_moved_closure_log_t* z_move(zc_owned_closure_log_t& closure_) { return zc_closure_log_move(&closure_); }; -inline zc_moved_closure_matching_status_t* z_move(zc_owned_closure_matching_status_t& closure_) { return zc_closure_matching_status_move(&closure_); }; -inline zc_moved_liveliness_token_t* z_move(zc_owned_liveliness_token_t& this_) { return zc_liveliness_token_move(&this_); }; -inline zc_moved_matching_listener_t* z_move(zc_owned_matching_listener_t& this_) { return zc_publisher_matching_listener_move(&this_); }; -inline zc_moved_shm_client_list_t* z_move(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_move(&this_); }; -inline ze_moved_publication_cache_t* z_move(ze_owned_publication_cache_t& this_) { return ze_publication_cache_move(&this_); }; -inline ze_moved_querying_subscriber_t* z_move(ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_move(&this_); }; inline ze_moved_serializer_t* z_move(ze_owned_serializer_t& this_) { return ze_serializer_move(&this_); }; -inline void z_internal_null(z_owned_alloc_layout_t* this_) { z_internal_alloc_layout_null(this_); }; inline void z_internal_null(z_owned_bytes_t* this_) { z_internal_bytes_null(this_); }; inline void z_internal_null(z_owned_bytes_writer_t* this_) { z_internal_bytes_writer_null(this_); }; -inline void z_internal_null(z_owned_chunk_alloc_result_t* this_) { z_internal_chunk_alloc_result_null(this_); }; inline void z_internal_null(z_owned_closure_hello_t* this_) { z_internal_closure_hello_null(this_); }; inline void z_internal_null(z_owned_closure_query_t* this_) { z_internal_closure_query_null(this_); }; inline void z_internal_null(z_owned_closure_reply_t* this_) { z_internal_closure_reply_null(this_); }; @@ -786,7 +587,6 @@ inline void z_internal_null(z_owned_fifo_handler_reply_t* this_) { z_internal_fi inline void z_internal_null(z_owned_fifo_handler_sample_t* this_) { z_internal_fifo_handler_sample_null(this_); }; inline void z_internal_null(z_owned_hello_t* this_) { z_internal_hello_null(this_); }; inline void z_internal_null(z_owned_keyexpr_t* this_) { z_internal_keyexpr_null(this_); }; -inline void z_internal_null(z_owned_memory_layout_t* this_) { z_internal_memory_layout_null(this_); }; inline void z_internal_null(z_owned_mutex_t* this_) { z_internal_mutex_null(this_); }; inline void z_internal_null(z_owned_publisher_t* this_) { z_internal_publisher_null(this_); }; inline void z_internal_null(z_owned_query_t* this_) { z_internal_query_null(this_); }; @@ -798,30 +598,16 @@ inline void z_internal_null(z_owned_ring_handler_reply_t* this_) { z_internal_ri inline void z_internal_null(z_owned_ring_handler_sample_t* this_) { z_internal_ring_handler_sample_null(this_); }; inline void z_internal_null(z_owned_sample_t* this_) { z_internal_sample_null(this_); }; inline void z_internal_null(z_owned_session_t* this_) { z_internal_session_null(this_); }; -inline void z_internal_null(z_owned_shm_client_t* this_) { z_internal_shm_client_null(this_); }; -inline void z_internal_null(z_owned_shm_client_storage_t* this_) { z_internal_shm_client_storage_null(this_); }; -inline void z_internal_null(z_owned_shm_mut_t* this_) { z_internal_shm_mut_null(this_); }; -inline void z_internal_null(z_owned_shm_t* this_) { z_internal_shm_null(this_); }; -inline void z_internal_null(z_owned_shm_provider_t* this_) { z_internal_shm_provider_null(this_); }; inline void z_internal_null(z_owned_slice_t* this_) { z_internal_slice_null(this_); }; -inline void z_internal_null(z_owned_source_info_t* this_) { z_internal_source_info_null(this_); }; inline void z_internal_null(z_owned_string_array_t* this_) { z_internal_string_array_null(this_); }; inline void z_internal_null(z_owned_string_t* this_) { z_internal_string_null(this_); }; inline void z_internal_null(z_owned_subscriber_t* this_) { z_internal_subscriber_null(this_); }; inline void z_internal_null(z_owned_task_t* this_) { z_internal_task_null(this_); }; inline void z_internal_null(zc_owned_closure_log_t* this_) { zc_internal_closure_log_null(this_); }; -inline void z_internal_null(zc_owned_closure_matching_status_t* this_) { zc_internal_closure_matching_status_null(this_); }; -inline void z_internal_null(zc_owned_liveliness_token_t* this_) { zc_internal_liveliness_token_null(this_); }; -inline void z_internal_null(zc_owned_matching_listener_t* this_) { zc_internal_matching_listener_null(this_); }; -inline void z_internal_null(zc_owned_shm_client_list_t* this_) { zc_internal_shm_client_list_null(this_); }; -inline void z_internal_null(ze_owned_publication_cache_t* this_) { ze_internal_publication_cache_null(this_); }; -inline void z_internal_null(ze_owned_querying_subscriber_t* this_) { ze_internal_querying_subscriber_null(this_); }; inline void z_internal_null(ze_owned_serializer_t* this_) { ze_internal_serializer_null(this_); }; -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } static inline void z_bytes_writer_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* x) { *this_ = x->_this; z_internal_bytes_writer_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } static inline void z_closure_reply_take(z_owned_closure_reply_t* closure_, z_moved_closure_reply_t* x) { *closure_ = x->_this; z_internal_closure_reply_null(&x->_this); } @@ -835,7 +621,6 @@ static inline void z_fifo_handler_reply_take(z_owned_fifo_handler_reply_t* this_ static inline void z_fifo_handler_sample_take(z_owned_fifo_handler_sample_t* this_, z_moved_fifo_handler_sample_t* x) { *this_ = x->_this; z_internal_fifo_handler_sample_null(&x->_this); } static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *this_ = x->_this; z_internal_hello_null(&x->_this); } static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -847,40 +632,22 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_closure_matching_status_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { *closure_ = x->_this; zc_internal_closure_matching_status_null(&x->_this); } -static inline void zc_liveliness_token_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { *this_ = x->_this; zc_internal_liveliness_token_null(&x->_this); } -static inline void zc_publisher_matching_listener_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { *this_ = x->_this; zc_internal_matching_listener_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { *this_ = x->_this; ze_internal_serializer_null(&x->_this); } -inline void z_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { - z_alloc_layout_take(this_, x); -}; inline void z_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { z_bytes_take(this_, x); }; inline void z_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* x) { z_bytes_writer_take(this_, x); }; -inline void z_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { - z_chunk_alloc_result_take(this_, x); -}; inline void z_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { z_closure_hello_take(this_, x); }; @@ -920,9 +687,6 @@ inline void z_take(z_owned_hello_t* this_, z_moved_hello_t* x) { inline void z_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { z_keyexpr_take(this_, x); }; -inline void z_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { - z_memory_layout_take(this_, x); -}; inline void z_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { z_mutex_take(this_, x); }; @@ -956,27 +720,9 @@ inline void z_take(z_owned_sample_t* this_, z_moved_sample_t* x) { inline void z_take(z_owned_session_t* this_, z_moved_session_t* x) { z_session_take(this_, x); }; -inline void z_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { - z_shm_client_take(this_, x); -}; -inline void z_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { - z_shm_client_storage_take(this_, x); -}; -inline void z_take(z_owned_shm_t* this_, z_moved_shm_t* x) { - z_shm_take(this_, x); -}; -inline void z_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { - z_shm_mut_take(this_, x); -}; -inline void z_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { - z_shm_provider_take(this_, x); -}; inline void z_take(z_owned_slice_t* this_, z_moved_slice_t* x) { z_slice_take(this_, x); }; -inline void z_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { - z_source_info_take(this_, x); -}; inline void z_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { z_string_array_take(this_, x); }; @@ -992,33 +738,13 @@ inline void z_take(z_owned_task_t* this_, z_moved_task_t* x) { inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { zc_closure_log_take(closure_, x); }; -inline void z_take(zc_owned_closure_matching_status_t* closure_, zc_moved_closure_matching_status_t* x) { - zc_closure_matching_status_take(closure_, x); -}; -inline void z_take(zc_owned_liveliness_token_t* this_, zc_moved_liveliness_token_t* x) { - zc_liveliness_token_take(this_, x); -}; -inline void z_take(zc_owned_matching_listener_t* this_, zc_moved_matching_listener_t* x) { - zc_publisher_matching_listener_take(this_, x); -}; -inline void z_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { - zc_shm_client_list_take(this_, x); -}; -inline void z_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { - ze_publication_cache_take(this_, x); -}; -inline void z_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { - ze_querying_subscriber_take(this_, x); -}; inline void z_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { ze_serializer_take(this_, x); }; -inline bool z_internal_check(const z_owned_alloc_layout_t& this_) { return z_internal_alloc_layout_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_writer_t& this_) { return z_internal_bytes_writer_check(&this_); }; -inline bool z_internal_check(const z_owned_chunk_alloc_result_t& this_) { return z_internal_chunk_alloc_result_check(&this_); }; inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; inline bool z_internal_check(const z_owned_closure_reply_t& this_) { return z_internal_closure_reply_check(&this_); }; @@ -1032,7 +758,6 @@ inline bool z_internal_check(const z_owned_fifo_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_fifo_handler_sample_t& this_) { return z_internal_fifo_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_hello_check(&this_); }; inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; -inline bool z_internal_check(const z_owned_memory_layout_t& this_) { return z_internal_memory_layout_check(&this_); }; inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; @@ -1044,24 +769,12 @@ inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_t& this_) { return z_internal_shm_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_t& this_) { return z_internal_shm_client_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_storage_t& this_) { return z_internal_shm_client_storage_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_mut_t& this_) { return z_internal_shm_mut_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_provider_t& this_) { return z_internal_shm_provider_check(&this_); }; inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; -inline bool z_internal_check(const z_owned_source_info_t& this_) { return z_internal_source_info_check(&this_); }; inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; -inline bool z_internal_check(const zc_owned_closure_matching_status_t& this_) { return zc_internal_closure_matching_status_check(&this_); }; -inline bool z_internal_check(const zc_owned_liveliness_token_t& this_) { return zc_internal_liveliness_token_check(&this_); }; -inline bool z_internal_check(const zc_owned_matching_listener_t& this_) { return zc_internal_matching_listener_check(&this_); }; -inline bool z_internal_check(const zc_owned_shm_client_list_t& this_) { return zc_internal_shm_client_list_check(&this_); }; -inline bool z_internal_check(const ze_owned_publication_cache_t& this_) { return ze_internal_publication_cache_check(&this_); }; -inline bool z_internal_check(const ze_owned_querying_subscriber_t& this_) { return ze_internal_querying_subscriber_check(&this_); }; inline bool z_internal_check(const ze_owned_serializer_t& this_) { return ze_internal_serializer_check(&this_); }; @@ -1080,9 +793,6 @@ inline void z_call(const z_loaned_closure_sample_t* closure, z_loaned_sample_t* inline void z_call(const z_loaned_closure_zid_t* closure, const z_id_t* z_id) { z_closure_zid_call(closure, z_id); }; -inline void z_call(const zc_loaned_closure_matching_status_t* closure, const zc_matching_status_t* mathing_status) { - zc_closure_matching_status_call(closure, mathing_status); -}; extern "C" using z_closure_drop_callback_t = void(void* context); extern "C" using z_closure_hello_callback_t = void(z_loaned_hello_t *hello, void *context); @@ -1091,7 +801,6 @@ extern "C" using z_closure_reply_callback_t = void(z_loaned_reply_t *reply, void extern "C" using z_closure_sample_callback_t = void(z_loaned_sample_t *sample, void *context); extern "C" using z_closure_zid_callback_t = void(const z_id_t *z_id, void *context); extern "C" using zc_closure_log_callback_t = void(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); -extern "C" using zc_closure_matching_status_callback_t = void(const zc_matching_status_t *matching_status, void *context); inline void z_closure(z_owned_closure_hello_t* this_, z_closure_hello_callback_t* call, z_closure_drop_callback_t* drop, void* context) { @@ -1117,10 +826,6 @@ inline void z_closure(zc_owned_closure_log_t* this_, zc_closure_log_callback_t* z_closure_drop_callback_t* drop, void* context) { zc_closure_log(this_, call, drop, context); }; -inline void z_closure(zc_owned_closure_matching_status_t* this_, zc_closure_matching_status_callback_t* call, - z_closure_drop_callback_t* drop, void* context) { - zc_closure_matching_status(this_, call, drop, context); -}; inline z_result_t z_try_recv(const z_loaned_fifo_handler_query_t* this_, z_owned_query_t* query) { @@ -1190,12 +895,6 @@ inline void z_clone(z_owned_reply_err_t* dst, z_loaned_reply_err_t* this_) { inline void z_clone(z_owned_sample_t* dst, z_loaned_sample_t* this_) { z_sample_clone(dst, this_); }; -inline void z_clone(z_owned_shm_client_storage_t* this_, z_loaned_shm_client_storage_t* from) { - z_shm_client_storage_clone(this_, from); -}; -inline void z_clone(z_owned_shm_t* out, z_loaned_shm_t* this_) { - z_shm_clone(out, this_); -}; inline void z_clone(z_owned_slice_t* dst, z_loaned_slice_t* this_) { z_slice_clone(dst, this_); }; @@ -1208,14 +907,10 @@ inline void z_clone(z_owned_string_t* dst, z_loaned_string_t* this_) { template struct z_loaned_to_owned_type_t {}; template struct z_owned_to_loaned_type_t {}; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_alloc_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_alloc_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_writer_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_writer_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_chunk_alloc_result_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_chunk_alloc_result_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_hello_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_closure_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_closure_query_t type; }; @@ -1242,8 +937,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_h template<> struct z_owned_to_loaned_type_t { typedef z_loaned_hello_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_keyexpr_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_keyexpr_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_memory_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_memory_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_publisher_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_publisher_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_query_t type; }; @@ -1264,18 +957,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_sample_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_session_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_session_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_client_storage_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_client_storage_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_mut_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_mut_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_provider_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_provider_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_slice_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_slice_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_source_info_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_source_info_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_array_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_string_array_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_t type; }; @@ -1284,16 +967,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_ow template<> struct z_owned_to_loaned_type_t { typedef z_loaned_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_log_t type; }; template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_log_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_matching_status_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_matching_status_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_liveliness_token_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_liveliness_token_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_shm_client_list_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_shm_client_list_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_publication_cache_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_publication_cache_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_querying_subscriber_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_querying_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef ze_owned_serializer_t type; }; template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_serializer_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_mutex_t type; }; diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 76170767f..b350e8840 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -25,7 +25,9 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_query_t, z_owned_closure_query_t, z_owned_query_t, }; decl_c_type!( @@ -109,8 +111,7 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan( pub unsafe extern "C" fn z_fifo_handler_query_loan_mut( this: &mut z_owned_fifo_handler_query_t, ) -> &mut z_loaned_fifo_handler_query_t { - this.as_rust_type_mut() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed handler @@ -119,7 +120,8 @@ pub extern "C" fn z_fifo_handler_query_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_fifo_handler_query_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until @@ -237,8 +239,7 @@ pub unsafe extern "C" fn z_ring_handler_query_loan( pub unsafe extern "C" fn z_ring_handler_query_loan_mut( this: &mut z_owned_ring_handler_query_t, ) -> &mut z_loaned_ring_handler_query_t { - this.as_rust_type_mut() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed handler @@ -247,7 +248,8 @@ pub extern "C" fn z_ring_handler_query_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_ring_handler_query_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index 50189c996..b5b94993d 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -25,7 +25,9 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_reply_t, z_owned_closure_reply_t, z_owned_reply_t, }; decl_c_type!( @@ -109,8 +111,7 @@ pub unsafe extern "C" fn z_fifo_handler_reply_loan( pub unsafe extern "C" fn z_fifo_handler_reply_loan_mut( this: &mut z_owned_fifo_handler_reply_t, ) -> &mut z_loaned_fifo_handler_reply_t { - this.as_rust_type_mut() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed handler @@ -119,7 +120,8 @@ pub extern "C" fn z_fifo_handler_reply_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_fifo_handler_reply_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until @@ -233,8 +235,7 @@ pub unsafe extern "C" fn z_ring_handler_reply_loan( pub unsafe extern "C" fn z_ring_handler_reply_loan_mut( this: &mut z_owned_ring_handler_reply_t, ) -> &mut z_loaned_ring_handler_reply_t { - this.as_rust_type_mut() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed handler @@ -243,7 +244,8 @@ pub extern "C" fn z_ring_handler_reply_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_ring_handler_reply_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 8c928e5d9..773b94d78 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -25,7 +25,9 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_sample_t, z_owned_closure_sample_t, z_owned_sample_t, }; decl_c_type!( @@ -109,8 +111,7 @@ pub unsafe extern "C" fn z_fifo_handler_sample_loan( pub unsafe extern "C" fn z_fifo_handler_sample_loan_mut( this: &mut z_owned_fifo_handler_sample_t, ) -> &mut z_loaned_fifo_handler_sample_t { - this.as_rust_type_mut() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed fifo_handler_sample @@ -119,7 +120,8 @@ pub extern "C" fn z_fifo_handler_sample_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_fifo_handler_sample_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until @@ -237,8 +239,7 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan( pub unsafe extern "C" fn z_ring_handler_sample_loan_mut( this: &mut z_owned_ring_handler_sample_t, ) -> &mut z_loaned_ring_handler_sample_t { - this.as_rust_type_mut() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed handler @@ -247,7 +248,8 @@ pub extern "C" fn z_ring_handler_sample_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_ring_handler_sample_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index c50da299c..0b361b0c1 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -17,7 +17,7 @@ use std::mem::MaybeUninit; use libc::c_void; use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, z_id_t, }; /// @brief A zenoh id-processing closure. @@ -130,12 +130,6 @@ impl From for z_owned_closure_zid_t { pub extern "C" fn z_closure_zid_loan(closure: &z_owned_closure_zid_t) -> &z_loaned_closure_zid_t { closure.as_loaned_c_type_ref() } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_zid_loan_mut(closure: &mut z_owned_closure_zid_t) -> &mut z_loaned_closure_zid_t { - closure.as_loaned_c_type_mut() -} /// Takes ownership of the mutably borrowed closure #[no_mangle] @@ -149,9 +143,9 @@ pub extern "C" fn z_closure_zid_take_loaned( /// @brief Mutably borrows closure. #[no_mangle] pub extern "C" fn z_closure_zid_loan_mut( - closure: &z_owned_closure_zid_t, -) -> &z_loaned_closure_zid_t { - closure.as_loaned_c_type_ref() + closure: &mut z_owned_closure_zid_t, +) -> &mut z_loaned_closure_zid_t { + closure.as_loaned_c_type_mut() } /// @brief Constructs closure. diff --git a/src/collections.rs b/src/collections.rs index c93560d76..6b203b98c 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -349,8 +349,12 @@ pub extern "C" fn z_slice_loan_mut(this_: &mut z_owned_slice_t) -> &mut z_loaned /// Takes ownership of mutably borrowed slice #[no_mangle] -pub extern "C" fn z_slice_take_loaned(dst: &mut MaybeUninit, src: &mut z_loaned_slice_t) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +pub extern "C" fn z_slice_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_slice_t, +) { + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Constructs an owned copy of a slice. @@ -612,8 +616,12 @@ pub extern "C" fn z_string_loan_mut(this_: &mut z_owned_string_t) -> &mut z_loan /// Takes ownership of mutably borrowed string. #[no_mangle] -pub extern "C" fn z_string_take_loaned(dst: &mut MaybeUninit, src: &mut z_loaned_string_t) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +pub extern "C" fn z_string_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_string_t, +) { + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Borrows view string. @@ -821,7 +829,8 @@ pub extern "C" fn z_string_array_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_string_array_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// @return number of elements in the array. diff --git a/src/commons.rs b/src/commons.rs index 02a56f18f..b128c9b6d 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -35,7 +35,10 @@ use crate::transmute::IntoCType; use crate::z_moved_source_info_t; use crate::{ result, - transmute::{CTypeRef, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + CTypeRef, LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, + TakeRustType, + }, z_id_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, }; @@ -214,15 +217,17 @@ pub unsafe extern "C" fn z_sample_loan(this_: &z_owned_sample_t) -> &z_loaned_sa #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loaned_sample_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed sample. #[no_mangle] -pub extern "C" fn z_sample_take_loaned(dst: &mut MaybeUninit, src: &mut z_loaned_sample_t) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); +pub extern "C" fn z_sample_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_sample_t, +) { + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Frees the memory and invalidates the sample, resetting it to a gravestone state. @@ -627,7 +632,8 @@ pub extern "C" fn z_source_info_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_source_info_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } #[cfg(feature = "unstable")] diff --git a/src/config.rs b/src/config.rs index e4832029b..28ca0ed6e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -94,7 +94,8 @@ pub extern "C" fn z_config_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_config_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Constructs a new empty configuration. diff --git a/src/encoding.rs b/src/encoding.rs index ed467960e..15975bffe 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -174,7 +174,8 @@ pub extern "C" fn z_encoding_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_encoding_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Constructs an owned copy of the encoding in provided uninitilized memory location. diff --git a/src/get.rs b/src/get.rs index 4b491b12a..9d1554e1c 100644 --- a/src/get.rs +++ b/src/get.rs @@ -25,7 +25,9 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_reply_err_t, z_moved_reply_err_t, z_owned_reply_err_t}; use crate::{ result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_closure_reply_call, z_closure_reply_loan, z_congestion_control_t, z_consolidation_mode_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_sample_t, z_loaned_session_t, z_moved_bytes_t, z_moved_closure_reply_t, z_moved_encoding_t, z_priority_t, @@ -74,7 +76,9 @@ pub extern "C" fn z_reply_err_loan(this_: &z_owned_reply_err_t) -> &z_loaned_rep /// Mutably borrows reply error. #[no_mangle] -pub extern "C" fn z_reply_err_loan_mut(this_: &mut z_owned_reply_err_t) -> &mut z_loaned_reply_err_t { +pub extern "C" fn z_reply_err_loan_mut( + this_: &mut z_owned_reply_err_t, +) -> &mut z_loaned_reply_err_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } @@ -84,10 +88,10 @@ pub extern "C" fn z_reply_err_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_reply_err_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } - /// Frees the memory and resets the reply error it to its default value. #[no_mangle] pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { @@ -328,9 +332,7 @@ pub unsafe extern "C" fn z_reply_loan(this_: &z_owned_reply_t) -> &z_loaned_repl #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned_reply_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed reply @@ -339,7 +341,8 @@ pub extern "C" fn z_reply_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_reply_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// The replies consolidation strategy to apply on replies to a `z_get()`. diff --git a/src/keyexpr.rs b/src/keyexpr.rs index 8d92bdede..347f590c0 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -26,7 +26,9 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t, Z_OK}, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_session_t, z_view_string_from_substr, z_view_string_t, }; @@ -137,10 +139,10 @@ pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_ /// Mutably borrows `z_owned_keyexpr_t`. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_keyexpr_loan_mut(this_: &mut z_owned_keyexpr_t) -> &mut z_loaned_keyexpr_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() +pub unsafe extern "C" fn z_keyexpr_loan_mut( + this_: &mut z_owned_keyexpr_t, +) -> &mut z_loaned_keyexpr_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed keyexpr @@ -149,7 +151,8 @@ pub extern "C" fn z_keyexpr_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_keyexpr_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Borrows `z_view_keyexpr_t`. diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index f832cf4f0..fe4f43be6 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -61,7 +61,8 @@ pub extern "C" fn z_mutex_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_mutex_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Locks mutex. If mutex is already locked, blocks the thread until it aquires the lock. diff --git a/src/publisher.rs b/src/publisher.rs index 55a65f2b9..92ac818b9 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -180,7 +180,8 @@ pub extern "C" fn z_publisher_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_publisher_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Options passed to the `z_publisher_put()` function. diff --git a/src/queryable.rs b/src/queryable.rs index 0a69ec12b..6d70efa20 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -27,7 +27,8 @@ use crate::transmute::IntoCType; use crate::{ result, transmute::{ - IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType + IntoRustType, LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, + TakeRustType, }, z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, @@ -61,10 +62,10 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa // Mutably borrows Queryable #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_queryable_loan_mut(this_: &mut z_owned_queryable_t) -> &mut z_loaned_queryable_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() +pub unsafe extern "C" fn z_queryable_loan_mut( + this_: &mut z_owned_queryable_t, +) -> &mut z_loaned_queryable_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed queryable @@ -73,7 +74,8 @@ pub extern "C" fn z_queryable_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_queryable_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; @@ -107,9 +109,7 @@ pub unsafe extern "C" fn z_query_loan(this_: &z_owned_query_t) -> &z_loaned_quer #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_query_loan_mut(this_: &mut z_owned_query_t) -> &mut z_loaned_query_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed query @@ -118,7 +118,8 @@ pub extern "C" fn z_query_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_query_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Destroys the query resetting it to its gravestone value. @@ -259,14 +260,13 @@ fn _declare_queryable_inner<'a, 'b>( if let Some(options) = options { builder = builder.complete(options.complete); } - let queryable = builder - .callback(move |query| { - let mut owned_query = Some(query); - z_closure_query_call( - z_closure_query_loan(&callback), - owned_query.as_loaned_c_type_mut(), - ) - }); + let queryable = builder.callback(move |query| { + let mut owned_query = Some(query); + z_closure_query_call( + z_closure_query_loan(&callback), + owned_query.as_loaned_c_type_mut(), + ) + }); queryable } diff --git a/src/scouting.rs b/src/scouting.rs index 902a699fa..ee7645f64 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -22,7 +22,10 @@ use zenoh::{ pub use crate::opaque_types::{z_loaned_hello_t, z_moved_hello_t, z_owned_hello_t}; use crate::{ result::{self, Z_OK}, - transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + IntoCType, LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, + TakeRustType, + }, z_closure_hello_call, z_closure_hello_loan, z_id_t, z_moved_closure_hello_t, z_moved_config_t, z_owned_string_array_t, z_view_string_t, CString, CStringView, ZVector, }; @@ -53,9 +56,7 @@ pub unsafe extern "C" fn z_hello_loan(this_: &z_owned_hello_t) -> &z_loaned_hell #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed hello @@ -64,7 +65,8 @@ pub extern "C" fn z_hello_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_hello_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. diff --git a/src/serialization.rs b/src/serialization.rs index 1a7c837e1..b954fef28 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -26,7 +26,9 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_bytes_t, z_loaned_slice_t, z_loaned_string_t, z_owned_bytes_t, z_owned_slice_t, z_owned_string_t, CSliceOwned, CStringOwned, }; @@ -76,10 +78,7 @@ pub unsafe extern "C" fn ze_serializer_loan( pub unsafe extern "C" fn ze_serializer_loan_mut( this: &mut ze_owned_serializer_t, ) -> &mut ze_loaned_serializer_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// @brief Constructs a serializer in a gravestone state. @@ -463,14 +462,18 @@ pub unsafe extern "C" fn ze_deserializer_is_done(this_: &ze_deserializer_t) -> b deserializer.done() } -fn ze_serializer_serialize_arithmetic(this: &mut ze_loaned_serializer_t, val: &T) +fn serializer_serialize_arithmetic(this: &mut ze_loaned_serializer_t, val: &T) -> z_result_t where T: Serialize, { - this.as_rust_type_mut().serialize(val); + let Some(serializer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; + serializer.serialize(val); + result::Z_OK } -fn ze_deserializer_deserialize_arithmetic<'a, T>( +fn zdeserializer_deserialize_arithmetic<'a, T>( this: &'a mut ze_deserializer_t, val: &'a mut T, ) -> z_result_t @@ -495,8 +498,7 @@ pub extern "C" fn ze_serializer_serialize_uint8( this_: &mut ze_loaned_serializer_t, val: u8, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes an unsigned integer. @@ -505,8 +507,7 @@ pub extern "C" fn ze_serializer_serialize_uint16( this_: &mut ze_loaned_serializer_t, val: u16, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes an unsigned integer. @@ -515,8 +516,7 @@ pub extern "C" fn ze_serializer_serialize_uint32( this_: &mut ze_loaned_serializer_t, val: u32, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes an unsigned integer. @@ -525,8 +525,7 @@ pub extern "C" fn ze_serializer_serialize_uint64( this_: &mut ze_loaned_serializer_t, val: u64, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a signed integer. @@ -535,8 +534,7 @@ pub extern "C" fn ze_serializer_serialize_int8( this_: &mut ze_loaned_serializer_t, val: i8, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a signed integer. @@ -545,8 +543,7 @@ pub extern "C" fn ze_serializer_serialize_int16( this_: &mut ze_loaned_serializer_t, val: i16, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a signed integer. @@ -555,8 +552,7 @@ pub extern "C" fn ze_serializer_serialize_int32( this_: &mut ze_loaned_serializer_t, val: i32, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a signed integer. @@ -565,8 +561,7 @@ pub extern "C" fn ze_serializer_serialize_int64( this_: &mut ze_loaned_serializer_t, val: i64, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a float. @@ -575,8 +570,7 @@ pub extern "C" fn ze_serializer_serialize_float( this_: &mut ze_loaned_serializer_t, val: f32, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a double. @@ -585,8 +579,7 @@ pub extern "C" fn ze_serializer_serialize_double( this_: &mut ze_loaned_serializer_t, val: f64, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Serializes a bool. @@ -595,8 +588,7 @@ pub extern "C" fn ze_serializer_serialize_bool( this_: &mut ze_loaned_serializer_t, val: bool, ) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK + serializer_serialize_arithmetic::(this_, &val) } /// @brief Deserializes into an unsigned integer. @@ -606,7 +598,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint8( this: &mut ze_deserializer_t, dst: &mut u8, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -616,7 +608,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint16( this: &mut ze_deserializer_t, dst: &mut u16, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -626,7 +618,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint32( this: &mut ze_deserializer_t, dst: &mut u32, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -636,7 +628,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint64( this: &mut ze_deserializer_t, dst: &mut u64, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -646,7 +638,7 @@ pub extern "C" fn ze_deserializer_deserialize_int8( this: &mut ze_deserializer_t, dst: &mut i8, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -656,7 +648,7 @@ pub extern "C" fn ze_deserializer_deserialize_int16( this: &mut ze_deserializer_t, dst: &mut i16, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -666,7 +658,7 @@ pub extern "C" fn ze_deserializer_deserialize_int32( this: &mut ze_deserializer_t, dst: &mut i32, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -676,7 +668,7 @@ pub extern "C" fn ze_deserializer_deserialize_int64( this: &mut ze_deserializer_t, dst: &mut i64, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a float. @@ -686,7 +678,7 @@ pub extern "C" fn ze_deserializer_deserialize_float( this: &mut ze_deserializer_t, dst: &mut f32, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -696,7 +688,7 @@ pub extern "C" fn ze_deserializer_deserialize_double( this: &mut ze_deserializer_t, dst: &mut f64, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a bool. @@ -706,7 +698,7 @@ pub extern "C" fn ze_deserializer_deserialize_bool( this: &mut ze_deserializer_t, dst: &mut bool, ) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) + zdeserializer_deserialize_arithmetic::(this, dst) } /// @brief Serializes a slice. @@ -715,8 +707,11 @@ pub extern "C" fn ze_serializer_serialize_slice( this: &mut ze_loaned_serializer_t, slice: &z_loaned_slice_t, ) -> z_result_t { + let Some(serializer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; let cslice = slice.as_rust_type_ref().slice(); - this.as_rust_type_mut().serialize(cslice); + serializer.serialize(cslice); result::Z_OK } @@ -730,8 +725,11 @@ pub extern "C" fn ze_serializer_serialize_buf( data: *const u8, len: usize, ) -> z_result_t { + let Some(serializer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; let slice = unsafe { from_raw_parts(data, len) }; - this.as_rust_type_mut().serialize(slice); + serializer.serialize(slice); result::Z_OK } @@ -764,9 +762,12 @@ pub extern "C" fn ze_serializer_serialize_string( this: &mut ze_loaned_serializer_t, str: &z_loaned_string_t, ) -> z_result_t { + let Some(serializer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; match str::from_utf8(str.as_rust_type_ref().slice()) { Ok(s) => { - this.as_rust_type_mut().serialize(s); + serializer.serialize(s); result::Z_OK } Err(e) => { @@ -785,10 +786,13 @@ pub extern "C" fn ze_serializer_serialize_substr( start: *const libc::c_char, len: usize, ) -> z_result_t { + let Some(serializer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; let slice = unsafe { from_raw_parts(start as *const u8, len) }; match str::from_utf8(slice) { Ok(s) => { - this.as_rust_type_mut().serialize(s); + serializer.serialize(s); result::Z_OK } Err(e) => { @@ -836,7 +840,10 @@ pub extern "C" fn ze_serializer_serialize_sequence_length( this: &mut ze_loaned_serializer_t, len: usize, ) -> z_result_t { - this.as_rust_type_mut().serialize(VarInt::(len)); + let Some(serializer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; + serializer.serialize(VarInt::(len)); result::Z_OK } diff --git a/src/session.rs b/src/session.rs index 1a345a1de..d9e304b0d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -21,7 +21,9 @@ use crate::z_loaned_shm_client_storage_t; use crate::{ opaque_types::{z_loaned_session_t, z_owned_session_t}, result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_moved_config_t, z_moved_session_t, }; decl_c_type!( @@ -43,10 +45,10 @@ pub unsafe extern "C" fn z_session_loan(this_: &z_owned_session_t) -> &z_loaned_ /// Mutably borrows session. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_session_loan_mut(this_: &mut z_owned_session_t) -> &mut z_loaned_session_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() +pub unsafe extern "C" fn z_session_loan_mut( + this_: &mut z_owned_session_t, +) -> &mut z_loaned_session_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed session @@ -55,7 +57,8 @@ pub extern "C" fn z_session_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_session_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Constructs a Zenoh session in its gravestone state. @@ -167,7 +170,9 @@ pub extern "C" fn z_close( session: &mut z_loaned_session_t, _options: Option<&z_close_options_t>, ) -> result::z_result_t { - let s = session.as_rust_type_mut(); + let Some(s) = session.as_rust_type_mut() else { + return result::Z_ENULL; + }; match s.close().wait() { Err(e) => { tracing::error!("Error closing session: {}", e); diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 2bceecddb..0e00c0269 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -20,7 +20,9 @@ use std::{ use zenoh::shm::{zshm, zshmmut, ZShm}; use crate::{ - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, }; @@ -89,7 +91,8 @@ pub extern "C" fn z_shm_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_shm_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index 3165dcc66..c1acbf21b 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -107,7 +107,8 @@ pub extern "C" fn z_shm_mut_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_shm_mut_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 9f088dfa0..bcfde4b95 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -219,6 +219,6 @@ pub extern "C" fn z_shm_client_storage_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_shm_client_storage_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } - diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index 2b5faff54..95f38fbf3 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -104,7 +104,8 @@ pub extern "C" fn z_alloc_layout_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_alloc_layout_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Deletes Alloc Layout diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 5519ec209..820314b45 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -141,7 +141,8 @@ pub extern "C" fn z_shm_provider_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_shm_provider_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index 1bd0c25a5..dd12d3542 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -191,7 +191,8 @@ pub extern "C" fn z_memory_layout_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_memory_layout_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -296,7 +297,8 @@ pub extern "C" fn z_chunk_alloc_result_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_chunk_alloc_result_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/subscriber.rs b/src/subscriber.rs index bd36e6927..34956e674 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -25,7 +25,9 @@ pub use crate::opaque_types::{z_loaned_subscriber_t, z_moved_subscriber_t, z_own use crate::{ keyexpr::*, result, - transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t, }; decl_c_type!( @@ -53,10 +55,10 @@ pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_l /// Mutably borrows subscriber. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_subscriber_loan_mut(this_: &mut z_owned_subscriber_t) -> &mut z_loaned_subscriber_t { - this_ - .as_rust_type_mut() - .as_loaned_c_type_mut() +pub unsafe extern "C" fn z_subscriber_loan_mut( + this_: &mut z_owned_subscriber_t, +) -> &mut z_loaned_subscriber_t { + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed subscriber @@ -65,7 +67,8 @@ pub extern "C" fn z_subscriber_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_subscriber_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Options passed to the `z_declare_subscriber()` function. diff --git a/src/zbytes.rs b/src/zbytes.rs index 510bcab61..aefe04c7c 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -32,7 +32,9 @@ pub use crate::opaque_types::{z_loaned_bytes_t, z_owned_bytes_t}; use crate::result::Z_ENULL; use crate::{ result::{self, z_result_t, Z_EINVAL, Z_EIO, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_slice_t, z_loaned_string_t, z_moved_bytes_t, z_moved_slice_t, z_moved_string_t, z_owned_slice_t, z_owned_string_t, z_view_slice_t, CSlice, CSliceOwned, CSliceView, CString, CStringOwned, @@ -87,7 +89,8 @@ pub extern "C" fn z_bytes_take_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_bytes_t, ) { - dst.as_rust_type_mut_uninit().write(std::mem::take(src.as_rust_type_mut())); + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); } /// Returns ``true`` if `this_` is empty, ``false`` otherwise. @@ -648,10 +651,7 @@ pub unsafe extern "C" fn z_bytes_writer_loan( pub unsafe extern "C" fn z_bytes_writer_loan_mut( this: &mut z_owned_bytes_writer_t, ) -> &mut z_loaned_bytes_writer_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Constructs a writer in a gravestone state. @@ -684,7 +684,10 @@ unsafe extern "C" fn z_bytes_writer_write_all( src: *const u8, len: usize, ) -> z_result_t { - match this.as_rust_type_mut().write_all(from_raw_parts(src, len)) { + let Some(writer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; + match writer.write_all(from_raw_parts(src, len)) { Ok(_) => Z_OK, Err(_) => Z_EIO, } @@ -700,6 +703,9 @@ extern "C" fn z_bytes_writer_append( this: &mut z_loaned_bytes_writer_t, bytes: &mut z_moved_bytes_t, ) -> z_result_t { - this.as_rust_type_mut().append(bytes.take_rust_type()); + let Some(writer) = this.as_rust_type_mut() else { + return result::Z_ENULL; + }; + writer.append(bytes.take_rust_type()); result::Z_OK } From 28c863eaf150fd0d6ac841db2dd33a5f6f4b4435 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 09:28:10 +0200 Subject: [PATCH 09/38] unsafe transmute for loaned mut - unifinished --- src/shm/buffer/zshm.rs | 16 +++++++++------- src/shm/buffer/zshmmut.rs | 2 +- src/transmute.rs | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 0e00c0269..386e5419c 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -21,13 +21,13 @@ use zenoh::shm::{zshm, zshmmut, ZShm}; use crate::{ transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + LoanedCTypeMut, LoanedCTypeMutUnsafe, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType }, z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, }; decl_c_type!( - owned(z_owned_shm_t, option ZShm), + owned(z_owned_shm_t, Option), loaned(z_loaned_shm_t, zshm), ); @@ -99,14 +99,14 @@ pub extern "C" fn z_shm_take_loaned( /// @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_mut_t { +pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> *mut z_loaned_shm_mut_t { let this = this_.as_rust_type_mut(); let this: &mut ZShm = this.as_mut().unwrap_unchecked(); let shm: &mut zshm = this.borrow_mut(); match shm.try_into() { Ok(val) => { let v: &mut zshmmut = val; - v.as_loaned_c_type_mut() + v.as_loaned_c_type_mut_unsafe() } Err(_) => std::ptr::null_mut(), } @@ -122,12 +122,14 @@ pub extern "C" fn z_shm_drop(this_: &mut z_moved_shm_t) { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Tries to reborrow mutably-borrowed ZShm slice as borrowed ZShmMut slice. #[no_mangle] -pub extern "C" fn z_shm_try_reloan_mut(this_: &mut z_loaned_shm_t) -> *mut z_loaned_shm_mut_t { - let this = this_.as_rust_type_mut(); +pub unsafe extern "C" fn z_shm_try_reloan_mut(this_: &mut z_loaned_shm_t) -> *mut z_loaned_shm_mut_t { + let Some(this) = this_.as_rust_type_mut() else { + return std::ptr::null_mut(); + }; match this.try_into() { Ok(val) => { let v: &mut zshmmut = val; - v.as_loaned_c_type_mut() + v.as_loaned_c_type_mut_unsafe() } Err(_) => std::ptr::null_mut(), } diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index c1acbf21b..a575da182 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -26,7 +26,7 @@ use crate::{ }; decl_c_type!( - owned(z_owned_shm_mut_t, option ZShmMut), + owned(z_owned_shm_mut_t, Option), loaned(z_loaned_shm_mut_t, zshmmut), ); diff --git a/src/transmute.rs b/src/transmute.rs index 39d4bbe91..a682b639d 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -31,6 +31,20 @@ pub(crate) trait LoanedCTypeRef: Sized { type LoanedCType; fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType; } +#[allow(dead_code)] +pub(crate) trait LoanedCTypeMutUnsafe: Sized { + type LoanedCType; + // Sometimes it's known that the value of type `&mut Foo` is actually + // points to the `Foo` inside the `&mut Option`. + // Therefore it's safe to convert this `&mut Foo` to + // `z_foo_loaned_mut_t*` (which is converted back to + // Rust type as `&mut Option`). + // + // Obviously this trait should be implemented only if + // `validate_equivalence!(Foo, Option)` is satisfied. + unsafe fn as_loaned_c_type_mut_unsafe(&mut self) -> &mut Self::LoanedCType; +} + #[allow(dead_code)] pub(crate) trait LoanedCTypeMut: Sized { type LoanedCType; @@ -164,6 +178,15 @@ macro_rules! impl_transmute { } } }; + (as_c_loaned_mut_unsafe ($rust_type:ty, $c_type:ty)) => { + validate_equivalence!($rust_type, $c_type); + impl $crate::transmute::LoanedCTypeMutUnsafe for $rust_type { + type LoanedCType = $c_type; + unsafe fn as_loaned_c_type_mut_unsafe(&mut self) -> &mut Self::LoanedCType { + unsafe { &mut *(self as *mut Self as *mut Self::LoanedCType) } + } + } + }; (as_c_loaned_mut ($rust_type:ty, $c_type:ty)) => { validate_equivalence!($rust_type, $c_type); impl $crate::transmute::LoanedCTypeMut for $rust_type { @@ -417,6 +440,7 @@ macro_rules! decl_c_type { $(,)?) => { impl_owned!(owned $c_owned_type, rust option $rust_inner_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut_unsafe($rust_inner_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut(Option<$rust_inner_type>, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); impl_transmute!(as_rust_mut($c_loaned_type, Option<$rust_inner_type>)); @@ -426,6 +450,7 @@ macro_rules! decl_c_type { $(,)?) => { impl_owned!(owned $c_owned_type, rust $rust_owned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut_unsafe($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_owned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); impl_transmute!(as_rust_mut($c_loaned_type, $rust_owned_type)); From 89db48c67e2700e6188550c5319fc6977245c67e Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 13:58:58 +0200 Subject: [PATCH 10/38] build fixes --- include/zenoh_commons.h | 34 +----------------- src/commons.rs | 4 ++- src/liveliness.rs | 22 +++++------- src/querying_subscriber.rs | 7 ++-- src/shm/buffer/zshm.rs | 7 ++-- src/shm/buffer/zshmmut.rs | 24 ++++++------- src/shm/client_storage/mod.rs | 19 +++++----- src/shm/provider/alloc_layout.rs | 9 +++-- src/shm/provider/shm_provider.rs | 9 +++-- src/shm/provider/shm_provider_backend.rs | 2 +- src/shm/provider/types.rs | 46 ------------------------ src/transmute.rs | 6 ++-- src/zbytes.rs | 4 ++- 13 files changed, 55 insertions(+), 138 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index f8c64d9f1..f678f74d7 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1594,14 +1594,6 @@ void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); ZENOHC_API const z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan(const z_owned_chunk_alloc_result_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows Chunk Alloc Result. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_loaned_chunk_alloc_result_t *z_chunk_alloc_result_loan_mut(z_owned_chunk_alloc_result_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Creates a new Chunk Alloc Result with Error value. @@ -1620,14 +1612,6 @@ ZENOHC_API z_result_t z_chunk_alloc_result_new_ok(z_owned_chunk_alloc_result_t *this_, struct z_allocated_chunk_t allocated_chunk); #endif -/** - * Takes ownership of the mutably borrowed Chunk Alloc Result. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_chunk_alloc_result_take_loaned(z_owned_chunk_alloc_result_t *dst, - z_loaned_chunk_alloc_result_t *src); -#endif /** * Get number of milliseconds passed since creation of `time`. */ @@ -3263,14 +3247,6 @@ void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, ZENOHC_API const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows Memory Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_loaned_memory_layout_t *z_memory_layout_loan_mut(z_owned_memory_layout_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Creates a new Memory Layout. @@ -3281,14 +3257,6 @@ z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif -/** - * Takes ownership of the mutably borrowed Memory Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_memory_layout_take_loaned(z_owned_memory_layout_t *dst, - z_loaned_memory_layout_t *src); -#endif /** * Drops mutex and resets it to its gravestone state. */ @@ -4484,7 +4452,7 @@ const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *th */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const z_loaned_source_info_t *z_source_info_loan_mut(const z_owned_source_info_t *this_); +z_loaned_source_info_t *z_source_info_loan_mut(z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/commons.rs b/src/commons.rs index b128c9b6d..065824251 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -620,7 +620,9 @@ pub extern "C" fn z_source_info_loan(this_: &z_owned_source_info_t) -> &z_loaned /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Borrows source info. #[no_mangle] -pub extern "C" fn z_source_info_loan_mut(this_: &z_owned_source_info_t) -> &z_loaned_source_info_t { +pub extern "C" fn z_source_info_loan_mut( + this_: &mut z_owned_source_info_t, +) -> &mut z_loaned_source_info_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/liveliness.rs b/src/liveliness.rs index 23929c2e2..2c681e85f 100644 --- a/src/liveliness.rs +++ b/src/liveliness.rs @@ -24,7 +24,7 @@ use zenoh::{ use crate::{ opaque_types::{zc_loaned_liveliness_token_t, zc_owned_liveliness_token_t}, result, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_reply_call, z_closure_reply_loan, z_closure_sample_call, z_closure_sample_loan, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_closure_reply_t, z_moved_closure_sample_t, z_owned_subscriber_t, zc_moved_liveliness_token_t, @@ -165,12 +165,10 @@ fn _liveliness_declare_subscriber_inner<'a, 'b>( .history(options.is_some_and(|o| o.history)) .callback(move |sample| { let mut owned_sample = Some(sample); - z_closure_sample_call(z_closure_sample_loan(&callback), unsafe { - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) + z_closure_sample_call( + z_closure_sample_loan(&callback), + owned_sample.as_loaned_c_type_mut(), + ) }); sub } @@ -269,12 +267,10 @@ pub extern "C" fn zc_liveliness_get( let liveliness = session.liveliness(); let mut builder = liveliness.get(key_expr).callback(move |response| { let mut owned_response = Some(response); - z_closure_reply_call(z_closure_reply_loan(&callback), unsafe { - owned_response - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) + z_closure_reply_call( + z_closure_reply_loan(&callback), + owned_response.as_loaned_c_type_mut(), + ) }); if let Some(options) = options { builder = builder.timeout(core::time::Duration::from_millis(options.timeout_ms as u64)); diff --git a/src/querying_subscriber.rs b/src/querying_subscriber.rs index 45edaaa11..79e0c8f79 100644 --- a/src/querying_subscriber.rs +++ b/src/querying_subscriber.rs @@ -20,7 +20,7 @@ use zenoh_ext::*; use crate::{ opaque_types::{ze_loaned_querying_subscriber_t, ze_owned_querying_subscriber_t}, result, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_sample_call, z_closure_sample_loan, z_get_options_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_closure_sample_t, z_query_consolidation_none, z_query_consolidation_t, z_query_target_default, z_query_target_t, @@ -121,10 +121,7 @@ unsafe fn _declare_querying_subscriber_inner<'a, 'b>( let mut owned_sample = Some(sample); z_closure_sample_call( z_closure_sample_loan(&callback), - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut(), + owned_sample.as_loaned_c_type_mut(), ); }); sub diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 386e5419c..ed20c5d98 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -21,7 +21,8 @@ use zenoh::shm::{zshm, zshmmut, ZShm}; use crate::{ transmute::{ - LoanedCTypeMut, LoanedCTypeMutUnsafe, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType + LoanedCTypeMut, LoanedCTypeMutUnsafe, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, + RustTypeRef, TakeRustType, }, z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, }; @@ -122,7 +123,9 @@ pub extern "C" fn z_shm_drop(this_: &mut z_moved_shm_t) { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Tries to reborrow mutably-borrowed ZShm slice as borrowed ZShmMut slice. #[no_mangle] -pub unsafe extern "C" fn z_shm_try_reloan_mut(this_: &mut z_loaned_shm_t) -> *mut z_loaned_shm_mut_t { +pub unsafe extern "C" fn z_shm_try_reloan_mut( + this_: &mut z_loaned_shm_t, +) -> *mut z_loaned_shm_mut_t { let Some(this) = this_.as_rust_type_mut() else { return std::ptr::null_mut(); }; diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index a575da182..b01e4211d 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -12,16 +12,15 @@ // ZettaScale Zenoh Team, // -use std::{ - borrow::{Borrow, BorrowMut}, - mem::MaybeUninit, -}; +use std::{borrow::Borrow, mem::MaybeUninit}; use zenoh::shm::{zshmmut, ZShmMut}; use crate::{ result, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_shm_mut_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_mut_t, z_owned_shm_t, }; @@ -93,12 +92,7 @@ pub unsafe extern "C" fn z_shm_mut_loan(this_: &z_owned_shm_mut_t) -> &z_loaned_ pub unsafe extern "C" fn z_shm_mut_loan_mut( this: &mut z_owned_shm_mut_t, ) -> &mut z_loaned_shm_mut_t { - let shmmut: &mut zshmmut = this - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .borrow_mut(); - shmmut.as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed shm_mut @@ -136,6 +130,10 @@ pub extern "C" fn z_shm_mut_data(this_: &z_loaned_shm_mut_t) -> *const libc::c_u /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return the mutable pointer to the underlying data. #[no_mangle] -pub extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { - this_.as_rust_type_mut().as_mut().as_mut_ptr() +pub unsafe extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_mut_ptr() } diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index bcfde4b95..6bc431d25 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -19,7 +19,9 @@ use zenoh::shm::{ProtocolID, ShmClient, ShmClientStorage, GLOBAL_CLIENT_STORAGE} use super::common::types::z_protocol_id_t; use crate::{ result::{z_result_t, Z_EINVAL, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_shm_client_storage_t, z_moved_shm_client_storage_t, z_moved_shm_client_t, z_owned_shm_client_storage_t, zc_loaned_shm_client_list_t, zc_moved_shm_client_list_t, zc_owned_shm_client_list_t, @@ -81,10 +83,7 @@ pub unsafe extern "C" fn zc_shm_client_list_loan( pub unsafe extern "C" fn zc_shm_client_list_loan_mut( this: &mut zc_owned_shm_client_list_t, ) -> &mut zc_loaned_shm_client_list_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -94,10 +93,13 @@ pub extern "C" fn zc_shm_client_list_add_client( id: z_protocol_id_t, client: &mut z_moved_shm_client_t, ) -> z_result_t { + let Some(this) = this.as_rust_type_mut() else { + return Z_EINVAL; + }; let Some(client) = client.take_rust_type() else { return Z_EINVAL; }; - this.as_rust_type_mut().push((id, client)); + this.push((id, client)); Z_OK } @@ -206,10 +208,7 @@ pub unsafe extern "C" fn z_shm_client_storage_loan( pub unsafe extern "C" fn z_shm_client_storage_loan_mut( this: &mut z_owned_shm_client_storage_t, ) -> &mut z_loaned_shm_client_storage_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index 95f38fbf3..3955508d9 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -28,7 +28,9 @@ use crate::{ context::{zc_threadsafe_context_t, Context, ThreadsafeContext}, result::z_result_t, shm::protocol_implementations::posix::posix_shm_provider::PosixAllocLayout, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_alloc_layout_t, z_loaned_shm_provider_t, z_moved_alloc_layout_t, z_owned_alloc_layout_t, }; @@ -92,10 +94,7 @@ pub unsafe extern "C" fn z_alloc_layout_loan( pub unsafe extern "C" fn z_alloc_layout_loan_mut( this: &mut z_owned_alloc_layout_t, ) -> &mut z_loaned_alloc_layout_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed Alloc Layout diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 820314b45..3928a853b 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -37,7 +37,9 @@ use crate::{ protocol_implementations::posix::posix_shm_provider::PosixShmProvider, provider::types::z_buf_layout_alloc_result_t, }, - transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, + transmute::{ + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, + }, z_loaned_shm_provider_t, z_moved_shm_provider_t, z_owned_shm_mut_t, z_owned_shm_provider_t, }; @@ -129,10 +131,7 @@ pub unsafe extern "C" fn z_shm_provider_loan( pub unsafe extern "C" fn z_shm_provider_loan_mut( this: &mut z_owned_shm_provider_t, ) -> &mut z_loaned_shm_provider_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() + this.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed SHM Provider diff --git a/src/shm/provider/shm_provider_backend.rs b/src/shm/provider/shm_provider_backend.rs index 21eda93b1..46baf634e 100644 --- a/src/shm/provider/shm_provider_backend.rs +++ b/src/shm/provider/shm_provider_backend.rs @@ -22,7 +22,7 @@ use zenoh::shm::{ use super::chunk::z_chunk_descriptor_t; use crate::{ context::DroppableContext, - transmute::{LoanedCTypeRef, OwnedCTypeRef, RustTypeRef}, + transmute::{LoanedCTypeRef, OwnedCTypeRef, RustTypeMut}, z_loaned_memory_layout_t, z_owned_chunk_alloc_result_t, z_owned_memory_layout_t, }; diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index dd12d3542..3204bdfe2 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -172,29 +172,6 @@ pub unsafe extern "C" fn z_memory_layout_loan( .as_loaned_c_type_ref() } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows Memory Layout. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_memory_layout_loan_mut( - this: &mut z_owned_memory_layout_t, -) -> &mut z_loaned_memory_layout_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Takes ownership of the mutably borrowed Memory Layout. -#[no_mangle] -pub extern "C" fn z_memory_layout_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_memory_layout_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes Memory Layout. #[no_mangle] @@ -278,29 +255,6 @@ pub unsafe extern "C" fn z_chunk_alloc_result_loan( .as_loaned_c_type_ref() } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows Chunk Alloc Result. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_chunk_alloc_result_loan_mut( - this: &mut z_owned_chunk_alloc_result_t, -) -> &mut z_loaned_chunk_alloc_result_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Takes ownership of the mutably borrowed Chunk Alloc Result. -#[no_mangle] -pub extern "C" fn z_chunk_alloc_result_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_chunk_alloc_result_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes Chunk Alloc Result. #[no_mangle] diff --git a/src/transmute.rs b/src/transmute.rs index a682b639d..28be41434 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -36,11 +36,11 @@ pub(crate) trait LoanedCTypeMutUnsafe: Sized { type LoanedCType; // Sometimes it's known that the value of type `&mut Foo` is actually // points to the `Foo` inside the `&mut Option`. - // Therefore it's safe to convert this `&mut Foo` to + // Therefore it's safe to convert this `&mut Foo` to // `z_foo_loaned_mut_t*` (which is converted back to // Rust type as `&mut Option`). - // - // Obviously this trait should be implemented only if + // + // Obviously this trait should be implemented only if // `validate_equivalence!(Foo, Option)` is satisfied. unsafe fn as_loaned_c_type_mut_unsafe(&mut self) -> &mut Self::LoanedCType; } diff --git a/src/zbytes.rs b/src/zbytes.rs index aefe04c7c..981d44eba 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -215,10 +215,12 @@ pub unsafe extern "C" fn z_bytes_to_mut_loaned_shm( this: &'static mut z_loaned_bytes_t, dst: &'static mut MaybeUninit<&'static mut z_loaned_shm_t>, ) -> z_result_t { + use crate::transmute::LoanedCTypeMutUnsafe; + let payload = this.as_rust_type_mut(); match payload.as_shm_mut() { Some(s) => { - dst.write(s.as_loaned_c_type_mut()); + dst.write(s.as_loaned_c_type_mut_unsafe()); result::Z_OK } None => { From ebb4e48049efb27b656c5aca6c9e882a150b08dc Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 14:37:02 +0200 Subject: [PATCH 11/38] header regenerated --- include/zenoh_commons.h | 618 +++++++++++++++++++++++++++------------- 1 file changed, 414 insertions(+), 204 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 467be6ba5..d120fb5e4 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -16,6 +16,32 @@ #define ALIGN(n) #define ZENOHC_API #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Allocation errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_alloc_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Defragmentation needed. + */ + Z_ALLOC_ERROR_NEED_DEFRAGMENT, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * The provider is out of memory. + */ + Z_ALLOC_ERROR_OUT_OF_MEMORY, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Other error. + */ + Z_ALLOC_ERROR_OTHER, +#endif +} z_alloc_error_t; +#endif typedef enum z_congestion_control_t { /** * Messages are not dropped in case of congestion. @@ -77,6 +103,26 @@ typedef enum z_keyexpr_intersection_level_t { Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3, } z_keyexpr_intersection_level_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Layouting errors + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum z_layout_error_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout arguments are incorrect. + */ + Z_LAYOUT_ERROR_INCORRECT_LAYOUT_ARGS, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layout incompatible with provider. + */ + Z_LAYOUT_ERROR_PROVIDER_INCOMPATIBLE_LAYOUT, +#endif +} z_layout_error_t; +#endif /** * The priority of zenoh messages. */ @@ -169,6 +215,52 @@ typedef enum z_whatami_t { Z_WHATAMI_PEER = 2, Z_WHATAMI_CLIENT = 4, } z_whatami_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +} zc_buf_alloc_status_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Status of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef enum zc_buf_layout_alloc_status_t { +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation ok + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_OK = 0, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Allocation error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_ALLOC_ERROR = 1, +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) + /** + * Layouting error + */ + ZC_BUF_LAYOUT_ALLOC_STATUS_LAYOUT_ERROR = 2, +#endif +} zc_buf_layout_alloc_status_t; +#endif /** * The locality of samples to be received by subscribers or targeted by publishers. */ @@ -237,19 +329,56 @@ typedef enum zc_reply_keyexpr_t { ZC_REPLY_KEYEXPR_MATCHING_QUERY = 1, } zc_reply_keyexpr_t; #endif -typedef struct z_moved_alloc_layout_t { - struct z_owned_alloc_layout_t _this; -} z_moved_alloc_layout_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_alloc_result_t { + enum zc_buf_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t error; +} z_buf_alloc_result_t; +#endif typedef int8_t z_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocAlignment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_alloc_alignment_t { + uint8_t pow; +} z_alloc_alignment_t; +#endif +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_data_t { + void *ptr; +} zc_threadsafe_context_data_t; +#endif +/** + * A tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a thread-safe context - the associated callbacks may be executed concurrently with the same + * zc_context_t instance. In other words, all the callbacks associated with this context data MUST be + * thread-safe. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_threadsafe_context_t { + struct zc_threadsafe_context_data_t context; + void (*delete_fn)(void*); +} zc_threadsafe_context_t; +#endif typedef struct z_moved_bytes_t { struct z_owned_bytes_t _this; } z_moved_bytes_t; -typedef struct z_moved_shm_t { - struct z_owned_shm_t _this; -} z_moved_shm_t; -typedef struct z_moved_shm_mut_t { - struct z_owned_shm_mut_t _this; -} z_moved_shm_mut_t; typedef struct z_moved_slice_t { struct z_owned_slice_t _this; } z_moved_slice_t; @@ -265,9 +394,41 @@ typedef struct ALIGN(8) z_bytes_slice_iterator_t { typedef struct z_moved_bytes_writer_t { struct z_owned_bytes_writer_t _this; } z_moved_bytes_writer_t; -typedef struct z_moved_chunk_alloc_result_t { - struct z_owned_chunk_alloc_result_t _this; -} z_moved_chunk_alloc_result_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Unique segment identifier. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_segment_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Chunk id within it's segment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef uint32_t z_chunk_id_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A ChunkDescriptor. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_chunk_descriptor_t { + z_segment_id_t segment; + z_chunk_id_t chunk; + size_t len; +} z_chunk_descriptor_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An AllocatedChunk. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_allocated_chunk_t { + struct z_chunk_descriptor_t descriptpr; + void *data; +} z_allocated_chunk_t; +#endif /** * Monotonic clock */ @@ -477,9 +638,6 @@ typedef struct z_moved_fifo_handler_sample_t { typedef struct z_query_consolidation_t { enum z_consolidation_mode_t mode; } z_query_consolidation_t; -typedef struct z_moved_source_info_t { - struct z_owned_source_info_t _this; -} z_moved_source_info_t; /** * Options passed to the `z_get()` function. */ @@ -534,7 +692,7 @@ typedef struct z_get_options_t { * * The source info for the query. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * An optional attachment to attach to the query. @@ -551,9 +709,6 @@ typedef struct z_moved_hello_t { typedef struct z_moved_keyexpr_t { struct z_owned_keyexpr_t _this; } z_moved_keyexpr_t; -typedef struct z_moved_memory_layout_t { - struct z_owned_memory_layout_t _this; -} z_moved_memory_layout_t; typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; @@ -594,7 +749,7 @@ typedef struct z_publisher_put_options_t { * * The source info for the publication. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to attach to the publication. @@ -647,7 +802,7 @@ typedef struct z_put_options_t { * * The source info for the message. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this message. @@ -688,7 +843,7 @@ typedef struct z_query_reply_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -722,7 +877,7 @@ typedef struct z_query_reply_del_options_t { * * The source info for the reply. */ - struct z_moved_source_info_t *source_info; + z_moved_source_info_t *source_info; #endif /** * The attachment to this reply. @@ -776,15 +931,46 @@ typedef struct z_scout_options_t { typedef struct z_moved_session_t { struct z_owned_session_t _this; } z_moved_session_t; -typedef struct z_moved_shm_client_t { - struct z_owned_shm_client_t _this; -} z_moved_shm_client_t; -typedef struct z_moved_shm_client_storage_t { - struct z_owned_shm_client_storage_t _this; -} z_moved_shm_client_storage_t; -typedef struct z_moved_shm_provider_t { - struct z_owned_shm_provider_t _this; -} z_moved_shm_provider_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_segment_callbacks_t { + uint8_t *(*map_fn)(z_chunk_id_t chunk_id, void *context); +} zc_shm_segment_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief An ShmSegment. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_shm_segment_t { + struct zc_threadsafe_context_t context; + struct zc_shm_segment_callbacks_t callbacks; +} z_shm_segment_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callback for ShmClient. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_client_callbacks_t { + bool (*attach_fn)(struct z_shm_segment_t *out_segment, z_segment_id_t segment_id, void *context); +} zc_shm_client_callbacks_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief A result of SHM buffer layouting + allocation operation. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct z_buf_layout_alloc_result_t { + enum zc_buf_layout_alloc_status_t status; + z_owned_shm_mut_t buf; + enum z_alloc_error_t alloc_error; + enum z_layout_error_t layout_error; +} z_buf_layout_alloc_result_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Unique protocol identifier. @@ -794,6 +980,47 @@ typedef struct z_moved_shm_provider_t { #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) typedef uint32_t z_protocol_id_t; #endif +/** + * A non-tread-safe droppable context. + * Contexts are idiomatically used in C together with callback interfaces to deliver associated state + * information to each callback. + * + * This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same + * zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated + * with this context data are not required to be thread-safe. + * + * NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can + * still be executed concurrently. The exact behavior depends on user's application, but we strongly + * discourage our users from pinning to some specific behavior unless they _really_ understand what they + * are doing. + * + * Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The + * delete_fn is guaranteed to be executed only once at some point of time after the last associated + * callback call returns. + * NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't + * be executed. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_context_t { + void *context; + void (*delete_fn)(void*); +} zc_context_t; +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Callbacks for ShmProviderBackend. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +typedef struct zc_shm_provider_backend_callbacks_t { + void (*alloc_fn)(z_owned_chunk_alloc_result_t *out_result, + const z_loaned_memory_layout_t *layout, + void *context); + void (*free_fn)(const struct z_chunk_descriptor_t *chunk, void *context); + size_t (*defragment_fn)(void *context); + size_t (*available_fn)(void *context); + void (*layout_for_fn)(z_owned_memory_layout_t *layout, void *context); +} zc_shm_provider_backend_callbacks_t; +#endif typedef struct z_moved_string_array_t { struct z_owned_string_array_t _this; } z_moved_string_array_t; @@ -853,6 +1080,15 @@ typedef struct zc_owned_closure_matching_status_t { void (*_drop)(void *context); } zc_owned_closure_matching_status_t; #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Loaned closure. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +typedef struct zc_loaned_closure_matching_status_t { + size_t _0[3]; +} zc_loaned_closure_matching_status_t; +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. @@ -889,15 +1125,6 @@ typedef struct zc_liveliness_get_options_t { uint32_t timeout_ms; } zc_liveliness_get_options_t; #endif -typedef struct zc_moved_liveliness_token_t { - struct zc_owned_liveliness_token_t _this; -} zc_moved_liveliness_token_t; -typedef struct zc_moved_matching_listener_t { - struct zc_owned_matching_listener_t _this; -} zc_moved_matching_listener_t; -typedef struct zc_moved_shm_client_list_t { - struct zc_owned_shm_client_list_t _this; -} zc_moved_shm_client_list_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Options passed to the `ze_declare_publication_cache()` function. @@ -966,19 +1193,6 @@ typedef struct ze_querying_subscriber_options_t { uint64_t query_timeout_ms; } ze_querying_subscriber_options_t; #endif -typedef struct ze_moved_publication_cache_t { - struct ze_owned_publication_cache_t _this; -} ze_moved_publication_cache_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A loaned Zenoh publication cache. - */ -typedef struct ALIGN(8) ze_loaned_publication_cache_t { - uint8_t _0[96]; -} ze_loaned_publication_cache_t; -typedef struct ze_moved_querying_subscriber_t { - struct ze_owned_querying_subscriber_t _this; -} ze_moved_querying_subscriber_t; typedef struct ze_moved_serializer_t { struct ze_owned_serializer_t _this; } ze_moved_serializer_t; @@ -1001,47 +1215,45 @@ ZENOHC_API extern const unsigned int Z_SHM_POSIX_PROTOCOL_ID; #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_blocking(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); + const z_loaned_alloc_layout_t *layout); #endif /** * Deletes Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_alloc_layout_drop(struct z_moved_alloc_layout_t *this_); +ZENOHC_API void z_alloc_layout_drop(z_moved_alloc_layout_t *this_); #endif /** * Borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_); #endif /** * Mutably borrows Alloc Layout */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(struct z_owned_alloc_layout_t *this_); +ZENOHC_API z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(z_owned_alloc_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1049,8 +1261,8 @@ struct z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(struct z_owned_alloc_lay */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_alloc_layout_new(z_owned_alloc_layout_t *this_, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -1059,13 +1271,13 @@ z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_alloc_layout_take_loaned(struct z_owned_alloc_layout_t *dst, - struct z_loaned_alloc_layout_t *src); +void z_alloc_layout_take_loaned(z_owned_alloc_layout_t *dst, + z_loaned_alloc_layout_t *src); #endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout, + const z_loaned_alloc_layout_t *layout, struct zc_threadsafe_context_t result_context, void (*result_callback)(void*, struct z_buf_alloc_result_t*)); @@ -1135,7 +1347,7 @@ z_result_t z_bytes_from_buf(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_from_shm(struct z_owned_bytes_t *this_, - struct z_moved_shm_t *shm); + z_moved_shm_t *shm); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1144,7 +1356,7 @@ z_result_t z_bytes_from_shm(struct z_owned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_from_shm_mut(struct z_owned_bytes_t *this_, - struct z_moved_shm_mut_t *shm); + z_moved_shm_mut_t *shm); #endif /** * Converts a slice into `z_owned_bytes_t`. @@ -1275,7 +1487,7 @@ ZENOHC_API void z_bytes_take_loaned(struct z_owned_bytes_t *dst, struct z_loaned #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_to_loaned_shm(const struct z_loaned_bytes_t *this_, - const struct z_loaned_shm_t **dst); + const z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1287,7 +1499,7 @@ z_result_t z_bytes_to_loaned_shm(const struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_to_mut_loaned_shm(struct z_loaned_bytes_t *this_, - struct z_loaned_shm_t **dst); + z_loaned_shm_t **dst); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1299,7 +1511,7 @@ z_result_t z_bytes_to_mut_loaned_shm(struct z_loaned_bytes_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_bytes_to_owned_shm(const struct z_loaned_bytes_t *this_, - struct z_owned_shm_t *dst); + z_owned_shm_t *dst); #endif /** * Converts data into an owned slice. @@ -1372,7 +1584,7 @@ z_result_t z_bytes_writer_write_all(struct z_loaned_bytes_writer_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); +void z_chunk_alloc_result_drop(z_moved_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -1380,7 +1592,7 @@ void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, +void z_chunk_alloc_result_new_error(z_owned_chunk_alloc_result_t *this_, enum z_alloc_error_t alloc_error); #endif /** @@ -1389,7 +1601,7 @@ void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this_, +z_result_t z_chunk_alloc_result_new_ok(z_owned_chunk_alloc_result_t *this_, struct z_allocated_chunk_t allocated_chunk); #endif /** @@ -2227,7 +2439,7 @@ const struct z_loaned_encoding_t *z_encoding_zenoh_string(void); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); +uint32_t z_entity_global_id_eid(const z_entity_global_id_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2235,7 +2447,7 @@ uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_id_t z_entity_global_id_zid(const struct z_entity_global_id_t *this_); +struct z_id_t z_entity_global_id_zid(const z_entity_global_id_t *this_); #endif /** * Constructs send and recieve ends of the fifo channel @@ -2464,13 +2676,13 @@ ZENOHC_API struct z_id_t z_info_zid(const struct z_loaned_session_t *session); * Returns ``true`` if `this` is valid. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_internal_alloc_layout_check(const struct z_owned_alloc_layout_t *this_); +ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); #endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_internal_alloc_layout_null(struct z_owned_alloc_layout_t *this_); +ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); #endif /** * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -2494,7 +2706,7 @@ ZENOHC_API void z_internal_bytes_writer_null(struct z_owned_bytes_writer_t *this */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result_t *this_); +bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2502,7 +2714,7 @@ bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_chunk_alloc_result_null(struct z_owned_chunk_alloc_result_t *this_); +void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); #endif /** * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. @@ -2617,7 +2829,7 @@ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_); +bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2625,7 +2837,7 @@ bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_memory_layout_null(struct z_owned_memory_layout_t *this_); +void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); #endif /** * Returns ``true`` if mutex is valid, ``false`` otherwise. @@ -2724,7 +2936,7 @@ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_check(const struct z_owned_shm_t *this_); +bool z_internal_shm_check(const z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2732,7 +2944,7 @@ bool z_internal_shm_check(const struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); +bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2740,7 +2952,7 @@ bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); +void z_internal_shm_client_null(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2748,7 +2960,7 @@ void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage_t *this_); +bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2756,7 +2968,7 @@ bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *this_); +void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2764,7 +2976,7 @@ void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); +bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2772,7 +2984,7 @@ bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); +void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2780,7 +2992,7 @@ void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_null(struct z_owned_shm_t *this_); +void z_internal_shm_null(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2788,7 +3000,7 @@ void z_internal_shm_null(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); +bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2796,7 +3008,7 @@ bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_internal_shm_provider_null(struct z_owned_shm_provider_t *this_); +void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); #endif /** * @return ``true`` if slice is not empty, ``false`` otherwise. @@ -2812,7 +3024,7 @@ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); +bool z_internal_source_info_check(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -2820,7 +3032,7 @@ bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_internal_source_info_null(struct z_owned_source_info_t *this_); +void z_internal_source_info_null(z_owned_source_info_t *this_); #endif /** * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. @@ -3007,7 +3219,7 @@ void z_keyexpr_take_loaned(struct z_owned_keyexpr_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); +void z_memory_layout_drop(z_moved_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3015,7 +3227,7 @@ void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, +void z_memory_layout_get_data(const z_loaned_memory_layout_t *this_, size_t *out_size, struct z_alloc_alignment_t *out_alignment); #endif @@ -3025,7 +3237,7 @@ void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned_memory_layout_t *this_); +const z_loaned_memory_layout_t *z_memory_layout_loan(const z_owned_memory_layout_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3033,7 +3245,7 @@ const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, +z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3093,7 +3305,7 @@ ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); ZENOHC_API z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, struct z_moved_config_t *config, - const struct z_loaned_shm_client_storage_t *shm_clients); + const z_loaned_shm_client_storage_t *shm_clients); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3101,7 +3313,7 @@ z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); +void z_posix_shm_client_new(z_owned_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3109,8 +3321,8 @@ void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_posix_shm_provider_new(struct z_owned_shm_provider_t *this_, - const struct z_loaned_memory_layout_t *layout); +z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, + const z_loaned_memory_layout_t *layout); #endif /** * Returns the default value of #z_priority_t. @@ -3139,7 +3351,7 @@ ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); +z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); #endif /** * Returns the key expression of the publisher. @@ -3374,7 +3586,7 @@ ZENOHC_API void z_queryable_drop(struct z_moved_queryable_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); +z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); #endif ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); @@ -3414,7 +3626,7 @@ ZENOHC_API uint8_t z_random_u8(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_ref_shm_client_storage_global(struct z_owned_shm_client_storage_t *this_); +void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3704,7 +3916,7 @@ enum z_reliability_t z_sample_reliability(const struct z_loaned_sample_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); +const z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); #endif /** * Takes ownership of the mutably borrowed sample. @@ -3763,7 +3975,7 @@ void z_session_take_loaned(struct z_owned_session_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_drop(struct z_moved_shm_client_t *this_); +void z_shm_client_drop(z_moved_shm_client_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3771,7 +3983,7 @@ void z_shm_client_drop(struct z_moved_shm_client_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_new(struct z_owned_shm_client_t *this_, +void z_shm_client_new(z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif @@ -3781,8 +3993,8 @@ void z_shm_client_new(struct z_owned_shm_client_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, - const struct z_loaned_shm_client_storage_t *from); +void z_shm_client_storage_clone(z_owned_shm_client_storage_t *this_, + const z_loaned_shm_client_storage_t *from); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3790,7 +4002,7 @@ void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); +void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3798,7 +4010,7 @@ void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const struct z_owned_shm_client_storage_t *this_); +const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3806,15 +4018,15 @@ const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const stru */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(struct z_owned_shm_client_storage_t *this_); +z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, - const struct zc_loaned_shm_client_list_t *clients, +z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, + const zc_loaned_shm_client_list_t *clients, bool add_default_client_set); #endif /** @@ -3822,7 +4034,7 @@ z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_); +void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3830,8 +4042,8 @@ void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_client_storage_take_loaned(struct z_owned_shm_client_storage_t *dst, - struct z_loaned_shm_client_storage_t *src); +void z_shm_client_storage_take_loaned(z_owned_shm_client_storage_t *dst, + z_loaned_shm_client_storage_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3839,8 +4051,8 @@ void z_shm_client_storage_take_loaned(struct z_owned_shm_client_storage_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_clone(struct z_owned_shm_t *out, - const struct z_loaned_shm_t *this_); +void z_shm_clone(z_owned_shm_t *out, + const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3848,7 +4060,7 @@ void z_shm_clone(struct z_owned_shm_t *out, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); +const unsigned char *z_shm_data(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3856,7 +4068,7 @@ const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_drop(struct z_moved_shm_t *this_); +void z_shm_drop(z_moved_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3864,8 +4076,8 @@ void z_shm_drop(struct z_moved_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_from_mut(struct z_owned_shm_t *this_, - struct z_moved_shm_mut_t *that); +void z_shm_from_mut(z_owned_shm_t *this_, + z_moved_shm_mut_t *that); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3873,7 +4085,7 @@ void z_shm_from_mut(struct z_owned_shm_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_len(const struct z_loaned_shm_t *this_); +size_t z_shm_len(const z_loaned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3881,13 +4093,13 @@ size_t z_shm_len(const struct z_loaned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_t *z_shm_loan(const struct z_owned_shm_t *this_); +const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); #endif /** * @brief Mutably borrows ZShm slice. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); +ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3895,7 +4107,7 @@ ZENOHC_API struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); +const unsigned char *z_shm_mut_data(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3903,7 +4115,7 @@ const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); +unsigned char *z_shm_mut_data_mut(z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3911,7 +4123,7 @@ unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); +void z_shm_mut_drop(z_moved_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3919,7 +4131,7 @@ void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); +size_t z_shm_mut_len(const z_loaned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3927,7 +4139,7 @@ size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t *this_); +const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3935,15 +4147,13 @@ const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); +z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); #endif /** * Takes ownership of the mutably borrowed shm_mut */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_mut_take_loaned(struct z_owned_shm_mut_t *dst, - struct z_loaned_shm_mut_t *src); +ZENOHC_API void z_shm_mut_take_loaned(z_owned_shm_mut_t *dst, z_loaned_shm_mut_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3957,9 +4167,9 @@ void z_shm_mut_take_loaned(struct z_owned_shm_mut_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, - struct z_moved_shm_t *that, - struct z_owned_shm_t *immut); +z_result_t z_shm_mut_try_from_immut(z_owned_shm_mut_t *this_, + z_moved_shm_t *that, + z_owned_shm_t *immut); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -3967,7 +4177,7 @@ z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3977,7 +4187,7 @@ void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3987,7 +4197,7 @@ void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -3997,7 +4207,7 @@ void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_resu #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment, struct zc_threadsafe_context_t result_context, @@ -4010,7 +4220,7 @@ z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4020,7 +4230,7 @@ void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, + const z_loaned_shm_provider_t *provider, size_t size, struct z_alloc_alignment_t alignment); #endif @@ -4029,14 +4239,14 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_available(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_defragment(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4044,14 +4254,14 @@ size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider) */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_drop(struct z_moved_shm_provider_t *this_); +void z_shm_provider_drop(z_moved_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *provider); +size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4059,7 +4269,7 @@ size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *prov */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_shm_provider_t *this_); +const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4067,15 +4277,15 @@ const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_s */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_provider_t *z_shm_provider_loan_mut(struct z_owned_shm_provider_t *this_); +z_loaned_shm_provider_t *z_shm_provider_loan_mut(z_owned_shm_provider_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, - const struct z_loaned_shm_provider_t *provider, +z_result_t z_shm_provider_map(z_owned_shm_mut_t *out_result, + const z_loaned_shm_provider_t *provider, struct z_allocated_chunk_t allocated_chunk, size_t len); #endif @@ -4085,7 +4295,7 @@ z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4095,8 +4305,8 @@ void z_shm_provider_new(struct z_owned_shm_provider_t *this_, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_take_loaned(struct z_owned_shm_provider_t *dst, - struct z_loaned_shm_provider_t *src); +void z_shm_provider_take_loaned(z_owned_shm_provider_t *dst, + z_loaned_shm_provider_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4104,7 +4314,7 @@ void z_shm_provider_take_loaned(struct z_owned_shm_provider_t *dst, */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, +void z_shm_provider_threadsafe_new(z_owned_shm_provider_t *this_, z_protocol_id_t id, struct zc_threadsafe_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); @@ -4113,7 +4323,7 @@ void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, * Takes ownership of the mutably borrowed shm */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_shm_take_loaned(struct z_owned_shm_t *dst, struct z_loaned_shm_t *src); +ZENOHC_API void z_shm_take_loaned(z_owned_shm_t *dst, z_loaned_shm_t *src); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4121,7 +4331,7 @@ ZENOHC_API void z_shm_take_loaned(struct z_owned_shm_t *dst, struct z_loaned_shm */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_mut(z_owned_shm_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4129,7 +4339,7 @@ struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_reloan_mut(struct z_loaned_shm_t *this_); +z_loaned_shm_mut_t *z_shm_try_reloan_mut(z_loaned_shm_t *this_); #endif /** * Puts current thread to sleep for specified amount of milliseconds. @@ -4210,7 +4420,7 @@ ZENOHC_API void z_slice_take_loaned(struct z_owned_slice_t *dst, struct z_loaned */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_drop(struct z_moved_source_info_t *this_); +void z_source_info_drop(z_moved_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4218,7 +4428,7 @@ void z_source_info_drop(struct z_moved_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t *this_); +z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4226,7 +4436,7 @@ struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_source_info_t *this_); +const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4234,7 +4444,7 @@ const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_sou */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -struct z_loaned_source_info_t *z_source_info_loan_mut(struct z_owned_source_info_t *this_); +z_loaned_source_info_t *z_source_info_loan_mut(z_owned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4242,8 +4452,8 @@ struct z_loaned_source_info_t *z_source_info_loan_mut(struct z_owned_source_info */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t z_source_info_new(struct z_owned_source_info_t *this_, - const struct z_entity_global_id_t *source_id, +z_result_t z_source_info_new(z_owned_source_info_t *this_, + const z_entity_global_id_t *source_id, uint32_t source_sn); #endif /** @@ -4252,7 +4462,7 @@ z_result_t z_source_info_new(struct z_owned_source_info_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); +uint32_t z_source_info_sn(const z_loaned_source_info_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4260,8 +4470,8 @@ uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void z_source_info_take_loaned(struct z_owned_source_info_t *dst, - struct z_loaned_source_info_t *src); +void z_source_info_take_loaned(z_owned_source_info_t *dst, + z_loaned_source_info_t *src); #endif /** * Constructs an owned copy of a string array. @@ -4879,7 +5089,7 @@ void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_s */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t *this_); +bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4887,7 +5097,7 @@ bool zc_internal_liveliness_token_check(const struct zc_owned_liveliness_token_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_); +void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4895,7 +5105,7 @@ void zc_internal_liveliness_token_null(struct zc_owned_liveliness_token_t *this_ */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener_t *this_); +bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4903,7 +5113,7 @@ bool zc_internal_matching_listener_check(const struct zc_owned_matching_listener */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *this_); +void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4911,7 +5121,7 @@ void zc_internal_matching_listener_null(struct zc_owned_matching_listener_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t *this_); +bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4919,7 +5129,7 @@ bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t * */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_internal_shm_client_list_null(struct zc_owned_shm_client_list_t *this_); +void zc_internal_shm_client_list_null(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -4982,7 +5192,7 @@ z_result_t zc_liveliness_declare_subscriber(const struct z_loaned_session_t *ses #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t zc_liveliness_declare_token(const struct z_loaned_session_t *session, - struct zc_owned_liveliness_token_t *token, + zc_owned_liveliness_token_t *token, const struct z_loaned_keyexpr_t *key_expr, const struct zc_liveliness_declaration_options_t *_options); #endif @@ -5024,7 +5234,7 @@ void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_op */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); +void zc_liveliness_token_drop(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5032,7 +5242,7 @@ void zc_liveliness_token_drop(struct zc_moved_liveliness_token_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct zc_owned_liveliness_token_t *this_); +const zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const zc_owned_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5040,7 +5250,7 @@ const struct zc_loaned_liveliness_token_t *zc_liveliness_token_loan(const struct */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t zc_liveliness_undeclare_token(struct zc_moved_liveliness_token_t *this_); +z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5078,7 +5288,7 @@ z_result_t zc_publisher_declare_background_matching_listener(const struct z_loan #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t zc_publisher_declare_matching_listener(const struct z_loaned_publisher_t *publisher, - struct zc_owned_matching_listener_t *matching_listener, + zc_owned_matching_listener_t *matching_listener, struct zc_moved_closure_matching_status_t *callback); #endif /** @@ -5098,7 +5308,7 @@ z_result_t zc_publisher_get_matching_status(const struct z_loaned_publisher_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void zc_publisher_matching_listener_drop(struct zc_moved_matching_listener_t *this_); +void zc_publisher_matching_listener_drop(zc_moved_matching_listener_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5113,9 +5323,9 @@ enum zc_reply_keyexpr_t zc_reply_keyexpr_default(void); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *this_, +z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, - struct z_moved_shm_client_t *client); + z_moved_shm_client_t *client); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5123,7 +5333,7 @@ z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *thi */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); +void zc_shm_client_list_drop(zc_moved_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5131,7 +5341,7 @@ void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct zc_owned_shm_client_list_t *this_); +const zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5139,7 +5349,7 @@ const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct z */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_shm_client_list_t *this_); +zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(zc_owned_shm_client_list_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5147,7 +5357,7 @@ struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_ */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -void zc_shm_client_list_new(struct zc_owned_shm_client_list_t *this_); +void zc_shm_client_list_new(zc_owned_shm_client_list_t *this_); #endif /** * Stops all Zenoh tasks and drops all related static variables. @@ -5215,7 +5425,7 @@ z_result_t ze_declare_background_querying_subscriber(const struct z_loaned_sessi #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t ze_declare_publication_cache(const struct z_loaned_session_t *session, - struct ze_owned_publication_cache_t *pub_cache, + ze_owned_publication_cache_t *pub_cache, const struct z_loaned_keyexpr_t *key_expr, struct ze_publication_cache_options_t *options); #endif @@ -5234,7 +5444,7 @@ z_result_t ze_declare_publication_cache(const struct z_loaned_session_t *session #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API z_result_t ze_declare_querying_subscriber(const struct z_loaned_session_t *session, - struct ze_owned_querying_subscriber_t *querying_subscriber, + ze_owned_querying_subscriber_t *querying_subscriber, const struct z_loaned_keyexpr_t *key_expr, struct z_moved_closure_sample_t *callback, struct ze_querying_subscriber_options_t *options); @@ -5418,7 +5628,7 @@ ZENOHC_API bool ze_deserializer_is_done(const struct ze_deserializer_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache_t *this_); +bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5426,7 +5636,7 @@ bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *this_); +void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5434,13 +5644,13 @@ void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *thi */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -bool ze_internal_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *this_); +bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); #endif /** * Constructs a querying subscriber in a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_subscriber_t *this_); +ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); #endif /** * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. @@ -5457,7 +5667,7 @@ ZENOHC_API void ze_internal_serializer_null(struct ze_owned_serializer_t *this_) */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); +void ze_publication_cache_drop(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5465,7 +5675,7 @@ void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_loaned_publication_cache_t *this_); +const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const ze_loaned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5473,7 +5683,7 @@ const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_lo */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_publication_cache_t *ze_publication_cache_loan(const struct ze_owned_publication_cache_t *this_); +const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5490,7 +5700,7 @@ void ze_publication_cache_options_default(struct ze_publication_cache_options_t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); +void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5500,7 +5710,7 @@ void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber_t *this_, +z_result_t ze_querying_subscriber_get(const ze_loaned_querying_subscriber_t *this_, const struct z_loaned_keyexpr_t *selector, struct z_get_options_t *options); #endif @@ -5510,7 +5720,7 @@ z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -const struct ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *this_); +const ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const ze_owned_querying_subscriber_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5755,7 +5965,7 @@ z_result_t ze_serializer_serialize_uint8(struct ze_loaned_serializer_t *this_, */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *this_); +z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_t *this_); #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -5765,5 +5975,5 @@ z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *t */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -z_result_t ze_undeclare_querying_subscriber(struct ze_moved_querying_subscriber_t *this_); +z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *this_); #endif From 41fca7e2c518903d9a28612cddca06a3a5909485 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 14:39:03 +0200 Subject: [PATCH 12/38] build fix --- src/shm/provider/types.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index a7b5f80ca..a8ddee36e 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -24,9 +24,8 @@ use crate::{ result::{z_result_t, Z_EINVAL, Z_OK}, shm::buffer::zshmmut::z_internal_shm_mut_null, transmute::{IntoCType, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, - z_loaned_chunk_alloc_result_t, z_loaned_memory_layout_t, z_moved_chunk_alloc_result_t, - z_moved_memory_layout_t, z_owned_chunk_alloc_result_t, z_owned_memory_layout_t, - z_owned_shm_mut_t, + z_loaned_memory_layout_t, z_moved_chunk_alloc_result_t, z_moved_memory_layout_t, + z_owned_chunk_alloc_result_t, z_owned_memory_layout_t, z_owned_shm_mut_t, }; /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. From 0ea664691e3fa61c209cedd18ae984bfc4109391 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 14:59:26 +0200 Subject: [PATCH 13/38] clippy fix --- src/shm/buffer/zshmmut.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index b01e4211d..ea4c494bc 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -130,6 +130,7 @@ pub extern "C" fn z_shm_mut_data(this_: &z_loaned_shm_mut_t) -> *const libc::c_u /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return the mutable pointer to the underlying data. #[no_mangle] +#[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { this_ .as_rust_type_mut() From b264590de5545eb2fd410474ae77c1e2e71e01bc Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 15:06:02 +0200 Subject: [PATCH 14/38] clippy fix --- src/shm/buffer/zshm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index ed20c5d98..26ee43d1e 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -123,6 +123,7 @@ pub extern "C" fn z_shm_drop(this_: &mut z_moved_shm_t) { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Tries to reborrow mutably-borrowed ZShm slice as borrowed ZShmMut slice. #[no_mangle] +#[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_shm_try_reloan_mut( this_: &mut z_loaned_shm_t, ) -> *mut z_loaned_shm_mut_t { From 12d0937255f03772027f63029acb98e49cc6c72c Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 23 Oct 2024 16:12:20 +0200 Subject: [PATCH 15/38] doc corrected --- docs/concepts.rst | 57 ++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/docs/concepts.rst b/docs/concepts.rst index 3e0102657..a8e4d23dc 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -151,65 +151,66 @@ Common operations The transition between "owned", "loaned" and "moved" structures above is performed by corresponding functions. The following operations are available: move, loan, mutable loan, take, check, and drop. They are performed for -"xxx" entity by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take_moved`, `z_xxx_take_loaned`, +"xxx" entities by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take_moved`, `z_xxx_take_loaned`, `z_xxx_check`, and `z_xxx_drop`. The generic macros `z_move`, `z_loan`, `z_loan_mut`, `z_take`, `z_check`, and `z_drop` are also provided. Loan operation -------------- -Function `z_xxx_loan` accepts `const z_owned_xxx_t*` and returns pointer `const z_loaned_xxx_t*` which gives read only -access to `z_owned_xxx_t` entity. +Function `z_xxx_loan` accepts `const z_owned_xxx_t*` and returns a pointer `const z_loaned_xxx_t*` which gives read-only +access to the `z_owned_xxx_t` entity. -`z_loan` macro accepts variable of `z_owned_xxx_t` type and calls corresponding `z_xxx_loan` function. +The `z_loan` macro accepts a variable of `z_owned_xxx_t` type and calls the corresponding `z_xxx_loan` function. Mutable loan operation ---------------------- -Function `z_xxx_loan_mut` accepts `z_owned_xxx_t*` and -returns pointer `z_xxx_loaned_t*` which allows to -read and modify `z_owned_xxx_t` entity and if supported by the type take ownership on it (see "take" operation) +The function `z_xxx_loan_mut` accepts `z_owned_xxx_t*` and +returns a pointer `z_xxx_loaned_t*` which allows +reading and modifying the `z_owned_xxx_t` entity. If supported by the type, it can also take ownership of it (see "take" operation). -`z_loan_mut` macro accepts variable of `z_owned_xxx_t` type and calls corresponding `z_xxx_loan_mut` function. +The `z_loan_mut` macro accepts a variable of `z_owned_xxx_t` type and calls the corresponding `z_xxx_loan_mut` function. Move operation -------------- -Function `z_xxx_move` accepts `z_owned_xxx_t*` and -returns pointer `z_moved_xxx_t*` which only allows to take -ownership of `z_owned_xxx_t`. The agreement is that the function which accepts `z_moved_xxx_t*` parameter -is obliged to take ownership on it (see "take" operation) +The function `z_xxx_move` accepts `z_owned_xxx_t*` and +returns a pointer `z_moved_xxx_t*` which only allows taking +ownership of the `z_owned_xxx_t`. The agreement is that the function which accepts a `z_moved_xxx_t*` parameter +is obliged to take ownership of it (see "take" operation). -`z_move` macro accepts varible of `z_owned_xxx_t` type anc calls corresponding `z_move_xxx` function +The `z_move` macro accepts a variable of `z_owned_xxx_t` type and calls the corresponding `z_xxx_move` function. Take operation -------------- -Functions `z_xxx_take_moved` and `z_xxx_take_loaned` accepts pointer -to unitialized `z_owned_xxx_t` destination structure and - `z_moved_xxx_t*` and `z_loaned_xxx_t*` source pointers correspondingly. +Functions `z_xxx_take_moved` and `z_xxx_take_loaned` accept pointers +to uninitialized `z_owned_xxx_t` destination structures and +`z_moved_xxx_t*` and `z_loaned_xxx_t*` source pointers, respectively. -These functions moves data from source `z_owned_xxx_t` structure into destination one. The source -structure is set to empty "gravestone" state (see "check" operation) +These functions move data from the source `z_owned_xxx_t` structure into the destination one. The source +structure is set to an empty "gravestone" state (see "check" operation). -`z_take` macro accepts `z_moved_xxx_t*` and `z_loaned_xxx_t*` pointers and calls corresponding +The `z_take` macro accepts `z_moved_xxx_t*` or `z_loaned_xxx_t*` pointer and calls the corresponding `z_xxx_take_moved` and `z_xxx_take_loaned` functions. Check operation --------------- -When owned object is dropped or taken it's set to so-called "gravestone" state which is safe to -double drop. No operations except "check" and "drop" are normally allowed on dropped/taken object. +When an owned object is dropped or taken, it's set to a so-called **gravestone** state, which is safe to +double drop. No operations except "check" and "drop" are usually allowed on a dropped/taken object. -Function `z_xxx_check` returns true if object is in valid state, e.g. if all operations -on the object are allowed. +The function `z_xxx_check` returns true if the object is in a **valid** state, e.g., if the loan operation +on the object is allowed. -There is small catch: for some objects the gravestone state is still valid state. -Examples are `z_owned_bytes_t` which is set to "empty" state by the drop and `z_owned_encoding_t` -which becomes `ZENOH_BYTES`. For such objects the `z_check` always returns true, even after "drop" or "take" -operation. +There is a catch: **gravestone** and **valid** states are not always opposite. +For some objects, the gravestone state is still a valid state. +Examples are `z_owned_bytes_t` in the "empty" state or `z_owned_encoding_t` +with `ZENOH_BYTES` encoding set. For such objects, the `z_check` always returns true, +even after a "drop" or "take" operation. -`z_check` macro accepts `const z_owned_xxx_t*` and calls corresponding `z_xxx_check` function +The `z_check` macro accepts `const z_owned_xxx_t*` and calls corresponding `z_xxx_check` function. Drop operation -------------- From d89df38fa4357dea4c6b04f77aef92469c7c73e1 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 13:48:33 +0200 Subject: [PATCH 16/38] generic for take loaned --- build.rs | 70 +++++++++++++--- include/zenoh_macros.h | 180 +++++++++++++++++++++++++++++++++-------- 2 files changed, 206 insertions(+), 44 deletions(-) diff --git a/build.rs b/build.rs index 1c5fde8e9..b91c54a81 100644 --- a/build.rs +++ b/build.rs @@ -966,10 +966,11 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { ) .unwrap(); - // Collect all function signatures to be wrappeb by macros and verify that all necessary functions are present for each entity + // Collect all function signatures to be wrapped by macros and verify that all necessary functions are present for each entity let (move_funcs, take_funcs) = make_move_take_signatures(path_in); let loan_funcs = find_loan_functions(path_in); let loan_mut_funcs = find_loan_mut_functions(path_in); + let take_loaned_funcs = find_take_loaned_functions(path_in); let drop_funcs = find_drop_functions(path_in); let null_funcs = find_null_functions(path_in); let check_funcs = find_check_functions(path_in); @@ -977,6 +978,8 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { let closure_constructors = find_closure_constructors(path_in); let recv_funcs = find_recv_functions(path_in); let clone_funcs = find_clone_functions(path_in); + let mut take_funcs_generic = take_funcs.clone(); + take_funcs_generic.extend(take_loaned_funcs); let drops = drop_funcs .iter() @@ -1067,7 +1070,7 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); - let out = generate_generic_take_c(&take_funcs); + let out = generate_generic_take_c(&take_funcs_generic); file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); @@ -1126,7 +1129,7 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); - let out = generate_generic_take_cpp(&take_funcs); + let out = generate_generic_take_cpp(&take_funcs_generic); file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); @@ -1302,6 +1305,35 @@ pub fn find_check_functions(path_in: &str) -> Vec { res } +pub fn find_take_loaned_functions(path_in: &str) -> Vec { + let bindings = std::fs::read_to_string(path_in).unwrap(); + let re = Regex::new( + r"void (\w+)_take_loaned\(struct\s+(\w+)\s*\*\s*(\w+),\s*struct\s+(\w+)\s*\*\s*(\w+)\);", + ) + .unwrap(); + let mut res = Vec::::new(); + + for ( + _, + [func_name, dst_type, dst_name, src_type, src_name], + ) in re.captures_iter(&bindings).map(|c| c.extract()) + { + let (_, _, semantic, _) = split_type_name(dst_type); + let f = FunctionSignature::new( + semantic, + "void", + func_name.to_string() + "_take_loaned", + vec![ + FuncArg::new(&(dst_type.to_string() + "*"), dst_name), + FuncArg::new(&(src_type.to_string() + "*"), src_name), + ], + ); + res.push(f); + } + res +} + + pub fn find_call_functions(path_in: &str) -> Vec { let bindings = std::fs::read_to_string(path_in).unwrap(); let re = Regex::new( @@ -1420,11 +1452,13 @@ pub fn find_clone_functions(path_in: &str) -> Vec { res } -pub fn generate_generic_c( +pub fn generate_generic_c_impl( macro_func: &[FunctionSignature], generic_name: &str, decay: bool, + generic_param_idx: usize, ) -> String { + assert!(!decay || generic_param_idx == 0); let va_args = macro_func .iter() .any(|f| f.args.len() != macro_func[0].args.len()); @@ -1440,25 +1474,25 @@ pub fn generate_generic_c( "#define {generic_name}({}, ...) \\ _Generic(({})", args.join(", "), - args[0], + args[generic_param_idx], ) } else { format!( "#define {generic_name}({}) \\ _Generic(({})", args.join(", "), - args[0], + args[generic_param_idx], ) }; if decay { - args[0] = format!("&{}", args[0]); + args[generic_param_idx] = format!("&{}", args[generic_param_idx]); } for func in macro_func { let owned_type = if decay { - func.args[0].typename.clone().decay().typename + func.args[generic_param_idx].typename.clone().decay().typename } else { - func.args[0].typename.typename.clone() + func.args[generic_param_idx].typename.typename.clone() }; let func_name = &func.func_name; out += ", \\\n"; @@ -1473,6 +1507,22 @@ pub fn generate_generic_c( out } +pub fn generate_generic_c( + macro_func: &[FunctionSignature], + generic_name: &str, + decay: bool, +) -> String { + generate_generic_c_impl(macro_func, generic_name, decay, 0) +} + +pub fn generate_generic_c_by_arg( + macro_func: &[FunctionSignature], + generic_name: &str, + generic_param_idx: usize +) -> String { + generate_generic_c_impl(macro_func, generic_name, false, generic_param_idx) +} + pub fn generate_generic_loan_c(macro_func: &[FunctionSignature]) -> String { generate_generic_c(macro_func, "z_loan", true) } @@ -1486,7 +1536,7 @@ pub fn generate_generic_move_c(macro_func: &[FunctionSignature]) -> String { } pub fn generate_generic_take_c(macro_func: &[FunctionSignature]) -> String { - generate_generic_c(macro_func, "z_take", false) + generate_generic_c_by_arg(macro_func, "z_take", 1) } pub fn generate_generic_drop_c(macro_func: &[FunctionSignature]) -> String { diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 7c0725f67..1449de5c9 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -259,40 +259,68 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser #define z_take(this_, x) \ - _Generic((this_), \ - z_owned_bytes_t* : z_bytes_take, \ - z_owned_bytes_writer_t* : z_bytes_writer_take, \ - z_owned_closure_hello_t* : z_closure_hello_take, \ - z_owned_closure_query_t* : z_closure_query_take, \ - z_owned_closure_reply_t* : z_closure_reply_take, \ - z_owned_closure_sample_t* : z_closure_sample_take, \ - z_owned_closure_zid_t* : z_closure_zid_take, \ - z_owned_condvar_t* : z_condvar_take, \ - z_owned_config_t* : z_config_take, \ - z_owned_encoding_t* : z_encoding_take, \ - z_owned_fifo_handler_query_t* : z_fifo_handler_query_take, \ - z_owned_fifo_handler_reply_t* : z_fifo_handler_reply_take, \ - z_owned_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ - z_owned_hello_t* : z_hello_take, \ - z_owned_keyexpr_t* : z_keyexpr_take, \ - z_owned_mutex_t* : z_mutex_take, \ - z_owned_publisher_t* : z_publisher_take, \ - z_owned_query_t* : z_query_take, \ - z_owned_queryable_t* : z_queryable_take, \ - z_owned_reply_t* : z_reply_take, \ - z_owned_reply_err_t* : z_reply_err_take, \ - z_owned_ring_handler_query_t* : z_ring_handler_query_take, \ - z_owned_ring_handler_reply_t* : z_ring_handler_reply_take, \ - z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ - z_owned_sample_t* : z_sample_take, \ - z_owned_session_t* : z_session_take, \ - z_owned_slice_t* : z_slice_take, \ - z_owned_string_array_t* : z_string_array_take, \ - z_owned_string_t* : z_string_take, \ - z_owned_subscriber_t* : z_subscriber_take, \ - z_owned_task_t* : z_task_take, \ - zc_owned_closure_log_t* : zc_closure_log_take, \ - ze_owned_serializer_t* : ze_serializer_take \ + _Generic((x), \ + z_moved_bytes_t* : z_bytes_take, \ + z_moved_bytes_writer_t* : z_bytes_writer_take, \ + z_moved_closure_hello_t* : z_closure_hello_take, \ + z_moved_closure_query_t* : z_closure_query_take, \ + z_moved_closure_reply_t* : z_closure_reply_take, \ + z_moved_closure_sample_t* : z_closure_sample_take, \ + z_moved_closure_zid_t* : z_closure_zid_take, \ + z_moved_condvar_t* : z_condvar_take, \ + z_moved_config_t* : z_config_take, \ + z_moved_encoding_t* : z_encoding_take, \ + z_moved_fifo_handler_query_t* : z_fifo_handler_query_take, \ + z_moved_fifo_handler_reply_t* : z_fifo_handler_reply_take, \ + z_moved_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ + z_moved_hello_t* : z_hello_take, \ + z_moved_keyexpr_t* : z_keyexpr_take, \ + z_moved_mutex_t* : z_mutex_take, \ + z_moved_publisher_t* : z_publisher_take, \ + z_moved_query_t* : z_query_take, \ + z_moved_queryable_t* : z_queryable_take, \ + z_moved_reply_t* : z_reply_take, \ + z_moved_reply_err_t* : z_reply_err_take, \ + z_moved_ring_handler_query_t* : z_ring_handler_query_take, \ + z_moved_ring_handler_reply_t* : z_ring_handler_reply_take, \ + z_moved_ring_handler_sample_t* : z_ring_handler_sample_take, \ + z_moved_sample_t* : z_sample_take, \ + z_moved_session_t* : z_session_take, \ + z_moved_slice_t* : z_slice_take, \ + z_moved_string_array_t* : z_string_array_take, \ + z_moved_string_t* : z_string_take, \ + z_moved_subscriber_t* : z_subscriber_take, \ + z_moved_task_t* : z_task_take, \ + zc_moved_closure_log_t* : zc_closure_log_take, \ + ze_moved_serializer_t* : ze_serializer_take, \ + z_loaned_bytes_t* : z_bytes_take_loaned, \ + z_loaned_closure_hello_t* : z_closure_hello_take_loaned, \ + z_loaned_closure_query_t* : z_closure_query_take_loaned, \ + z_loaned_closure_reply_t* : z_closure_reply_take_loaned, \ + z_loaned_closure_sample_t* : z_closure_sample_take_loaned, \ + z_loaned_closure_zid_t* : z_closure_zid_take_loaned, \ + z_loaned_config_t* : z_config_take_loaned, \ + z_loaned_encoding_t* : z_encoding_take_loaned, \ + z_loaned_fifo_handler_query_t* : z_fifo_handler_query_take_loaned, \ + z_loaned_fifo_handler_reply_t* : z_fifo_handler_reply_take_loaned, \ + z_loaned_fifo_handler_sample_t* : z_fifo_handler_sample_take_loaned, \ + z_loaned_hello_t* : z_hello_take_loaned, \ + z_loaned_keyexpr_t* : z_keyexpr_take_loaned, \ + z_loaned_mutex_t* : z_mutex_take_loaned, \ + z_loaned_publisher_t* : z_publisher_take_loaned, \ + z_loaned_query_t* : z_query_take_loaned, \ + z_loaned_queryable_t* : z_queryable_take_loaned, \ + z_loaned_reply_err_t* : z_reply_err_take_loaned, \ + z_loaned_reply_t* : z_reply_take_loaned, \ + z_loaned_ring_handler_query_t* : z_ring_handler_query_take_loaned, \ + z_loaned_ring_handler_reply_t* : z_ring_handler_reply_take_loaned, \ + z_loaned_ring_handler_sample_t* : z_ring_handler_sample_take_loaned, \ + z_loaned_sample_t* : z_sample_take_loaned, \ + z_loaned_session_t* : z_session_take_loaned, \ + z_loaned_slice_t* : z_slice_take_loaned, \ + z_loaned_string_array_t* : z_string_array_take_loaned, \ + z_loaned_string_t* : z_string_take_loaned, \ + z_loaned_subscriber_t* : z_subscriber_take_loaned \ )(this_, x) #define z_internal_check(this_) \ @@ -741,6 +769,90 @@ inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) inline void z_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { ze_serializer_take(this_, x); }; +inline void z_take(z_owned_bytes_t* dst, z_loaned_bytes_t* src) { + z_bytes_take_loaned(dst, src); +}; +inline void z_take(z_owned_closure_hello_t* dst, z_loaned_closure_hello_t* src) { + z_closure_hello_take_loaned(dst, src); +}; +inline void z_take(z_owned_closure_query_t* dst, z_loaned_closure_query_t* src) { + z_closure_query_take_loaned(dst, src); +}; +inline void z_take(z_owned_closure_reply_t* dst, z_loaned_closure_reply_t* src) { + z_closure_reply_take_loaned(dst, src); +}; +inline void z_take(z_owned_closure_sample_t* dst, z_loaned_closure_sample_t* src) { + z_closure_sample_take_loaned(dst, src); +}; +inline void z_take(z_owned_closure_zid_t* dst, z_loaned_closure_zid_t* src) { + z_closure_zid_take_loaned(dst, src); +}; +inline void z_take(z_owned_config_t* dst, z_loaned_config_t* src) { + z_config_take_loaned(dst, src); +}; +inline void z_take(z_owned_encoding_t* dst, z_loaned_encoding_t* src) { + z_encoding_take_loaned(dst, src); +}; +inline void z_take(z_owned_fifo_handler_query_t* dst, z_loaned_fifo_handler_query_t* src) { + z_fifo_handler_query_take_loaned(dst, src); +}; +inline void z_take(z_owned_fifo_handler_reply_t* dst, z_loaned_fifo_handler_reply_t* src) { + z_fifo_handler_reply_take_loaned(dst, src); +}; +inline void z_take(z_owned_fifo_handler_sample_t* dst, z_loaned_fifo_handler_sample_t* src) { + z_fifo_handler_sample_take_loaned(dst, src); +}; +inline void z_take(z_owned_hello_t* dst, z_loaned_hello_t* src) { + z_hello_take_loaned(dst, src); +}; +inline void z_take(z_owned_keyexpr_t* dst, z_loaned_keyexpr_t* src) { + z_keyexpr_take_loaned(dst, src); +}; +inline void z_take(z_owned_mutex_t* dst, z_loaned_mutex_t* src) { + z_mutex_take_loaned(dst, src); +}; +inline void z_take(z_owned_publisher_t* dst, z_loaned_publisher_t* src) { + z_publisher_take_loaned(dst, src); +}; +inline void z_take(z_owned_query_t* dst, z_loaned_query_t* src) { + z_query_take_loaned(dst, src); +}; +inline void z_take(z_owned_queryable_t* dst, z_loaned_queryable_t* src) { + z_queryable_take_loaned(dst, src); +}; +inline void z_take(z_owned_reply_err_t* dst, z_loaned_reply_err_t* src) { + z_reply_err_take_loaned(dst, src); +}; +inline void z_take(z_owned_reply_t* dst, z_loaned_reply_t* src) { + z_reply_take_loaned(dst, src); +}; +inline void z_take(z_owned_ring_handler_query_t* dst, z_loaned_ring_handler_query_t* src) { + z_ring_handler_query_take_loaned(dst, src); +}; +inline void z_take(z_owned_ring_handler_reply_t* dst, z_loaned_ring_handler_reply_t* src) { + z_ring_handler_reply_take_loaned(dst, src); +}; +inline void z_take(z_owned_ring_handler_sample_t* dst, z_loaned_ring_handler_sample_t* src) { + z_ring_handler_sample_take_loaned(dst, src); +}; +inline void z_take(z_owned_sample_t* dst, z_loaned_sample_t* src) { + z_sample_take_loaned(dst, src); +}; +inline void z_take(z_owned_session_t* dst, z_loaned_session_t* src) { + z_session_take_loaned(dst, src); +}; +inline void z_take(z_owned_slice_t* dst, z_loaned_slice_t* src) { + z_slice_take_loaned(dst, src); +}; +inline void z_take(z_owned_string_array_t* dst, z_loaned_string_array_t* src) { + z_string_array_take_loaned(dst, src); +}; +inline void z_take(z_owned_string_t* dst, z_loaned_string_t* src) { + z_string_take_loaned(dst, src); +}; +inline void z_take(z_owned_subscriber_t* dst, z_loaned_subscriber_t* src) { + z_subscriber_take_loaned(dst, src); +}; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; From 6eb5e629574dd934aa72ccf8265385d4ef44ed1a Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 14:32:02 +0200 Subject: [PATCH 17/38] missing loan_muts added, unnecessry unsafe removed, test for loan_mut added --- build.rs | 15 ++++++++------- include/zenoh_commons.h | 12 ++++++++++++ include/zenoh_macros.h | 10 +++++++++- src/closures/query_channel.rs | 6 ++---- src/closures/response_channel.rs | 6 ++---- src/closures/sample_channel.rs | 6 ++---- src/closures/zenohid_closure.rs | 16 ++++++++-------- src/collections.rs | 8 ++------ src/commons.rs | 3 +-- src/config.rs | 14 ++++++++------ src/get.rs | 3 +-- src/keyexpr.rs | 5 +---- src/platform/synchronization.rs | 3 +-- src/publisher.rs | 3 +-- src/queryable.rs | 6 ++---- src/scouting.rs | 3 +-- src/serialization.rs | 13 +++++++++++-- src/session.rs | 5 +---- src/shm/buffer/zshm.rs | 3 +-- src/shm/buffer/zshmmut.rs | 5 +---- src/shm/client_storage/mod.rs | 3 +-- src/shm/provider/alloc_layout.rs | 3 +-- src/shm/provider/shm_provider.rs | 3 +-- src/subscriber.rs | 3 +-- src/zbytes.rs | 13 +++++++++++-- tests/z_api_null_drop_test.c | 10 ++++++++++ 26 files changed, 100 insertions(+), 80 deletions(-) diff --git a/build.rs b/build.rs index b91c54a81..6625fd8dc 100644 --- a/build.rs +++ b/build.rs @@ -1313,10 +1313,8 @@ pub fn find_take_loaned_functions(path_in: &str) -> Vec { .unwrap(); let mut res = Vec::::new(); - for ( - _, - [func_name, dst_type, dst_name, src_type, src_name], - ) in re.captures_iter(&bindings).map(|c| c.extract()) + for (_, [func_name, dst_type, dst_name, src_type, src_name]) in + re.captures_iter(&bindings).map(|c| c.extract()) { let (_, _, semantic, _) = split_type_name(dst_type); let f = FunctionSignature::new( @@ -1333,7 +1331,6 @@ pub fn find_take_loaned_functions(path_in: &str) -> Vec { res } - pub fn find_call_functions(path_in: &str) -> Vec { let bindings = std::fs::read_to_string(path_in).unwrap(); let re = Regex::new( @@ -1490,7 +1487,11 @@ pub fn generate_generic_c_impl( for func in macro_func { let owned_type = if decay { - func.args[generic_param_idx].typename.clone().decay().typename + func.args[generic_param_idx] + .typename + .clone() + .decay() + .typename } else { func.args[generic_param_idx].typename.typename.clone() }; @@ -1518,7 +1519,7 @@ pub fn generate_generic_c( pub fn generate_generic_c_by_arg( macro_func: &[FunctionSignature], generic_name: &str, - generic_param_idx: usize + generic_param_idx: usize, ) -> String { generate_generic_c_impl(macro_func, generic_name, false, generic_param_idx) } diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index d120fb5e4..e795aef0c 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1569,6 +1569,12 @@ const struct z_loaned_bytes_writer_t *z_bytes_writer_loan(const struct z_owned_b */ ZENOHC_API struct z_loaned_bytes_writer_t *z_bytes_writer_loan_mut(struct z_owned_bytes_writer_t *this_); +/** + * Takes ownership of the mutably borrowed writer + */ +ZENOHC_API +void z_bytes_writer_take_loaned(struct z_owned_bytes_writer_t *dst, + struct z_loaned_bytes_writer_t *src); /** * Writes `len` bytes from `src` into underlying data. * @@ -5958,6 +5964,12 @@ z_result_t ze_serializer_serialize_uint64(struct ze_loaned_serializer_t *this_, ZENOHC_API z_result_t ze_serializer_serialize_uint8(struct ze_loaned_serializer_t *this_, uint8_t val); +/** + * @brief Takes ownership of the mutably borrowed serializer. + */ +ZENOHC_API +void ze_serializer_take_loaned(struct ze_owned_serializer_t *dst, + struct ze_loaned_serializer_t *src); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Undeclares publication cache. diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 1449de5c9..667f734b7 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -294,6 +294,7 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser zc_moved_closure_log_t* : zc_closure_log_take, \ ze_moved_serializer_t* : ze_serializer_take, \ z_loaned_bytes_t* : z_bytes_take_loaned, \ + z_loaned_bytes_writer_t* : z_bytes_writer_take_loaned, \ z_loaned_closure_hello_t* : z_closure_hello_take_loaned, \ z_loaned_closure_query_t* : z_closure_query_take_loaned, \ z_loaned_closure_reply_t* : z_closure_reply_take_loaned, \ @@ -320,7 +321,8 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_loaned_slice_t* : z_slice_take_loaned, \ z_loaned_string_array_t* : z_string_array_take_loaned, \ z_loaned_string_t* : z_string_take_loaned, \ - z_loaned_subscriber_t* : z_subscriber_take_loaned \ + z_loaned_subscriber_t* : z_subscriber_take_loaned, \ + ze_loaned_serializer_t* : ze_serializer_take_loaned \ )(this_, x) #define z_internal_check(this_) \ @@ -772,6 +774,9 @@ inline void z_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { inline void z_take(z_owned_bytes_t* dst, z_loaned_bytes_t* src) { z_bytes_take_loaned(dst, src); }; +inline void z_take(z_owned_bytes_writer_t* dst, z_loaned_bytes_writer_t* src) { + z_bytes_writer_take_loaned(dst, src); +}; inline void z_take(z_owned_closure_hello_t* dst, z_loaned_closure_hello_t* src) { z_closure_hello_take_loaned(dst, src); }; @@ -853,6 +858,9 @@ inline void z_take(z_owned_string_t* dst, z_loaned_string_t* src) { inline void z_take(z_owned_subscriber_t* dst, z_loaned_subscriber_t* src) { z_subscriber_take_loaned(dst, src); }; +inline void z_take(ze_owned_serializer_t* dst, ze_loaned_serializer_t* src) { + ze_serializer_take_loaned(dst, src); +}; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index b350e8840..417348fb5 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -107,8 +107,7 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan( /// Borrows handler. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_query_loan_mut( +pub extern "C" fn z_fifo_handler_query_loan_mut( this: &mut z_owned_fifo_handler_query_t, ) -> &mut z_loaned_fifo_handler_query_t { this.as_rust_type_mut().as_loaned_c_type_mut() @@ -235,8 +234,7 @@ pub unsafe extern "C" fn z_ring_handler_query_loan( /// Borrows handler. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_query_loan_mut( +pub extern "C" fn z_ring_handler_query_loan_mut( this: &mut z_owned_ring_handler_query_t, ) -> &mut z_loaned_ring_handler_query_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index b5b94993d..1b0d7158e 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -107,8 +107,7 @@ pub unsafe extern "C" fn z_fifo_handler_reply_loan( /// Mutably borrows handler. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_reply_loan_mut( +pub extern "C" fn z_fifo_handler_reply_loan_mut( this: &mut z_owned_fifo_handler_reply_t, ) -> &mut z_loaned_fifo_handler_reply_t { this.as_rust_type_mut().as_loaned_c_type_mut() @@ -231,8 +230,7 @@ pub unsafe extern "C" fn z_ring_handler_reply_loan( /// Mutably borrows handler. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_reply_loan_mut( +pub extern "C" fn z_ring_handler_reply_loan_mut( this: &mut z_owned_ring_handler_reply_t, ) -> &mut z_loaned_ring_handler_reply_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 773b94d78..fd7eb8b04 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -107,8 +107,7 @@ pub unsafe extern "C" fn z_fifo_handler_sample_loan( /// Mutably borrows handler. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_sample_loan_mut( +pub extern "C" fn z_fifo_handler_sample_loan_mut( this: &mut z_owned_fifo_handler_sample_t, ) -> &mut z_loaned_fifo_handler_sample_t { this.as_rust_type_mut().as_loaned_c_type_mut() @@ -235,8 +234,7 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan( /// Borrows handler. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_sample_loan_mut( +pub extern "C" fn z_ring_handler_sample_loan_mut( this: &mut z_owned_ring_handler_sample_t, ) -> &mut z_loaned_ring_handler_sample_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index 0b361b0c1..c4fc17112 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -131,6 +131,14 @@ pub extern "C" fn z_closure_zid_loan(closure: &z_owned_closure_zid_t) -> &z_loan closure.as_loaned_c_type_ref() } +/// @brief Mutably borrows closure. +#[no_mangle] +pub extern "C" fn z_closure_zid_loan_mut( + closure: &mut z_owned_closure_zid_t, +) -> &mut z_loaned_closure_zid_t { + closure.as_loaned_c_type_mut() +} + /// Takes ownership of the mutably borrowed closure #[no_mangle] pub extern "C" fn z_closure_zid_take_loaned( @@ -140,14 +148,6 @@ pub extern "C" fn z_closure_zid_take_loaned( dst.write(std::mem::take(src.as_owned_c_type_mut())); } -/// @brief Mutably borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_zid_loan_mut( - closure: &mut z_owned_closure_zid_t, -) -> &mut z_loaned_closure_zid_t { - closure.as_loaned_c_type_mut() -} - /// @brief Constructs closure. /// /// Closures are not guaranteed not to be called concurrently. diff --git a/src/collections.rs b/src/collections.rs index 6b203b98c..1c5a22e55 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -807,17 +807,13 @@ pub extern "C" fn z_string_array_drop(this_: &mut z_moved_string_array_t) { /// Borrows string array. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_array_loan( - this: &z_owned_string_array_t, -) -> &z_loaned_string_array_t { +pub extern "C" fn z_string_array_loan(this: &z_owned_string_array_t) -> &z_loaned_string_array_t { this.as_rust_type_ref().as_loaned_c_type_ref() } /// Mutably borrows string array. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_array_loan_mut( +pub extern "C" fn z_string_array_loan_mut( this: &mut z_owned_string_array_t, ) -> &mut z_loaned_string_array_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/commons.rs b/src/commons.rs index 065824251..1544389ed 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -215,8 +215,7 @@ pub unsafe extern "C" fn z_sample_loan(this_: &z_owned_sample_t) -> &z_loaned_sa /// Mutably borrows sample. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loaned_sample_t { +pub extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loaned_sample_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/config.rs b/src/config.rs index 28ca0ed6e..92d46c269 100644 --- a/src/config.rs +++ b/src/config.rs @@ -75,17 +75,19 @@ decl_c_type!( /// Borrows config. #[no_mangle] -pub extern "C" fn z_config_loan(this_: &'static z_owned_config_t) -> &z_loaned_config_t { - let this = this_.as_rust_type_ref(); - let this = unsafe { this.as_ref().unwrap_unchecked() }; - this.as_loaned_c_type_ref() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_config_loan(this_: &'static z_owned_config_t) -> &z_loaned_config_t { + this_ + .as_rust_type_ref() + .as_ref() + .unwrap_unchecked() + .as_loaned_c_type_ref() } /// Mutably borrows config. #[no_mangle] pub extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loaned_config_t { - let this = this_.as_rust_type_mut(); - this.as_loaned_c_type_mut() + this_.as_rust_type_mut().as_loaned_c_type_mut() } /// Takes ownership of the mutably borrowed config. diff --git a/src/get.rs b/src/get.rs index 9d1554e1c..ae1d1770b 100644 --- a/src/get.rs +++ b/src/get.rs @@ -330,8 +330,7 @@ pub unsafe extern "C" fn z_reply_loan(this_: &z_owned_reply_t) -> &z_loaned_repl /// Mutably borrows reply. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned_reply_t { +pub extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned_reply_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/keyexpr.rs b/src/keyexpr.rs index 347f590c0..ea6e288e2 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -138,10 +138,7 @@ pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_ /// Mutably borrows `z_owned_keyexpr_t`. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_keyexpr_loan_mut( - this_: &mut z_owned_keyexpr_t, -) -> &mut z_loaned_keyexpr_t { +pub extern "C" fn z_keyexpr_loan_mut(this_: &mut z_owned_keyexpr_t) -> &mut z_loaned_keyexpr_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index 3b071f6f2..ad0a78a52 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -50,8 +50,7 @@ pub extern "C" fn z_internal_mutex_null(this_: &mut MaybeUninit /// Mutably borrows mutex. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned_mutex_t { +pub extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned_mutex_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/publisher.rs b/src/publisher.rs index 92ac818b9..d0837bf20 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -167,8 +167,7 @@ pub unsafe extern "C" fn z_publisher_loan(this_: &z_owned_publisher_t) -> &z_loa /// Mutably borrows publisher. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_publisher_loan_mut( +pub extern "C" fn z_publisher_loan_mut( this: &mut z_owned_publisher_t, ) -> &mut z_loaned_publisher_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/queryable.rs b/src/queryable.rs index 6d70efa20..c70658432 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -61,8 +61,7 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa // Mutably borrows Queryable #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_queryable_loan_mut( +pub extern "C" fn z_queryable_loan_mut( this_: &mut z_owned_queryable_t, ) -> &mut z_loaned_queryable_t { this_.as_rust_type_mut().as_loaned_c_type_mut() @@ -107,8 +106,7 @@ pub unsafe extern "C" fn z_query_loan(this_: &z_owned_query_t) -> &z_loaned_quer /// Mutably borrows the query. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_query_loan_mut(this_: &mut z_owned_query_t) -> &mut z_loaned_query_t { +pub extern "C" fn z_query_loan_mut(this_: &mut z_owned_query_t) -> &mut z_loaned_query_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/scouting.rs b/src/scouting.rs index ee7645f64..9561e47c2 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -54,8 +54,7 @@ pub unsafe extern "C" fn z_hello_loan(this_: &z_owned_hello_t) -> &z_loaned_hell /// Borrows hello message. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { +pub extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/serialization.rs b/src/serialization.rs index b954fef28..b6156d420 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -74,13 +74,22 @@ pub unsafe extern "C" fn ze_serializer_loan( /// @brief Muatably borrows serializer. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_serializer_loan_mut( +pub extern "C" fn ze_serializer_loan_mut( this: &mut ze_owned_serializer_t, ) -> &mut ze_loaned_serializer_t { this.as_rust_type_mut().as_loaned_c_type_mut() } +/// @brief Takes ownership of the mutably borrowed serializer. +#[no_mangle] +pub extern "C" fn ze_serializer_take_loaned( + dst: &mut MaybeUninit, + src: &mut ze_loaned_serializer_t, +) { + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); +} + /// @brief Constructs a serializer in a gravestone state. #[no_mangle] pub extern "C" fn ze_internal_serializer_null(this_: &mut MaybeUninit) { diff --git a/src/session.rs b/src/session.rs index d9e304b0d..26306cbe7 100644 --- a/src/session.rs +++ b/src/session.rs @@ -44,10 +44,7 @@ pub unsafe extern "C" fn z_session_loan(this_: &z_owned_session_t) -> &z_loaned_ /// Mutably borrows session. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_session_loan_mut( - this_: &mut z_owned_session_t, -) -> &mut z_loaned_session_t { +pub extern "C" fn z_session_loan_mut(this_: &mut z_owned_session_t) -> &mut z_loaned_session_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 26ee43d1e..442bb8f76 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -81,8 +81,7 @@ pub unsafe extern "C" fn z_shm_loan(this_: &z_owned_shm_t) -> &z_loaned_shm_t { /// @brief Mutably borrows ZShm slice. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_t { +pub extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_t { this_.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index ea4c494bc..ee8d09761 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -88,10 +88,7 @@ pub unsafe extern "C" fn z_shm_mut_loan(this_: &z_owned_shm_mut_t) -> &z_loaned_ /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows ZShmMut slice. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_mut_loan_mut( - this: &mut z_owned_shm_mut_t, -) -> &mut z_loaned_shm_mut_t { +pub extern "C" fn z_shm_mut_loan_mut(this: &mut z_owned_shm_mut_t) -> &mut z_loaned_shm_mut_t { this.as_rust_type_mut().as_loaned_c_type_mut() } diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 6bc431d25..a0c9b045e 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -204,8 +204,7 @@ pub unsafe extern "C" fn z_shm_client_storage_loan( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows SHM Client Storage. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_client_storage_loan_mut( +pub extern "C" fn z_shm_client_storage_loan_mut( this: &mut z_owned_shm_client_storage_t, ) -> &mut z_loaned_shm_client_storage_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index 3955508d9..b9e4a3a5c 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -90,8 +90,7 @@ pub unsafe extern "C" fn z_alloc_layout_loan( /// Mutably borrows Alloc Layout #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_alloc_layout_loan_mut( +pub extern "C" fn z_alloc_layout_loan_mut( this: &mut z_owned_alloc_layout_t, ) -> &mut z_loaned_alloc_layout_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 3928a853b..3143ee091 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -127,8 +127,7 @@ pub unsafe extern "C" fn z_shm_provider_loan( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows SHM Provider. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_provider_loan_mut( +pub extern "C" fn z_shm_provider_loan_mut( this: &mut z_owned_shm_provider_t, ) -> &mut z_loaned_shm_provider_t { this.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/subscriber.rs b/src/subscriber.rs index 34956e674..6462d1094 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -54,8 +54,7 @@ pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_l /// Mutably borrows subscriber. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_subscriber_loan_mut( +pub extern "C" fn z_subscriber_loan_mut( this_: &mut z_owned_subscriber_t, ) -> &mut z_loaned_subscriber_t { this_.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/zbytes.rs b/src/zbytes.rs index 981d44eba..6ef3d944d 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -649,13 +649,22 @@ pub unsafe extern "C" fn z_bytes_writer_loan( /// Muatably borrows writer. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_writer_loan_mut( +pub extern "C" fn z_bytes_writer_loan_mut( this: &mut z_owned_bytes_writer_t, ) -> &mut z_loaned_bytes_writer_t { this.as_rust_type_mut().as_loaned_c_type_mut() } +/// Takes ownership of the mutably borrowed writer +#[no_mangle] +pub extern "C" fn z_bytes_writer_take_loaned( + dst: &mut MaybeUninit, + src: &mut z_loaned_bytes_writer_t, +) { + dst.as_rust_type_mut_uninit() + .write(std::mem::take(src.as_rust_type_mut())); +} + /// Constructs a writer in a gravestone state. #[no_mangle] pub extern "C" fn z_internal_bytes_writer_null(this_: &mut MaybeUninit) { diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 4ce86e395..f9438ca10 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -30,6 +30,11 @@ // set v1 to null // move v to v1 // make sure that v is null now +// +// set v2 to null +// move v1 to v2 using z_take from mutable loaned +// make sure that v1 is null now +// #define TEST(name) \ { \ name v; \ @@ -43,6 +48,11 @@ memset(&v, -1, sizeof(v)); \ z_take(&v1, z_move(v)); \ assert(!z_internal_check(v)); \ + name v2; \ + z_internal_null(&v2); \ + memset(&v1, -1, sizeof(v1)); \ + z_take(&v2, z_loan_mut(v1)); \ + assert(!z_internal_check(v1));\ } int main(void) { From 5fed212e2e78e76fef64b7ab13fb77fea8ee54a5 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 14:53:28 +0200 Subject: [PATCH 18/38] z_check is not internal anymore --- build.rs | 8 +- docs/concepts.rst | 12 +- include/zenoh_commons.h | 506 ++++++++++++------------ include/zenoh_macros.h | 134 +++---- src/closures/hello_closure.rs | 2 +- src/closures/log_closure.rs | 2 +- src/closures/matching_status_closure.rs | 2 +- src/closures/query_channel.rs | 8 +- src/closures/query_closure.rs | 2 +- src/closures/reply_closure.rs | 2 +- src/closures/response_channel.rs | 8 +- src/closures/sample_channel.rs | 8 +- src/closures/sample_closure.rs | 2 +- src/closures/zenohid_closure.rs | 2 +- src/collections.rs | 6 +- src/commons.rs | 4 +- src/config.rs | 2 +- src/encoding.rs | 2 +- src/get.rs | 4 +- src/keyexpr.rs | 2 +- src/liveliness.rs | 2 +- src/platform/synchronization.rs | 6 +- src/publication_cache.rs | 4 +- src/publisher.rs | 6 +- src/queryable.rs | 4 +- src/querying_subscriber.rs | 4 +- src/scouting.rs | 2 +- src/serialization.rs | 2 +- src/session.rs | 2 +- src/shm/buffer/zshm.rs | 2 +- src/shm/buffer/zshmmut.rs | 2 +- src/shm/client/shm_client.rs | 2 +- src/shm/client_storage/mod.rs | 6 +- src/shm/provider/alloc_layout.rs | 2 +- src/shm/provider/shm_provider.rs | 2 +- src/shm/provider/types.rs | 6 +- src/subscriber.rs | 2 +- src/zbytes.rs | 4 +- 38 files changed, 379 insertions(+), 399 deletions(-) diff --git a/build.rs b/build.rs index 6625fd8dc..935b59e37 100644 --- a/build.rs +++ b/build.rs @@ -1016,7 +1016,7 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { if drops != checks { msgs.push(format!( - "the list of z_xxx_drop and z_internal_xxx_check functions are different:\n missing z_internal_xxx_check for {:?}\n missing z_xxx_drop for {:?}", + "the list of z_xxx_drop and z_xxx_check functions are different:\n missing z_xxx_check for {:?}\n missing z_xxx_drop for {:?}", drops.difference(&checks), checks.difference(&drops) )); @@ -1286,7 +1286,7 @@ pub fn find_null_functions(path_in: &str) -> Vec { pub fn find_check_functions(path_in: &str) -> Vec { let bindings = std::fs::read_to_string(path_in).unwrap(); - let re = Regex::new(r"bool (z.?_internal_\w+_check)\(const struct (\w+) \*(\w+)\);").unwrap(); + let re = Regex::new(r"bool (z.?_\w+_check)\(const struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); for (_, [func_name, arg_type, arg_name]) in re.captures_iter(&bindings).map(|c| c.extract()) { @@ -1602,7 +1602,7 @@ pub fn generate_generic_null_c(macro_func: &[FunctionSignature]) -> String { } pub fn generate_generic_check_c(macro_func: &[FunctionSignature]) -> String { - generate_generic_c(macro_func, "z_internal_check", true) + generate_generic_c(macro_func, "z_check", true) } pub fn generate_generic_call_c(macro_func: &[FunctionSignature]) -> String { @@ -1748,7 +1748,7 @@ pub fn generate_generic_null_cpp(macro_func: &[FunctionSignature]) -> String { } pub fn generate_generic_check_cpp(macro_func: &[FunctionSignature]) -> String { - generate_generic_cpp(macro_func, "z_internal_check", true) + generate_generic_cpp(macro_func, "z_check", true) } pub fn generate_generic_call_cpp(macro_func: &[FunctionSignature]) -> String { diff --git a/docs/concepts.rst b/docs/concepts.rst index a8e4d23dc..2adc497d2 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -167,8 +167,16 @@ Mutable loan operation ---------------------- The function `z_xxx_loan_mut` accepts `z_owned_xxx_t*` and -returns a pointer `z_xxx_loaned_t*` which allows -reading and modifying the `z_owned_xxx_t` entity. If supported by the type, it can also take ownership of it (see "take" operation). +returns a pointer `z_xxx_loaned_t*` which allows reading and modifying the `z_owned_xxx_t` entity. + +There is also API for taking ownership of the mutably loaned object: `z_xxx_take_loaned` functions. This +is useful when user's code accepts a mutable loaned object. In this case the user's code is free to take +the passed object for further processing or to process it on place without taking ownership. This was done +primarily for the callback functions: the callback handler is not obliged to take ownership of the passed object but +can do it if needed. + +Though it's important to note that the zenoh API itself **never** takes ownership of the mutably loaned object. Otherwise, +the user would be obliged to call `z_check` on the object each time after mutably passing it to the zenoh API. The `z_loan_mut` macro accepts a variable of `z_owned_xxx_t` type and calls the corresponding `z_xxx_loan_mut` function. diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index e795aef0c..4c9bc4dbf 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1237,6 +1237,12 @@ ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, const z_loaned_alloc_layout_t *layout); #endif +/** + * Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API bool z_alloc_layout_check(const z_owned_alloc_layout_t *this_); +#endif /** * Deletes Alloc Layout */ @@ -1282,6 +1288,10 @@ z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_re void (*result_callback)(void*, struct z_buf_alloc_result_t*)); #endif +/** + * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_bytes_check(const struct z_owned_bytes_t *this_); /** * Constructs an owned shallow copy of data in provided uninitialized memory location. */ @@ -1541,6 +1551,10 @@ z_result_t z_bytes_to_string(const struct z_loaned_bytes_t *this_, ZENOHC_API z_result_t z_bytes_writer_append(struct z_loaned_bytes_writer_t *this_, struct z_moved_bytes_t *bytes); +/** + * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_bytes_writer_check(const struct z_owned_bytes_writer_t *this_); /** * Drops `this_`, resetting it to gravestone value. */ @@ -1584,6 +1598,14 @@ ZENOHC_API z_result_t z_bytes_writer_write_all(struct z_loaned_bytes_writer_t *this_, const uint8_t *src, size_t len); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes Chunk Alloc Result. @@ -1665,6 +1687,10 @@ void z_closure_hello(struct z_owned_closure_hello_t *this_, ZENOHC_API void z_closure_hello_call(const struct z_loaned_closure_hello_t *closure, struct z_loaned_hello_t *hello); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_closure_hello_check(const struct z_owned_closure_hello_t *this_); /** * Drops the closure. Droping an uninitialized closure is a no-op. */ @@ -1710,6 +1736,10 @@ void z_closure_query(struct z_owned_closure_query_t *this_, ZENOHC_API void z_closure_query_call(const struct z_loaned_closure_query_t *closure, struct z_loaned_query_t *query); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_closure_query_check(const struct z_owned_closure_query_t *this_); /** * Drops the closure, resetting it to its gravestone state. */ @@ -1755,6 +1785,10 @@ void z_closure_reply(struct z_owned_closure_reply_t *this_, ZENOHC_API void z_closure_reply_call(const struct z_loaned_closure_reply_t *closure, struct z_loaned_reply_t *reply); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_closure_reply_check(const struct z_owned_closure_reply_t *this_); /** * Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. */ @@ -1801,6 +1835,10 @@ void z_closure_sample(struct z_owned_closure_sample_t *this_, ZENOHC_API void z_closure_sample_call(const struct z_loaned_closure_sample_t *closure, struct z_loaned_sample_t *sample); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_closure_sample_check(const struct z_owned_closure_sample_t *this_); /** * Drops the closure. Droping an uninitialized closure is a no-op. */ @@ -1846,6 +1884,10 @@ void z_closure_zid(struct z_owned_closure_zid_t *this_, ZENOHC_API void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, const struct z_id_t *z_id); +/** + * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_closure_zid_check(const struct z_owned_closure_zid_t *this_); /** * @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized (null) closure is a no-op. */ @@ -1867,6 +1909,10 @@ struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid ZENOHC_API void z_closure_zid_take_loaned(struct z_owned_closure_zid_t *dst, struct z_loaned_closure_zid_t *src); +/** + * Returns ``true`` if conditional variable is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_condvar_check(const struct z_owned_condvar_t *this_); /** * Drops conditional variable. */ @@ -1898,6 +1944,10 @@ ZENOHC_API z_result_t z_condvar_signal(const struct z_loaned_condvar_t *this_); ZENOHC_API z_result_t z_condvar_wait(const struct z_loaned_condvar_t *this_, struct z_loaned_mutex_t *m); +/** + * Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_config_check(const struct z_owned_config_t *this_); /** * Clones the config into provided uninitialized memory location. */ @@ -2190,6 +2240,10 @@ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_audio_ogg(void); * Constant alias for string: `"audio/vorbis"`. */ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_audio_vorbis(void); +/** + * Returns ``true`` if encoding is in non-default state, ``false`` otherwise. + */ +ZENOHC_API bool z_encoding_check(const struct z_owned_encoding_t *this_); /** * Constructs an owned copy of the encoding in provided uninitilized memory location. */ @@ -2476,6 +2530,10 @@ ZENOHC_API void z_fifo_channel_sample_new(struct z_owned_closure_sample_t *callback, struct z_owned_fifo_handler_sample_t *handler, size_t capacity); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_fifo_handler_query_check(const struct z_owned_fifo_handler_query_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -2513,6 +2571,10 @@ void z_fifo_handler_query_take_loaned(struct z_owned_fifo_handler_query_t *dst, ZENOHC_API z_result_t z_fifo_handler_query_try_recv(const struct z_loaned_fifo_handler_query_t *this_, struct z_owned_query_t *query); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_fifo_handler_reply_check(const struct z_owned_fifo_handler_reply_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -2549,6 +2611,10 @@ void z_fifo_handler_reply_take_loaned(struct z_owned_fifo_handler_reply_t *dst, ZENOHC_API z_result_t z_fifo_handler_reply_try_recv(const struct z_loaned_fifo_handler_reply_t *this_, struct z_owned_reply_t *reply); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_fifo_handler_sample_check(const struct z_owned_fifo_handler_sample_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -2608,6 +2674,10 @@ z_result_t z_get(const struct z_loaned_session_t *session, * Constructs default `z_get_options_t` */ ZENOHC_API void z_get_options_default(struct z_get_options_t *this_); +/** + * Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_hello_check(const struct z_owned_hello_t *this_); /** * Constructs an owned copy of hello message. */ @@ -2678,42 +2748,20 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, * to pass it a valid session. */ ZENOHC_API struct z_id_t z_info_zid(const struct z_loaned_session_t *session); -/** - * Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); -#endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); #endif -/** - * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_internal_bytes_check(const struct z_owned_bytes_t *this_); /** * The gravestone value for `z_owned_bytes_t`. */ ZENOHC_API void z_internal_bytes_null(struct z_owned_bytes_t *this_); -/** - * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_internal_bytes_writer_check(const struct z_owned_bytes_writer_t *this_); /** * Constructs a writer in a gravestone state. */ ZENOHC_API void z_internal_bytes_writer_null(struct z_owned_bytes_writer_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs Chunk Alloc Result in its gravestone value. @@ -2722,121 +2770,58 @@ bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *thi ZENOHC_API void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); #endif -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_closure_hello_check(const struct z_owned_closure_hello_t *this_); /** * Constructs a closure in a gravestone state. */ ZENOHC_API void z_internal_closure_hello_null(struct z_owned_closure_hello_t *this_); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_closure_query_check(const struct z_owned_closure_query_t *this_); /** * Constructs a closure in its gravestone state. */ ZENOHC_API void z_internal_closure_query_null(struct z_owned_closure_query_t *this_); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_closure_reply_check(const struct z_owned_closure_reply_t *this_); /** * Constructs a closure int its gravestone state. */ ZENOHC_API void z_internal_closure_reply_null(struct z_owned_closure_reply_t *this_); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_closure_sample_check(const struct z_owned_closure_sample_t *this_); /** * Constructs a closure in its gravestone state. */ ZENOHC_API void z_internal_closure_sample_null(struct z_owned_closure_sample_t *this_); -/** - * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_closure_zid_check(const struct z_owned_closure_zid_t *this_); /** * @brief Constructs a null closure. */ ZENOHC_API void z_internal_closure_zid_null(struct z_owned_closure_zid_t *this_); -/** - * Returns ``true`` if conditional variable is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_condvar_check(const struct z_owned_condvar_t *this_); /** * Constructs conditional variable in a gravestone state. */ ZENOHC_API void z_internal_condvar_null(struct z_owned_condvar_t *this_); -/** - * Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_internal_config_check(const struct z_owned_config_t *this_); /** * Constructs config in its gravestone state. */ ZENOHC_API void z_internal_config_null(struct z_owned_config_t *this_); -/** - * Returns ``true`` if encoding is in non-default state, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_encoding_check(const struct z_owned_encoding_t *this_); /** * Constructs a default `z_owned_encoding_t`. */ ZENOHC_API void z_internal_encoding_null(struct z_owned_encoding_t *this_); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API -bool z_internal_fifo_handler_query_check(const struct z_owned_fifo_handler_query_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_fifo_handler_query_null(struct z_owned_fifo_handler_query_t *this_); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API -bool z_internal_fifo_handler_reply_check(const struct z_owned_fifo_handler_reply_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_fifo_handler_reply_null(struct z_owned_fifo_handler_reply_t *this_); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API -bool z_internal_fifo_handler_sample_check(const struct z_owned_fifo_handler_sample_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_fifo_handler_sample_null(struct z_owned_fifo_handler_sample_t *this_); -/** - * Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_internal_hello_check(const struct z_owned_hello_t *this_); /** * Constructs hello message in a gravestone state. */ ZENOHC_API void z_internal_hello_null(struct z_owned_hello_t *this_); -/** - * Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_keyexpr_check(const struct z_owned_keyexpr_t *this_); /** * Constructs an owned key expression in a gravestone state. */ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs Memory Layout in its gravestone value. @@ -2845,46 +2830,22 @@ bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); ZENOHC_API void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); #endif -/** - * Returns ``true`` if mutex is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_mutex_check(const struct z_owned_mutex_t *this_); /** * Constructs mutex in a gravestone state. */ ZENOHC_API void z_internal_mutex_null(struct z_owned_mutex_t *this_); -/** - * Returns ``true`` if publisher is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_publisher_check(const struct z_owned_publisher_t *this_); /** * Constructs a publisher in a gravestone state. */ ZENOHC_API void z_internal_publisher_null(struct z_owned_publisher_t *this_); -/** - * Returns `false` if `this` is in a gravestone state, `true` otherwise. - */ -ZENOHC_API bool z_internal_query_check(const struct z_owned_query_t *query); /** * Constructs query in its gravestone value. */ ZENOHC_API void z_internal_query_null(struct z_owned_query_t *this_); -/** - * Returns ``true`` if queryable is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_queryable_check(const struct z_owned_queryable_t *this_); /** * Constructs a queryable in its gravestone value. */ ZENOHC_API void z_internal_queryable_null(struct z_owned_queryable_t *this_); -/** - * Returns ``true`` if `reply` is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_reply_check(const struct z_owned_reply_t *this_); -/** - * Returns ``true`` if reply error is in non-default state, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_reply_err_check(const struct z_owned_reply_err_t *this_); /** * Constructs an empty `z_owned_reply_err_t`. */ @@ -2893,65 +2854,26 @@ ZENOHC_API void z_internal_reply_err_null(struct z_owned_reply_err_t *this_); * Constructs the reply in its gravestone state. */ ZENOHC_API void z_internal_reply_null(struct z_owned_reply_t *this_); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API -bool z_internal_ring_handler_query_check(const struct z_owned_ring_handler_query_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_ring_handler_query_null(struct z_owned_ring_handler_query_t *this_); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API -bool z_internal_ring_handler_reply_check(const struct z_owned_ring_handler_reply_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_ring_handler_reply_null(struct z_owned_ring_handler_reply_t *this_); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API -bool z_internal_ring_handler_sample_check(const struct z_owned_ring_handler_sample_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_ring_handler_sample_null(struct z_owned_ring_handler_sample_t *this_); -/** - * Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_sample_check(const struct z_owned_sample_t *this_); /** * Constructs sample in its gravestone state. */ ZENOHC_API void z_internal_sample_null(struct z_owned_sample_t *this_); -/** - * Returns ``true`` if `session` is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_session_check(const struct z_owned_session_t *this_); /** * Constructs a Zenoh session in its gravestone state. */ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_check(const z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs SHM client in its gravestone value. @@ -2960,14 +2882,6 @@ bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); ZENOHC_API void z_internal_shm_client_null(z_owned_shm_client_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * Constructs SHM Client Storage in its gravestone value. @@ -2976,14 +2890,6 @@ bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *thi ZENOHC_API void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs ZShmMut slice in its gravestone value. @@ -3000,14 +2906,6 @@ void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); ZENOHC_API void z_internal_shm_null(z_owned_shm_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs SHM Provider in its gravestone value. @@ -3016,22 +2914,10 @@ bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); ZENOHC_API void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); #endif -/** - * @return ``true`` if slice is not empty, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_slice_check(const struct z_owned_slice_t *this_); /** * Constructs an empty `z_owned_slice_t`. */ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool z_internal_source_info_check(const z_owned_source_info_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs source info in its gravestone state. @@ -3040,34 +2926,18 @@ bool z_internal_source_info_check(const z_owned_source_info_t *this_); ZENOHC_API void z_internal_source_info_null(z_owned_source_info_t *this_); #endif -/** - * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_internal_string_array_check(const struct z_owned_string_array_t *this_); /** * Constructs string array in its gravestone state. */ ZENOHC_API void z_internal_string_array_null(struct z_owned_string_array_t *this_); -/** - * @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_internal_string_check(const struct z_owned_string_t *this_); /** * Constructs owned string in a gravestone state. */ ZENOHC_API void z_internal_string_null(struct z_owned_string_t *this_); -/** - * Returns ``true`` if subscriber is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_subscriber_check(const struct z_owned_subscriber_t *this_); /** * Constructs a subscriber in a gravestone state. */ ZENOHC_API void z_internal_subscriber_null(struct z_owned_subscriber_t *this_); -/** - * Returns ``true`` if task is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_internal_task_check(const struct z_owned_task_t *this_); /** * Constructs task in a gravestone state. */ @@ -3098,6 +2968,10 @@ z_result_t z_keyexpr_canonize(char *start, */ ZENOHC_API z_result_t z_keyexpr_canonize_null_terminated(char *start); +/** + * Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_keyexpr_check(const struct z_owned_keyexpr_t *this_); /** * Constructs a copy of the key expression. */ @@ -3219,6 +3093,14 @@ enum z_keyexpr_intersection_level_t z_keyexpr_relation_to(const struct z_loaned_ ZENOHC_API void z_keyexpr_take_loaned(struct z_owned_keyexpr_t *dst, struct z_loaned_keyexpr_t *src); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_memory_layout_check(const z_owned_memory_layout_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes Memory Layout. @@ -3255,6 +3137,10 @@ z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif +/** + * Returns ``true`` if mutex is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_mutex_check(const struct z_owned_mutex_t *this_); /** * Drops mutex and resets it to its gravestone state. */ @@ -3334,6 +3220,10 @@ z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, * Returns the default value of #z_priority_t. */ ZENOHC_API enum z_priority_t z_priority_default(void); +/** + * Returns ``true`` if publisher is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_publisher_check(const struct z_owned_publisher_t *this_); /** * Sends a `DELETE` message onto the publisher's key expression. * @@ -3428,6 +3318,10 @@ ZENOHC_API void z_put_options_default(struct z_put_options_t *this_); * Returns NULL if query does not contain an attachment. */ ZENOHC_API const struct z_loaned_bytes_t *z_query_attachment(const struct z_loaned_query_t *this_); +/** + * Returns `false` if `this` is in a gravestone state, `true` otherwise. + */ +ZENOHC_API bool z_query_check(const struct z_owned_query_t *query); /** * Constructs a shallow copy of the query, allowing to keep it in an "open" state past the callback's return. * @@ -3581,6 +3475,10 @@ ZENOHC_API void z_query_take_loaned(struct z_owned_query_t *dst, struct z_loaned * Create a default `z_query_target_t`. */ ZENOHC_API enum z_query_target_t z_query_target_default(void); +/** + * Returns ``true`` if queryable is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_queryable_check(const struct z_owned_queryable_t *this_); /** * Undeclares queryable callback and resets it to its gravestone state. * This is equivalent to calling `z_undeclare_queryable()` and discarding its return value. @@ -3642,6 +3540,10 @@ void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); ZENOHC_API enum z_reliability_t z_reliability_default(void); #endif +/** + * Returns ``true`` if `reply` is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_reply_check(const struct z_owned_reply_t *this_); /** * Constructs an owned shallow copy of reply in provided uninitialized memory location. */ @@ -3656,6 +3558,10 @@ ZENOHC_API void z_reply_drop(struct z_moved_reply_t *this_); * Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). */ ZENOHC_API const struct z_loaned_reply_err_t *z_reply_err(const struct z_loaned_reply_t *this_); +/** + * Returns ``true`` if reply error is in non-default state, ``false`` otherwise. + */ +ZENOHC_API bool z_reply_err_check(const struct z_owned_reply_err_t *this_); /** * Constructs a copy of the reply error message. */ @@ -3745,6 +3651,10 @@ ZENOHC_API void z_ring_channel_sample_new(struct z_owned_closure_sample_t *callback, struct z_owned_ring_handler_sample_t *handler, size_t capacity); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_ring_handler_query_check(const struct z_owned_ring_handler_query_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -3781,6 +3691,10 @@ void z_ring_handler_query_take_loaned(struct z_owned_ring_handler_query_t *dst, ZENOHC_API z_result_t z_ring_handler_query_try_recv(const struct z_loaned_ring_handler_query_t *this_, struct z_owned_query_t *query); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_ring_handler_reply_check(const struct z_owned_ring_handler_reply_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -3817,6 +3731,10 @@ void z_ring_handler_reply_take_loaned(struct z_owned_ring_handler_reply_t *dst, ZENOHC_API z_result_t z_ring_handler_reply_try_recv(const struct z_loaned_ring_handler_reply_t *this_, struct z_owned_reply_t *reply); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_ring_handler_sample_check(const struct z_owned_ring_handler_sample_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -3860,6 +3778,10 @@ z_result_t z_ring_handler_sample_try_recv(const struct z_loaned_ring_handler_sam */ ZENOHC_API const struct z_loaned_bytes_t *z_sample_attachment(const struct z_loaned_sample_t *this_); +/** + * Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_sample_check(const struct z_owned_sample_t *this_); /** * Constructs an owned shallow copy of the sample (i.e. all modficiations applied to the copy, might be visible in the original) in provided uninitilized memory location. */ @@ -3951,6 +3873,10 @@ z_result_t z_scout(struct z_moved_config_t *config, * Constructs the default values for the scouting operation. */ ZENOHC_API void z_scout_options_default(struct z_scout_options_t *this_); +/** + * Returns ``true`` if `session` is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_session_check(const struct z_owned_session_t *this_); /** * Closes and invalidates the session. */ @@ -3975,6 +3901,22 @@ ZENOHC_API struct z_loaned_session_t *z_session_loan_mut(struct z_owned_session_ ZENOHC_API void z_session_take_loaned(struct z_owned_session_t *dst, struct z_loaned_session_t *src); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_shm_check(const z_owned_shm_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_shm_client_check(const z_owned_shm_client_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes SHM Client. @@ -3993,6 +3935,14 @@ void z_shm_client_new(z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Performs a shallow copy of SHM Client Storage. @@ -4107,6 +4057,14 @@ const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_shm_mut_check(const z_owned_shm_mut_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @return the immutable pointer to the underlying data. @@ -4247,6 +4205,14 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * ZENOHC_API size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_shm_provider_check(const z_owned_shm_provider_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ @@ -4359,6 +4325,10 @@ ZENOHC_API z_result_t z_sleep_s(size_t time); * Puts current thread to sleep for specified amount of microseconds. */ ZENOHC_API z_result_t z_sleep_us(size_t time); +/** + * @return ``true`` if slice is not empty, ``false`` otherwise. + */ +ZENOHC_API bool z_slice_check(const struct z_owned_slice_t *this_); /** * Constructs an owned copy of a slice. */ @@ -4420,6 +4390,14 @@ ZENOHC_API struct z_loaned_slice_t *z_slice_loan_mut(struct z_owned_slice_t *thi * Takes ownership of mutably borrowed slice */ ZENOHC_API void z_slice_take_loaned(struct z_owned_slice_t *dst, struct z_loaned_slice_t *src); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool z_source_info_check(const z_owned_source_info_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. @@ -4479,6 +4457,10 @@ ZENOHC_API void z_source_info_take_loaned(z_owned_source_info_t *dst, z_loaned_source_info_t *src); #endif +/** + * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_string_array_check(const struct z_owned_string_array_t *this_); /** * Constructs an owned copy of a string array. */ @@ -4542,6 +4524,10 @@ ZENOHC_API void z_string_array_take_loaned(struct z_owned_string_array_t *dst, struct z_loaned_string_array_t *src); ZENOHC_API const struct z_loaned_slice_t *z_string_as_slice(const struct z_loaned_string_t *this_); +/** + * @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_string_check(const struct z_owned_string_t *this_); /** * Constructs an owned copy of a string. */ @@ -4608,6 +4594,10 @@ ZENOHC_API struct z_loaned_string_t *z_string_loan_mut(struct z_owned_string_t * * Takes ownership of mutably borrowed string. */ ZENOHC_API void z_string_take_loaned(struct z_owned_string_t *dst, struct z_loaned_string_t *src); +/** + * Returns ``true`` if subscriber is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_subscriber_check(const struct z_owned_subscriber_t *this_); /** * Undeclares subscriber callback and resets it to its gravestone state. * This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value. @@ -4637,6 +4627,10 @@ ZENOHC_API void z_subscriber_options_default(struct z_subscriber_options_t *this ZENOHC_API void z_subscriber_take_loaned(struct z_owned_subscriber_t *dst, struct z_loaned_subscriber_t *src); +/** + * Returns ``true`` if task is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_task_check(const struct z_owned_task_t *this_); /** * Detaches the task and releases all allocated resources. */ @@ -4922,6 +4916,10 @@ ZENOHC_API void zc_closure_log_call(const struct zc_loaned_closure_log_t *closure, enum zc_log_severity_t severity, const struct z_loaned_string_t *msg); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool zc_closure_log_check(const struct zc_owned_closure_log_t *this_); /** * Drops the closure. Droping an uninitialized closure is a no-op. */ @@ -4963,6 +4961,14 @@ ZENOHC_API void zc_closure_matching_status_call(const struct zc_loaned_closure_matching_status_t *closure, const struct zc_matching_status_t *mathing_status); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool zc_closure_matching_status_check(const struct zc_owned_closure_matching_status_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. @@ -5065,22 +5071,10 @@ z_result_t zc_init_log_from_env_or(const char *fallback_filter); ZENOHC_API void zc_init_log_with_callback(enum zc_log_severity_t min_severity, struct zc_moved_closure_log_t *callback); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool zc_internal_closure_log_check(const struct zc_owned_closure_log_t *this_); /** * Constructs a closure in a gravestone state. */ ZENOHC_API void zc_internal_closure_log_null(struct zc_owned_closure_log_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_internal_closure_matching_status_check(const struct zc_owned_closure_matching_status_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs a null value of 'zc_owned_closure_matching_status_t' type @@ -5089,14 +5083,6 @@ bool zc_internal_closure_matching_status_check(const struct zc_owned_closure_mat ZENOHC_API void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_status_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs liveliness token in its gravestone state. @@ -5105,14 +5091,6 @@ bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_ ZENOHC_API void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Checks the matching listener is for the gravestone state - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs an empty matching listener. @@ -5121,14 +5099,6 @@ bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *thi ZENOHC_API void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs SHM client list in its gravestone value. @@ -5234,6 +5204,14 @@ void zc_liveliness_get_options_default(struct zc_liveliness_get_options_t *this_ ZENOHC_API void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_options_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool zc_liveliness_token_check(const zc_owned_liveliness_token_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Undeclares liveliness token, frees memory and resets it to a gravestone state. @@ -5266,6 +5244,14 @@ z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); ZENOHC_API enum zc_locality_t zc_locality_default(void); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Checks the matching listener is for the gravestone state + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool zc_matching_listener_check(const zc_owned_matching_listener_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Declares a matching listener, registering a callback for notifying subscribers matching with a given publisher. @@ -5333,6 +5319,14 @@ z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, z_moved_shm_client_t *client); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool zc_shm_client_list_check(const zc_owned_shm_client_list_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes list of SHM Clients. @@ -5628,14 +5622,6 @@ struct ze_deserializer_t ze_deserializer_from_bytes(const struct z_loaned_bytes_ * @return `true` if there is no more data to parse, `false` otherwise. */ ZENOHC_API bool ze_deserializer_is_done(const struct ze_deserializer_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs a publication cache in a gravestone state. @@ -5644,28 +5630,24 @@ bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *thi ZENOHC_API void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); -#endif /** * Constructs a querying subscriber in a gravestone state. */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); #endif -/** - * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool ze_internal_serializer_check(const struct ze_owned_serializer_t *this_); /** * @brief Constructs a serializer in a gravestone state. */ ZENOHC_API void ze_internal_serializer_null(struct ze_owned_serializer_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool ze_publication_cache_check(const ze_owned_publication_cache_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Drops publication cache and resets it to its gravestone state. @@ -5699,6 +5681,14 @@ const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_pu ZENOHC_API void ze_publication_cache_options_default(struct ze_publication_cache_options_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool ze_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Undeclares querying subscriber callback and resets it to its gravestone state. @@ -5823,6 +5813,10 @@ ZENOHC_API z_result_t ze_serialize_uint64(struct z_owned_bytes_t *this_, uint64_ * @brief Serializes an unsigned integer. */ ZENOHC_API z_result_t ze_serialize_uint8(struct z_owned_bytes_t *this_, uint8_t val); +/** + * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool ze_serializer_check(const struct ze_owned_serializer_t *this_); /** * @brief Drops `this_`, resetting it to gravestone value. */ diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 667f734b7..8365389d9 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -325,41 +325,41 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser ze_loaned_serializer_t* : ze_serializer_take_loaned \ )(this_, x) -#define z_internal_check(this_) \ +#define z_check(this_) \ _Generic((this_), \ - z_owned_bytes_t : z_internal_bytes_check, \ - z_owned_bytes_writer_t : z_internal_bytes_writer_check, \ - z_owned_closure_hello_t : z_internal_closure_hello_check, \ - z_owned_closure_query_t : z_internal_closure_query_check, \ - z_owned_closure_reply_t : z_internal_closure_reply_check, \ - z_owned_closure_sample_t : z_internal_closure_sample_check, \ - z_owned_closure_zid_t : z_internal_closure_zid_check, \ - z_owned_condvar_t : z_internal_condvar_check, \ - z_owned_config_t : z_internal_config_check, \ - z_owned_encoding_t : z_internal_encoding_check, \ - z_owned_fifo_handler_query_t : z_internal_fifo_handler_query_check, \ - z_owned_fifo_handler_reply_t : z_internal_fifo_handler_reply_check, \ - z_owned_fifo_handler_sample_t : z_internal_fifo_handler_sample_check, \ - z_owned_hello_t : z_internal_hello_check, \ - z_owned_keyexpr_t : z_internal_keyexpr_check, \ - z_owned_mutex_t : z_internal_mutex_check, \ - z_owned_publisher_t : z_internal_publisher_check, \ - z_owned_query_t : z_internal_query_check, \ - z_owned_queryable_t : z_internal_queryable_check, \ - z_owned_reply_t : z_internal_reply_check, \ - z_owned_reply_err_t : z_internal_reply_err_check, \ - z_owned_ring_handler_query_t : z_internal_ring_handler_query_check, \ - z_owned_ring_handler_reply_t : z_internal_ring_handler_reply_check, \ - z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ - z_owned_sample_t : z_internal_sample_check, \ - z_owned_session_t : z_internal_session_check, \ - z_owned_slice_t : z_internal_slice_check, \ - z_owned_string_array_t : z_internal_string_array_check, \ - z_owned_string_t : z_internal_string_check, \ - z_owned_subscriber_t : z_internal_subscriber_check, \ - z_owned_task_t : z_internal_task_check, \ - zc_owned_closure_log_t : zc_internal_closure_log_check, \ - ze_owned_serializer_t : ze_internal_serializer_check \ + z_owned_bytes_t : z_bytes_check, \ + z_owned_bytes_writer_t : z_bytes_writer_check, \ + z_owned_closure_hello_t : z_closure_hello_check, \ + z_owned_closure_query_t : z_closure_query_check, \ + z_owned_closure_reply_t : z_closure_reply_check, \ + z_owned_closure_sample_t : z_closure_sample_check, \ + z_owned_closure_zid_t : z_closure_zid_check, \ + z_owned_condvar_t : z_condvar_check, \ + z_owned_config_t : z_config_check, \ + z_owned_encoding_t : z_encoding_check, \ + z_owned_fifo_handler_query_t : z_fifo_handler_query_check, \ + z_owned_fifo_handler_reply_t : z_fifo_handler_reply_check, \ + z_owned_fifo_handler_sample_t : z_fifo_handler_sample_check, \ + z_owned_hello_t : z_hello_check, \ + z_owned_keyexpr_t : z_keyexpr_check, \ + z_owned_mutex_t : z_mutex_check, \ + z_owned_publisher_t : z_publisher_check, \ + z_owned_query_t : z_query_check, \ + z_owned_queryable_t : z_queryable_check, \ + z_owned_reply_t : z_reply_check, \ + z_owned_reply_err_t : z_reply_err_check, \ + z_owned_ring_handler_query_t : z_ring_handler_query_check, \ + z_owned_ring_handler_reply_t : z_ring_handler_reply_check, \ + z_owned_ring_handler_sample_t : z_ring_handler_sample_check, \ + z_owned_sample_t : z_sample_check, \ + z_owned_session_t : z_session_check, \ + z_owned_slice_t : z_slice_check, \ + z_owned_string_array_t : z_string_array_check, \ + z_owned_string_t : z_string_check, \ + z_owned_subscriber_t : z_subscriber_check, \ + z_owned_task_t : z_task_check, \ + zc_owned_closure_log_t : zc_closure_log_check, \ + ze_owned_serializer_t : ze_serializer_check \ )(&this_) #define z_call(closure, hello) \ @@ -863,39 +863,39 @@ inline void z_take(ze_owned_serializer_t* dst, ze_loaned_serializer_t* src) { }; -inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; -inline bool z_internal_check(const z_owned_bytes_writer_t& this_) { return z_internal_bytes_writer_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_reply_t& this_) { return z_internal_closure_reply_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_sample_t& this_) { return z_internal_closure_sample_check(&this_); }; -inline bool z_internal_check(const z_owned_closure_zid_t& this_) { return z_internal_closure_zid_check(&this_); }; -inline bool z_internal_check(const z_owned_condvar_t& this_) { return z_internal_condvar_check(&this_); }; -inline bool z_internal_check(const z_owned_config_t& this_) { return z_internal_config_check(&this_); }; -inline bool z_internal_check(const z_owned_encoding_t& this_) { return z_internal_encoding_check(&this_); }; -inline bool z_internal_check(const z_owned_fifo_handler_query_t& this_) { return z_internal_fifo_handler_query_check(&this_); }; -inline bool z_internal_check(const z_owned_fifo_handler_reply_t& this_) { return z_internal_fifo_handler_reply_check(&this_); }; -inline bool z_internal_check(const z_owned_fifo_handler_sample_t& this_) { return z_internal_fifo_handler_sample_check(&this_); }; -inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_hello_check(&this_); }; -inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; -inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; -inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; -inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; -inline bool z_internal_check(const z_owned_queryable_t& this_) { return z_internal_queryable_check(&this_); }; -inline bool z_internal_check(const z_owned_reply_t& this_) { return z_internal_reply_check(&this_); }; -inline bool z_internal_check(const z_owned_reply_err_t& this_) { return z_internal_reply_err_check(&this_); }; -inline bool z_internal_check(const z_owned_ring_handler_query_t& this_) { return z_internal_ring_handler_query_check(&this_); }; -inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return z_internal_ring_handler_reply_check(&this_); }; -inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; -inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; -inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; -inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; -inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; -inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; -inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; -inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; -inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; -inline bool z_internal_check(const ze_owned_serializer_t& this_) { return ze_internal_serializer_check(&this_); }; +inline bool z_check(const z_owned_bytes_t& this_) { return z_bytes_check(&this_); }; +inline bool z_check(const z_owned_bytes_writer_t& this_) { return z_bytes_writer_check(&this_); }; +inline bool z_check(const z_owned_closure_hello_t& this_) { return z_closure_hello_check(&this_); }; +inline bool z_check(const z_owned_closure_query_t& this_) { return z_closure_query_check(&this_); }; +inline bool z_check(const z_owned_closure_reply_t& this_) { return z_closure_reply_check(&this_); }; +inline bool z_check(const z_owned_closure_sample_t& this_) { return z_closure_sample_check(&this_); }; +inline bool z_check(const z_owned_closure_zid_t& this_) { return z_closure_zid_check(&this_); }; +inline bool z_check(const z_owned_condvar_t& this_) { return z_condvar_check(&this_); }; +inline bool z_check(const z_owned_config_t& this_) { return z_config_check(&this_); }; +inline bool z_check(const z_owned_encoding_t& this_) { return z_encoding_check(&this_); }; +inline bool z_check(const z_owned_fifo_handler_query_t& this_) { return z_fifo_handler_query_check(&this_); }; +inline bool z_check(const z_owned_fifo_handler_reply_t& this_) { return z_fifo_handler_reply_check(&this_); }; +inline bool z_check(const z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_check(&this_); }; +inline bool z_check(const z_owned_hello_t& this_) { return z_hello_check(&this_); }; +inline bool z_check(const z_owned_keyexpr_t& this_) { return z_keyexpr_check(&this_); }; +inline bool z_check(const z_owned_mutex_t& this_) { return z_mutex_check(&this_); }; +inline bool z_check(const z_owned_publisher_t& this_) { return z_publisher_check(&this_); }; +inline bool z_check(const z_owned_query_t& query) { return z_query_check(&query); }; +inline bool z_check(const z_owned_queryable_t& this_) { return z_queryable_check(&this_); }; +inline bool z_check(const z_owned_reply_t& this_) { return z_reply_check(&this_); }; +inline bool z_check(const z_owned_reply_err_t& this_) { return z_reply_err_check(&this_); }; +inline bool z_check(const z_owned_ring_handler_query_t& this_) { return z_ring_handler_query_check(&this_); }; +inline bool z_check(const z_owned_ring_handler_reply_t& this_) { return z_ring_handler_reply_check(&this_); }; +inline bool z_check(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_check(&this_); }; +inline bool z_check(const z_owned_sample_t& this_) { return z_sample_check(&this_); }; +inline bool z_check(const z_owned_session_t& this_) { return z_session_check(&this_); }; +inline bool z_check(const z_owned_slice_t& this_) { return z_slice_check(&this_); }; +inline bool z_check(const z_owned_string_array_t& this_) { return z_string_array_check(&this_); }; +inline bool z_check(const z_owned_string_t& this_) { return z_string_check(&this_); }; +inline bool z_check(const z_owned_subscriber_t& this_) { return z_subscriber_check(&this_); }; +inline bool z_check(const z_owned_task_t& this_) { return z_task_check(&this_); }; +inline bool z_check(const zc_owned_closure_log_t& this_) { return zc_closure_log_check(&this_); }; +inline bool z_check(const ze_owned_serializer_t& this_) { return ze_serializer_check(&this_); }; inline void z_call(const z_loaned_closure_hello_t* closure, z_loaned_hello_t* hello) { diff --git a/src/closures/hello_closure.rs b/src/closures/hello_closure.rs index 83a8b738f..abecb9811 100644 --- a/src/closures/hello_closure.rs +++ b/src/closures/hello_closure.rs @@ -122,7 +122,7 @@ impl From for z_owned_closure_hello_t { /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_closure_hello_check(this_: &z_owned_closure_hello_t) -> bool { +pub extern "C" fn z_closure_hello_check(this_: &z_owned_closure_hello_t) -> bool { !this_.is_empty() } diff --git a/src/closures/log_closure.rs b/src/closures/log_closure.rs index c8f58a6f7..c43b45bb5 100644 --- a/src/closures/log_closure.rs +++ b/src/closures/log_closure.rs @@ -167,7 +167,7 @@ pub extern "C" fn zc_closure_log_drop(closure_: &mut zc_moved_closure_log_t) { /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn zc_internal_closure_log_check(this_: &zc_owned_closure_log_t) -> bool { +pub extern "C" fn zc_closure_log_check(this_: &zc_owned_closure_log_t) -> bool { !this_.is_empty() } diff --git a/src/closures/matching_status_closure.rs b/src/closures/matching_status_closure.rs index dcb359526..1c040a585 100644 --- a/src/closures/matching_status_closure.rs +++ b/src/closures/matching_status_closure.rs @@ -87,7 +87,7 @@ pub unsafe extern "C" fn zc_internal_closure_matching_status_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn zc_internal_closure_matching_status_check( +pub extern "C" fn zc_closure_matching_status_check( this: &zc_owned_closure_matching_status_t, ) -> bool { !this.is_empty() diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 417348fb5..1ef97cb10 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -51,9 +51,7 @@ pub extern "C" fn z_internal_fifo_handler_query_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_fifo_handler_query_check( - this_: &z_owned_fifo_handler_query_t, -) -> bool { +pub extern "C" fn z_fifo_handler_query_check(this_: &z_owned_fifo_handler_query_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -195,9 +193,7 @@ pub extern "C" fn z_internal_ring_handler_query_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_ring_handler_query_check( - this_: &z_owned_ring_handler_query_t, -) -> bool { +pub extern "C" fn z_ring_handler_query_check(this_: &z_owned_ring_handler_query_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/closures/query_closure.rs b/src/closures/query_closure.rs index 02e733e07..8e503460d 100644 --- a/src/closures/query_closure.rs +++ b/src/closures/query_closure.rs @@ -83,7 +83,7 @@ pub unsafe extern "C" fn z_internal_closure_query_null( /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_closure_query_check(this_: &z_owned_closure_query_t) -> bool { +pub extern "C" fn z_closure_query_check(this_: &z_owned_closure_query_t) -> bool { !this_.is_empty() } diff --git a/src/closures/reply_closure.rs b/src/closures/reply_closure.rs index fdf7cfd2e..4549c3523 100644 --- a/src/closures/reply_closure.rs +++ b/src/closures/reply_closure.rs @@ -85,7 +85,7 @@ pub unsafe extern "C" fn z_internal_closure_reply_null( /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_closure_reply_check(this_: &z_owned_closure_reply_t) -> bool { +pub extern "C" fn z_closure_reply_check(this_: &z_owned_closure_reply_t) -> bool { !this_.is_empty() } diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index 1b0d7158e..ad4e3fe58 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -51,9 +51,7 @@ pub extern "C" fn z_internal_fifo_handler_reply_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_fifo_handler_reply_check( - this_: &z_owned_fifo_handler_reply_t, -) -> bool { +pub extern "C" fn z_fifo_handler_reply_check(this_: &z_owned_fifo_handler_reply_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -191,9 +189,7 @@ pub extern "C" fn z_internal_ring_handler_reply_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_ring_handler_reply_check( - this_: &z_owned_ring_handler_reply_t, -) -> bool { +pub extern "C" fn z_ring_handler_reply_check(this_: &z_owned_ring_handler_reply_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index fd7eb8b04..2e3fb3f4a 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -51,9 +51,7 @@ pub extern "C" fn z_internal_fifo_handler_sample_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_fifo_handler_sample_check( - this_: &z_owned_fifo_handler_sample_t, -) -> bool { +pub extern "C" fn z_fifo_handler_sample_check(this_: &z_owned_fifo_handler_sample_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -195,9 +193,7 @@ pub extern "C" fn z_internal_ring_handler_sample_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_ring_handler_sample_check( - this_: &z_owned_ring_handler_sample_t, -) -> bool { +pub extern "C" fn z_ring_handler_sample_check(this_: &z_owned_ring_handler_sample_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/closures/sample_closure.rs b/src/closures/sample_closure.rs index 3141a7f64..870162b81 100644 --- a/src/closures/sample_closure.rs +++ b/src/closures/sample_closure.rs @@ -84,7 +84,7 @@ pub unsafe extern "C" fn z_internal_closure_sample_null( /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_closure_sample_check(this_: &z_owned_closure_sample_t) -> bool { +pub extern "C" fn z_closure_sample_check(this_: &z_owned_closure_sample_t) -> bool { !this_.is_empty() } diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index c4fc17112..9512deba5 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -76,7 +76,7 @@ impl Drop for z_owned_closure_zid_t { /// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_zid_check(this_: &z_owned_closure_zid_t) -> bool { +pub unsafe extern "C" fn z_closure_zid_check(this_: &z_owned_closure_zid_t) -> bool { !this_.is_empty() } diff --git a/src/collections.rs b/src/collections.rs index 1c5a22e55..29a9cfd5a 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -366,7 +366,7 @@ pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: & /// @return ``true`` if slice is not empty, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_slice_check(this_: &z_owned_slice_t) -> bool { +pub extern "C" fn z_slice_check(this_: &z_owned_slice_t) -> bool { !this_.as_rust_type_ref().is_empty() } @@ -566,7 +566,7 @@ pub unsafe extern "C" fn z_string_drop(this_: &mut z_moved_string_t) { /// @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_string_check(this_: &z_owned_string_t) -> bool { +pub extern "C" fn z_string_check(this_: &z_owned_string_t) -> bool { !this_.as_rust_type_ref().is_empty() } @@ -795,7 +795,7 @@ pub extern "C" fn z_internal_string_array_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_string_array_check(this_: &z_owned_string_array_t) -> bool { !this_.as_rust_type_ref().is_empty() } diff --git a/src/commons.rs b/src/commons.rs index 1544389ed..657cb786b 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -198,7 +198,7 @@ pub extern "C" fn z_sample_reliability(this_: &z_loaned_sample_t) -> z_reliabili /// Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_sample_check(this_: &z_owned_sample_t) -> bool { +pub extern "C" fn z_sample_check(this_: &z_owned_sample_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -603,7 +603,7 @@ pub extern "C" fn z_source_info_sn(this_: &z_loaned_source_info_t) -> u32 { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_source_info_check(this_: &z_owned_source_info_t) -> bool { +pub extern "C" fn z_source_info_check(this_: &z_owned_source_info_t) -> bool { this_.as_rust_type_ref().source_id().is_some() || this_.as_rust_type_ref().source_sn().is_some() } diff --git a/src/config.rs b/src/config.rs index 92d46c269..280f4a432 100644 --- a/src/config.rs +++ b/src/config.rs @@ -245,7 +245,7 @@ pub extern "C" fn z_config_drop(this_: &mut z_moved_config_t) { /// Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_internal_config_check(this_: &z_owned_config_t) -> bool { +pub extern "C" fn z_config_check(this_: &z_owned_config_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/encoding.rs b/src/encoding.rs index 15975bffe..55a3c819c 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -152,7 +152,7 @@ pub extern "C" fn z_encoding_drop(this_: &mut z_moved_encoding_t) { /// Returns ``true`` if encoding is in non-default state, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_encoding_check(this_: &'static z_owned_encoding_t) -> bool { +pub extern "C" fn z_encoding_check(this_: &'static z_owned_encoding_t) -> bool { *this_.as_rust_type_ref() != Encoding::default() } diff --git a/src/get.rs b/src/get.rs index ae1d1770b..a02edfe06 100644 --- a/src/get.rs +++ b/src/get.rs @@ -52,7 +52,7 @@ pub extern "C" fn z_internal_reply_err_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_reply_err_check(this_: &'static z_owned_reply_err_t) -> bool { !this_.as_rust_type_ref().payload().is_empty() } @@ -313,7 +313,7 @@ pub extern "C" fn z_reply_drop(this_: &mut z_moved_reply_t) { /// Returns ``true`` if `reply` is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_reply_check(this_: &z_owned_reply_t) -> bool { +pub extern "C" fn z_reply_check(this_: &z_owned_reply_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/keyexpr.rs b/src/keyexpr.rs index ea6e288e2..cbe7a551c 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -171,7 +171,7 @@ pub extern "C" fn z_keyexpr_drop(this_: &mut z_moved_keyexpr_t) { /// Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_keyexpr_check(this_: &z_owned_keyexpr_t) -> bool { +pub extern "C" fn z_keyexpr_check(this_: &z_owned_keyexpr_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/liveliness.rs b/src/liveliness.rs index 2c681e85f..408abd82f 100644 --- a/src/liveliness.rs +++ b/src/liveliness.rs @@ -46,7 +46,7 @@ pub extern "C" fn zc_internal_liveliness_token_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn zc_internal_liveliness_token_check(this_: &zc_owned_liveliness_token_t) -> bool { +pub extern "C" fn zc_liveliness_token_check(this_: &zc_owned_liveliness_token_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index ad0a78a52..ad5618d64 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -38,7 +38,7 @@ pub extern "C" fn z_mutex_drop(this_: &mut z_moved_mutex_t) { /// Returns ``true`` if mutex is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_mutex_check(this_: &z_owned_mutex_t) -> bool { +pub extern "C" fn z_mutex_check(this_: &z_owned_mutex_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -147,7 +147,7 @@ pub extern "C" fn z_condvar_drop(this_: &mut z_moved_condvar_t) { /// Returns ``true`` if conditional variable is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_condvar_check(this_: &z_owned_condvar_t) -> bool { +pub extern "C" fn z_condvar_check(this_: &z_owned_condvar_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -252,7 +252,7 @@ pub extern "C" fn z_task_drop(this_: &mut z_moved_task_t) { /// Returns ``true`` if task is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_task_check(this_: &z_owned_task_t) -> bool { +pub extern "C" fn z_task_check(this_: &z_owned_task_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/publication_cache.rs b/src/publication_cache.rs index ae0e3d575..ed2d4dc0f 100644 --- a/src/publication_cache.rs +++ b/src/publication_cache.rs @@ -164,9 +164,7 @@ pub extern "C" fn ze_internal_publication_cache_null( /// @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_internal_publication_cache_check( - this_: &ze_owned_publication_cache_t, -) -> bool { +pub extern "C" fn ze_publication_cache_check(this_: &ze_owned_publication_cache_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/publisher.rs b/src/publisher.rs index d0837bf20..5c7ba57f8 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -150,7 +150,7 @@ pub extern "C" fn z_internal_publisher_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_publisher_check(this_: &z_owned_publisher_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -337,9 +337,7 @@ pub extern "C" fn zc_internal_matching_listener_null( #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Checks the matching listener is for the gravestone state -pub extern "C" fn zc_internal_matching_listener_check( - this_: &zc_owned_matching_listener_t, -) -> bool { +pub extern "C" fn zc_matching_listener_check(this_: &zc_owned_matching_listener_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/queryable.rs b/src/queryable.rs index c70658432..20be31354 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -90,7 +90,7 @@ pub extern "C" fn z_internal_query_null(this_: &mut MaybeUninit } /// Returns `false` if `this` is in a gravestone state, `true` otherwise. #[no_mangle] -pub extern "C" fn z_internal_query_check(query: &z_owned_query_t) -> bool { +pub extern "C" fn z_query_check(query: &z_owned_query_t) -> bool { query.as_rust_type_ref().is_some() } /// Borrows the query. @@ -336,7 +336,7 @@ pub extern "C" fn z_queryable_drop(this_: &mut z_moved_queryable_t) { /// Returns ``true`` if queryable is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_queryable_check(this_: &z_owned_queryable_t) -> bool { +pub extern "C" fn z_queryable_check(this_: &z_owned_queryable_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/querying_subscriber.rs b/src/querying_subscriber.rs index 79e0c8f79..6fba52555 100644 --- a/src/querying_subscriber.rs +++ b/src/querying_subscriber.rs @@ -265,9 +265,7 @@ pub extern "C" fn ze_querying_subscriber_drop(this_: &mut ze_moved_querying_subs /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn ze_internal_querying_subscriber_check( - this_: &ze_owned_querying_subscriber_t, -) -> bool { +pub extern "C" fn ze_querying_subscriber_check(this_: &ze_owned_querying_subscriber_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/scouting.rs b/src/scouting.rs index 9561e47c2..41ddd5247 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -70,7 +70,7 @@ pub extern "C" fn z_hello_take_loaned( /// Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. #[no_mangle] -pub extern "C" fn z_internal_hello_check(this_: &z_owned_hello_t) -> bool { +pub extern "C" fn z_hello_check(this_: &z_owned_hello_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/serialization.rs b/src/serialization.rs index b6156d420..e39238fe5 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -56,7 +56,7 @@ extern "C" fn ze_serializer_drop(this_: &mut ze_moved_serializer_t) { /// @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. #[no_mangle] -extern "C" fn ze_internal_serializer_check(this: &ze_owned_serializer_t) -> bool { +extern "C" fn ze_serializer_check(this: &ze_owned_serializer_t) -> bool { this.as_rust_type_ref().is_some() } diff --git a/src/session.rs b/src/session.rs index 26306cbe7..9a68884e3 100644 --- a/src/session.rs +++ b/src/session.rs @@ -143,7 +143,7 @@ pub extern "C" fn z_open_with_custom_shm_clients( /// Returns ``true`` if `session` is valid, ``false`` otherwise. #[allow(clippy::missing_safety_doc)] #[no_mangle] -pub extern "C" fn z_internal_session_check(this_: &z_owned_session_t) -> bool { +pub extern "C" fn z_session_check(this_: &z_owned_session_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 442bb8f76..e5cda6ed2 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -53,7 +53,7 @@ pub extern "C" fn z_internal_shm_null(this_: &mut MaybeUninit) { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_internal_shm_check(this_: &z_owned_shm_t) -> bool { +pub extern "C" fn z_shm_check(this_: &z_owned_shm_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index ee8d09761..109fd247c 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -68,7 +68,7 @@ pub extern "C" fn z_internal_shm_mut_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_shm_mut_check(this_: &z_owned_shm_mut_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/client/shm_client.rs b/src/shm/client/shm_client.rs index 5bcc28921..061defa89 100644 --- a/src/shm/client/shm_client.rs +++ b/src/shm/client/shm_client.rs @@ -90,7 +90,7 @@ pub extern "C" fn z_internal_shm_client_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_shm_client_check(this_: &z_owned_shm_client_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index a0c9b045e..7bf7eeb03 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -52,7 +52,7 @@ pub extern "C" fn zc_internal_shm_client_list_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn zc_internal_shm_client_list_check(this_: &zc_owned_shm_client_list_t) -> bool { +pub extern "C" fn zc_shm_client_list_check(this_: &zc_owned_shm_client_list_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -175,9 +175,7 @@ pub extern "C" fn z_internal_shm_client_storage_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_internal_shm_client_storage_check( - this_: &z_owned_shm_client_storage_t, -) -> bool { +pub extern "C" fn z_shm_client_storage_check(this_: &z_owned_shm_client_storage_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index b9e4a3a5c..6c4fa5b80 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -72,7 +72,7 @@ pub extern "C" fn z_internal_alloc_layout_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_alloc_layout_check(this_: &z_owned_alloc_layout_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 3143ee091..10dd34d01 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -107,7 +107,7 @@ pub extern "C" fn z_internal_shm_provider_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_shm_provider_check(this_: &z_owned_shm_provider_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index a8ddee36e..968092b8e 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -151,7 +151,7 @@ pub extern "C" fn z_internal_memory_layout_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_memory_layout_check(this_: &z_owned_memory_layout_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -231,9 +231,7 @@ pub extern "C" fn z_internal_chunk_alloc_result_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_internal_chunk_alloc_result_check( - this_: &z_owned_chunk_alloc_result_t, -) -> bool { +pub extern "C" fn z_chunk_alloc_result_check(this_: &z_owned_chunk_alloc_result_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/subscriber.rs b/src/subscriber.rs index 6462d1094..4a3d7ba21 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -182,7 +182,7 @@ pub extern "C" fn z_subscriber_drop(this_: &mut z_moved_subscriber_t) { /// Returns ``true`` if subscriber is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_internal_subscriber_check(this_: &z_owned_subscriber_t) -> bool { +pub extern "C" fn z_subscriber_check(this_: &z_owned_subscriber_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/zbytes.rs b/src/zbytes.rs index 6ef3d944d..5937cc263 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -67,7 +67,7 @@ extern "C" fn z_bytes_drop(this_: &mut z_moved_bytes_t) { /// Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. #[no_mangle] -extern "C" fn z_internal_bytes_check(this: &z_owned_bytes_t) -> bool { +extern "C" fn z_bytes_check(this: &z_owned_bytes_t) -> bool { !this.as_rust_type_ref().is_empty() } @@ -631,7 +631,7 @@ extern "C" fn z_bytes_writer_drop(this_: &mut z_moved_bytes_writer_t) { /// Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. #[no_mangle] -extern "C" fn z_internal_bytes_writer_check(this: &z_owned_bytes_writer_t) -> bool { +extern "C" fn z_bytes_writer_check(this: &z_owned_bytes_writer_t) -> bool { this.as_rust_type_ref().is_some() } From 29cde90fc7eca7da83f7f31d6883d16fc9fbc425 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 14:56:59 +0200 Subject: [PATCH 19/38] clang fmt --- tests/z_api_null_drop_test.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index f9438ca10..4c6198e4e 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -35,24 +35,24 @@ // move v1 to v2 using z_take from mutable loaned // make sure that v1 is null now // -#define TEST(name) \ - { \ - name v; \ - memset(&v, -1, sizeof(v)); \ - z_internal_null(&v); \ - assert(!z_internal_check(v)); \ - z_drop(z_move(v)); \ - z_drop(z_move(v)); \ - name v1; \ - z_internal_null(&v1); \ - memset(&v, -1, sizeof(v)); \ - z_take(&v1, z_move(v)); \ - assert(!z_internal_check(v)); \ - name v2; \ - z_internal_null(&v2); \ - memset(&v1, -1, sizeof(v1)); \ - z_take(&v2, z_loan_mut(v1)); \ - assert(!z_internal_check(v1));\ +#define TEST(name) \ + { \ + name v; \ + memset(&v, -1, sizeof(v)); \ + z_internal_null(&v); \ + assert(!z_internal_check(v)); \ + z_drop(z_move(v)); \ + z_drop(z_move(v)); \ + name v1; \ + z_internal_null(&v1); \ + memset(&v, -1, sizeof(v)); \ + z_take(&v1, z_move(v)); \ + assert(!z_internal_check(v)); \ + name v2; \ + z_internal_null(&v2); \ + memset(&v1, -1, sizeof(v1)); \ + z_take(&v2, z_loan_mut(v1)); \ + assert(!z_internal_check(v1)); \ } int main(void) { From 75b9d20f4802cfb2be254721e91f4270693851dc Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 15:48:32 +0200 Subject: [PATCH 20/38] internal check in examples renamed --- tests/z_api_alignment_test.c | 16 ++++++------- tests/z_api_double_drop_test.c | 38 +++++++++++++++---------------- tests/z_api_drop_options.c | 8 +++---- tests/z_api_encoding_test.c | 14 ++++++------ tests/z_api_keyexpr_drop_test.c | 2 +- tests/z_api_keyexpr_test.c | 4 ++-- tests/z_api_null_drop_test.c | 6 ++--- tests/z_api_payload_test.c | 4 ++-- tests/z_api_shm_test.c | 6 ++--- tests/z_api_unitinialized_check.c | 4 ++-- 10 files changed, 51 insertions(+), 51 deletions(-) diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index cfc1df46a..f7ed0d6df 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -161,7 +161,7 @@ int main(int argc, char **argv) { z_owned_config_t _ret_config; z_config_default(&_ret_config); - assert(z_internal_check(_ret_config)); + assert(z_check(_ret_config)); z_drop(z_move(_ret_config)); #ifdef ZENOH_PICO _ret_int8 = zp_config_insert(z_loan(_ret_config), Z_CONFIG_PEER_KEY, z_string_make(argv[1])); @@ -174,7 +174,7 @@ int main(int argc, char **argv) { #ifdef ZENOH_PICO z_owned_scouting_config_t _ret_sconfig; z_scouting_config_default(&_ret_sconfig); - assert(z_internal_check(_ret_sconfig)); + assert(z_check(_ret_sconfig)); _ret_int8 = zp_scouting_config_insert(z_loan(_ret_sconfig), Z_CONFIG_SCOUTING_TIMEOUT_KEY, z_string_make(SCOUTING_TIMEOUT)); assert(_ret_int8 == 0); @@ -197,7 +197,7 @@ int main(int argc, char **argv) { z_owned_session_t s1; assert(0 == z_open(&s1, z_move(_ret_config), NULL)); - assert(z_internal_check(s1)); + assert(z_check(s1)); z_id_t _ret_zid = z_info_zid(z_loan(s1)); z_owned_string_t str; @@ -239,7 +239,7 @@ int main(int argc, char **argv) { z_owned_session_t s2; assert(0 == z_open(&s2, z_move(_ret_config), NULL)); - assert(z_internal_check(s2)); + assert(z_check(s2)); #if defined(Z_FEATURE_UNSTABLE_API) _ret_zid = z_info_zid(z_loan(s2)); @@ -265,7 +265,7 @@ int main(int argc, char **argv) { z_view_keyexpr_from_str(&ke, keyexpr_str); z_owned_subscriber_t _ret_sub; z_declare_subscriber(z_loan(s2), &_ret_sub, z_loan(ke), z_move(_ret_closure_sample), &_ret_sub_opt); - assert(z_internal_check(_ret_sub)); + assert(z_check(_ret_sub)); z_sleep_s(SLEEP); @@ -275,7 +275,7 @@ int main(int argc, char **argv) { z_view_keyexpr_from_str(&s1_key, s1_res); z_owned_keyexpr_t _ret_expr; z_declare_keyexpr(z_loan(s1), &_ret_expr, z_loan(s1_key)); - assert(z_internal_check(_ret_expr)); + assert(z_check(_ret_expr)); z_put_options_t _ret_put_opt; z_put_options_default(&_ret_put_opt); _ret_put_opt.congestion_control = Z_CONGESTION_CONTROL_BLOCK; @@ -299,7 +299,7 @@ int main(int argc, char **argv) { _ret_int8 = z_undeclare_keyexpr(z_loan(s1), z_move(_ret_expr)); assert(_ret_int8 == 0); - assert(!z_internal_check(_ret_expr)); + assert(!z_check(_ret_expr)); z_drop(z_move(_ret_sub)); @@ -311,7 +311,7 @@ int main(int argc, char **argv) { z_queryable_options_default(&_ret_qle_opt); z_owned_queryable_t qle; z_declare_queryable(z_loan(s1), &qle, z_loan(s1_key), z_move(_ret_closure_query), &_ret_qle_opt); - assert(z_internal_check(qle)); + assert(z_check(qle)); z_sleep_s(SLEEP); diff --git a/tests/z_api_double_drop_test.c b/tests/z_api_double_drop_test.c index 03f74620c..574768bd0 100644 --- a/tests/z_api_double_drop_test.c +++ b/tests/z_api_double_drop_test.c @@ -25,14 +25,14 @@ void test_session() { z_owned_config_t config; z_config_default(&config); - assert(z_internal_check(config)); + assert(z_check(config)); z_owned_session_t session; z_open(&session, z_move(config), NULL); - assert(z_internal_check(session)); + assert(z_check(session)); z_drop(z_move(session)); - assert(!z_internal_check(session)); + assert(!z_check(session)); z_drop(z_move(session)); - assert(!z_internal_check(session)); + assert(!z_check(session)); } void test_publisher() { @@ -46,11 +46,11 @@ void test_publisher() { z_owned_publisher_t pub; z_declare_publisher(z_loan(s), &pub, z_loan(keyexpr), NULL); - assert(z_internal_check(pub)); + assert(z_check(pub)); z_drop(z_move(pub)); - assert(!z_internal_check(pub)); + assert(!z_check(pub)); z_drop(z_move(pub)); - assert(!z_internal_check(pub)); + assert(!z_check(pub)); z_drop(z_move(s)); } @@ -58,21 +58,21 @@ void test_keyexpr() { z_owned_keyexpr_t keyexpr; z_keyexpr_from_str(&keyexpr, URL); - assert(z_internal_check(keyexpr)); + assert(z_check(keyexpr)); z_drop(z_move(keyexpr)); - assert(!z_internal_check(keyexpr)); + assert(!z_check(keyexpr)); z_drop(z_move(keyexpr)); - assert(!z_internal_check(keyexpr)); + assert(!z_check(keyexpr)); } void test_config() { z_owned_config_t config; z_config_default(&config); - assert(z_internal_check(config)); + assert(z_check(config)); z_drop(z_move(config)); - assert(!z_internal_check(config)); + assert(!z_check(config)); z_drop(z_move(config)); - assert(!z_internal_check(config)); + assert(!z_check(config)); } void data_handler(z_loaned_sample_t *sample, void *arg) {} @@ -89,11 +89,11 @@ void test_subscriber() { z_view_keyexpr_from_str(&keyexpr, URL); z_owned_subscriber_t sub; z_declare_subscriber(z_loan(s), &sub, z_loan(keyexpr), z_move(callback), NULL); - assert(z_internal_check(sub)); + assert(z_check(sub)); z_drop(z_move(sub)); - assert(!z_internal_check(sub)); + assert(!z_check(sub)); z_drop(z_move(sub)); - assert(!z_internal_check(sub)); + assert(!z_check(sub)); z_drop(z_move(s)); } @@ -111,11 +111,11 @@ void test_queryable() { z_view_keyexpr_from_str(&keyexpr, URL); z_owned_queryable_t queryable; z_declare_queryable(z_loan(s), &queryable, z_loan(keyexpr), z_move(callback), NULL); - assert(z_internal_check(queryable)); + assert(z_check(queryable)); z_drop(z_move(queryable)); - assert(!z_internal_check(queryable)); + assert(!z_check(queryable)); z_drop(z_move(queryable)); - assert(!z_internal_check(queryable)); + assert(!z_check(queryable)); z_drop(z_move(s)); } diff --git a/tests/z_api_drop_options.c b/tests/z_api_drop_options.c index 05e54f205..05c2c97e2 100644 --- a/tests/z_api_drop_options.c +++ b/tests/z_api_drop_options.c @@ -40,8 +40,8 @@ void put() { opts.attachment = z_move(attachment); z_bytes_copy_from_str(&payload, "cde"); z_put(z_loan(s), z_loan(ke), z_move(payload), &opts); - assert(!z_internal_check(payload)); - assert(!z_internal_check(attachment)); + assert(!z_check(payload)); + assert(!z_check(attachment)); z_drop(z_move(s)); } @@ -68,8 +68,8 @@ void get() { z_closure(&closure, cb, drop, NULL); z_get(z_loan(s), z_loan(ke), "", z_move(closure), &opts); - assert(!z_internal_check(payload)); - assert(!z_internal_check(attachment)); + assert(!z_check(payload)); + assert(!z_check(attachment)); z_drop(z_move(s)); } diff --git a/tests/z_api_encoding_test.c b/tests/z_api_encoding_test.c index 13d0465db..cdd654bfc 100644 --- a/tests/z_api_encoding_test.c +++ b/tests/z_api_encoding_test.c @@ -11,14 +11,14 @@ void test_null_encoding(void) { z_owned_encoding_t e; z_internal_encoding_null(&e); - assert(!z_internal_encoding_check(&e)); + assert(!z_encoding_check(&e)); z_encoding_drop(z_move(e)); } void test_encoding_without_id(void) { z_owned_encoding_t e1; z_encoding_from_str(&e1, "my_encoding"); - assert(z_internal_encoding_check(&e1)); + assert(z_encoding_check(&e1)); z_owned_string_t s; z_encoding_to_string(z_encoding_loan(&e1), &s); assert(strncmp("zenoh/bytes;my_encoding", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -27,7 +27,7 @@ void test_encoding_without_id(void) { z_owned_encoding_t e2; z_encoding_from_substr(&e2, "my_encoding", 4); - assert(z_internal_encoding_check(&e2)); + assert(z_encoding_check(&e2)); z_encoding_to_string(z_encoding_loan(&e2), &s); assert(strncmp("zenoh/bytes;my_e", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -38,7 +38,7 @@ void test_encoding_without_id(void) { void test_encoding_with_id(void) { z_owned_encoding_t e1; z_encoding_from_str(&e1, "zenoh/string;utf8"); - assert(z_internal_encoding_check(&e1)); + assert(z_encoding_check(&e1)); z_owned_string_t s; z_encoding_to_string(z_encoding_loan(&e1), &s); assert(strncmp("zenoh/string;utf8", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -47,7 +47,7 @@ void test_encoding_with_id(void) { z_owned_encoding_t e2; z_encoding_from_substr(&e2, "zenoh/string;utf8", 15); - assert(z_internal_encoding_check(&e2)); + assert(z_encoding_check(&e2)); z_encoding_to_string(z_encoding_loan(&e2), &s); assert(strncmp("zenoh/string;utf8", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -56,7 +56,7 @@ void test_encoding_with_id(void) { z_owned_encoding_t e3; z_encoding_from_str(&e3, "custom_id;custom_schema"); - assert(z_internal_encoding_check(&e3)); + assert(z_encoding_check(&e3)); z_encoding_to_string(z_encoding_loan(&e3), &s); assert(strncmp("zenoh/bytes;custom_id;custom_schema", z_string_data(z_string_loan(&s)), @@ -66,7 +66,7 @@ void test_encoding_with_id(void) { z_owned_encoding_t e4; z_encoding_from_substr(&e4, "custom_id;custom_schema", 16); - assert(z_internal_encoding_check(&e4)); + assert(z_encoding_check(&e4)); z_encoding_to_string(z_encoding_loan(&e4), &s); assert(strncmp("zenoh/bytes;custom_id;custom", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == diff --git a/tests/z_api_keyexpr_drop_test.c b/tests/z_api_keyexpr_drop_test.c index c415c6684..d8aa2d02c 100644 --- a/tests/z_api_keyexpr_drop_test.c +++ b/tests/z_api_keyexpr_drop_test.c @@ -25,7 +25,7 @@ void test_publisher() { z_config_default(&config); z_owned_session_t s; z_open(&s, z_move(config), NULL); - assert(z_internal_check(s)); + assert(z_check(s)); char keyexpr[256]; strncpy(keyexpr, "foo/bar", 256); z_view_keyexpr_t ke; diff --git a/tests/z_api_keyexpr_test.c b/tests/z_api_keyexpr_test.c index 8a5c50120..c0ca4cc20 100644 --- a/tests/z_api_keyexpr_test.c +++ b/tests/z_api_keyexpr_test.c @@ -92,9 +92,9 @@ void undeclare() { z_view_keyexpr_from_str(&view_ke, "test/thr"); z_owned_keyexpr_t ke; z_declare_keyexpr(z_loan(s), &ke, z_loan(view_ke)); - assert(z_internal_keyexpr_check(&ke)); + assert(z_keyexpr_check(&ke)); z_undeclare_keyexpr(z_loan(s), z_move(ke)); - assert(!z_internal_keyexpr_check(&ke)); + assert(!z_keyexpr_check(&ke)); } #if defined(Z_FEATURE_UNSTABLE_API) diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 4c6198e4e..700d7a940 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -40,19 +40,19 @@ name v; \ memset(&v, -1, sizeof(v)); \ z_internal_null(&v); \ - assert(!z_internal_check(v)); \ + assert(!z_check(v)); \ z_drop(z_move(v)); \ z_drop(z_move(v)); \ name v1; \ z_internal_null(&v1); \ memset(&v, -1, sizeof(v)); \ z_take(&v1, z_move(v)); \ - assert(!z_internal_check(v)); \ + assert(!z_check(v)); \ name v2; \ z_internal_null(&v2); \ memset(&v1, -1, sizeof(v1)); \ z_take(&v2, z_loan_mut(v1)); \ - assert(!z_internal_check(v1)); \ + assert(!z_check(v1)); \ } int main(void) { diff --git a/tests/z_api_payload_test.c b/tests/z_api_payload_test.c index 745e49389..0b29e6beb 100644 --- a/tests/z_api_payload_test.c +++ b/tests/z_api_payload_test.c @@ -167,14 +167,14 @@ void test_slice(void) { z_owned_slice_t s; z_slice_copy_from_buf(&s, data, 10); z_bytes_copy_from_slice(&payload2, z_loan(s)); - assert(z_internal_slice_check(&s)); + assert(z_slice_check(&s)); z_slice_drop(z_slice_move(&s)); assert(z_check_and_drop_payload(&payload2, data, 10)); z_owned_bytes_t payload3; z_slice_copy_from_buf(&s, data, 10); z_bytes_from_slice(&payload3, z_slice_move(&s)); - assert(!z_internal_slice_check(&s)); + assert(!z_slice_check(&s)); assert(z_check_and_drop_payload(&payload3, data, 10)); z_owned_bytes_t payload4; diff --git a/tests/z_api_shm_test.c b/tests/z_api_shm_test.c index 1a6607667..26094acf0 100644 --- a/tests/z_api_shm_test.c +++ b/tests/z_api_shm_test.c @@ -34,13 +34,13 @@ } #define ASSERT_CHECK(var) \ - if (!z_internal_check(var)) { \ + if (!z_check(var)) { \ assert(false); \ return -100; \ } #define ASSERT_CHECK_ERR(var) \ - if (z_internal_check(var)) { \ + if (z_check(var)) { \ assert(false); \ return -200; \ } @@ -248,7 +248,7 @@ void layout_for_fn(struct z_owned_memory_layout_t* layout, void* context) { assert(context); assert(layout); - assert(z_internal_check(*layout)); + assert(z_check(*layout)); // check size and alignment size_t size = 0; diff --git a/tests/z_api_unitinialized_check.c b/tests/z_api_unitinialized_check.c index 8ffa75117..c27b14078 100644 --- a/tests/z_api_unitinialized_check.c +++ b/tests/z_api_unitinialized_check.c @@ -24,9 +24,9 @@ int main(int argc, char **argv) { z_owned_keyexpr_t owned_keyexpr; assert(z_keyexpr_from_str(&owned_keyexpr, NULL) == Z_EINVAL); - assert(!z_internal_check(owned_keyexpr)); + assert(!z_check(owned_keyexpr)); assert(z_keyexpr_from_str_autocanonize(&owned_keyexpr, NULL) == Z_EINVAL); - assert(!z_internal_check(owned_keyexpr)); + assert(!z_check(owned_keyexpr)); assert(z_keyexpr_canonize_null_terminated(NULL) == Z_EINVAL); From c43af3451d7b28df1338447a0a17e4451cf53222 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 15:55:01 +0200 Subject: [PATCH 21/38] clang format --- tests/z_api_shm_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/z_api_shm_test.c b/tests/z_api_shm_test.c index 26094acf0..715195b8b 100644 --- a/tests/z_api_shm_test.c +++ b/tests/z_api_shm_test.c @@ -33,16 +33,16 @@ return -300; \ } -#define ASSERT_CHECK(var) \ - if (!z_check(var)) { \ - assert(false); \ - return -100; \ +#define ASSERT_CHECK(var) \ + if (!z_check(var)) { \ + assert(false); \ + return -100; \ } -#define ASSERT_CHECK_ERR(var) \ - if (z_check(var)) { \ - assert(false); \ - return -200; \ +#define ASSERT_CHECK_ERR(var) \ + if (z_check(var)) { \ + assert(false); \ + return -200; \ } int test_shm_buffer(z_moved_shm_mut_t* mbuf) { From fe67f272cd08f8600c98dd54848424489b28f0dc Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 24 Oct 2024 15:58:19 +0200 Subject: [PATCH 22/38] clang format --- tests/z_api_null_drop_test.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 700d7a940..264fe9b63 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -35,24 +35,24 @@ // move v1 to v2 using z_take from mutable loaned // make sure that v1 is null now // -#define TEST(name) \ - { \ - name v; \ - memset(&v, -1, sizeof(v)); \ - z_internal_null(&v); \ - assert(!z_check(v)); \ - z_drop(z_move(v)); \ - z_drop(z_move(v)); \ - name v1; \ - z_internal_null(&v1); \ - memset(&v, -1, sizeof(v)); \ - z_take(&v1, z_move(v)); \ - assert(!z_check(v)); \ - name v2; \ - z_internal_null(&v2); \ - memset(&v1, -1, sizeof(v1)); \ - z_take(&v2, z_loan_mut(v1)); \ - assert(!z_check(v1)); \ +#define TEST(name) \ + { \ + name v; \ + memset(&v, -1, sizeof(v)); \ + z_internal_null(&v); \ + assert(!z_check(v)); \ + z_drop(z_move(v)); \ + z_drop(z_move(v)); \ + name v1; \ + z_internal_null(&v1); \ + memset(&v, -1, sizeof(v)); \ + z_take(&v1, z_move(v)); \ + assert(!z_check(v)); \ + name v2; \ + z_internal_null(&v2); \ + memset(&v1, -1, sizeof(v1)); \ + z_take(&v2, z_loan_mut(v1)); \ + assert(!z_check(v1)); \ } int main(void) { From fd04bef9f4a25568612c135f80e075d76122c431 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 25 Oct 2024 16:22:36 +0200 Subject: [PATCH 23/38] take_loaned kept only for calllback parameters --- build.rs | 77 +-- docs/concepts.rst | 47 +- include/zenoh_commons.h | 692 +++++++++--------------- include/zenoh_macros.h | 322 ++++------- src/closures/hello_closure.rs | 11 +- src/closures/log_closure.rs | 2 +- src/closures/matching_status_closure.rs | 2 +- src/closures/query_channel.rs | 24 +- src/closures/query_closure.rs | 11 +- src/closures/reply_closure.rs | 11 +- src/closures/response_channel.rs | 24 +- src/closures/sample_channel.rs | 24 +- src/closures/sample_closure.rs | 11 +- src/closures/zenohid_closure.rs | 11 +- src/collections.rs | 36 +- src/commons.rs | 16 +- src/config.rs | 12 +- src/encoding.rs | 12 +- src/get.rs | 14 +- src/keyexpr.rs | 12 +- src/liveliness.rs | 2 +- src/platform/synchronization.rs | 16 +- src/publication_cache.rs | 2 +- src/publisher.rs | 14 +- src/queryable.rs | 14 +- src/querying_subscriber.rs | 2 +- src/scouting.rs | 2 +- src/serialization.rs | 2 +- src/session.rs | 12 +- src/shm/buffer/zshm.rs | 12 +- src/shm/buffer/zshmmut.rs | 12 +- src/shm/client/shm_client.rs | 2 +- src/shm/client_storage/mod.rs | 15 +- src/shm/provider/alloc_layout.rs | 12 +- src/shm/provider/shm_provider.rs | 12 +- src/shm/provider/types.rs | 4 +- src/subscriber.rs | 12 +- src/zbytes.rs | 24 +- tests/z_api_alignment_test.c | 16 +- tests/z_api_double_drop_test.c | 38 +- tests/z_api_drop_options.c | 8 +- tests/z_api_encoding_test.c | 14 +- tests/z_api_keyexpr_drop_test.c | 2 +- tests/z_api_keyexpr_test.c | 4 +- tests/z_api_null_drop_test.c | 50 +- tests/z_api_payload_test.c | 4 +- tests/z_api_shm_test.c | 6 +- tests/z_api_unitinialized_check.c | 4 +- 48 files changed, 508 insertions(+), 1180 deletions(-) diff --git a/build.rs b/build.rs index 935b59e37..6a251395d 100644 --- a/build.rs +++ b/build.rs @@ -970,7 +970,6 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { let (move_funcs, take_funcs) = make_move_take_signatures(path_in); let loan_funcs = find_loan_functions(path_in); let loan_mut_funcs = find_loan_mut_functions(path_in); - let take_loaned_funcs = find_take_loaned_functions(path_in); let drop_funcs = find_drop_functions(path_in); let null_funcs = find_null_functions(path_in); let check_funcs = find_check_functions(path_in); @@ -978,8 +977,6 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { let closure_constructors = find_closure_constructors(path_in); let recv_funcs = find_recv_functions(path_in); let clone_funcs = find_clone_functions(path_in); - let mut take_funcs_generic = take_funcs.clone(); - take_funcs_generic.extend(take_loaned_funcs); let drops = drop_funcs .iter() @@ -1016,7 +1013,7 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { if drops != checks { msgs.push(format!( - "the list of z_xxx_drop and z_xxx_check functions are different:\n missing z_xxx_check for {:?}\n missing z_xxx_drop for {:?}", + "the list of z_xxx_drop and z_internal_xxx_check functions are different:\n missing z_internal_xxx_check for {:?}\n missing z_xxx_drop for {:?}", drops.difference(&checks), checks.difference(&drops) )); @@ -1070,7 +1067,7 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); - let out = generate_generic_take_c(&take_funcs_generic); + let out = generate_generic_take_c(&take_funcs); file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); @@ -1129,7 +1126,7 @@ pub fn create_generics_header(path_in: &str, path_out: &str) { file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); - let out = generate_generic_take_cpp(&take_funcs_generic); + let out = generate_generic_take_cpp(&take_funcs); file_out.write_all(out.as_bytes()).unwrap(); file_out.write_all("\n\n".as_bytes()).unwrap(); @@ -1286,7 +1283,7 @@ pub fn find_null_functions(path_in: &str) -> Vec { pub fn find_check_functions(path_in: &str) -> Vec { let bindings = std::fs::read_to_string(path_in).unwrap(); - let re = Regex::new(r"bool (z.?_\w+_check)\(const struct (\w+) \*(\w+)\);").unwrap(); + let re = Regex::new(r"bool (z.?_internal_\w+_check)\(const struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); for (_, [func_name, arg_type, arg_name]) in re.captures_iter(&bindings).map(|c| c.extract()) { @@ -1305,32 +1302,6 @@ pub fn find_check_functions(path_in: &str) -> Vec { res } -pub fn find_take_loaned_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); - let re = Regex::new( - r"void (\w+)_take_loaned\(struct\s+(\w+)\s*\*\s*(\w+),\s*struct\s+(\w+)\s*\*\s*(\w+)\);", - ) - .unwrap(); - let mut res = Vec::::new(); - - for (_, [func_name, dst_type, dst_name, src_type, src_name]) in - re.captures_iter(&bindings).map(|c| c.extract()) - { - let (_, _, semantic, _) = split_type_name(dst_type); - let f = FunctionSignature::new( - semantic, - "void", - func_name.to_string() + "_take_loaned", - vec![ - FuncArg::new(&(dst_type.to_string() + "*"), dst_name), - FuncArg::new(&(src_type.to_string() + "*"), src_name), - ], - ); - res.push(f); - } - res -} - pub fn find_call_functions(path_in: &str) -> Vec { let bindings = std::fs::read_to_string(path_in).unwrap(); let re = Regex::new( @@ -1449,13 +1420,11 @@ pub fn find_clone_functions(path_in: &str) -> Vec { res } -pub fn generate_generic_c_impl( +pub fn generate_generic_c( macro_func: &[FunctionSignature], generic_name: &str, decay: bool, - generic_param_idx: usize, ) -> String { - assert!(!decay || generic_param_idx == 0); let va_args = macro_func .iter() .any(|f| f.args.len() != macro_func[0].args.len()); @@ -1471,29 +1440,25 @@ pub fn generate_generic_c_impl( "#define {generic_name}({}, ...) \\ _Generic(({})", args.join(", "), - args[generic_param_idx], + args[0], ) } else { format!( "#define {generic_name}({}) \\ _Generic(({})", args.join(", "), - args[generic_param_idx], + args[0], ) }; if decay { - args[generic_param_idx] = format!("&{}", args[generic_param_idx]); + args[0] = format!("&{}", args[0]); } for func in macro_func { let owned_type = if decay { - func.args[generic_param_idx] - .typename - .clone() - .decay() - .typename + func.args[0].typename.clone().decay().typename } else { - func.args[generic_param_idx].typename.typename.clone() + func.args[0].typename.typename.clone() }; let func_name = &func.func_name; out += ", \\\n"; @@ -1508,22 +1473,6 @@ pub fn generate_generic_c_impl( out } -pub fn generate_generic_c( - macro_func: &[FunctionSignature], - generic_name: &str, - decay: bool, -) -> String { - generate_generic_c_impl(macro_func, generic_name, decay, 0) -} - -pub fn generate_generic_c_by_arg( - macro_func: &[FunctionSignature], - generic_name: &str, - generic_param_idx: usize, -) -> String { - generate_generic_c_impl(macro_func, generic_name, false, generic_param_idx) -} - pub fn generate_generic_loan_c(macro_func: &[FunctionSignature]) -> String { generate_generic_c(macro_func, "z_loan", true) } @@ -1537,7 +1486,7 @@ pub fn generate_generic_move_c(macro_func: &[FunctionSignature]) -> String { } pub fn generate_generic_take_c(macro_func: &[FunctionSignature]) -> String { - generate_generic_c_by_arg(macro_func, "z_take", 1) + generate_generic_c(macro_func, "z_take", false) } pub fn generate_generic_drop_c(macro_func: &[FunctionSignature]) -> String { @@ -1602,7 +1551,7 @@ pub fn generate_generic_null_c(macro_func: &[FunctionSignature]) -> String { } pub fn generate_generic_check_c(macro_func: &[FunctionSignature]) -> String { - generate_generic_c(macro_func, "z_check", true) + generate_generic_c(macro_func, "z_internal_check", true) } pub fn generate_generic_call_c(macro_func: &[FunctionSignature]) -> String { @@ -1748,7 +1697,7 @@ pub fn generate_generic_null_cpp(macro_func: &[FunctionSignature]) -> String { } pub fn generate_generic_check_cpp(macro_func: &[FunctionSignature]) -> String { - generate_generic_cpp(macro_func, "z_check", true) + generate_generic_cpp(macro_func, "z_internal_check", true) } pub fn generate_generic_call_cpp(macro_func: &[FunctionSignature]) -> String { diff --git a/docs/concepts.rst b/docs/concepts.rst index 2adc497d2..d1128518f 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -150,10 +150,10 @@ Common operations ================= The transition between "owned", "loaned" and "moved" structures above is performed by corresponding functions. -The following operations are available: move, loan, mutable loan, take, check, and drop. They are performed for +The following operations are available: move, loan, mutable loan, take, and drop. They are performed for "xxx" entities by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take_moved`, `z_xxx_take_loaned`, -`z_xxx_check`, and `z_xxx_drop`. -The generic macros `z_move`, `z_loan`, `z_loan_mut`, `z_take`, `z_check`, and `z_drop` are also provided. +and `z_xxx_drop`. +The generic macros `z_move`, `z_loan`, `z_loan_mut`, `z_take`, and `z_drop` are also provided. Loan operation -------------- @@ -169,15 +169,6 @@ Mutable loan operation The function `z_xxx_loan_mut` accepts `z_owned_xxx_t*` and returns a pointer `z_xxx_loaned_t*` which allows reading and modifying the `z_owned_xxx_t` entity. -There is also API for taking ownership of the mutably loaned object: `z_xxx_take_loaned` functions. This -is useful when user's code accepts a mutable loaned object. In this case the user's code is free to take -the passed object for further processing or to process it on place without taking ownership. This was done -primarily for the callback functions: the callback handler is not obliged to take ownership of the passed object but -can do it if needed. - -Though it's important to note that the zenoh API itself **never** takes ownership of the mutably loaned object. Otherwise, -the user would be obliged to call `z_check` on the object each time after mutably passing it to the zenoh API. - The `z_loan_mut` macro accepts a variable of `z_owned_xxx_t` type and calls the corresponding `z_xxx_loan_mut` function. Move operation @@ -193,32 +184,22 @@ The `z_move` macro accepts a variable of `z_owned_xxx_t` type and calls the corr Take operation -------------- -Functions `z_xxx_take_moved` and `z_xxx_take_loaned` accept pointers -to uninitialized `z_owned_xxx_t` destination structures and -`z_moved_xxx_t*` and `z_loaned_xxx_t*` source pointers, respectively. +Functions `z_xxx_take` accept pointers to uninitialized `z_owned_xxx_t` destination structures and +`z_moved_xxx_t*` source pointers. These functions move data from the source `z_owned_xxx_t` structure into the destination one. The source -structure is set to an empty "gravestone" state (see "check" operation). - -The `z_take` macro accepts `z_moved_xxx_t*` or `z_loaned_xxx_t*` pointer and calls the corresponding -`z_xxx_take_moved` and `z_xxx_take_loaned` functions. - -Check operation ---------------- - -When an owned object is dropped or taken, it's set to a so-called **gravestone** state, which is safe to -double drop. No operations except "check" and "drop" are usually allowed on a dropped/taken object. +structure is set to an empty "gravestone" state, like after a drop operation. -The function `z_xxx_check` returns true if the object is in a **valid** state, e.g., if the loan operation -on the object is allowed. +The `z_take` macro accepts `z_moved_xxx_t*` pointer and calls the corresponding +`z_xxx_take` functions. -There is a catch: **gravestone** and **valid** states are not always opposite. -For some objects, the gravestone state is still a valid state. -Examples are `z_owned_bytes_t` in the "empty" state or `z_owned_encoding_t` -with `ZENOH_BYTES` encoding set. For such objects, the `z_check` always returns true, -even after a "drop" or "take" operation. +There is also an API for taking ownership of a mutably loaned object: the `z_xxx_take_loaned` functions. These functions +are available only for types passed to callback functions as mutable references, such as `z_loaned_sample_t*`, `z_loaned_reply_t*`, +`z_loaned_hello_t*`, and `z_loaned_query_t*`. -The `z_check` macro accepts `const z_owned_xxx_t*` and calls corresponding `z_xxx_check` function. +This feature is specifically designed for callbacks: it allows the callback to either process the passed object in place or take +ownership of it for further processing. No zenoh-c API functions take ownership of mutably loaned objects, i.e it's always safe to pass object +to function with `z_loan_mut` and continue using it after return. Drop operation -------------- diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 4c9bc4dbf..6efe4b75f 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1237,12 +1237,6 @@ ZENOHC_API void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, const z_loaned_alloc_layout_t *layout); #endif -/** - * Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API bool z_alloc_layout_check(const z_owned_alloc_layout_t *this_); -#endif /** * Deletes Alloc Layout */ @@ -1272,14 +1266,6 @@ z_result_t z_alloc_layout_new(z_owned_alloc_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif -/** - * Takes ownership of the mutably borrowed Alloc Layout - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_take_loaned(z_owned_alloc_layout_t *dst, - z_loaned_alloc_layout_t *src); -#endif #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, @@ -1288,10 +1274,6 @@ z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_re void (*result_callback)(void*, struct z_buf_alloc_result_t*)); #endif -/** - * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_bytes_check(const struct z_owned_bytes_t *this_); /** * Constructs an owned shallow copy of data in provided uninitialized memory location. */ @@ -1483,10 +1465,6 @@ ZENOHC_API int64_t z_bytes_reader_tell(struct z_bytes_reader_t *this_); ZENOHC_API bool z_bytes_slice_iterator_next(struct z_bytes_slice_iterator_t *this_, struct z_view_slice_t *slice); -/** - * Takes ownership of the mutably borrowed bytes - */ -ZENOHC_API void z_bytes_take_loaned(struct z_owned_bytes_t *dst, struct z_loaned_bytes_t *src); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Converts data into a loaned SHM buffer. @@ -1551,10 +1529,6 @@ z_result_t z_bytes_to_string(const struct z_loaned_bytes_t *this_, ZENOHC_API z_result_t z_bytes_writer_append(struct z_loaned_bytes_writer_t *this_, struct z_moved_bytes_t *bytes); -/** - * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_bytes_writer_check(const struct z_owned_bytes_writer_t *this_); /** * Drops `this_`, resetting it to gravestone value. */ @@ -1583,12 +1557,6 @@ const struct z_loaned_bytes_writer_t *z_bytes_writer_loan(const struct z_owned_b */ ZENOHC_API struct z_loaned_bytes_writer_t *z_bytes_writer_loan_mut(struct z_owned_bytes_writer_t *this_); -/** - * Takes ownership of the mutably borrowed writer - */ -ZENOHC_API -void z_bytes_writer_take_loaned(struct z_owned_bytes_writer_t *dst, - struct z_loaned_bytes_writer_t *src); /** * Writes `len` bytes from `src` into underlying data. * @@ -1598,14 +1566,6 @@ ZENOHC_API z_result_t z_bytes_writer_write_all(struct z_loaned_bytes_writer_t *this_, const uint8_t *src, size_t len); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes Chunk Alloc Result. @@ -1687,10 +1647,6 @@ void z_closure_hello(struct z_owned_closure_hello_t *this_, ZENOHC_API void z_closure_hello_call(const struct z_loaned_closure_hello_t *closure, struct z_loaned_hello_t *hello); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_closure_hello_check(const struct z_owned_closure_hello_t *this_); /** * Drops the closure. Droping an uninitialized closure is a no-op. */ @@ -1705,12 +1661,6 @@ const struct z_loaned_closure_hello_t *z_closure_hello_loan(const struct z_owned */ ZENOHC_API struct z_loaned_closure_hello_t *z_closure_hello_loan_mut(struct z_owned_closure_hello_t *closure); -/** - * Takes ownership of the mutably borrowed closure - */ -ZENOHC_API -void z_closure_hello_take_loaned(struct z_owned_closure_hello_t *dst, - struct z_loaned_closure_hello_t *src); /** * @brief Constructs closure. * @@ -1736,10 +1686,6 @@ void z_closure_query(struct z_owned_closure_query_t *this_, ZENOHC_API void z_closure_query_call(const struct z_loaned_closure_query_t *closure, struct z_loaned_query_t *query); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_closure_query_check(const struct z_owned_closure_query_t *this_); /** * Drops the closure, resetting it to its gravestone state. */ @@ -1754,12 +1700,6 @@ const struct z_loaned_closure_query_t *z_closure_query_loan(const struct z_owned */ ZENOHC_API struct z_loaned_closure_query_t *z_closure_query_loan_mut(struct z_owned_closure_query_t *closure); -/** - * Takes ownership of the mutably borrowed closure - */ -ZENOHC_API -void z_closure_query_take_loaned(struct z_owned_closure_query_t *dst, - struct z_loaned_closure_query_t *src); /** * @brief Constructs closure. * @@ -1785,10 +1725,6 @@ void z_closure_reply(struct z_owned_closure_reply_t *this_, ZENOHC_API void z_closure_reply_call(const struct z_loaned_closure_reply_t *closure, struct z_loaned_reply_t *reply); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_closure_reply_check(const struct z_owned_closure_reply_t *this_); /** * Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. */ @@ -1804,12 +1740,6 @@ const struct z_loaned_closure_reply_t *z_closure_reply_loan(const struct z_owned */ ZENOHC_API struct z_loaned_closure_reply_t *z_closure_reply_loan_mut(struct z_owned_closure_reply_t *closure); -/** - * Takes ownership of the mutably borrowed closure - */ -ZENOHC_API -void z_closure_reply_take_loaned(struct z_owned_closure_reply_t *dst, - struct z_loaned_closure_reply_t *src); /** * @brief Constructs closure. * @@ -1835,10 +1765,6 @@ void z_closure_sample(struct z_owned_closure_sample_t *this_, ZENOHC_API void z_closure_sample_call(const struct z_loaned_closure_sample_t *closure, struct z_loaned_sample_t *sample); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_closure_sample_check(const struct z_owned_closure_sample_t *this_); /** * Drops the closure. Droping an uninitialized closure is a no-op. */ @@ -1853,12 +1779,6 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own */ ZENOHC_API struct z_loaned_closure_sample_t *z_closure_sample_loan_mut(struct z_owned_closure_sample_t *closure); -/** - * Takes ownership of the mutably borrowed closure - */ -ZENOHC_API -void z_closure_sample_take_loaned(struct z_owned_closure_sample_t *dst, - struct z_loaned_closure_sample_t *src); /** * @brief Constructs closure. * @@ -1884,10 +1804,6 @@ void z_closure_zid(struct z_owned_closure_zid_t *this_, ZENOHC_API void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure, const struct z_id_t *z_id); -/** - * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_closure_zid_check(const struct z_owned_closure_zid_t *this_); /** * @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized (null) closure is a no-op. */ @@ -1903,16 +1819,6 @@ const struct z_loaned_closure_zid_t *z_closure_zid_loan(const struct z_owned_clo */ ZENOHC_API struct z_loaned_closure_zid_t *z_closure_zid_loan_mut(struct z_owned_closure_zid_t *closure); -/** - * Takes ownership of the mutably borrowed closure - */ -ZENOHC_API -void z_closure_zid_take_loaned(struct z_owned_closure_zid_t *dst, - struct z_loaned_closure_zid_t *src); -/** - * Returns ``true`` if conditional variable is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_condvar_check(const struct z_owned_condvar_t *this_); /** * Drops conditional variable. */ @@ -1944,10 +1850,6 @@ ZENOHC_API z_result_t z_condvar_signal(const struct z_loaned_condvar_t *this_); ZENOHC_API z_result_t z_condvar_wait(const struct z_loaned_condvar_t *this_, struct z_loaned_mutex_t *m); -/** - * Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_config_check(const struct z_owned_config_t *this_); /** * Clones the config into provided uninitialized memory location. */ @@ -1968,10 +1870,6 @@ ZENOHC_API const struct z_loaned_config_t *z_config_loan(const struct z_owned_co * Mutably borrows config. */ ZENOHC_API struct z_loaned_config_t *z_config_loan_mut(struct z_owned_config_t *this_); -/** - * Takes ownership of the mutably borrowed config. - */ -ZENOHC_API void z_config_take_loaned(struct z_owned_config_t *dst, struct z_loaned_config_t *src); /** * Declares a background queryable for a given keyexpr. The queryable callback will be be called * to proccess incoming queries until the corresponding session is closed or dropped. @@ -2240,10 +2138,6 @@ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_audio_ogg(void); * Constant alias for string: `"audio/vorbis"`. */ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_audio_vorbis(void); -/** - * Returns ``true`` if encoding is in non-default state, ``false`` otherwise. - */ -ZENOHC_API bool z_encoding_check(const struct z_owned_encoding_t *this_); /** * Constructs an owned copy of the encoding in provided uninitilized memory location. */ @@ -2329,12 +2223,6 @@ ZENOHC_API z_result_t z_encoding_set_schema_from_substr(struct z_loaned_encoding_t *this_, const char *s, size_t len); -/** - * Takes ownership of the mutably borrowed encoding - */ -ZENOHC_API -void z_encoding_take_loaned(struct z_owned_encoding_t *dst, - struct z_loaned_encoding_t *src); /** * A CSS file. * @@ -2530,10 +2418,6 @@ ZENOHC_API void z_fifo_channel_sample_new(struct z_owned_closure_sample_t *callback, struct z_owned_fifo_handler_sample_t *handler, size_t capacity); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_fifo_handler_query_check(const struct z_owned_fifo_handler_query_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -2557,12 +2441,6 @@ struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan_mut(struct z_own ZENOHC_API z_result_t z_fifo_handler_query_recv(const struct z_loaned_fifo_handler_query_t *this_, struct z_owned_query_t *query); -/** - * Takes ownership of the mutably borrowed handler - */ -ZENOHC_API -void z_fifo_handler_query_take_loaned(struct z_owned_fifo_handler_query_t *dst, - struct z_loaned_fifo_handler_query_t *src); /** * Returns query from the fifo buffer. If there are no more pending queries will return immediately (with query set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -2571,10 +2449,6 @@ void z_fifo_handler_query_take_loaned(struct z_owned_fifo_handler_query_t *dst, ZENOHC_API z_result_t z_fifo_handler_query_try_recv(const struct z_loaned_fifo_handler_query_t *this_, struct z_owned_query_t *query); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_fifo_handler_reply_check(const struct z_owned_fifo_handler_reply_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -2597,12 +2471,6 @@ struct z_loaned_fifo_handler_reply_t *z_fifo_handler_reply_loan_mut(struct z_own ZENOHC_API z_result_t z_fifo_handler_reply_recv(const struct z_loaned_fifo_handler_reply_t *this_, struct z_owned_reply_t *reply); -/** - * Takes ownership of the mutably borrowed handler - */ -ZENOHC_API -void z_fifo_handler_reply_take_loaned(struct z_owned_fifo_handler_reply_t *dst, - struct z_loaned_fifo_handler_reply_t *src); /** * Returns reply from the fifo buffer. If there are no more pending replies will return immediately (with reply set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state), @@ -2611,10 +2479,6 @@ void z_fifo_handler_reply_take_loaned(struct z_owned_fifo_handler_reply_t *dst, ZENOHC_API z_result_t z_fifo_handler_reply_try_recv(const struct z_loaned_fifo_handler_reply_t *this_, struct z_owned_reply_t *reply); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_fifo_handler_sample_check(const struct z_owned_fifo_handler_sample_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -2637,12 +2501,6 @@ struct z_loaned_fifo_handler_sample_t *z_fifo_handler_sample_loan_mut(struct z_o ZENOHC_API z_result_t z_fifo_handler_sample_recv(const struct z_loaned_fifo_handler_sample_t *this_, struct z_owned_sample_t *sample); -/** - * Takes ownership of the mutably borrowed fifo_handler_sample - */ -ZENOHC_API -void z_fifo_handler_sample_take_loaned(struct z_owned_fifo_handler_sample_t *dst, - struct z_loaned_fifo_handler_sample_t *src); /** * Returns sample from the fifo buffer. * If there are no more pending replies will return immediately (with sample set to its gravestone state). @@ -2674,10 +2532,6 @@ z_result_t z_get(const struct z_loaned_session_t *session, * Constructs default `z_get_options_t` */ ZENOHC_API void z_get_options_default(struct z_get_options_t *this_); -/** - * Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_hello_check(const struct z_owned_hello_t *this_); /** * Constructs an owned copy of hello message. */ @@ -2748,20 +2602,42 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, * to pass it a valid session. */ ZENOHC_API struct z_id_t z_info_zid(const struct z_loaned_session_t *session); +/** + * Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API bool z_internal_alloc_layout_check(const z_owned_alloc_layout_t *this_); +#endif /** * Constructs Alloc Layout in its gravestone value. */ #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API void z_internal_alloc_layout_null(z_owned_alloc_layout_t *this_); #endif +/** + * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_internal_bytes_check(const struct z_owned_bytes_t *this_); /** * The gravestone value for `z_owned_bytes_t`. */ ZENOHC_API void z_internal_bytes_null(struct z_owned_bytes_t *this_); +/** + * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_internal_bytes_writer_check(const struct z_owned_bytes_writer_t *this_); /** * Constructs a writer in a gravestone state. */ ZENOHC_API void z_internal_bytes_writer_null(struct z_owned_bytes_writer_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_chunk_alloc_result_check(const z_owned_chunk_alloc_result_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs Chunk Alloc Result in its gravestone value. @@ -2770,58 +2646,121 @@ ZENOHC_API void z_internal_bytes_writer_null(struct z_owned_bytes_writer_t *this ZENOHC_API void z_internal_chunk_alloc_result_null(z_owned_chunk_alloc_result_t *this_); #endif +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_closure_hello_check(const struct z_owned_closure_hello_t *this_); /** * Constructs a closure in a gravestone state. */ ZENOHC_API void z_internal_closure_hello_null(struct z_owned_closure_hello_t *this_); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_closure_query_check(const struct z_owned_closure_query_t *this_); /** * Constructs a closure in its gravestone state. */ ZENOHC_API void z_internal_closure_query_null(struct z_owned_closure_query_t *this_); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_closure_reply_check(const struct z_owned_closure_reply_t *this_); /** * Constructs a closure int its gravestone state. */ ZENOHC_API void z_internal_closure_reply_null(struct z_owned_closure_reply_t *this_); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_closure_sample_check(const struct z_owned_closure_sample_t *this_); /** * Constructs a closure in its gravestone state. */ ZENOHC_API void z_internal_closure_sample_null(struct z_owned_closure_sample_t *this_); +/** + * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_closure_zid_check(const struct z_owned_closure_zid_t *this_); /** * @brief Constructs a null closure. */ ZENOHC_API void z_internal_closure_zid_null(struct z_owned_closure_zid_t *this_); +/** + * Returns ``true`` if conditional variable is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_condvar_check(const struct z_owned_condvar_t *this_); /** * Constructs conditional variable in a gravestone state. */ ZENOHC_API void z_internal_condvar_null(struct z_owned_condvar_t *this_); +/** + * Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_internal_config_check(const struct z_owned_config_t *this_); /** * Constructs config in its gravestone state. */ ZENOHC_API void z_internal_config_null(struct z_owned_config_t *this_); +/** + * Returns ``true`` if encoding is in non-default state, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_encoding_check(const struct z_owned_encoding_t *this_); /** * Constructs a default `z_owned_encoding_t`. */ ZENOHC_API void z_internal_encoding_null(struct z_owned_encoding_t *this_); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API +bool z_internal_fifo_handler_query_check(const struct z_owned_fifo_handler_query_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_fifo_handler_query_null(struct z_owned_fifo_handler_query_t *this_); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API +bool z_internal_fifo_handler_reply_check(const struct z_owned_fifo_handler_reply_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_fifo_handler_reply_null(struct z_owned_fifo_handler_reply_t *this_); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API +bool z_internal_fifo_handler_sample_check(const struct z_owned_fifo_handler_sample_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_fifo_handler_sample_null(struct z_owned_fifo_handler_sample_t *this_); +/** + * Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_internal_hello_check(const struct z_owned_hello_t *this_); /** * Constructs hello message in a gravestone state. */ ZENOHC_API void z_internal_hello_null(struct z_owned_hello_t *this_); +/** + * Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_keyexpr_check(const struct z_owned_keyexpr_t *this_); /** * Constructs an owned key expression in a gravestone state. */ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_memory_layout_check(const z_owned_memory_layout_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs Memory Layout in its gravestone value. @@ -2830,22 +2769,46 @@ ZENOHC_API void z_internal_keyexpr_null(struct z_owned_keyexpr_t *this_); ZENOHC_API void z_internal_memory_layout_null(z_owned_memory_layout_t *this_); #endif +/** + * Returns ``true`` if mutex is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_mutex_check(const struct z_owned_mutex_t *this_); /** * Constructs mutex in a gravestone state. */ ZENOHC_API void z_internal_mutex_null(struct z_owned_mutex_t *this_); +/** + * Returns ``true`` if publisher is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_publisher_check(const struct z_owned_publisher_t *this_); /** * Constructs a publisher in a gravestone state. */ ZENOHC_API void z_internal_publisher_null(struct z_owned_publisher_t *this_); +/** + * Returns `false` if `this` is in a gravestone state, `true` otherwise. + */ +ZENOHC_API bool z_internal_query_check(const struct z_owned_query_t *query); /** * Constructs query in its gravestone value. */ ZENOHC_API void z_internal_query_null(struct z_owned_query_t *this_); +/** + * Returns ``true`` if queryable is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_queryable_check(const struct z_owned_queryable_t *this_); /** * Constructs a queryable in its gravestone value. */ ZENOHC_API void z_internal_queryable_null(struct z_owned_queryable_t *this_); +/** + * Returns ``true`` if `reply` is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_reply_check(const struct z_owned_reply_t *this_); +/** + * Returns ``true`` if reply error is in non-default state, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_reply_err_check(const struct z_owned_reply_err_t *this_); /** * Constructs an empty `z_owned_reply_err_t`. */ @@ -2854,26 +2817,65 @@ ZENOHC_API void z_internal_reply_err_null(struct z_owned_reply_err_t *this_); * Constructs the reply in its gravestone state. */ ZENOHC_API void z_internal_reply_null(struct z_owned_reply_t *this_); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API +bool z_internal_ring_handler_query_check(const struct z_owned_ring_handler_query_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_ring_handler_query_null(struct z_owned_ring_handler_query_t *this_); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API +bool z_internal_ring_handler_reply_check(const struct z_owned_ring_handler_reply_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_ring_handler_reply_null(struct z_owned_ring_handler_reply_t *this_); +/** + * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API +bool z_internal_ring_handler_sample_check(const struct z_owned_ring_handler_sample_t *this_); /** * Constructs a handler in gravestone state. */ ZENOHC_API void z_internal_ring_handler_sample_null(struct z_owned_ring_handler_sample_t *this_); +/** + * Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_sample_check(const struct z_owned_sample_t *this_); /** * Constructs sample in its gravestone state. */ ZENOHC_API void z_internal_sample_null(struct z_owned_sample_t *this_); +/** + * Returns ``true`` if `session` is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_session_check(const struct z_owned_session_t *this_); /** * Constructs a Zenoh session in its gravestone state. */ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_shm_check(const z_owned_shm_t *this_); +#endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_shm_client_check(const z_owned_shm_client_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs SHM client in its gravestone value. @@ -2882,6 +2884,14 @@ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); ZENOHC_API void z_internal_shm_client_null(z_owned_shm_client_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * Constructs SHM Client Storage in its gravestone value. @@ -2890,6 +2900,14 @@ void z_internal_shm_client_null(z_owned_shm_client_t *this_); ZENOHC_API void z_internal_shm_client_storage_null(z_owned_shm_client_storage_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @return ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_shm_mut_check(const z_owned_shm_mut_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs ZShmMut slice in its gravestone value. @@ -2906,6 +2924,14 @@ void z_internal_shm_mut_null(z_owned_shm_mut_t *this_); ZENOHC_API void z_internal_shm_null(z_owned_shm_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool z_internal_shm_provider_check(const z_owned_shm_provider_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs SHM Provider in its gravestone value. @@ -2914,10 +2940,22 @@ void z_internal_shm_null(z_owned_shm_t *this_); ZENOHC_API void z_internal_shm_provider_null(z_owned_shm_provider_t *this_); #endif +/** + * @return ``true`` if slice is not empty, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_slice_check(const struct z_owned_slice_t *this_); /** * Constructs an empty `z_owned_slice_t`. */ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool z_internal_source_info_check(const z_owned_source_info_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs source info in its gravestone state. @@ -2926,18 +2964,34 @@ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); ZENOHC_API void z_internal_source_info_null(z_owned_source_info_t *this_); #endif +/** + * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. + */ +ZENOHC_API bool z_internal_string_array_check(const struct z_owned_string_array_t *this_); /** * Constructs string array in its gravestone state. */ ZENOHC_API void z_internal_string_array_null(struct z_owned_string_array_t *this_); +/** + * @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool z_internal_string_check(const struct z_owned_string_t *this_); /** * Constructs owned string in a gravestone state. */ ZENOHC_API void z_internal_string_null(struct z_owned_string_t *this_); +/** + * Returns ``true`` if subscriber is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_subscriber_check(const struct z_owned_subscriber_t *this_); /** * Constructs a subscriber in a gravestone state. */ ZENOHC_API void z_internal_subscriber_null(struct z_owned_subscriber_t *this_); +/** + * Returns ``true`` if task is valid, ``false`` otherwise. + */ +ZENOHC_API bool z_internal_task_check(const struct z_owned_task_t *this_); /** * Constructs task in a gravestone state. */ @@ -2968,10 +3022,6 @@ z_result_t z_keyexpr_canonize(char *start, */ ZENOHC_API z_result_t z_keyexpr_canonize_null_terminated(char *start); -/** - * Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_keyexpr_check(const struct z_owned_keyexpr_t *this_); /** * Constructs a copy of the key expression. */ @@ -3087,20 +3137,6 @@ ZENOHC_API enum z_keyexpr_intersection_level_t z_keyexpr_relation_to(const struct z_loaned_keyexpr_t *left, const struct z_loaned_keyexpr_t *right); #endif -/** - * Takes ownership of the mutably borrowed keyexpr - */ -ZENOHC_API -void z_keyexpr_take_loaned(struct z_owned_keyexpr_t *dst, - struct z_loaned_keyexpr_t *src); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_memory_layout_check(const z_owned_memory_layout_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes Memory Layout. @@ -3137,10 +3173,6 @@ z_result_t z_memory_layout_new(z_owned_memory_layout_t *this_, size_t size, struct z_alloc_alignment_t alignment); #endif -/** - * Returns ``true`` if mutex is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_mutex_check(const struct z_owned_mutex_t *this_); /** * Drops mutex and resets it to its gravestone state. */ @@ -3159,10 +3191,6 @@ ZENOHC_API struct z_loaned_mutex_t *z_mutex_loan_mut(struct z_owned_mutex_t *thi * @return 0 in case of success, negative error code in case of failure. */ ZENOHC_API z_result_t z_mutex_lock(struct z_loaned_mutex_t *this_); -/** - * Takes ownership of the mutably borrowed mutex - */ -ZENOHC_API void z_mutex_take_loaned(struct z_owned_mutex_t *dst, struct z_loaned_mutex_t *src); /** * Tries to lock mutex. If mutex is already locked, return immediately. * @return 0 in case of success, negative value if failed to aquire the lock. @@ -3220,10 +3248,6 @@ z_result_t z_posix_shm_provider_new(z_owned_shm_provider_t *this_, * Returns the default value of #z_priority_t. */ ZENOHC_API enum z_priority_t z_priority_default(void); -/** - * Returns ``true`` if publisher is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_publisher_check(const struct z_owned_publisher_t *this_); /** * Sends a `DELETE` message onto the publisher's key expression. * @@ -3287,12 +3311,6 @@ z_result_t z_publisher_put(const struct z_loaned_publisher_t *this_, * Constructs the default value for `z_publisher_put_options_t`. */ ZENOHC_API void z_publisher_put_options_default(struct z_publisher_put_options_t *this_); -/** - * Takes ownership of the mutably borrowed publisher - */ -ZENOHC_API -void z_publisher_take_loaned(struct z_owned_publisher_t *dst, - struct z_loaned_publisher_t *src); /** * Publishes data on specified key expression. * @@ -3318,10 +3336,6 @@ ZENOHC_API void z_put_options_default(struct z_put_options_t *this_); * Returns NULL if query does not contain an attachment. */ ZENOHC_API const struct z_loaned_bytes_t *z_query_attachment(const struct z_loaned_query_t *this_); -/** - * Returns `false` if `this` is in a gravestone state, `true` otherwise. - */ -ZENOHC_API bool z_query_check(const struct z_owned_query_t *query); /** * Constructs a shallow copy of the query, allowing to keep it in an "open" state past the callback's return. * @@ -3475,10 +3489,6 @@ ZENOHC_API void z_query_take_loaned(struct z_owned_query_t *dst, struct z_loaned * Create a default `z_query_target_t`. */ ZENOHC_API enum z_query_target_t z_query_target_default(void); -/** - * Returns ``true`` if queryable is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_queryable_check(const struct z_owned_queryable_t *this_); /** * Undeclares queryable callback and resets it to its gravestone state. * This is equivalent to calling `z_undeclare_queryable()` and discarding its return value. @@ -3499,12 +3509,6 @@ ZENOHC_API struct z_loaned_queryable_t *z_queryable_loan_mut(struct z_owned_quer * Constructs the default value for `z_query_reply_options_t`. */ ZENOHC_API void z_queryable_options_default(struct z_queryable_options_t *this_); -/** - * Takes ownership of the mutably borrowed queryable - */ -ZENOHC_API -void z_queryable_take_loaned(struct z_owned_queryable_t *dst, - struct z_loaned_queryable_t *src); /** * Fills buffer with random data. */ @@ -3540,10 +3544,6 @@ void z_ref_shm_client_storage_global(z_owned_shm_client_storage_t *this_); ZENOHC_API enum z_reliability_t z_reliability_default(void); #endif -/** - * Returns ``true`` if `reply` is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_reply_check(const struct z_owned_reply_t *this_); /** * Constructs an owned shallow copy of reply in provided uninitialized memory location. */ @@ -3558,10 +3558,6 @@ ZENOHC_API void z_reply_drop(struct z_moved_reply_t *this_); * Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). */ ZENOHC_API const struct z_loaned_reply_err_t *z_reply_err(const struct z_loaned_reply_t *this_); -/** - * Returns ``true`` if reply error is in non-default state, ``false`` otherwise. - */ -ZENOHC_API bool z_reply_err_check(const struct z_owned_reply_err_t *this_); /** * Constructs a copy of the reply error message. */ @@ -3591,12 +3587,6 @@ ZENOHC_API struct z_loaned_reply_err_t *z_reply_err_loan_mut(struct z_owned_repl */ ZENOHC_API const struct z_loaned_bytes_t *z_reply_err_payload(const struct z_loaned_reply_err_t *this_); -/** - * Takes ownership of the mutably borrowed reply error - */ -ZENOHC_API -void z_reply_err_take_loaned(struct z_owned_reply_err_t *dst, - struct z_loaned_reply_err_t *src); /** * Returns ``true`` if reply contains a valid response, ``false`` otherwise (in this case it contains a errror value). */ @@ -3651,10 +3641,6 @@ ZENOHC_API void z_ring_channel_sample_new(struct z_owned_closure_sample_t *callback, struct z_owned_ring_handler_sample_t *handler, size_t capacity); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_ring_handler_query_check(const struct z_owned_ring_handler_query_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -3677,12 +3663,6 @@ struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan_mut(struct z_own ZENOHC_API z_result_t z_ring_handler_query_recv(const struct z_loaned_ring_handler_query_t *this_, struct z_owned_query_t *query); -/** - * Takes ownership of the mutably borrowed handler - */ -ZENOHC_API -void z_ring_handler_query_take_loaned(struct z_owned_ring_handler_query_t *dst, - struct z_loaned_ring_handler_query_t *src); /** * Returns query from the ring buffer. If there are no more pending queries will return immediately (with query set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -3691,10 +3671,6 @@ void z_ring_handler_query_take_loaned(struct z_owned_ring_handler_query_t *dst, ZENOHC_API z_result_t z_ring_handler_query_try_recv(const struct z_loaned_ring_handler_query_t *this_, struct z_owned_query_t *query); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_ring_handler_reply_check(const struct z_owned_ring_handler_reply_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -3717,12 +3693,6 @@ struct z_loaned_ring_handler_reply_t *z_ring_handler_reply_loan_mut(struct z_own ZENOHC_API z_result_t z_ring_handler_reply_recv(const struct z_loaned_ring_handler_reply_t *this_, struct z_owned_reply_t *reply); -/** - * Takes ownership of the mutably borrowed handler - */ -ZENOHC_API -void z_ring_handler_reply_take_loaned(struct z_owned_ring_handler_reply_t *dst, - struct z_loaned_ring_handler_reply_t *src); /** * Returns reply from the ring buffer. If there are no more pending replies will return immediately (with reply set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state), @@ -3731,10 +3701,6 @@ void z_ring_handler_reply_take_loaned(struct z_owned_ring_handler_reply_t *dst, ZENOHC_API z_result_t z_ring_handler_reply_try_recv(const struct z_loaned_ring_handler_reply_t *this_, struct z_owned_reply_t *reply); -/** - * Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_ring_handler_sample_check(const struct z_owned_ring_handler_sample_t *this_); /** * Drops the handler and resets it to a gravestone state. */ @@ -3757,12 +3723,6 @@ struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan_mut(struct z_o ZENOHC_API z_result_t z_ring_handler_sample_recv(const struct z_loaned_ring_handler_sample_t *this_, struct z_owned_sample_t *sample); -/** - * Takes ownership of the mutably borrowed handler - */ -ZENOHC_API -void z_ring_handler_sample_take_loaned(struct z_owned_ring_handler_sample_t *dst, - struct z_loaned_ring_handler_sample_t *src); /** * Returns sample from the ring buffer. If there are no more pending replies will return immediately (with sample set to its gravestone state). * @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state), @@ -3778,10 +3738,6 @@ z_result_t z_ring_handler_sample_try_recv(const struct z_loaned_ring_handler_sam */ ZENOHC_API const struct z_loaned_bytes_t *z_sample_attachment(const struct z_loaned_sample_t *this_); -/** - * Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_sample_check(const struct z_owned_sample_t *this_); /** * Constructs an owned shallow copy of the sample (i.e. all modficiations applied to the copy, might be visible in the original) in provided uninitilized memory location. */ @@ -3873,10 +3829,6 @@ z_result_t z_scout(struct z_moved_config_t *config, * Constructs the default values for the scouting operation. */ ZENOHC_API void z_scout_options_default(struct z_scout_options_t *this_); -/** - * Returns ``true`` if `session` is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_session_check(const struct z_owned_session_t *this_); /** * Closes and invalidates the session. */ @@ -3895,28 +3847,6 @@ ZENOHC_API const struct z_loaned_session_t *z_session_loan(const struct z_owned_ * Mutably borrows session. */ ZENOHC_API struct z_loaned_session_t *z_session_loan_mut(struct z_owned_session_t *this_); -/** - * Takes ownership of the mutably borrowed session - */ -ZENOHC_API -void z_session_take_loaned(struct z_owned_session_t *dst, - struct z_loaned_session_t *src); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_shm_check(const z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_shm_client_check(const z_owned_shm_client_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes SHM Client. @@ -3935,14 +3865,6 @@ void z_shm_client_new(z_owned_shm_client_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_client_callbacks_t callbacks); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_shm_client_storage_check(const z_owned_shm_client_storage_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Performs a shallow copy of SHM Client Storage. @@ -3992,15 +3914,6 @@ z_result_t z_shm_client_storage_new(z_owned_shm_client_storage_t *this_, ZENOHC_API void z_shm_client_storage_new_default(z_owned_shm_client_storage_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Takes ownership of the mutably borrowed SHM Client Storage. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_client_storage_take_loaned(z_owned_shm_client_storage_t *dst, - z_loaned_shm_client_storage_t *src); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Converts borrowed ZShm slice to owned ZShm slice by performing a shallow SHM reference copy. @@ -4057,14 +3970,6 @@ const z_loaned_shm_t *z_shm_loan(const z_owned_shm_t *this_); #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API z_loaned_shm_t *z_shm_loan_mut(z_owned_shm_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_shm_mut_check(const z_owned_shm_mut_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @return the immutable pointer to the underlying data. @@ -4113,12 +4018,6 @@ const z_loaned_shm_mut_t *z_shm_mut_loan(const z_owned_shm_mut_t *this_); ZENOHC_API z_loaned_shm_mut_t *z_shm_mut_loan_mut(z_owned_shm_mut_t *this_); #endif -/** - * Takes ownership of the mutably borrowed shm_mut - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_shm_mut_take_loaned(z_owned_shm_mut_t *dst, z_loaned_shm_mut_t *src); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Tries to obtain mutable SHM buffer instead of immutable one. @@ -4205,14 +4104,6 @@ void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t * ZENOHC_API size_t z_shm_provider_available(const z_loaned_shm_provider_t *provider); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_shm_provider_check(const z_owned_shm_provider_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ @@ -4272,14 +4163,6 @@ void z_shm_provider_new(z_owned_shm_provider_t *this_, struct zc_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); #endif -/** - * Takes ownership of the mutably borrowed SHM Provider - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_take_loaned(z_owned_shm_provider_t *dst, - z_loaned_shm_provider_t *src); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Creates a new threadsafe SHM Provider. @@ -4291,12 +4174,6 @@ void z_shm_provider_threadsafe_new(z_owned_shm_provider_t *this_, struct zc_threadsafe_context_t context, struct zc_shm_provider_backend_callbacks_t callbacks); #endif -/** - * Takes ownership of the mutably borrowed shm - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API void z_shm_take_loaned(z_owned_shm_t *dst, z_loaned_shm_t *src); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. @@ -4325,10 +4202,6 @@ ZENOHC_API z_result_t z_sleep_s(size_t time); * Puts current thread to sleep for specified amount of microseconds. */ ZENOHC_API z_result_t z_sleep_us(size_t time); -/** - * @return ``true`` if slice is not empty, ``false`` otherwise. - */ -ZENOHC_API bool z_slice_check(const struct z_owned_slice_t *this_); /** * Constructs an owned copy of a slice. */ @@ -4386,18 +4259,6 @@ ZENOHC_API const struct z_loaned_slice_t *z_slice_loan(const struct z_owned_slic * Mutably borrows slice. */ ZENOHC_API struct z_loaned_slice_t *z_slice_loan_mut(struct z_owned_slice_t *this_); -/** - * Takes ownership of mutably borrowed slice - */ -ZENOHC_API void z_slice_take_loaned(struct z_owned_slice_t *dst, struct z_loaned_slice_t *src); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool z_source_info_check(const z_owned_source_info_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. @@ -4448,19 +4309,6 @@ z_result_t z_source_info_new(z_owned_source_info_t *this_, ZENOHC_API uint32_t z_source_info_sn(const z_loaned_source_info_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Takes ownership of the mutably borrowed source info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void z_source_info_take_loaned(z_owned_source_info_t *dst, - z_loaned_source_info_t *src); -#endif -/** - * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool z_string_array_check(const struct z_owned_string_array_t *this_); /** * Constructs an owned copy of a string array. */ @@ -4517,17 +4365,7 @@ size_t z_string_array_push_by_alias(struct z_loaned_string_array_t *this_, ZENOHC_API size_t z_string_array_push_by_copy(struct z_loaned_string_array_t *this_, const struct z_loaned_string_t *value); -/** - * Takes ownership of mutably borrowed string array. - */ -ZENOHC_API -void z_string_array_take_loaned(struct z_owned_string_array_t *dst, - struct z_loaned_string_array_t *src); ZENOHC_API const struct z_loaned_slice_t *z_string_as_slice(const struct z_loaned_string_t *this_); -/** - * @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool z_string_check(const struct z_owned_string_t *this_); /** * Constructs an owned copy of a string. */ @@ -4590,14 +4428,6 @@ ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_st * Mutably borrows string. */ ZENOHC_API struct z_loaned_string_t *z_string_loan_mut(struct z_owned_string_t *this_); -/** - * Takes ownership of mutably borrowed string. - */ -ZENOHC_API void z_string_take_loaned(struct z_owned_string_t *dst, struct z_loaned_string_t *src); -/** - * Returns ``true`` if subscriber is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_subscriber_check(const struct z_owned_subscriber_t *this_); /** * Undeclares subscriber callback and resets it to its gravestone state. * This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value. @@ -4621,16 +4451,6 @@ ZENOHC_API struct z_loaned_subscriber_t *z_subscriber_loan_mut(struct z_owned_su * Constructs the default value for `z_subscriber_options_t`. */ ZENOHC_API void z_subscriber_options_default(struct z_subscriber_options_t *this_); -/** - * Takes ownership of the mutably borrowed subscriber - */ -ZENOHC_API -void z_subscriber_take_loaned(struct z_owned_subscriber_t *dst, - struct z_loaned_subscriber_t *src); -/** - * Returns ``true`` if task is valid, ``false`` otherwise. - */ -ZENOHC_API bool z_task_check(const struct z_owned_task_t *this_); /** * Detaches the task and releases all allocated resources. */ @@ -4916,10 +4736,6 @@ ZENOHC_API void zc_closure_log_call(const struct zc_loaned_closure_log_t *closure, enum zc_log_severity_t severity, const struct z_loaned_string_t *msg); -/** - * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -ZENOHC_API bool zc_closure_log_check(const struct zc_owned_closure_log_t *this_); /** * Drops the closure. Droping an uninitialized closure is a no-op. */ @@ -4961,14 +4777,6 @@ ZENOHC_API void zc_closure_matching_status_call(const struct zc_loaned_closure_matching_status_t *closure, const struct zc_matching_status_t *mathing_status); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_closure_matching_status_check(const struct zc_owned_closure_matching_status_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. @@ -5071,10 +4879,22 @@ z_result_t zc_init_log_from_env_or(const char *fallback_filter); ZENOHC_API void zc_init_log_with_callback(enum zc_log_severity_t min_severity, struct zc_moved_closure_log_t *callback); +/** + * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +ZENOHC_API bool zc_internal_closure_log_check(const struct zc_owned_closure_log_t *this_); /** * Constructs a closure in a gravestone state. */ ZENOHC_API void zc_internal_closure_log_null(struct zc_owned_closure_log_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool zc_internal_closure_matching_status_check(const struct zc_owned_closure_matching_status_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs a null value of 'zc_owned_closure_matching_status_t' type @@ -5083,6 +4903,14 @@ ZENOHC_API void zc_internal_closure_log_null(struct zc_owned_closure_log_t *this ZENOHC_API void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_status_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool zc_internal_liveliness_token_check(const zc_owned_liveliness_token_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs liveliness token in its gravestone state. @@ -5091,6 +4919,14 @@ void zc_internal_closure_matching_status_null(struct zc_owned_closure_matching_s ZENOHC_API void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Checks the matching listener is for the gravestone state + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool zc_internal_matching_listener_check(const zc_owned_matching_listener_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs an empty matching listener. @@ -5099,6 +4935,14 @@ void zc_internal_liveliness_token_null(zc_owned_liveliness_token_t *this_); ZENOHC_API void zc_internal_matching_listener_null(zc_owned_matching_listener_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if `this` is valid. + */ +#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) +ZENOHC_API +bool zc_internal_shm_client_list_check(const zc_owned_shm_client_list_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs SHM client list in its gravestone value. @@ -5204,14 +5048,6 @@ void zc_liveliness_get_options_default(struct zc_liveliness_get_options_t *this_ ZENOHC_API void zc_liveliness_subscriber_options_default(struct zc_liveliness_subscriber_options_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_liveliness_token_check(const zc_owned_liveliness_token_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Undeclares liveliness token, frees memory and resets it to a gravestone state. @@ -5244,14 +5080,6 @@ z_result_t zc_liveliness_undeclare_token(zc_moved_liveliness_token_t *this_); ZENOHC_API enum zc_locality_t zc_locality_default(void); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Checks the matching listener is for the gravestone state - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_matching_listener_check(const zc_owned_matching_listener_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Declares a matching listener, registering a callback for notifying subscribers matching with a given publisher. @@ -5319,14 +5147,6 @@ z_result_t zc_shm_client_list_add_client(zc_loaned_shm_client_list_t *this_, z_protocol_id_t id, z_moved_shm_client_t *client); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool zc_shm_client_list_check(const zc_owned_shm_client_list_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Deletes list of SHM Clients. @@ -5622,6 +5442,14 @@ struct ze_deserializer_t ze_deserializer_from_bytes(const struct z_loaned_bytes_ * @return `true` if there is no more data to parse, `false` otherwise. */ ZENOHC_API bool ze_deserializer_is_done(const struct ze_deserializer_t *this_); +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool ze_internal_publication_cache_check(const ze_owned_publication_cache_t *this_); +#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs a publication cache in a gravestone state. @@ -5630,6 +5458,14 @@ ZENOHC_API bool ze_deserializer_is_done(const struct ze_deserializer_t *this_); ZENOHC_API void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); #endif +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. + */ +#if defined(Z_FEATURE_UNSTABLE_API) +ZENOHC_API +bool ze_internal_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); +#endif /** * Constructs a querying subscriber in a gravestone state. */ @@ -5637,17 +5473,13 @@ void ze_internal_publication_cache_null(ze_owned_publication_cache_t *this_); ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_); #endif /** - * @brief Constructs a serializer in a gravestone state. + * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. */ -ZENOHC_API void ze_internal_serializer_null(struct ze_owned_serializer_t *this_); +ZENOHC_API bool ze_internal_serializer_check(const struct ze_owned_serializer_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. + * @brief Constructs a serializer in a gravestone state. */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_publication_cache_check(const ze_owned_publication_cache_t *this_); -#endif +ZENOHC_API void ze_internal_serializer_null(struct ze_owned_serializer_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Drops publication cache and resets it to its gravestone state. @@ -5681,14 +5513,6 @@ const ze_loaned_publication_cache_t *ze_publication_cache_loan(const ze_owned_pu ZENOHC_API void ze_publication_cache_options_default(struct ze_publication_cache_options_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_querying_subscriber_check(const ze_owned_querying_subscriber_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Undeclares querying subscriber callback and resets it to its gravestone state. @@ -5813,10 +5637,6 @@ ZENOHC_API z_result_t ze_serialize_uint64(struct z_owned_bytes_t *this_, uint64_ * @brief Serializes an unsigned integer. */ ZENOHC_API z_result_t ze_serialize_uint8(struct z_owned_bytes_t *this_, uint8_t val); -/** - * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. - */ -ZENOHC_API bool ze_serializer_check(const struct ze_owned_serializer_t *this_); /** * @brief Drops `this_`, resetting it to gravestone value. */ diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 8365389d9..7c0725f67 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -259,107 +259,77 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser #define z_take(this_, x) \ - _Generic((x), \ - z_moved_bytes_t* : z_bytes_take, \ - z_moved_bytes_writer_t* : z_bytes_writer_take, \ - z_moved_closure_hello_t* : z_closure_hello_take, \ - z_moved_closure_query_t* : z_closure_query_take, \ - z_moved_closure_reply_t* : z_closure_reply_take, \ - z_moved_closure_sample_t* : z_closure_sample_take, \ - z_moved_closure_zid_t* : z_closure_zid_take, \ - z_moved_condvar_t* : z_condvar_take, \ - z_moved_config_t* : z_config_take, \ - z_moved_encoding_t* : z_encoding_take, \ - z_moved_fifo_handler_query_t* : z_fifo_handler_query_take, \ - z_moved_fifo_handler_reply_t* : z_fifo_handler_reply_take, \ - z_moved_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ - z_moved_hello_t* : z_hello_take, \ - z_moved_keyexpr_t* : z_keyexpr_take, \ - z_moved_mutex_t* : z_mutex_take, \ - z_moved_publisher_t* : z_publisher_take, \ - z_moved_query_t* : z_query_take, \ - z_moved_queryable_t* : z_queryable_take, \ - z_moved_reply_t* : z_reply_take, \ - z_moved_reply_err_t* : z_reply_err_take, \ - z_moved_ring_handler_query_t* : z_ring_handler_query_take, \ - z_moved_ring_handler_reply_t* : z_ring_handler_reply_take, \ - z_moved_ring_handler_sample_t* : z_ring_handler_sample_take, \ - z_moved_sample_t* : z_sample_take, \ - z_moved_session_t* : z_session_take, \ - z_moved_slice_t* : z_slice_take, \ - z_moved_string_array_t* : z_string_array_take, \ - z_moved_string_t* : z_string_take, \ - z_moved_subscriber_t* : z_subscriber_take, \ - z_moved_task_t* : z_task_take, \ - zc_moved_closure_log_t* : zc_closure_log_take, \ - ze_moved_serializer_t* : ze_serializer_take, \ - z_loaned_bytes_t* : z_bytes_take_loaned, \ - z_loaned_bytes_writer_t* : z_bytes_writer_take_loaned, \ - z_loaned_closure_hello_t* : z_closure_hello_take_loaned, \ - z_loaned_closure_query_t* : z_closure_query_take_loaned, \ - z_loaned_closure_reply_t* : z_closure_reply_take_loaned, \ - z_loaned_closure_sample_t* : z_closure_sample_take_loaned, \ - z_loaned_closure_zid_t* : z_closure_zid_take_loaned, \ - z_loaned_config_t* : z_config_take_loaned, \ - z_loaned_encoding_t* : z_encoding_take_loaned, \ - z_loaned_fifo_handler_query_t* : z_fifo_handler_query_take_loaned, \ - z_loaned_fifo_handler_reply_t* : z_fifo_handler_reply_take_loaned, \ - z_loaned_fifo_handler_sample_t* : z_fifo_handler_sample_take_loaned, \ - z_loaned_hello_t* : z_hello_take_loaned, \ - z_loaned_keyexpr_t* : z_keyexpr_take_loaned, \ - z_loaned_mutex_t* : z_mutex_take_loaned, \ - z_loaned_publisher_t* : z_publisher_take_loaned, \ - z_loaned_query_t* : z_query_take_loaned, \ - z_loaned_queryable_t* : z_queryable_take_loaned, \ - z_loaned_reply_err_t* : z_reply_err_take_loaned, \ - z_loaned_reply_t* : z_reply_take_loaned, \ - z_loaned_ring_handler_query_t* : z_ring_handler_query_take_loaned, \ - z_loaned_ring_handler_reply_t* : z_ring_handler_reply_take_loaned, \ - z_loaned_ring_handler_sample_t* : z_ring_handler_sample_take_loaned, \ - z_loaned_sample_t* : z_sample_take_loaned, \ - z_loaned_session_t* : z_session_take_loaned, \ - z_loaned_slice_t* : z_slice_take_loaned, \ - z_loaned_string_array_t* : z_string_array_take_loaned, \ - z_loaned_string_t* : z_string_take_loaned, \ - z_loaned_subscriber_t* : z_subscriber_take_loaned, \ - ze_loaned_serializer_t* : ze_serializer_take_loaned \ + _Generic((this_), \ + z_owned_bytes_t* : z_bytes_take, \ + z_owned_bytes_writer_t* : z_bytes_writer_take, \ + z_owned_closure_hello_t* : z_closure_hello_take, \ + z_owned_closure_query_t* : z_closure_query_take, \ + z_owned_closure_reply_t* : z_closure_reply_take, \ + z_owned_closure_sample_t* : z_closure_sample_take, \ + z_owned_closure_zid_t* : z_closure_zid_take, \ + z_owned_condvar_t* : z_condvar_take, \ + z_owned_config_t* : z_config_take, \ + z_owned_encoding_t* : z_encoding_take, \ + z_owned_fifo_handler_query_t* : z_fifo_handler_query_take, \ + z_owned_fifo_handler_reply_t* : z_fifo_handler_reply_take, \ + z_owned_fifo_handler_sample_t* : z_fifo_handler_sample_take, \ + z_owned_hello_t* : z_hello_take, \ + z_owned_keyexpr_t* : z_keyexpr_take, \ + z_owned_mutex_t* : z_mutex_take, \ + z_owned_publisher_t* : z_publisher_take, \ + z_owned_query_t* : z_query_take, \ + z_owned_queryable_t* : z_queryable_take, \ + z_owned_reply_t* : z_reply_take, \ + z_owned_reply_err_t* : z_reply_err_take, \ + z_owned_ring_handler_query_t* : z_ring_handler_query_take, \ + z_owned_ring_handler_reply_t* : z_ring_handler_reply_take, \ + z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ + z_owned_sample_t* : z_sample_take, \ + z_owned_session_t* : z_session_take, \ + z_owned_slice_t* : z_slice_take, \ + z_owned_string_array_t* : z_string_array_take, \ + z_owned_string_t* : z_string_take, \ + z_owned_subscriber_t* : z_subscriber_take, \ + z_owned_task_t* : z_task_take, \ + zc_owned_closure_log_t* : zc_closure_log_take, \ + ze_owned_serializer_t* : ze_serializer_take \ )(this_, x) -#define z_check(this_) \ +#define z_internal_check(this_) \ _Generic((this_), \ - z_owned_bytes_t : z_bytes_check, \ - z_owned_bytes_writer_t : z_bytes_writer_check, \ - z_owned_closure_hello_t : z_closure_hello_check, \ - z_owned_closure_query_t : z_closure_query_check, \ - z_owned_closure_reply_t : z_closure_reply_check, \ - z_owned_closure_sample_t : z_closure_sample_check, \ - z_owned_closure_zid_t : z_closure_zid_check, \ - z_owned_condvar_t : z_condvar_check, \ - z_owned_config_t : z_config_check, \ - z_owned_encoding_t : z_encoding_check, \ - z_owned_fifo_handler_query_t : z_fifo_handler_query_check, \ - z_owned_fifo_handler_reply_t : z_fifo_handler_reply_check, \ - z_owned_fifo_handler_sample_t : z_fifo_handler_sample_check, \ - z_owned_hello_t : z_hello_check, \ - z_owned_keyexpr_t : z_keyexpr_check, \ - z_owned_mutex_t : z_mutex_check, \ - z_owned_publisher_t : z_publisher_check, \ - z_owned_query_t : z_query_check, \ - z_owned_queryable_t : z_queryable_check, \ - z_owned_reply_t : z_reply_check, \ - z_owned_reply_err_t : z_reply_err_check, \ - z_owned_ring_handler_query_t : z_ring_handler_query_check, \ - z_owned_ring_handler_reply_t : z_ring_handler_reply_check, \ - z_owned_ring_handler_sample_t : z_ring_handler_sample_check, \ - z_owned_sample_t : z_sample_check, \ - z_owned_session_t : z_session_check, \ - z_owned_slice_t : z_slice_check, \ - z_owned_string_array_t : z_string_array_check, \ - z_owned_string_t : z_string_check, \ - z_owned_subscriber_t : z_subscriber_check, \ - z_owned_task_t : z_task_check, \ - zc_owned_closure_log_t : zc_closure_log_check, \ - ze_owned_serializer_t : ze_serializer_check \ + z_owned_bytes_t : z_internal_bytes_check, \ + z_owned_bytes_writer_t : z_internal_bytes_writer_check, \ + z_owned_closure_hello_t : z_internal_closure_hello_check, \ + z_owned_closure_query_t : z_internal_closure_query_check, \ + z_owned_closure_reply_t : z_internal_closure_reply_check, \ + z_owned_closure_sample_t : z_internal_closure_sample_check, \ + z_owned_closure_zid_t : z_internal_closure_zid_check, \ + z_owned_condvar_t : z_internal_condvar_check, \ + z_owned_config_t : z_internal_config_check, \ + z_owned_encoding_t : z_internal_encoding_check, \ + z_owned_fifo_handler_query_t : z_internal_fifo_handler_query_check, \ + z_owned_fifo_handler_reply_t : z_internal_fifo_handler_reply_check, \ + z_owned_fifo_handler_sample_t : z_internal_fifo_handler_sample_check, \ + z_owned_hello_t : z_internal_hello_check, \ + z_owned_keyexpr_t : z_internal_keyexpr_check, \ + z_owned_mutex_t : z_internal_mutex_check, \ + z_owned_publisher_t : z_internal_publisher_check, \ + z_owned_query_t : z_internal_query_check, \ + z_owned_queryable_t : z_internal_queryable_check, \ + z_owned_reply_t : z_internal_reply_check, \ + z_owned_reply_err_t : z_internal_reply_err_check, \ + z_owned_ring_handler_query_t : z_internal_ring_handler_query_check, \ + z_owned_ring_handler_reply_t : z_internal_ring_handler_reply_check, \ + z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ + z_owned_sample_t : z_internal_sample_check, \ + z_owned_session_t : z_internal_session_check, \ + z_owned_slice_t : z_internal_slice_check, \ + z_owned_string_array_t : z_internal_string_array_check, \ + z_owned_string_t : z_internal_string_check, \ + z_owned_subscriber_t : z_internal_subscriber_check, \ + z_owned_task_t : z_internal_task_check, \ + zc_owned_closure_log_t : zc_internal_closure_log_check, \ + ze_owned_serializer_t : ze_internal_serializer_check \ )(&this_) #define z_call(closure, hello) \ @@ -771,131 +741,41 @@ inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) inline void z_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { ze_serializer_take(this_, x); }; -inline void z_take(z_owned_bytes_t* dst, z_loaned_bytes_t* src) { - z_bytes_take_loaned(dst, src); -}; -inline void z_take(z_owned_bytes_writer_t* dst, z_loaned_bytes_writer_t* src) { - z_bytes_writer_take_loaned(dst, src); -}; -inline void z_take(z_owned_closure_hello_t* dst, z_loaned_closure_hello_t* src) { - z_closure_hello_take_loaned(dst, src); -}; -inline void z_take(z_owned_closure_query_t* dst, z_loaned_closure_query_t* src) { - z_closure_query_take_loaned(dst, src); -}; -inline void z_take(z_owned_closure_reply_t* dst, z_loaned_closure_reply_t* src) { - z_closure_reply_take_loaned(dst, src); -}; -inline void z_take(z_owned_closure_sample_t* dst, z_loaned_closure_sample_t* src) { - z_closure_sample_take_loaned(dst, src); -}; -inline void z_take(z_owned_closure_zid_t* dst, z_loaned_closure_zid_t* src) { - z_closure_zid_take_loaned(dst, src); -}; -inline void z_take(z_owned_config_t* dst, z_loaned_config_t* src) { - z_config_take_loaned(dst, src); -}; -inline void z_take(z_owned_encoding_t* dst, z_loaned_encoding_t* src) { - z_encoding_take_loaned(dst, src); -}; -inline void z_take(z_owned_fifo_handler_query_t* dst, z_loaned_fifo_handler_query_t* src) { - z_fifo_handler_query_take_loaned(dst, src); -}; -inline void z_take(z_owned_fifo_handler_reply_t* dst, z_loaned_fifo_handler_reply_t* src) { - z_fifo_handler_reply_take_loaned(dst, src); -}; -inline void z_take(z_owned_fifo_handler_sample_t* dst, z_loaned_fifo_handler_sample_t* src) { - z_fifo_handler_sample_take_loaned(dst, src); -}; -inline void z_take(z_owned_hello_t* dst, z_loaned_hello_t* src) { - z_hello_take_loaned(dst, src); -}; -inline void z_take(z_owned_keyexpr_t* dst, z_loaned_keyexpr_t* src) { - z_keyexpr_take_loaned(dst, src); -}; -inline void z_take(z_owned_mutex_t* dst, z_loaned_mutex_t* src) { - z_mutex_take_loaned(dst, src); -}; -inline void z_take(z_owned_publisher_t* dst, z_loaned_publisher_t* src) { - z_publisher_take_loaned(dst, src); -}; -inline void z_take(z_owned_query_t* dst, z_loaned_query_t* src) { - z_query_take_loaned(dst, src); -}; -inline void z_take(z_owned_queryable_t* dst, z_loaned_queryable_t* src) { - z_queryable_take_loaned(dst, src); -}; -inline void z_take(z_owned_reply_err_t* dst, z_loaned_reply_err_t* src) { - z_reply_err_take_loaned(dst, src); -}; -inline void z_take(z_owned_reply_t* dst, z_loaned_reply_t* src) { - z_reply_take_loaned(dst, src); -}; -inline void z_take(z_owned_ring_handler_query_t* dst, z_loaned_ring_handler_query_t* src) { - z_ring_handler_query_take_loaned(dst, src); -}; -inline void z_take(z_owned_ring_handler_reply_t* dst, z_loaned_ring_handler_reply_t* src) { - z_ring_handler_reply_take_loaned(dst, src); -}; -inline void z_take(z_owned_ring_handler_sample_t* dst, z_loaned_ring_handler_sample_t* src) { - z_ring_handler_sample_take_loaned(dst, src); -}; -inline void z_take(z_owned_sample_t* dst, z_loaned_sample_t* src) { - z_sample_take_loaned(dst, src); -}; -inline void z_take(z_owned_session_t* dst, z_loaned_session_t* src) { - z_session_take_loaned(dst, src); -}; -inline void z_take(z_owned_slice_t* dst, z_loaned_slice_t* src) { - z_slice_take_loaned(dst, src); -}; -inline void z_take(z_owned_string_array_t* dst, z_loaned_string_array_t* src) { - z_string_array_take_loaned(dst, src); -}; -inline void z_take(z_owned_string_t* dst, z_loaned_string_t* src) { - z_string_take_loaned(dst, src); -}; -inline void z_take(z_owned_subscriber_t* dst, z_loaned_subscriber_t* src) { - z_subscriber_take_loaned(dst, src); -}; -inline void z_take(ze_owned_serializer_t* dst, ze_loaned_serializer_t* src) { - ze_serializer_take_loaned(dst, src); -}; -inline bool z_check(const z_owned_bytes_t& this_) { return z_bytes_check(&this_); }; -inline bool z_check(const z_owned_bytes_writer_t& this_) { return z_bytes_writer_check(&this_); }; -inline bool z_check(const z_owned_closure_hello_t& this_) { return z_closure_hello_check(&this_); }; -inline bool z_check(const z_owned_closure_query_t& this_) { return z_closure_query_check(&this_); }; -inline bool z_check(const z_owned_closure_reply_t& this_) { return z_closure_reply_check(&this_); }; -inline bool z_check(const z_owned_closure_sample_t& this_) { return z_closure_sample_check(&this_); }; -inline bool z_check(const z_owned_closure_zid_t& this_) { return z_closure_zid_check(&this_); }; -inline bool z_check(const z_owned_condvar_t& this_) { return z_condvar_check(&this_); }; -inline bool z_check(const z_owned_config_t& this_) { return z_config_check(&this_); }; -inline bool z_check(const z_owned_encoding_t& this_) { return z_encoding_check(&this_); }; -inline bool z_check(const z_owned_fifo_handler_query_t& this_) { return z_fifo_handler_query_check(&this_); }; -inline bool z_check(const z_owned_fifo_handler_reply_t& this_) { return z_fifo_handler_reply_check(&this_); }; -inline bool z_check(const z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_check(&this_); }; -inline bool z_check(const z_owned_hello_t& this_) { return z_hello_check(&this_); }; -inline bool z_check(const z_owned_keyexpr_t& this_) { return z_keyexpr_check(&this_); }; -inline bool z_check(const z_owned_mutex_t& this_) { return z_mutex_check(&this_); }; -inline bool z_check(const z_owned_publisher_t& this_) { return z_publisher_check(&this_); }; -inline bool z_check(const z_owned_query_t& query) { return z_query_check(&query); }; -inline bool z_check(const z_owned_queryable_t& this_) { return z_queryable_check(&this_); }; -inline bool z_check(const z_owned_reply_t& this_) { return z_reply_check(&this_); }; -inline bool z_check(const z_owned_reply_err_t& this_) { return z_reply_err_check(&this_); }; -inline bool z_check(const z_owned_ring_handler_query_t& this_) { return z_ring_handler_query_check(&this_); }; -inline bool z_check(const z_owned_ring_handler_reply_t& this_) { return z_ring_handler_reply_check(&this_); }; -inline bool z_check(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_check(&this_); }; -inline bool z_check(const z_owned_sample_t& this_) { return z_sample_check(&this_); }; -inline bool z_check(const z_owned_session_t& this_) { return z_session_check(&this_); }; -inline bool z_check(const z_owned_slice_t& this_) { return z_slice_check(&this_); }; -inline bool z_check(const z_owned_string_array_t& this_) { return z_string_array_check(&this_); }; -inline bool z_check(const z_owned_string_t& this_) { return z_string_check(&this_); }; -inline bool z_check(const z_owned_subscriber_t& this_) { return z_subscriber_check(&this_); }; -inline bool z_check(const z_owned_task_t& this_) { return z_task_check(&this_); }; -inline bool z_check(const zc_owned_closure_log_t& this_) { return zc_closure_log_check(&this_); }; -inline bool z_check(const ze_owned_serializer_t& this_) { return ze_serializer_check(&this_); }; +inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; +inline bool z_internal_check(const z_owned_bytes_writer_t& this_) { return z_internal_bytes_writer_check(&this_); }; +inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; +inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; +inline bool z_internal_check(const z_owned_closure_reply_t& this_) { return z_internal_closure_reply_check(&this_); }; +inline bool z_internal_check(const z_owned_closure_sample_t& this_) { return z_internal_closure_sample_check(&this_); }; +inline bool z_internal_check(const z_owned_closure_zid_t& this_) { return z_internal_closure_zid_check(&this_); }; +inline bool z_internal_check(const z_owned_condvar_t& this_) { return z_internal_condvar_check(&this_); }; +inline bool z_internal_check(const z_owned_config_t& this_) { return z_internal_config_check(&this_); }; +inline bool z_internal_check(const z_owned_encoding_t& this_) { return z_internal_encoding_check(&this_); }; +inline bool z_internal_check(const z_owned_fifo_handler_query_t& this_) { return z_internal_fifo_handler_query_check(&this_); }; +inline bool z_internal_check(const z_owned_fifo_handler_reply_t& this_) { return z_internal_fifo_handler_reply_check(&this_); }; +inline bool z_internal_check(const z_owned_fifo_handler_sample_t& this_) { return z_internal_fifo_handler_sample_check(&this_); }; +inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_hello_check(&this_); }; +inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; +inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; +inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; +inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; +inline bool z_internal_check(const z_owned_queryable_t& this_) { return z_internal_queryable_check(&this_); }; +inline bool z_internal_check(const z_owned_reply_t& this_) { return z_internal_reply_check(&this_); }; +inline bool z_internal_check(const z_owned_reply_err_t& this_) { return z_internal_reply_err_check(&this_); }; +inline bool z_internal_check(const z_owned_ring_handler_query_t& this_) { return z_internal_ring_handler_query_check(&this_); }; +inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return z_internal_ring_handler_reply_check(&this_); }; +inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; +inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; +inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; +inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; +inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; +inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; +inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; +inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; +inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; +inline bool z_internal_check(const ze_owned_serializer_t& this_) { return ze_internal_serializer_check(&this_); }; inline void z_call(const z_loaned_closure_hello_t* closure, z_loaned_hello_t* hello) { diff --git a/src/closures/hello_closure.rs b/src/closures/hello_closure.rs index abecb9811..0c5963433 100644 --- a/src/closures/hello_closure.rs +++ b/src/closures/hello_closure.rs @@ -122,7 +122,7 @@ impl From for z_owned_closure_hello_t { /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_closure_hello_check(this_: &z_owned_closure_hello_t) -> bool { +pub extern "C" fn z_internal_closure_hello_check(this_: &z_owned_closure_hello_t) -> bool { !this_.is_empty() } @@ -142,15 +142,6 @@ pub extern "C" fn z_closure_hello_loan_mut( closure.as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed closure -#[no_mangle] -pub extern "C" fn z_closure_hello_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_closure_hello_t, -) { - dst.write(std::mem::take(src.as_owned_c_type_mut())); -} - /// @brief Constructs closure. /// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: /// diff --git a/src/closures/log_closure.rs b/src/closures/log_closure.rs index c43b45bb5..c8f58a6f7 100644 --- a/src/closures/log_closure.rs +++ b/src/closures/log_closure.rs @@ -167,7 +167,7 @@ pub extern "C" fn zc_closure_log_drop(closure_: &mut zc_moved_closure_log_t) { /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn zc_closure_log_check(this_: &zc_owned_closure_log_t) -> bool { +pub extern "C" fn zc_internal_closure_log_check(this_: &zc_owned_closure_log_t) -> bool { !this_.is_empty() } diff --git a/src/closures/matching_status_closure.rs b/src/closures/matching_status_closure.rs index 1c040a585..dcb359526 100644 --- a/src/closures/matching_status_closure.rs +++ b/src/closures/matching_status_closure.rs @@ -87,7 +87,7 @@ pub unsafe extern "C" fn zc_internal_closure_matching_status_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn zc_closure_matching_status_check( +pub extern "C" fn zc_internal_closure_matching_status_check( this: &zc_owned_closure_matching_status_t, ) -> bool { !this.is_empty() diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 1ef97cb10..732c40bd9 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -51,7 +51,7 @@ pub extern "C" fn z_internal_fifo_handler_query_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_fifo_handler_query_check(this_: &z_owned_fifo_handler_query_t) -> bool { +pub extern "C" fn z_internal_fifo_handler_query_check(this_: &z_owned_fifo_handler_query_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -111,16 +111,6 @@ pub extern "C" fn z_fifo_handler_query_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed handler -#[no_mangle] -pub extern "C" fn z_fifo_handler_query_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_fifo_handler_query_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -193,7 +183,7 @@ pub extern "C" fn z_internal_ring_handler_query_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_ring_handler_query_check(this_: &z_owned_ring_handler_query_t) -> bool { +pub extern "C" fn z_internal_ring_handler_query_check(this_: &z_owned_ring_handler_query_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -236,16 +226,6 @@ pub extern "C" fn z_ring_handler_query_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed handler -#[no_mangle] -pub extern "C" fn z_ring_handler_query_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_ring_handler_query_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state). diff --git a/src/closures/query_closure.rs b/src/closures/query_closure.rs index 8e503460d..329592eb4 100644 --- a/src/closures/query_closure.rs +++ b/src/closures/query_closure.rs @@ -83,7 +83,7 @@ pub unsafe extern "C" fn z_internal_closure_query_null( /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_closure_query_check(this_: &z_owned_closure_query_t) -> bool { +pub extern "C" fn z_internal_closure_query_check(this_: &z_owned_closure_query_t) -> bool { !this_.is_empty() } @@ -142,15 +142,6 @@ pub extern "C" fn z_closure_query_loan_mut( closure.as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed closure -#[no_mangle] -pub extern "C" fn z_closure_query_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_closure_query_t, -) { - dst.write(std::mem::take(src.as_owned_c_type_mut())); -} - /// @brief Constructs closure. /// /// Closures are not guaranteed not to be called concurrently. diff --git a/src/closures/reply_closure.rs b/src/closures/reply_closure.rs index 4549c3523..264bde778 100644 --- a/src/closures/reply_closure.rs +++ b/src/closures/reply_closure.rs @@ -85,7 +85,7 @@ pub unsafe extern "C" fn z_internal_closure_reply_null( /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_closure_reply_check(this_: &z_owned_closure_reply_t) -> bool { +pub extern "C" fn z_internal_closure_reply_check(this_: &z_owned_closure_reply_t) -> bool { !this_.is_empty() } @@ -146,15 +146,6 @@ pub extern "C" fn z_closure_reply_loan_mut( closure.as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed closure -#[no_mangle] -pub extern "C" fn z_closure_reply_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_closure_reply_t, -) { - dst.write(std::mem::take(src.as_owned_c_type_mut())); -} - /// @brief Constructs closure. /// /// Closures are not guaranteed not to be called concurrently. diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index ad4e3fe58..63587ee60 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -51,7 +51,7 @@ pub extern "C" fn z_internal_fifo_handler_reply_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_fifo_handler_reply_check(this_: &z_owned_fifo_handler_reply_t) -> bool { +pub extern "C" fn z_internal_fifo_handler_reply_check(this_: &z_owned_fifo_handler_reply_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -111,16 +111,6 @@ pub extern "C" fn z_fifo_handler_reply_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed handler -#[no_mangle] -pub extern "C" fn z_fifo_handler_reply_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_fifo_handler_reply_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). @@ -189,7 +179,7 @@ pub extern "C" fn z_internal_ring_handler_reply_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_ring_handler_reply_check(this_: &z_owned_ring_handler_reply_t) -> bool { +pub extern "C" fn z_internal_ring_handler_reply_check(this_: &z_owned_ring_handler_reply_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -232,16 +222,6 @@ pub extern "C" fn z_ring_handler_reply_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed handler -#[no_mangle] -pub extern "C" fn z_ring_handler_reply_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_ring_handler_reply_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 2e3fb3f4a..a8014e6be 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -51,7 +51,7 @@ pub extern "C" fn z_internal_fifo_handler_sample_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_fifo_handler_sample_check(this_: &z_owned_fifo_handler_sample_t) -> bool { +pub extern "C" fn z_internal_fifo_handler_sample_check(this_: &z_owned_fifo_handler_sample_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -111,16 +111,6 @@ pub extern "C" fn z_fifo_handler_sample_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed fifo_handler_sample -#[no_mangle] -pub extern "C" fn z_fifo_handler_sample_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_fifo_handler_sample_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more samples to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). @@ -193,7 +183,7 @@ pub extern "C" fn z_internal_ring_handler_sample_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_ring_handler_sample_check(this_: &z_owned_ring_handler_sample_t) -> bool { +pub extern "C" fn z_internal_ring_handler_sample_check(this_: &z_owned_ring_handler_sample_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -236,16 +226,6 @@ pub extern "C" fn z_ring_handler_sample_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed handler -#[no_mangle] -pub extern "C" fn z_ring_handler_sample_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_ring_handler_sample_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more replies to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). diff --git a/src/closures/sample_closure.rs b/src/closures/sample_closure.rs index 870162b81..d9e6bcbc3 100644 --- a/src/closures/sample_closure.rs +++ b/src/closures/sample_closure.rs @@ -84,7 +84,7 @@ pub unsafe extern "C" fn z_internal_closure_sample_null( /// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_closure_sample_check(this_: &z_owned_closure_sample_t) -> bool { +pub extern "C" fn z_internal_closure_sample_check(this_: &z_owned_closure_sample_t) -> bool { !this_.is_empty() } @@ -144,15 +144,6 @@ pub extern "C" fn z_closure_sample_loan_mut( closure.as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed closure -#[no_mangle] -pub extern "C" fn z_closure_sample_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_closure_sample_t, -) { - dst.write(std::mem::take(src.as_owned_c_type_mut())); -} - /// @brief Constructs closure. /// /// Closures are not guaranteed not to be called concurrently. diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs index 9512deba5..5bc4a46bd 100644 --- a/src/closures/zenohid_closure.rs +++ b/src/closures/zenohid_closure.rs @@ -76,7 +76,7 @@ impl Drop for z_owned_closure_zid_t { /// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_closure_zid_check(this_: &z_owned_closure_zid_t) -> bool { +pub unsafe extern "C" fn z_internal_closure_zid_check(this_: &z_owned_closure_zid_t) -> bool { !this_.is_empty() } @@ -139,15 +139,6 @@ pub extern "C" fn z_closure_zid_loan_mut( closure.as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed closure -#[no_mangle] -pub extern "C" fn z_closure_zid_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_closure_zid_t, -) { - dst.write(std::mem::take(src.as_owned_c_type_mut())); -} - /// @brief Constructs closure. /// /// Closures are not guaranteed not to be called concurrently. diff --git a/src/collections.rs b/src/collections.rs index 29a9cfd5a..f51ec23cb 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -347,16 +347,6 @@ pub extern "C" fn z_slice_loan_mut(this_: &mut z_owned_slice_t) -> &mut z_loaned this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of mutably borrowed slice -#[no_mangle] -pub extern "C" fn z_slice_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_slice_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Constructs an owned copy of a slice. #[no_mangle] pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: &z_loaned_slice_t) { @@ -366,7 +356,7 @@ pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: & /// @return ``true`` if slice is not empty, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_slice_check(this_: &z_owned_slice_t) -> bool { +pub extern "C" fn z_internal_slice_check(this_: &z_owned_slice_t) -> bool { !this_.as_rust_type_ref().is_empty() } @@ -566,7 +556,7 @@ pub unsafe extern "C" fn z_string_drop(this_: &mut z_moved_string_t) { /// @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_string_check(this_: &z_owned_string_t) -> bool { +pub extern "C" fn z_internal_string_check(this_: &z_owned_string_t) -> bool { !this_.as_rust_type_ref().is_empty() } @@ -614,16 +604,6 @@ pub extern "C" fn z_string_loan_mut(this_: &mut z_owned_string_t) -> &mut z_loan this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of mutably borrowed string. -#[no_mangle] -pub extern "C" fn z_string_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_string_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Borrows view string. #[no_mangle] pub extern "C" fn z_view_string_loan(this_: &z_view_string_t) -> &z_loaned_string_t { @@ -795,7 +775,7 @@ pub extern "C" fn z_internal_string_array_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_string_array_check(this_: &z_owned_string_array_t) -> bool { !this_.as_rust_type_ref().is_empty() } @@ -819,16 +799,6 @@ pub extern "C" fn z_string_array_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of mutably borrowed string array. -#[no_mangle] -pub extern "C" fn z_string_array_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_string_array_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @return number of elements in the array. #[no_mangle] pub extern "C" fn z_string_array_len(this_: &z_loaned_string_array_t) -> usize { diff --git a/src/commons.rs b/src/commons.rs index 657cb786b..dcb6d6e66 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -198,7 +198,7 @@ pub extern "C" fn z_sample_reliability(this_: &z_loaned_sample_t) -> z_reliabili /// Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_sample_check(this_: &z_owned_sample_t) -> bool { +pub extern "C" fn z_internal_sample_check(this_: &z_owned_sample_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -603,7 +603,7 @@ pub extern "C" fn z_source_info_sn(this_: &z_loaned_source_info_t) -> u32 { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_source_info_check(this_: &z_owned_source_info_t) -> bool { +pub extern "C" fn z_internal_source_info_check(this_: &z_owned_source_info_t) -> bool { this_.as_rust_type_ref().source_id().is_some() || this_.as_rust_type_ref().source_sn().is_some() } @@ -625,18 +625,6 @@ pub extern "C" fn z_source_info_loan_mut( this_.as_rust_type_mut().as_loaned_c_type_mut() } -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Takes ownership of the mutably borrowed source info. -#[no_mangle] -pub extern "C" fn z_source_info_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_source_info_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. diff --git a/src/config.rs b/src/config.rs index 280f4a432..f41f8734e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -90,16 +90,6 @@ pub extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loan this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed config. -#[no_mangle] -pub extern "C" fn z_config_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_config_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Constructs a new empty configuration. #[no_mangle] pub extern "C" fn z_config_default( @@ -245,7 +235,7 @@ pub extern "C" fn z_config_drop(this_: &mut z_moved_config_t) { /// Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_config_check(this_: &z_owned_config_t) -> bool { +pub extern "C" fn z_internal_config_check(this_: &z_owned_config_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/encoding.rs b/src/encoding.rs index 55a3c819c..776a5f533 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -152,7 +152,7 @@ pub extern "C" fn z_encoding_drop(this_: &mut z_moved_encoding_t) { /// Returns ``true`` if encoding is in non-default state, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_encoding_check(this_: &'static z_owned_encoding_t) -> bool { +pub extern "C" fn z_internal_encoding_check(this_: &'static z_owned_encoding_t) -> bool { *this_.as_rust_type_ref() != Encoding::default() } @@ -168,16 +168,6 @@ pub extern "C" fn z_encoding_loan_mut(this_: &mut z_owned_encoding_t) -> &mut z_ this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed encoding -#[no_mangle] -pub extern "C" fn z_encoding_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_encoding_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Constructs an owned copy of the encoding in provided uninitilized memory location. #[no_mangle] pub extern "C" fn z_encoding_clone( diff --git a/src/get.rs b/src/get.rs index a02edfe06..890d5f64a 100644 --- a/src/get.rs +++ b/src/get.rs @@ -52,7 +52,7 @@ pub extern "C" fn z_internal_reply_err_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_reply_err_check(this_: &'static z_owned_reply_err_t) -> bool { !this_.as_rust_type_ref().payload().is_empty() } @@ -82,16 +82,6 @@ pub extern "C" fn z_reply_err_loan_mut( this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed reply error -#[no_mangle] -pub extern "C" fn z_reply_err_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_reply_err_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Frees the memory and resets the reply error it to its default value. #[no_mangle] pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { @@ -313,7 +303,7 @@ pub extern "C" fn z_reply_drop(this_: &mut z_moved_reply_t) { /// Returns ``true`` if `reply` is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_reply_check(this_: &z_owned_reply_t) -> bool { +pub extern "C" fn z_internal_reply_check(this_: &z_owned_reply_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/keyexpr.rs b/src/keyexpr.rs index cbe7a551c..bf1c65537 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -142,16 +142,6 @@ pub extern "C" fn z_keyexpr_loan_mut(this_: &mut z_owned_keyexpr_t) -> &mut z_lo this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed keyexpr -#[no_mangle] -pub extern "C" fn z_keyexpr_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_keyexpr_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Borrows `z_view_keyexpr_t`. #[no_mangle] #[allow(clippy::missing_safety_doc)] @@ -171,7 +161,7 @@ pub extern "C" fn z_keyexpr_drop(this_: &mut z_moved_keyexpr_t) { /// Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_keyexpr_check(this_: &z_owned_keyexpr_t) -> bool { +pub extern "C" fn z_internal_keyexpr_check(this_: &z_owned_keyexpr_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/liveliness.rs b/src/liveliness.rs index 408abd82f..2c681e85f 100644 --- a/src/liveliness.rs +++ b/src/liveliness.rs @@ -46,7 +46,7 @@ pub extern "C" fn zc_internal_liveliness_token_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn zc_liveliness_token_check(this_: &zc_owned_liveliness_token_t) -> bool { +pub extern "C" fn zc_internal_liveliness_token_check(this_: &zc_owned_liveliness_token_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index ad5618d64..b6b89189a 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -38,7 +38,7 @@ pub extern "C" fn z_mutex_drop(this_: &mut z_moved_mutex_t) { /// Returns ``true`` if mutex is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_mutex_check(this_: &z_owned_mutex_t) -> bool { +pub extern "C" fn z_internal_mutex_check(this_: &z_owned_mutex_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -54,16 +54,6 @@ pub extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed mutex -#[no_mangle] -pub extern "C" fn z_mutex_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_mutex_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Locks mutex. If mutex is already locked, blocks the thread until it aquires the lock. /// @return 0 in case of success, negative error code in case of failure. #[no_mangle] @@ -147,7 +137,7 @@ pub extern "C" fn z_condvar_drop(this_: &mut z_moved_condvar_t) { /// Returns ``true`` if conditional variable is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_condvar_check(this_: &z_owned_condvar_t) -> bool { +pub extern "C" fn z_internal_condvar_check(this_: &z_owned_condvar_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -252,7 +242,7 @@ pub extern "C" fn z_task_drop(this_: &mut z_moved_task_t) { /// Returns ``true`` if task is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_task_check(this_: &z_owned_task_t) -> bool { +pub extern "C" fn z_internal_task_check(this_: &z_owned_task_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/publication_cache.rs b/src/publication_cache.rs index ed2d4dc0f..4b0198e5b 100644 --- a/src/publication_cache.rs +++ b/src/publication_cache.rs @@ -164,7 +164,7 @@ pub extern "C" fn ze_internal_publication_cache_null( /// @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_publication_cache_check(this_: &ze_owned_publication_cache_t) -> bool { +pub extern "C" fn ze_internal_publication_cache_check(this_: &ze_owned_publication_cache_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/publisher.rs b/src/publisher.rs index 5c7ba57f8..fd82a81bc 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -150,7 +150,7 @@ pub extern "C" fn z_internal_publisher_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_publisher_check(this_: &z_owned_publisher_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -173,16 +173,6 @@ pub extern "C" fn z_publisher_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed publisher -#[no_mangle] -pub extern "C" fn z_publisher_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_publisher_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Options passed to the `z_publisher_put()` function. #[repr(C)] pub struct z_publisher_put_options_t { @@ -337,7 +327,7 @@ pub extern "C" fn zc_internal_matching_listener_null( #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Checks the matching listener is for the gravestone state -pub extern "C" fn zc_matching_listener_check(this_: &zc_owned_matching_listener_t) -> bool { +pub extern "C" fn zc_internal_matching_listener_check(this_: &zc_owned_matching_listener_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/queryable.rs b/src/queryable.rs index 20be31354..042fa145b 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -67,16 +67,6 @@ pub extern "C" fn z_queryable_loan_mut( this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed queryable -#[no_mangle] -pub extern "C" fn z_queryable_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_queryable_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; decl_c_type!( owned(z_owned_query_t, option Query), @@ -90,7 +80,7 @@ pub extern "C" fn z_internal_query_null(this_: &mut MaybeUninit } /// Returns `false` if `this` is in a gravestone state, `true` otherwise. #[no_mangle] -pub extern "C" fn z_query_check(query: &z_owned_query_t) -> bool { +pub extern "C" fn z_internal_query_check(query: &z_owned_query_t) -> bool { query.as_rust_type_ref().is_some() } /// Borrows the query. @@ -336,7 +326,7 @@ pub extern "C" fn z_queryable_drop(this_: &mut z_moved_queryable_t) { /// Returns ``true`` if queryable is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_queryable_check(this_: &z_owned_queryable_t) -> bool { +pub extern "C" fn z_internal_queryable_check(this_: &z_owned_queryable_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/querying_subscriber.rs b/src/querying_subscriber.rs index 6fba52555..d240f5751 100644 --- a/src/querying_subscriber.rs +++ b/src/querying_subscriber.rs @@ -265,7 +265,7 @@ pub extern "C" fn ze_querying_subscriber_drop(this_: &mut ze_moved_querying_subs /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn ze_querying_subscriber_check(this_: &ze_owned_querying_subscriber_t) -> bool { +pub extern "C" fn ze_internal_querying_subscriber_check(this_: &ze_owned_querying_subscriber_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/scouting.rs b/src/scouting.rs index 41ddd5247..9561e47c2 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -70,7 +70,7 @@ pub extern "C" fn z_hello_take_loaned( /// Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. #[no_mangle] -pub extern "C" fn z_hello_check(this_: &z_owned_hello_t) -> bool { +pub extern "C" fn z_internal_hello_check(this_: &z_owned_hello_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/serialization.rs b/src/serialization.rs index e39238fe5..b6156d420 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -56,7 +56,7 @@ extern "C" fn ze_serializer_drop(this_: &mut ze_moved_serializer_t) { /// @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. #[no_mangle] -extern "C" fn ze_serializer_check(this: &ze_owned_serializer_t) -> bool { +extern "C" fn ze_internal_serializer_check(this: &ze_owned_serializer_t) -> bool { this.as_rust_type_ref().is_some() } diff --git a/src/session.rs b/src/session.rs index 9a68884e3..ac614fa9b 100644 --- a/src/session.rs +++ b/src/session.rs @@ -48,16 +48,6 @@ pub extern "C" fn z_session_loan_mut(this_: &mut z_owned_session_t) -> &mut z_lo this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed session -#[no_mangle] -pub extern "C" fn z_session_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_session_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Constructs a Zenoh session in its gravestone state. #[no_mangle] #[allow(clippy::missing_safety_doc)] @@ -143,7 +133,7 @@ pub extern "C" fn z_open_with_custom_shm_clients( /// Returns ``true`` if `session` is valid, ``false`` otherwise. #[allow(clippy::missing_safety_doc)] #[no_mangle] -pub extern "C" fn z_session_check(this_: &z_owned_session_t) -> bool { +pub extern "C" fn z_internal_session_check(this_: &z_owned_session_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index e5cda6ed2..5b63e7187 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -53,7 +53,7 @@ pub extern "C" fn z_internal_shm_null(this_: &mut MaybeUninit) { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_shm_check(this_: &z_owned_shm_t) -> bool { +pub extern "C" fn z_internal_shm_check(this_: &z_owned_shm_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -85,16 +85,6 @@ pub extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed shm -#[no_mangle] -pub extern "C" fn z_shm_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_shm_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. #[no_mangle] diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index 109fd247c..9fe6a17d7 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -68,7 +68,7 @@ pub extern "C" fn z_internal_shm_mut_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_shm_mut_check(this_: &z_owned_shm_mut_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -92,16 +92,6 @@ pub extern "C" fn z_shm_mut_loan_mut(this: &mut z_owned_shm_mut_t) -> &mut z_loa this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed shm_mut -#[no_mangle] -pub extern "C" fn z_shm_mut_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_shm_mut_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes ZShmMut slice. #[no_mangle] diff --git a/src/shm/client/shm_client.rs b/src/shm/client/shm_client.rs index 061defa89..5bcc28921 100644 --- a/src/shm/client/shm_client.rs +++ b/src/shm/client/shm_client.rs @@ -90,7 +90,7 @@ pub extern "C" fn z_internal_shm_client_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_shm_client_check(this_: &z_owned_shm_client_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 7bf7eeb03..24d4dfd67 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -52,7 +52,7 @@ pub extern "C" fn zc_internal_shm_client_list_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn zc_shm_client_list_check(this_: &zc_owned_shm_client_list_t) -> bool { +pub extern "C" fn zc_internal_shm_client_list_check(this_: &zc_owned_shm_client_list_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -175,7 +175,7 @@ pub extern "C" fn z_internal_shm_client_storage_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_shm_client_storage_check(this_: &z_owned_shm_client_storage_t) -> bool { +pub extern "C" fn z_internal_shm_client_storage_check(this_: &z_owned_shm_client_storage_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -207,14 +207,3 @@ pub extern "C" fn z_shm_client_storage_loan_mut( ) -> &mut z_loaned_shm_client_storage_t { this.as_rust_type_mut().as_loaned_c_type_mut() } - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Takes ownership of the mutably borrowed SHM Client Storage. -#[no_mangle] -pub extern "C" fn z_shm_client_storage_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_shm_client_storage_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index 6c4fa5b80..32530b757 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -72,7 +72,7 @@ pub extern "C" fn z_internal_alloc_layout_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_alloc_layout_check(this_: &z_owned_alloc_layout_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -96,16 +96,6 @@ pub extern "C" fn z_alloc_layout_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed Alloc Layout -#[no_mangle] -pub extern "C" fn z_alloc_layout_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_alloc_layout_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Deletes Alloc Layout #[no_mangle] pub extern "C" fn z_alloc_layout_drop(this_: &mut z_moved_alloc_layout_t) { diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 10dd34d01..5625da296 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -107,7 +107,7 @@ pub extern "C" fn z_internal_shm_provider_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_shm_provider_check(this_: &z_owned_shm_provider_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -133,16 +133,6 @@ pub extern "C" fn z_shm_provider_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed SHM Provider -#[no_mangle] -pub extern "C" fn z_shm_provider_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_shm_provider_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes SHM Provider. #[no_mangle] diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index 968092b8e..a03381d20 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -151,7 +151,7 @@ pub extern "C" fn z_internal_memory_layout_null(this_: &mut MaybeUninit bool { +pub extern "C" fn z_internal_memory_layout_check(this_: &z_owned_memory_layout_t) -> bool { this_.as_rust_type_ref().is_some() } @@ -231,7 +231,7 @@ pub extern "C" fn z_internal_chunk_alloc_result_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_chunk_alloc_result_check(this_: &z_owned_chunk_alloc_result_t) -> bool { +pub extern "C" fn z_internal_chunk_alloc_result_check(this_: &z_owned_chunk_alloc_result_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/subscriber.rs b/src/subscriber.rs index 4a3d7ba21..b0f6d338f 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -60,16 +60,6 @@ pub extern "C" fn z_subscriber_loan_mut( this_.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed subscriber -#[no_mangle] -pub extern "C" fn z_subscriber_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_subscriber_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Options passed to the `z_declare_subscriber()` function. #[allow(non_camel_case_types)] #[repr(C)] @@ -182,7 +172,7 @@ pub extern "C" fn z_subscriber_drop(this_: &mut z_moved_subscriber_t) { /// Returns ``true`` if subscriber is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn z_subscriber_check(this_: &z_owned_subscriber_t) -> bool { +pub extern "C" fn z_internal_subscriber_check(this_: &z_owned_subscriber_t) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/zbytes.rs b/src/zbytes.rs index 5937cc263..29464b34e 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -67,7 +67,7 @@ extern "C" fn z_bytes_drop(this_: &mut z_moved_bytes_t) { /// Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. #[no_mangle] -extern "C" fn z_bytes_check(this: &z_owned_bytes_t) -> bool { +extern "C" fn z_internal_bytes_check(this: &z_owned_bytes_t) -> bool { !this.as_rust_type_ref().is_empty() } @@ -83,16 +83,6 @@ extern "C" fn z_bytes_loan_mut(this: &mut z_owned_bytes_t) -> &mut z_loaned_byte this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed bytes -#[no_mangle] -pub extern "C" fn z_bytes_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_bytes_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Returns ``true`` if `this_` is empty, ``false`` otherwise. #[no_mangle] extern "C" fn z_bytes_is_empty(this: &z_loaned_bytes_t) -> bool { @@ -631,7 +621,7 @@ extern "C" fn z_bytes_writer_drop(this_: &mut z_moved_bytes_writer_t) { /// Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. #[no_mangle] -extern "C" fn z_bytes_writer_check(this: &z_owned_bytes_writer_t) -> bool { +extern "C" fn z_internal_bytes_writer_check(this: &z_owned_bytes_writer_t) -> bool { this.as_rust_type_ref().is_some() } @@ -655,16 +645,6 @@ pub extern "C" fn z_bytes_writer_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// Takes ownership of the mutably borrowed writer -#[no_mangle] -pub extern "C" fn z_bytes_writer_take_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_bytes_writer_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// Constructs a writer in a gravestone state. #[no_mangle] pub extern "C" fn z_internal_bytes_writer_null(this_: &mut MaybeUninit) { diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index f7ed0d6df..cfc1df46a 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -161,7 +161,7 @@ int main(int argc, char **argv) { z_owned_config_t _ret_config; z_config_default(&_ret_config); - assert(z_check(_ret_config)); + assert(z_internal_check(_ret_config)); z_drop(z_move(_ret_config)); #ifdef ZENOH_PICO _ret_int8 = zp_config_insert(z_loan(_ret_config), Z_CONFIG_PEER_KEY, z_string_make(argv[1])); @@ -174,7 +174,7 @@ int main(int argc, char **argv) { #ifdef ZENOH_PICO z_owned_scouting_config_t _ret_sconfig; z_scouting_config_default(&_ret_sconfig); - assert(z_check(_ret_sconfig)); + assert(z_internal_check(_ret_sconfig)); _ret_int8 = zp_scouting_config_insert(z_loan(_ret_sconfig), Z_CONFIG_SCOUTING_TIMEOUT_KEY, z_string_make(SCOUTING_TIMEOUT)); assert(_ret_int8 == 0); @@ -197,7 +197,7 @@ int main(int argc, char **argv) { z_owned_session_t s1; assert(0 == z_open(&s1, z_move(_ret_config), NULL)); - assert(z_check(s1)); + assert(z_internal_check(s1)); z_id_t _ret_zid = z_info_zid(z_loan(s1)); z_owned_string_t str; @@ -239,7 +239,7 @@ int main(int argc, char **argv) { z_owned_session_t s2; assert(0 == z_open(&s2, z_move(_ret_config), NULL)); - assert(z_check(s2)); + assert(z_internal_check(s2)); #if defined(Z_FEATURE_UNSTABLE_API) _ret_zid = z_info_zid(z_loan(s2)); @@ -265,7 +265,7 @@ int main(int argc, char **argv) { z_view_keyexpr_from_str(&ke, keyexpr_str); z_owned_subscriber_t _ret_sub; z_declare_subscriber(z_loan(s2), &_ret_sub, z_loan(ke), z_move(_ret_closure_sample), &_ret_sub_opt); - assert(z_check(_ret_sub)); + assert(z_internal_check(_ret_sub)); z_sleep_s(SLEEP); @@ -275,7 +275,7 @@ int main(int argc, char **argv) { z_view_keyexpr_from_str(&s1_key, s1_res); z_owned_keyexpr_t _ret_expr; z_declare_keyexpr(z_loan(s1), &_ret_expr, z_loan(s1_key)); - assert(z_check(_ret_expr)); + assert(z_internal_check(_ret_expr)); z_put_options_t _ret_put_opt; z_put_options_default(&_ret_put_opt); _ret_put_opt.congestion_control = Z_CONGESTION_CONTROL_BLOCK; @@ -299,7 +299,7 @@ int main(int argc, char **argv) { _ret_int8 = z_undeclare_keyexpr(z_loan(s1), z_move(_ret_expr)); assert(_ret_int8 == 0); - assert(!z_check(_ret_expr)); + assert(!z_internal_check(_ret_expr)); z_drop(z_move(_ret_sub)); @@ -311,7 +311,7 @@ int main(int argc, char **argv) { z_queryable_options_default(&_ret_qle_opt); z_owned_queryable_t qle; z_declare_queryable(z_loan(s1), &qle, z_loan(s1_key), z_move(_ret_closure_query), &_ret_qle_opt); - assert(z_check(qle)); + assert(z_internal_check(qle)); z_sleep_s(SLEEP); diff --git a/tests/z_api_double_drop_test.c b/tests/z_api_double_drop_test.c index 574768bd0..03f74620c 100644 --- a/tests/z_api_double_drop_test.c +++ b/tests/z_api_double_drop_test.c @@ -25,14 +25,14 @@ void test_session() { z_owned_config_t config; z_config_default(&config); - assert(z_check(config)); + assert(z_internal_check(config)); z_owned_session_t session; z_open(&session, z_move(config), NULL); - assert(z_check(session)); + assert(z_internal_check(session)); z_drop(z_move(session)); - assert(!z_check(session)); + assert(!z_internal_check(session)); z_drop(z_move(session)); - assert(!z_check(session)); + assert(!z_internal_check(session)); } void test_publisher() { @@ -46,11 +46,11 @@ void test_publisher() { z_owned_publisher_t pub; z_declare_publisher(z_loan(s), &pub, z_loan(keyexpr), NULL); - assert(z_check(pub)); + assert(z_internal_check(pub)); z_drop(z_move(pub)); - assert(!z_check(pub)); + assert(!z_internal_check(pub)); z_drop(z_move(pub)); - assert(!z_check(pub)); + assert(!z_internal_check(pub)); z_drop(z_move(s)); } @@ -58,21 +58,21 @@ void test_keyexpr() { z_owned_keyexpr_t keyexpr; z_keyexpr_from_str(&keyexpr, URL); - assert(z_check(keyexpr)); + assert(z_internal_check(keyexpr)); z_drop(z_move(keyexpr)); - assert(!z_check(keyexpr)); + assert(!z_internal_check(keyexpr)); z_drop(z_move(keyexpr)); - assert(!z_check(keyexpr)); + assert(!z_internal_check(keyexpr)); } void test_config() { z_owned_config_t config; z_config_default(&config); - assert(z_check(config)); + assert(z_internal_check(config)); z_drop(z_move(config)); - assert(!z_check(config)); + assert(!z_internal_check(config)); z_drop(z_move(config)); - assert(!z_check(config)); + assert(!z_internal_check(config)); } void data_handler(z_loaned_sample_t *sample, void *arg) {} @@ -89,11 +89,11 @@ void test_subscriber() { z_view_keyexpr_from_str(&keyexpr, URL); z_owned_subscriber_t sub; z_declare_subscriber(z_loan(s), &sub, z_loan(keyexpr), z_move(callback), NULL); - assert(z_check(sub)); + assert(z_internal_check(sub)); z_drop(z_move(sub)); - assert(!z_check(sub)); + assert(!z_internal_check(sub)); z_drop(z_move(sub)); - assert(!z_check(sub)); + assert(!z_internal_check(sub)); z_drop(z_move(s)); } @@ -111,11 +111,11 @@ void test_queryable() { z_view_keyexpr_from_str(&keyexpr, URL); z_owned_queryable_t queryable; z_declare_queryable(z_loan(s), &queryable, z_loan(keyexpr), z_move(callback), NULL); - assert(z_check(queryable)); + assert(z_internal_check(queryable)); z_drop(z_move(queryable)); - assert(!z_check(queryable)); + assert(!z_internal_check(queryable)); z_drop(z_move(queryable)); - assert(!z_check(queryable)); + assert(!z_internal_check(queryable)); z_drop(z_move(s)); } diff --git a/tests/z_api_drop_options.c b/tests/z_api_drop_options.c index 05c2c97e2..05e54f205 100644 --- a/tests/z_api_drop_options.c +++ b/tests/z_api_drop_options.c @@ -40,8 +40,8 @@ void put() { opts.attachment = z_move(attachment); z_bytes_copy_from_str(&payload, "cde"); z_put(z_loan(s), z_loan(ke), z_move(payload), &opts); - assert(!z_check(payload)); - assert(!z_check(attachment)); + assert(!z_internal_check(payload)); + assert(!z_internal_check(attachment)); z_drop(z_move(s)); } @@ -68,8 +68,8 @@ void get() { z_closure(&closure, cb, drop, NULL); z_get(z_loan(s), z_loan(ke), "", z_move(closure), &opts); - assert(!z_check(payload)); - assert(!z_check(attachment)); + assert(!z_internal_check(payload)); + assert(!z_internal_check(attachment)); z_drop(z_move(s)); } diff --git a/tests/z_api_encoding_test.c b/tests/z_api_encoding_test.c index cdd654bfc..13d0465db 100644 --- a/tests/z_api_encoding_test.c +++ b/tests/z_api_encoding_test.c @@ -11,14 +11,14 @@ void test_null_encoding(void) { z_owned_encoding_t e; z_internal_encoding_null(&e); - assert(!z_encoding_check(&e)); + assert(!z_internal_encoding_check(&e)); z_encoding_drop(z_move(e)); } void test_encoding_without_id(void) { z_owned_encoding_t e1; z_encoding_from_str(&e1, "my_encoding"); - assert(z_encoding_check(&e1)); + assert(z_internal_encoding_check(&e1)); z_owned_string_t s; z_encoding_to_string(z_encoding_loan(&e1), &s); assert(strncmp("zenoh/bytes;my_encoding", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -27,7 +27,7 @@ void test_encoding_without_id(void) { z_owned_encoding_t e2; z_encoding_from_substr(&e2, "my_encoding", 4); - assert(z_encoding_check(&e2)); + assert(z_internal_encoding_check(&e2)); z_encoding_to_string(z_encoding_loan(&e2), &s); assert(strncmp("zenoh/bytes;my_e", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -38,7 +38,7 @@ void test_encoding_without_id(void) { void test_encoding_with_id(void) { z_owned_encoding_t e1; z_encoding_from_str(&e1, "zenoh/string;utf8"); - assert(z_encoding_check(&e1)); + assert(z_internal_encoding_check(&e1)); z_owned_string_t s; z_encoding_to_string(z_encoding_loan(&e1), &s); assert(strncmp("zenoh/string;utf8", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -47,7 +47,7 @@ void test_encoding_with_id(void) { z_owned_encoding_t e2; z_encoding_from_substr(&e2, "zenoh/string;utf8", 15); - assert(z_encoding_check(&e2)); + assert(z_internal_encoding_check(&e2)); z_encoding_to_string(z_encoding_loan(&e2), &s); assert(strncmp("zenoh/string;utf8", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == 0); @@ -56,7 +56,7 @@ void test_encoding_with_id(void) { z_owned_encoding_t e3; z_encoding_from_str(&e3, "custom_id;custom_schema"); - assert(z_encoding_check(&e3)); + assert(z_internal_encoding_check(&e3)); z_encoding_to_string(z_encoding_loan(&e3), &s); assert(strncmp("zenoh/bytes;custom_id;custom_schema", z_string_data(z_string_loan(&s)), @@ -66,7 +66,7 @@ void test_encoding_with_id(void) { z_owned_encoding_t e4; z_encoding_from_substr(&e4, "custom_id;custom_schema", 16); - assert(z_encoding_check(&e4)); + assert(z_internal_encoding_check(&e4)); z_encoding_to_string(z_encoding_loan(&e4), &s); assert(strncmp("zenoh/bytes;custom_id;custom", z_string_data(z_string_loan(&s)), z_string_len(z_string_loan(&s))) == diff --git a/tests/z_api_keyexpr_drop_test.c b/tests/z_api_keyexpr_drop_test.c index d8aa2d02c..c415c6684 100644 --- a/tests/z_api_keyexpr_drop_test.c +++ b/tests/z_api_keyexpr_drop_test.c @@ -25,7 +25,7 @@ void test_publisher() { z_config_default(&config); z_owned_session_t s; z_open(&s, z_move(config), NULL); - assert(z_check(s)); + assert(z_internal_check(s)); char keyexpr[256]; strncpy(keyexpr, "foo/bar", 256); z_view_keyexpr_t ke; diff --git a/tests/z_api_keyexpr_test.c b/tests/z_api_keyexpr_test.c index c0ca4cc20..8a5c50120 100644 --- a/tests/z_api_keyexpr_test.c +++ b/tests/z_api_keyexpr_test.c @@ -92,9 +92,9 @@ void undeclare() { z_view_keyexpr_from_str(&view_ke, "test/thr"); z_owned_keyexpr_t ke; z_declare_keyexpr(z_loan(s), &ke, z_loan(view_ke)); - assert(z_keyexpr_check(&ke)); + assert(z_internal_keyexpr_check(&ke)); z_undeclare_keyexpr(z_loan(s), z_move(ke)); - assert(!z_keyexpr_check(&ke)); + assert(!z_internal_keyexpr_check(&ke)); } #if defined(Z_FEATURE_UNSTABLE_API) diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 264fe9b63..52eace72b 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -31,28 +31,29 @@ // move v to v1 // make sure that v is null now // -// set v2 to null -// move v1 to v2 using z_take from mutable loaned -// make sure that v1 is null now -// -#define TEST(name) \ - { \ - name v; \ - memset(&v, -1, sizeof(v)); \ - z_internal_null(&v); \ - assert(!z_check(v)); \ - z_drop(z_move(v)); \ - z_drop(z_move(v)); \ - name v1; \ - z_internal_null(&v1); \ - memset(&v, -1, sizeof(v)); \ - z_take(&v1, z_move(v)); \ - assert(!z_check(v)); \ - name v2; \ - z_internal_null(&v2); \ - memset(&v1, -1, sizeof(v1)); \ - z_take(&v2, z_loan_mut(v1)); \ - assert(!z_check(v1)); \ +#define TEST(name) \ + { \ + name v; \ + memset(&v, -1, sizeof(v)); \ + z_internal_null(&v); \ + assert(!z_internal_check(v)); \ + z_drop(z_move(v)); \ + z_drop(z_move(v)); \ + name v1; \ + z_internal_null(&v1); \ + memset(&v, -1, sizeof(v)); \ + z_take(&v1, z_move(v)); \ + assert(!z_internal_check(v)); \ + } + +#define TEST_TAKE_MUT(name, take_loan_func) \ + { \ + name v; \ + name v1; \ + z_internal_null(&v1); \ + memset(&v, -1, sizeof(v)); \ + take_loan_func(&v1, z_loan_mut(v)); \ + assert(!z_internal_check(v)); \ } int main(void) { @@ -86,5 +87,10 @@ int main(void) { // TEST(z_owned_mutex_t) // TEST(z_owned_condvar_t) + TEST_TAKE_MUT(z_owned_sample_t, z_sample_take_loaned) + TEST_TAKE_MUT(z_owned_query_t, z_query_take_loaned) + TEST_TAKE_MUT(z_owned_reply_t, z_reply_take_loaned) + TEST_TAKE_MUT(z_owned_hello_t, z_hello_take_loaned) + return 0; } \ No newline at end of file diff --git a/tests/z_api_payload_test.c b/tests/z_api_payload_test.c index 0b29e6beb..745e49389 100644 --- a/tests/z_api_payload_test.c +++ b/tests/z_api_payload_test.c @@ -167,14 +167,14 @@ void test_slice(void) { z_owned_slice_t s; z_slice_copy_from_buf(&s, data, 10); z_bytes_copy_from_slice(&payload2, z_loan(s)); - assert(z_slice_check(&s)); + assert(z_internal_slice_check(&s)); z_slice_drop(z_slice_move(&s)); assert(z_check_and_drop_payload(&payload2, data, 10)); z_owned_bytes_t payload3; z_slice_copy_from_buf(&s, data, 10); z_bytes_from_slice(&payload3, z_slice_move(&s)); - assert(!z_slice_check(&s)); + assert(!z_internal_slice_check(&s)); assert(z_check_and_drop_payload(&payload3, data, 10)); z_owned_bytes_t payload4; diff --git a/tests/z_api_shm_test.c b/tests/z_api_shm_test.c index 715195b8b..5dddb966a 100644 --- a/tests/z_api_shm_test.c +++ b/tests/z_api_shm_test.c @@ -34,13 +34,13 @@ } #define ASSERT_CHECK(var) \ - if (!z_check(var)) { \ + if (!z_internal_check(var)) { \ assert(false); \ return -100; \ } #define ASSERT_CHECK_ERR(var) \ - if (z_check(var)) { \ + if (z_internal_check(var)) { \ assert(false); \ return -200; \ } @@ -248,7 +248,7 @@ void layout_for_fn(struct z_owned_memory_layout_t* layout, void* context) { assert(context); assert(layout); - assert(z_check(*layout)); + assert(z_internal_check(*layout)); // check size and alignment size_t size = 0; diff --git a/tests/z_api_unitinialized_check.c b/tests/z_api_unitinialized_check.c index c27b14078..8ffa75117 100644 --- a/tests/z_api_unitinialized_check.c +++ b/tests/z_api_unitinialized_check.c @@ -24,9 +24,9 @@ int main(int argc, char **argv) { z_owned_keyexpr_t owned_keyexpr; assert(z_keyexpr_from_str(&owned_keyexpr, NULL) == Z_EINVAL); - assert(!z_check(owned_keyexpr)); + assert(!z_internal_check(owned_keyexpr)); assert(z_keyexpr_from_str_autocanonize(&owned_keyexpr, NULL) == Z_EINVAL); - assert(!z_check(owned_keyexpr)); + assert(!z_internal_check(owned_keyexpr)); assert(z_keyexpr_canonize_null_terminated(NULL) == Z_EINVAL); From 608e43624dbdb42bf7b9a587baa4ff99b204d2d2 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 25 Oct 2024 16:27:14 +0200 Subject: [PATCH 24/38] clang format --- tests/z_api_shm_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/z_api_shm_test.c b/tests/z_api_shm_test.c index 5dddb966a..1a6607667 100644 --- a/tests/z_api_shm_test.c +++ b/tests/z_api_shm_test.c @@ -33,16 +33,16 @@ return -300; \ } -#define ASSERT_CHECK(var) \ - if (!z_internal_check(var)) { \ - assert(false); \ - return -100; \ +#define ASSERT_CHECK(var) \ + if (!z_internal_check(var)) { \ + assert(false); \ + return -100; \ } -#define ASSERT_CHECK_ERR(var) \ - if (z_internal_check(var)) { \ - assert(false); \ - return -200; \ +#define ASSERT_CHECK_ERR(var) \ + if (z_internal_check(var)) { \ + assert(false); \ + return -200; \ } int test_shm_buffer(z_moved_shm_mut_t* mbuf) { From 482491ecf2747aaf72d7e7c8c384dc10330b0ea1 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 25 Oct 2024 16:34:36 +0200 Subject: [PATCH 25/38] cargo fmt --- src/closures/query_channel.rs | 8 ++++++-- src/closures/response_channel.rs | 8 ++++++-- src/closures/sample_channel.rs | 8 ++++++-- src/publication_cache.rs | 4 +++- src/publisher.rs | 4 +++- src/querying_subscriber.rs | 4 +++- src/shm/client_storage/mod.rs | 4 +++- src/shm/provider/types.rs | 4 +++- 8 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 732c40bd9..78e86f970 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -51,7 +51,9 @@ pub extern "C" fn z_internal_fifo_handler_query_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_fifo_handler_query_check(this_: &z_owned_fifo_handler_query_t) -> bool { +pub extern "C" fn z_internal_fifo_handler_query_check( + this_: &z_owned_fifo_handler_query_t, +) -> bool { this_.as_rust_type_ref().is_some() } @@ -183,7 +185,9 @@ pub extern "C" fn z_internal_ring_handler_query_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_ring_handler_query_check(this_: &z_owned_ring_handler_query_t) -> bool { +pub extern "C" fn z_internal_ring_handler_query_check( + this_: &z_owned_ring_handler_query_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index 63587ee60..19592143a 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -51,7 +51,9 @@ pub extern "C" fn z_internal_fifo_handler_reply_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_fifo_handler_reply_check(this_: &z_owned_fifo_handler_reply_t) -> bool { +pub extern "C" fn z_internal_fifo_handler_reply_check( + this_: &z_owned_fifo_handler_reply_t, +) -> bool { this_.as_rust_type_ref().is_some() } @@ -179,7 +181,9 @@ pub extern "C" fn z_internal_ring_handler_reply_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_ring_handler_reply_check(this_: &z_owned_ring_handler_reply_t) -> bool { +pub extern "C" fn z_internal_ring_handler_reply_check( + this_: &z_owned_ring_handler_reply_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index a8014e6be..81a7ad2e7 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -51,7 +51,9 @@ pub extern "C" fn z_internal_fifo_handler_sample_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_fifo_handler_sample_check(this_: &z_owned_fifo_handler_sample_t) -> bool { +pub extern "C" fn z_internal_fifo_handler_sample_check( + this_: &z_owned_fifo_handler_sample_t, +) -> bool { this_.as_rust_type_ref().is_some() } @@ -183,7 +185,9 @@ pub extern "C" fn z_internal_ring_handler_sample_null( /// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. #[no_mangle] -pub extern "C" fn z_internal_ring_handler_sample_check(this_: &z_owned_ring_handler_sample_t) -> bool { +pub extern "C" fn z_internal_ring_handler_sample_check( + this_: &z_owned_ring_handler_sample_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/publication_cache.rs b/src/publication_cache.rs index 4b0198e5b..ae0e3d575 100644 --- a/src/publication_cache.rs +++ b/src/publication_cache.rs @@ -164,7 +164,9 @@ pub extern "C" fn ze_internal_publication_cache_null( /// @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_internal_publication_cache_check(this_: &ze_owned_publication_cache_t) -> bool { +pub extern "C" fn ze_internal_publication_cache_check( + this_: &ze_owned_publication_cache_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/publisher.rs b/src/publisher.rs index fd82a81bc..57ac6ebc5 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -327,7 +327,9 @@ pub extern "C" fn zc_internal_matching_listener_null( #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Checks the matching listener is for the gravestone state -pub extern "C" fn zc_internal_matching_listener_check(this_: &zc_owned_matching_listener_t) -> bool { +pub extern "C" fn zc_internal_matching_listener_check( + this_: &zc_owned_matching_listener_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/querying_subscriber.rs b/src/querying_subscriber.rs index d240f5751..79e0c8f79 100644 --- a/src/querying_subscriber.rs +++ b/src/querying_subscriber.rs @@ -265,7 +265,9 @@ pub extern "C" fn ze_querying_subscriber_drop(this_: &mut ze_moved_querying_subs /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. #[no_mangle] -pub extern "C" fn ze_internal_querying_subscriber_check(this_: &ze_owned_querying_subscriber_t) -> bool { +pub extern "C" fn ze_internal_querying_subscriber_check( + this_: &ze_owned_querying_subscriber_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 24d4dfd67..577b0ab44 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -175,7 +175,9 @@ pub extern "C" fn z_internal_shm_client_storage_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_internal_shm_client_storage_check(this_: &z_owned_shm_client_storage_t) -> bool { +pub extern "C" fn z_internal_shm_client_storage_check( + this_: &z_owned_shm_client_storage_t, +) -> bool { this_.as_rust_type_ref().is_some() } diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs index a03381d20..a8ddee36e 100644 --- a/src/shm/provider/types.rs +++ b/src/shm/provider/types.rs @@ -231,7 +231,9 @@ pub extern "C" fn z_internal_chunk_alloc_result_null( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return ``true`` if `this` is valid. #[no_mangle] -pub extern "C" fn z_internal_chunk_alloc_result_check(this_: &z_owned_chunk_alloc_result_t) -> bool { +pub extern "C" fn z_internal_chunk_alloc_result_check( + this_: &z_owned_chunk_alloc_result_t, +) -> bool { this_.as_rust_type_ref().is_some() } From 9e3a063c2513b0ed85ef2760388cecc9dc810aae Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 25 Oct 2024 16:48:18 +0200 Subject: [PATCH 26/38] doc comments corrected --- include/zenoh_commons.h | 20 +++++++++++++------- src/closures/query_channel.rs | 4 ++-- src/closures/sample_channel.rs | 2 +- src/commons.rs | 2 +- src/queryable.rs | 4 ++-- src/scouting.rs | 2 +- src/serialization.rs | 2 +- src/zbytes.rs | 2 +- 8 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 6efe4b75f..b2ea46a6f 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1553,7 +1553,7 @@ void z_bytes_writer_finish(struct z_moved_bytes_writer_t *this_, ZENOHC_API const struct z_loaned_bytes_writer_t *z_bytes_writer_loan(const struct z_owned_bytes_writer_t *this_); /** - * Muatably borrows writer. + * Mutably borrows writer. */ ZENOHC_API struct z_loaned_bytes_writer_t *z_bytes_writer_loan_mut(struct z_owned_bytes_writer_t *this_); @@ -2428,7 +2428,7 @@ ZENOHC_API void z_fifo_handler_query_drop(struct z_moved_fifo_handler_query_t *t ZENOHC_API const struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan(const struct z_owned_fifo_handler_query_t *this_); /** - * Borrows handler. + * Mutably borrows handler. */ ZENOHC_API struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan_mut(struct z_owned_fifo_handler_query_t *this_); @@ -2545,7 +2545,7 @@ ZENOHC_API void z_hello_drop(struct z_moved_hello_t *this_); */ ZENOHC_API const struct z_loaned_hello_t *z_hello_loan(const struct z_owned_hello_t *this_); /** - * Borrows hello message. + * Mutably borrows hello message. */ ZENOHC_API struct z_loaned_hello_t *z_hello_loan_mut(struct z_owned_hello_t *this_); /** @@ -3502,8 +3502,14 @@ ZENOHC_API void z_queryable_drop(struct z_moved_queryable_t *this_); ZENOHC_API z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); #endif +/** + * Borrows Queryable. + */ ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); +/** + * Mutably borrows Queryable. + */ ZENOHC_API struct z_loaned_queryable_t *z_queryable_loan_mut(struct z_owned_queryable_t *this_); /** * Constructs the default value for `z_query_reply_options_t`. @@ -3651,7 +3657,7 @@ ZENOHC_API void z_ring_handler_query_drop(struct z_moved_ring_handler_query_t *t ZENOHC_API const struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan(const struct z_owned_ring_handler_query_t *this_); /** - * Borrows handler. + * Mutably borrows handler. */ ZENOHC_API struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan_mut(struct z_owned_ring_handler_query_t *this_); @@ -3711,7 +3717,7 @@ ZENOHC_API void z_ring_handler_sample_drop(struct z_moved_ring_handler_sample_t ZENOHC_API const struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan(const struct z_owned_ring_handler_sample_t *this_); /** - * Borrows handler. + * Mutably borrows handler. */ ZENOHC_API struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan_mut(struct z_owned_ring_handler_sample_t *this_); @@ -4285,7 +4291,7 @@ const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *th #endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows source info. + * @brief Mutably borrows source info. */ #if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API @@ -5661,7 +5667,7 @@ void ze_serializer_finish(struct ze_moved_serializer_t *this_, ZENOHC_API const struct ze_loaned_serializer_t *ze_serializer_loan(const struct ze_owned_serializer_t *this_); /** - * @brief Muatably borrows serializer. + * @brief Mutably borrows serializer. */ ZENOHC_API struct ze_loaned_serializer_t *ze_serializer_loan_mut(struct ze_owned_serializer_t *this_); diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 78e86f970..7fb6559c0 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -105,7 +105,7 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan( .as_loaned_c_type_ref() } -/// Borrows handler. +/// Mutably borrows handler. #[no_mangle] pub extern "C" fn z_fifo_handler_query_loan_mut( this: &mut z_owned_fifo_handler_query_t, @@ -222,7 +222,7 @@ pub unsafe extern "C" fn z_ring_handler_query_loan( .as_loaned_c_type_ref() } -/// Borrows handler. +/// Mutably borrows handler. #[no_mangle] pub extern "C" fn z_ring_handler_query_loan_mut( this: &mut z_owned_ring_handler_query_t, diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 81a7ad2e7..0fb1add5d 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -222,7 +222,7 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan( .as_loaned_c_type_ref() } -/// Borrows handler. +/// Mutably borrows handler. #[no_mangle] pub extern "C" fn z_ring_handler_sample_loan_mut( this: &mut z_owned_ring_handler_sample_t, diff --git a/src/commons.rs b/src/commons.rs index dcb6d6e66..11748a5d0 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -617,7 +617,7 @@ pub extern "C" fn z_source_info_loan(this_: &z_owned_source_info_t) -> &z_loaned #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows source info. +/// @brief Mutably borrows source info. #[no_mangle] pub extern "C" fn z_source_info_loan_mut( this_: &mut z_owned_source_info_t, diff --git a/src/queryable.rs b/src/queryable.rs index 042fa145b..be5841109 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -48,7 +48,7 @@ pub extern "C" fn z_internal_queryable_null(this_: &mut MaybeUninit &z_loaned_queryable_t { @@ -59,7 +59,7 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa .as_loaned_c_type_ref() } -// Mutably borrows Queryable +/// Mutably borrows Queryable. #[no_mangle] pub extern "C" fn z_queryable_loan_mut( this_: &mut z_owned_queryable_t, diff --git a/src/scouting.rs b/src/scouting.rs index 9561e47c2..dd34afaf9 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -52,7 +52,7 @@ pub unsafe extern "C" fn z_hello_loan(this_: &z_owned_hello_t) -> &z_loaned_hell .as_loaned_c_type_ref() } -/// Borrows hello message. +/// Mutably borrows hello message. #[no_mangle] pub extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { this_.as_rust_type_mut().as_loaned_c_type_mut() diff --git a/src/serialization.rs b/src/serialization.rs index b6156d420..e6ced4dfc 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -72,7 +72,7 @@ pub unsafe extern "C" fn ze_serializer_loan( .as_loaned_c_type_ref() } -/// @brief Muatably borrows serializer. +/// @brief Mutably borrows serializer. #[no_mangle] pub extern "C" fn ze_serializer_loan_mut( this: &mut ze_owned_serializer_t, diff --git a/src/zbytes.rs b/src/zbytes.rs index 29464b34e..7bd5fd5ab 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -637,7 +637,7 @@ pub unsafe extern "C" fn z_bytes_writer_loan( .as_loaned_c_type_ref() } -/// Muatably borrows writer. +/// Mutably borrows writer. #[no_mangle] pub extern "C" fn z_bytes_writer_loan_mut( this: &mut z_owned_bytes_writer_t, From a87992f8b7265de7f6d483f98d69f5d1f14a942e Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 25 Oct 2024 16:55:01 +0200 Subject: [PATCH 27/38] internal local names no need to have 'z..' prefix --- src/serialization.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/serialization.rs b/src/serialization.rs index e6ced4dfc..b492e3ce2 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -482,7 +482,7 @@ where result::Z_OK } -fn zdeserializer_deserialize_arithmetic<'a, T>( +fn deserializer_deserialize_arithmetic<'a, T>( this: &'a mut ze_deserializer_t, val: &'a mut T, ) -> z_result_t @@ -607,7 +607,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint8( this: &mut ze_deserializer_t, dst: &mut u8, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -617,7 +617,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint16( this: &mut ze_deserializer_t, dst: &mut u16, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -627,7 +627,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint32( this: &mut ze_deserializer_t, dst: &mut u32, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -637,7 +637,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint64( this: &mut ze_deserializer_t, dst: &mut u64, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -647,7 +647,7 @@ pub extern "C" fn ze_deserializer_deserialize_int8( this: &mut ze_deserializer_t, dst: &mut i8, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -657,7 +657,7 @@ pub extern "C" fn ze_deserializer_deserialize_int16( this: &mut ze_deserializer_t, dst: &mut i16, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -667,7 +667,7 @@ pub extern "C" fn ze_deserializer_deserialize_int32( this: &mut ze_deserializer_t, dst: &mut i32, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -677,7 +677,7 @@ pub extern "C" fn ze_deserializer_deserialize_int64( this: &mut ze_deserializer_t, dst: &mut i64, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a float. @@ -687,7 +687,7 @@ pub extern "C" fn ze_deserializer_deserialize_float( this: &mut ze_deserializer_t, dst: &mut f32, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -697,7 +697,7 @@ pub extern "C" fn ze_deserializer_deserialize_double( this: &mut ze_deserializer_t, dst: &mut f64, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a bool. @@ -707,7 +707,7 @@ pub extern "C" fn ze_deserializer_deserialize_bool( this: &mut ze_deserializer_t, dst: &mut bool, ) -> z_result_t { - zdeserializer_deserialize_arithmetic::(this, dst) + deserializer_deserialize_arithmetic::(this, dst) } /// @brief Serializes a slice. From 097ac4a6c3c9b5a286eabec4793979e4a526c9fb Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Sat, 26 Oct 2024 16:44:15 +0200 Subject: [PATCH 28/38] use loaned_mut on Option only where required --- include/zenoh_commons.h | 6 ---- src/collections.rs | 4 +-- src/commons.rs | 6 ++-- src/config.rs | 4 +-- src/encoding.rs | 2 +- src/get.rs | 6 ++-- src/platform/synchronization.rs | 17 +++------- src/queryable.rs | 4 +-- src/scouting.rs | 4 +-- src/serialization.rs | 40 ++++------------------ src/session.rs | 4 +-- src/shm/buffer/zshm.rs | 7 ++-- src/shm/buffer/zshmmut.rs | 8 ++--- src/shm/client_storage/mod.rs | 5 +-- src/transmute.rs | 60 ++++++++++++++------------------- src/zbytes.rs | 10 ++---- 16 files changed, 57 insertions(+), 130 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index b2ea46a6f..1ef001732 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -5784,12 +5784,6 @@ z_result_t ze_serializer_serialize_uint64(struct ze_loaned_serializer_t *this_, ZENOHC_API z_result_t ze_serializer_serialize_uint8(struct ze_loaned_serializer_t *this_, uint8_t val); -/** - * @brief Takes ownership of the mutably borrowed serializer. - */ -ZENOHC_API -void ze_serializer_take_loaned(struct ze_owned_serializer_t *dst, - struct ze_loaned_serializer_t *src); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Undeclares publication cache. diff --git a/src/collections.rs b/src/collections.rs index f51ec23cb..7a1f6df7a 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -269,7 +269,7 @@ pub use crate::opaque_types::{z_loaned_slice_t, z_moved_slice_t, z_owned_slice_t decl_c_type!( owned(z_owned_slice_t, CSliceOwned), - loaned(z_loaned_slice_t, CSlice), + loaned(z_loaned_slice_t, CSlice, CSlice), view(z_view_slice_t, CSliceView), ); @@ -543,7 +543,7 @@ impl From for CSlice { decl_c_type!( owned(z_owned_string_t, CStringOwned), - loaned(z_loaned_string_t, CString), + loaned(z_loaned_string_t, CString, CString), view(z_view_string_t, CStringView), ); diff --git a/src/commons.rs b/src/commons.rs index 11748a5d0..e0e1d66f9 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -102,8 +102,8 @@ pub extern "C" fn z_timestamp_id(this_: &z_timestamp_t) -> z_id_t { use crate::opaque_types::z_loaned_sample_t; pub use crate::opaque_types::{z_moved_sample_t, z_owned_sample_t}; decl_c_type!( - owned(z_owned_sample_t, option Sample), - loaned(z_loaned_sample_t), + owned(z_owned_sample_t, Option), + loaned(z_loaned_sample_t, Sample, Option), ); /// Returns the key expression of the sample. @@ -561,7 +561,7 @@ pub use crate::opaque_types::{z_loaned_source_info_t, z_owned_source_info_t}; #[cfg(feature = "unstable")] decl_c_type!( owned(z_owned_source_info_t, SourceInfo), - loaned(z_loaned_source_info_t, SourceInfo), + loaned(z_loaned_source_info_t), ); #[cfg(feature = "unstable")] diff --git a/src/config.rs b/src/config.rs index f41f8734e..f554678ee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -195,9 +195,7 @@ pub unsafe extern "C" fn zc_config_insert_json5_from_substr( value: *const c_char, value_len: usize, ) -> result::z_result_t { - let Some(config) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; + let config = this.as_rust_type_mut(); let key = match from_utf8(from_raw_parts(key as _, key_len)) { Ok(s) => s, Err(e) => { diff --git a/src/encoding.rs b/src/encoding.rs index 776a5f533..e97277be4 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -34,7 +34,7 @@ use crate::{ decl_c_type!( owned(z_owned_encoding_t, Encoding), - loaned(z_loaned_encoding_t, Encoding), + loaned(z_loaned_encoding_t), ); /// Constructs a `z_owned_encoding_t` from a specified substring. diff --git a/src/get.rs b/src/get.rs index 890d5f64a..0d1243917 100644 --- a/src/get.rs +++ b/src/get.rs @@ -40,7 +40,7 @@ use crate::{ }; decl_c_type!( owned(z_owned_reply_err_t, ReplyError), - loaned(z_loaned_reply_err_t, ReplyError), + loaned(z_loaned_reply_err_t), ); /// Constructs an empty `z_owned_reply_err_t`. @@ -90,8 +90,8 @@ pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { pub use crate::opaque_types::{z_loaned_reply_t, z_moved_reply_t, z_owned_reply_t}; decl_c_type!( - owned(z_owned_reply_t, option Reply), - loaned(z_loaned_reply_t), + owned(z_owned_reply_t, Option), + loaned(z_loaned_reply_t, Reply, Option), ); /// Returns ``true`` if reply contains a valid response, ``false`` otherwise (in this case it contains a errror value). diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index b6b89189a..dba5bb0c8 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -58,10 +58,7 @@ pub extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned /// @return 0 in case of success, negative error code in case of failure. #[no_mangle] pub extern "C" fn z_mutex_lock(this_: &'static mut z_loaned_mutex_t) -> result::z_result_t { - let Some(this) = this_.as_rust_type_mut() else { - return result::Z_ENULL; - }; - + let this = this_.as_rust_type_mut(); match this.0.lock() { Ok(new_lock) => { let old_lock = this.1.replace(new_lock); @@ -78,9 +75,7 @@ pub extern "C" fn z_mutex_lock(this_: &'static mut z_loaned_mutex_t) -> result:: /// @return 0 in case of success, negative error code otherwise. #[no_mangle] pub extern "C" fn z_mutex_unlock(this_: &mut z_loaned_mutex_t) -> result::z_result_t { - let Some(this) = this_.as_rust_type_mut() else { - return result::Z_ENULL; - }; + let this = this_.as_rust_type_mut(); if this.1.is_none() { return result::Z_EINVAL_MUTEX; } else { @@ -96,9 +91,7 @@ pub extern "C" fn z_mutex_unlock(this_: &mut z_loaned_mutex_t) -> result::z_resu pub unsafe extern "C" fn z_mutex_try_lock( this: &'static mut z_loaned_mutex_t, ) -> result::z_result_t { - let Some(this) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; + let this = this.as_rust_type_mut(); match this.0.try_lock() { Ok(new_lock) => { let old_lock = this.1.replace(new_lock); @@ -185,9 +178,7 @@ pub unsafe extern "C" fn z_condvar_wait( m: &mut z_loaned_mutex_t, ) -> result::z_result_t { let this = this.as_rust_type_ref(); - let Some(m) = m.as_rust_type_mut() else { - return result::Z_ENULL; - }; + let m = m.as_rust_type_mut(); if m.1.is_none() { return result::Z_EINVAL_MUTEX; // lock was not aquired prior to wait call } diff --git a/src/queryable.rs b/src/queryable.rs index be5841109..f55868612 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -69,8 +69,8 @@ pub extern "C" fn z_queryable_loan_mut( pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; decl_c_type!( - owned(z_owned_query_t, option Query), - loaned(z_loaned_query_t), + owned(z_owned_query_t, Option), + loaned(z_loaned_query_t, Query, Option), ); /// Constructs query in its gravestone value. diff --git a/src/scouting.rs b/src/scouting.rs index dd34afaf9..9e53452b1 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -30,8 +30,8 @@ use crate::{ z_owned_string_array_t, z_view_string_t, CString, CStringView, ZVector, }; decl_c_type!( - owned(z_owned_hello_t, option Hello ), - loaned(z_loaned_hello_t), + owned(z_owned_hello_t, Option), + loaned(z_loaned_hello_t, Hello, Option), ); /// Frees memory and resets hello message to its gravestone state. diff --git a/src/serialization.rs b/src/serialization.rs index b492e3ce2..7c73b2ac6 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -80,16 +80,6 @@ pub extern "C" fn ze_serializer_loan_mut( this.as_rust_type_mut().as_loaned_c_type_mut() } -/// @brief Takes ownership of the mutably borrowed serializer. -#[no_mangle] -pub extern "C" fn ze_serializer_take_loaned( - dst: &mut MaybeUninit, - src: &mut ze_loaned_serializer_t, -) { - dst.as_rust_type_mut_uninit() - .write(std::mem::take(src.as_rust_type_mut())); -} - /// @brief Constructs a serializer in a gravestone state. #[no_mangle] pub extern "C" fn ze_internal_serializer_null(this_: &mut MaybeUninit) { @@ -475,10 +465,7 @@ fn serializer_serialize_arithmetic(this: &mut ze_loaned_serializer_t, val: &T where T: Serialize, { - let Some(serializer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; - serializer.serialize(val); + this.as_rust_type_mut().serialize(val); result::Z_OK } @@ -716,11 +703,8 @@ pub extern "C" fn ze_serializer_serialize_slice( this: &mut ze_loaned_serializer_t, slice: &z_loaned_slice_t, ) -> z_result_t { - let Some(serializer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; let cslice = slice.as_rust_type_ref().slice(); - serializer.serialize(cslice); + this.as_rust_type_mut().serialize(cslice); result::Z_OK } @@ -734,11 +718,8 @@ pub extern "C" fn ze_serializer_serialize_buf( data: *const u8, len: usize, ) -> z_result_t { - let Some(serializer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; let slice = unsafe { from_raw_parts(data, len) }; - serializer.serialize(slice); + this.as_rust_type_mut().serialize(slice); result::Z_OK } @@ -771,12 +752,9 @@ pub extern "C" fn ze_serializer_serialize_string( this: &mut ze_loaned_serializer_t, str: &z_loaned_string_t, ) -> z_result_t { - let Some(serializer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; match str::from_utf8(str.as_rust_type_ref().slice()) { Ok(s) => { - serializer.serialize(s); + this.as_rust_type_mut().serialize(s); result::Z_OK } Err(e) => { @@ -795,13 +773,10 @@ pub extern "C" fn ze_serializer_serialize_substr( start: *const libc::c_char, len: usize, ) -> z_result_t { - let Some(serializer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; let slice = unsafe { from_raw_parts(start as *const u8, len) }; match str::from_utf8(slice) { Ok(s) => { - serializer.serialize(s); + this.as_rust_type_mut().serialize(s); result::Z_OK } Err(e) => { @@ -849,10 +824,7 @@ pub extern "C" fn ze_serializer_serialize_sequence_length( this: &mut ze_loaned_serializer_t, len: usize, ) -> z_result_t { - let Some(serializer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; - serializer.serialize(VarInt::(len)); + this.as_rust_type_mut().serialize(VarInt::(len)); result::Z_OK } diff --git a/src/session.rs b/src/session.rs index ac614fa9b..ad8c424fd 100644 --- a/src/session.rs +++ b/src/session.rs @@ -157,9 +157,7 @@ pub extern "C" fn z_close( session: &mut z_loaned_session_t, _options: Option<&z_close_options_t>, ) -> result::z_result_t { - let Some(s) = session.as_rust_type_mut() else { - return result::Z_ENULL; - }; + let s = session.as_rust_type_mut(); match s.close().wait() { Err(e) => { tracing::error!("Error closing session: {}", e); diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index 5b63e7187..b66c01ccb 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -29,7 +29,7 @@ use crate::{ decl_c_type!( owned(z_owned_shm_t, Option), - loaned(z_loaned_shm_t, zshm), + loaned(z_loaned_shm_t, zshm, zshm), ); /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -116,10 +116,7 @@ pub extern "C" fn z_shm_drop(this_: &mut z_moved_shm_t) { pub unsafe extern "C" fn z_shm_try_reloan_mut( this_: &mut z_loaned_shm_t, ) -> *mut z_loaned_shm_mut_t { - let Some(this) = this_.as_rust_type_mut() else { - return std::ptr::null_mut(); - }; - match this.try_into() { + match this_.as_rust_type_mut().try_into() { Ok(val) => { let v: &mut zshmmut = val; v.as_loaned_c_type_mut_unsafe() diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index 9fe6a17d7..5f00ae72b 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -26,7 +26,7 @@ use crate::{ decl_c_type!( owned(z_owned_shm_mut_t, Option), - loaned(z_loaned_shm_mut_t, zshmmut), + loaned(z_loaned_shm_mut_t, zshmmut, zshmmut), ); /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -119,9 +119,5 @@ pub extern "C" fn z_shm_mut_data(this_: &z_loaned_shm_mut_t) -> *const libc::c_u #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_mut_ptr() + this_.as_rust_type_mut().as_mut().as_mut_ptr() } diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 577b0ab44..4c04e6f9c 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -93,13 +93,10 @@ pub extern "C" fn zc_shm_client_list_add_client( id: z_protocol_id_t, client: &mut z_moved_shm_client_t, ) -> z_result_t { - let Some(this) = this.as_rust_type_mut() else { - return Z_EINVAL; - }; let Some(client) = client.take_rust_type() else { return Z_EINVAL; }; - this.push((id, client)); + this.as_rust_type_mut().push((id, client)); Z_OK } diff --git a/src/transmute.rs b/src/transmute.rs index 28be41434..0dce8b9a2 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -433,37 +433,42 @@ macro_rules! decl_c_type { impl_owned!(owned $c_owned_type, rust $rust_owned_type); }; // - // Owned with with explicit rust loaned type - rarely used + // Owned with with loaned types explicitely defined // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) - $(,)?) => { - impl_owned!(owned $c_owned_type, rust option $rust_inner_type); - impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); - impl_transmute!(as_c_loaned_mut_unsafe($rust_inner_type, $c_loaned_type)); - impl_transmute!(as_c_loaned_mut(Option<$rust_inner_type>, $c_loaned_type)); - impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); - impl_transmute!(as_rust_mut($c_loaned_type, Option<$rust_inner_type>)); - }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) + loaned ($c_loaned_type:ty, $rust_loaned_type:ty, $rust_loaned_mut_type:ty $(,)?) $(,)?) => { impl_owned!(owned $c_owned_type, rust $rust_owned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut_unsafe($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_owned_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); - impl_transmute!(as_rust_mut($c_loaned_type, $rust_owned_type)); + impl_transmute!(as_rust_mut($c_loaned_type, $rust_loaned_mut_type)); }; // - // Owned with loaned type same as inner type - typical case + // Owned with loaned types explicitely defined + view type + // + (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), + loaned ($c_loaned_type:ty, $rust_loaned_type:ty, $rust_loaned_mut_type:ty $(,)?), + view ($c_view_type:ty, $rust_view_type:ty $(,)?) + $(,)?) => { + decl_c_type!( + owned($c_owned_type, $rust_owned_type), + loaned($c_loaned_type, $rust_loaned_type, $rust_loaned_mut_type) + ); + impl_transmute!(as_c_view($rust_view_type, $c_view_type)); + impl_transmute!(as_rust($c_view_type, $rust_view_type)); + impl_transmute!(as_rust_mut($c_view_type, $rust_view_type)); + }; + // + // Shortcuts for typical case, when C loaned type (both const and mut) points to the same Rust type (under option if owned type is Option) // (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), loaned ($c_loaned_type:ty $(,)?) $(,)?) => { decl_c_type!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type, $rust_inner_type), + owned($c_owned_type, Option<$rust_inner_type>), + loaned($c_loaned_type, $rust_inner_type, $rust_inner_type), ); }; (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), @@ -471,19 +476,16 @@ macro_rules! decl_c_type { $(,)?) => { decl_c_type!( owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_owned_type), + loaned($c_loaned_type, $rust_owned_type, $rust_owned_type), ); }; - // - // With view type - // (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), loaned ($c_loaned_type:ty $(,)?), view ($c_view_type:ty, $rust_view_type:ty $(,)?) $(,)?) => { decl_c_type!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type), + owned($c_owned_type, Option<$rust_inner_type>), + loaned($c_loaned_type, $rust_inner_type, $rust_inner_type), ); impl_transmute!(as_c_view($rust_view_type, $c_view_type)); impl_transmute!(as_rust($c_view_type, $rust_view_type)); @@ -495,19 +497,7 @@ macro_rules! decl_c_type { $(,)?) => { decl_c_type!( owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_owned_type), - ); - impl_transmute!(as_c_view($rust_view_type, $c_view_type)); - impl_transmute!(as_rust($c_view_type, $rust_view_type)); - impl_transmute!(as_rust_mut($c_view_type, $rust_view_type)); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_loaned_type), + loaned($c_loaned_type, $rust_owned_type, $rust_owned_type), ); impl_transmute!(as_c_view($rust_view_type, $c_view_type)); impl_transmute!(as_rust($c_view_type, $rust_view_type)); diff --git a/src/zbytes.rs b/src/zbytes.rs index 7bd5fd5ab..d97c1446c 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -675,10 +675,7 @@ unsafe extern "C" fn z_bytes_writer_write_all( src: *const u8, len: usize, ) -> z_result_t { - let Some(writer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; - match writer.write_all(from_raw_parts(src, len)) { + match this.as_rust_type_mut().write_all(from_raw_parts(src, len)) { Ok(_) => Z_OK, Err(_) => Z_EIO, } @@ -694,9 +691,6 @@ extern "C" fn z_bytes_writer_append( this: &mut z_loaned_bytes_writer_t, bytes: &mut z_moved_bytes_t, ) -> z_result_t { - let Some(writer) = this.as_rust_type_mut() else { - return result::Z_ENULL; - }; - writer.append(bytes.take_rust_type()); + this.as_rust_type_mut().append(bytes.take_rust_type()); result::Z_OK } From 792aa7ec113a9859ec433dbcb8b66365f64c6204 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Sat, 26 Oct 2024 17:39:10 +0200 Subject: [PATCH 29/38] transmute rs corrected --- src/closures/query_channel.rs | 16 ++++++-- src/closures/response_channel.rs | 16 ++++++-- src/closures/sample_channel.rs | 16 ++++++-- src/config.rs | 9 ++++- src/keyexpr.rs | 11 +++++- src/platform/synchronization.rs | 9 ++++- src/publisher.rs | 8 +++- src/queryable.rs | 9 ++++- src/serialization.rs | 68 +++++++++++++++++++------------- src/session.rs | 11 +++++- src/shm/buffer/zshm.rs | 10 ++++- src/shm/buffer/zshmmut.rs | 17 ++++++-- src/shm/client_storage/mod.rs | 13 ++++-- src/shm/provider/alloc_layout.rs | 8 +++- src/shm/provider/shm_provider.rs | 8 +++- src/subscriber.rs | 9 ++++- src/transmute.rs | 2 +- src/zbytes.rs | 8 +++- 18 files changed, 180 insertions(+), 68 deletions(-) diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index 7fb6559c0..ecec642a3 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -107,10 +107,14 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan( /// Mutably borrows handler. #[no_mangle] -pub extern "C" fn z_fifo_handler_query_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_fifo_handler_query_loan_mut( this: &mut z_owned_fifo_handler_query_t, ) -> &mut z_loaned_fifo_handler_query_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until @@ -224,10 +228,14 @@ pub unsafe extern "C" fn z_ring_handler_query_loan( /// Mutably borrows handler. #[no_mangle] -pub extern "C" fn z_ring_handler_query_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_ring_handler_query_loan_mut( this: &mut z_owned_ring_handler_query_t, ) -> &mut z_loaned_ring_handler_query_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index 19592143a..4e027e94b 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -107,10 +107,14 @@ pub unsafe extern "C" fn z_fifo_handler_reply_loan( /// Mutably borrows handler. #[no_mangle] -pub extern "C" fn z_fifo_handler_reply_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_fifo_handler_reply_loan_mut( this: &mut z_owned_fifo_handler_reply_t, ) -> &mut z_loaned_fifo_handler_reply_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until @@ -220,10 +224,14 @@ pub unsafe extern "C" fn z_ring_handler_reply_loan( /// Mutably borrows handler. #[no_mangle] -pub extern "C" fn z_ring_handler_reply_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_ring_handler_reply_loan_mut( this: &mut z_owned_ring_handler_reply_t, ) -> &mut z_loaned_ring_handler_reply_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 0fb1add5d..3fefc7b32 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -107,10 +107,14 @@ pub unsafe extern "C" fn z_fifo_handler_sample_loan( /// Mutably borrows handler. #[no_mangle] -pub extern "C" fn z_fifo_handler_sample_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_fifo_handler_sample_loan_mut( this: &mut z_owned_fifo_handler_sample_t, ) -> &mut z_loaned_fifo_handler_sample_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until @@ -224,10 +228,14 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan( /// Mutably borrows handler. #[no_mangle] -pub extern "C" fn z_ring_handler_sample_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_ring_handler_sample_loan_mut( this: &mut z_owned_ring_handler_sample_t, ) -> &mut z_loaned_ring_handler_sample_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until diff --git a/src/config.rs b/src/config.rs index f554678ee..34dd515c1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -86,8 +86,13 @@ pub unsafe extern "C" fn z_config_loan(this_: &'static z_owned_config_t) -> &z_l /// Mutably borrows config. #[no_mangle] -pub extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loaned_config_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loaned_config_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Constructs a new empty configuration. diff --git a/src/keyexpr.rs b/src/keyexpr.rs index bf1c65537..e75c0bd06 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -138,8 +138,15 @@ pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_ /// Mutably borrows `z_owned_keyexpr_t`. #[no_mangle] -pub extern "C" fn z_keyexpr_loan_mut(this_: &mut z_owned_keyexpr_t) -> &mut z_loaned_keyexpr_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_keyexpr_loan_mut( + this_: &mut z_owned_keyexpr_t, +) -> &mut z_loaned_keyexpr_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Borrows `z_view_keyexpr_t`. diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index dba5bb0c8..958d11f74 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -50,8 +50,13 @@ pub extern "C" fn z_internal_mutex_null(this_: &mut MaybeUninit /// Mutably borrows mutex. #[no_mangle] -pub extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned_mutex_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned_mutex_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Locks mutex. If mutex is already locked, blocks the thread until it aquires the lock. diff --git a/src/publisher.rs b/src/publisher.rs index 57ac6ebc5..be7b91c37 100644 --- a/src/publisher.rs +++ b/src/publisher.rs @@ -167,10 +167,14 @@ pub unsafe extern "C" fn z_publisher_loan(this_: &z_owned_publisher_t) -> &z_loa /// Mutably borrows publisher. #[no_mangle] -pub extern "C" fn z_publisher_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_publisher_loan_mut( this: &mut z_owned_publisher_t, ) -> &mut z_loaned_publisher_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Options passed to the `z_publisher_put()` function. diff --git a/src/queryable.rs b/src/queryable.rs index f55868612..b66833833 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -61,10 +61,15 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa /// Mutably borrows Queryable. #[no_mangle] -pub extern "C" fn z_queryable_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_queryable_loan_mut( this_: &mut z_owned_queryable_t, ) -> &mut z_loaned_queryable_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; diff --git a/src/serialization.rs b/src/serialization.rs index 7c73b2ac6..82d2ac8cb 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -74,10 +74,14 @@ pub unsafe extern "C" fn ze_serializer_loan( /// @brief Mutably borrows serializer. #[no_mangle] -pub extern "C" fn ze_serializer_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn ze_serializer_loan_mut( this: &mut ze_owned_serializer_t, ) -> &mut ze_loaned_serializer_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// @brief Constructs a serializer in a gravestone state. @@ -461,15 +465,14 @@ pub unsafe extern "C" fn ze_deserializer_is_done(this_: &ze_deserializer_t) -> b deserializer.done() } -fn serializer_serialize_arithmetic(this: &mut ze_loaned_serializer_t, val: &T) -> z_result_t +fn ze_serializer_serialize_arithmetic(this: &mut ze_loaned_serializer_t, val: &T) where T: Serialize, { this.as_rust_type_mut().serialize(val); - result::Z_OK } -fn deserializer_deserialize_arithmetic<'a, T>( +fn ze_deserializer_deserialize_arithmetic<'a, T>( this: &'a mut ze_deserializer_t, val: &'a mut T, ) -> z_result_t @@ -494,7 +497,8 @@ pub extern "C" fn ze_serializer_serialize_uint8( this_: &mut ze_loaned_serializer_t, val: u8, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes an unsigned integer. @@ -503,7 +507,8 @@ pub extern "C" fn ze_serializer_serialize_uint16( this_: &mut ze_loaned_serializer_t, val: u16, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes an unsigned integer. @@ -512,7 +517,8 @@ pub extern "C" fn ze_serializer_serialize_uint32( this_: &mut ze_loaned_serializer_t, val: u32, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes an unsigned integer. @@ -521,7 +527,8 @@ pub extern "C" fn ze_serializer_serialize_uint64( this_: &mut ze_loaned_serializer_t, val: u64, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a signed integer. @@ -530,7 +537,8 @@ pub extern "C" fn ze_serializer_serialize_int8( this_: &mut ze_loaned_serializer_t, val: i8, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a signed integer. @@ -539,7 +547,8 @@ pub extern "C" fn ze_serializer_serialize_int16( this_: &mut ze_loaned_serializer_t, val: i16, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a signed integer. @@ -548,7 +557,8 @@ pub extern "C" fn ze_serializer_serialize_int32( this_: &mut ze_loaned_serializer_t, val: i32, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a signed integer. @@ -557,7 +567,8 @@ pub extern "C" fn ze_serializer_serialize_int64( this_: &mut ze_loaned_serializer_t, val: i64, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a float. @@ -566,7 +577,8 @@ pub extern "C" fn ze_serializer_serialize_float( this_: &mut ze_loaned_serializer_t, val: f32, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a double. @@ -575,7 +587,8 @@ pub extern "C" fn ze_serializer_serialize_double( this_: &mut ze_loaned_serializer_t, val: f64, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Serializes a bool. @@ -584,7 +597,8 @@ pub extern "C" fn ze_serializer_serialize_bool( this_: &mut ze_loaned_serializer_t, val: bool, ) -> z_result_t { - serializer_serialize_arithmetic::(this_, &val) + ze_serializer_serialize_arithmetic::(this_, &val); + result::Z_OK } /// @brief Deserializes into an unsigned integer. @@ -594,7 +608,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint8( this: &mut ze_deserializer_t, dst: &mut u8, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -604,7 +618,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint16( this: &mut ze_deserializer_t, dst: &mut u16, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -614,7 +628,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint32( this: &mut ze_deserializer_t, dst: &mut u32, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into an unsigned integer. @@ -624,7 +638,7 @@ pub extern "C" fn ze_deserializer_deserialize_uint64( this: &mut ze_deserializer_t, dst: &mut u64, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -634,7 +648,7 @@ pub extern "C" fn ze_deserializer_deserialize_int8( this: &mut ze_deserializer_t, dst: &mut i8, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -644,7 +658,7 @@ pub extern "C" fn ze_deserializer_deserialize_int16( this: &mut ze_deserializer_t, dst: &mut i16, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -654,7 +668,7 @@ pub extern "C" fn ze_deserializer_deserialize_int32( this: &mut ze_deserializer_t, dst: &mut i32, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -664,7 +678,7 @@ pub extern "C" fn ze_deserializer_deserialize_int64( this: &mut ze_deserializer_t, dst: &mut i64, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a float. @@ -674,7 +688,7 @@ pub extern "C" fn ze_deserializer_deserialize_float( this: &mut ze_deserializer_t, dst: &mut f32, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a signed integer. @@ -684,7 +698,7 @@ pub extern "C" fn ze_deserializer_deserialize_double( this: &mut ze_deserializer_t, dst: &mut f64, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Deserializes into a bool. @@ -694,7 +708,7 @@ pub extern "C" fn ze_deserializer_deserialize_bool( this: &mut ze_deserializer_t, dst: &mut bool, ) -> z_result_t { - deserializer_deserialize_arithmetic::(this, dst) + ze_deserializer_deserialize_arithmetic::(this, dst) } /// @brief Serializes a slice. diff --git a/src/session.rs b/src/session.rs index ad8c424fd..25fba150c 100644 --- a/src/session.rs +++ b/src/session.rs @@ -44,8 +44,15 @@ pub unsafe extern "C" fn z_session_loan(this_: &z_owned_session_t) -> &z_loaned_ /// Mutably borrows session. #[no_mangle] -pub extern "C" fn z_session_loan_mut(this_: &mut z_owned_session_t) -> &mut z_loaned_session_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_session_loan_mut( + this_: &mut z_owned_session_t, +) -> &mut z_loaned_session_t { + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Constructs a Zenoh session in its gravestone state. diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index b66c01ccb..a074ffb49 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -81,8 +81,14 @@ pub unsafe extern "C" fn z_shm_loan(this_: &z_owned_shm_t) -> &z_loaned_shm_t { /// @brief Mutably borrows ZShm slice. #[no_mangle] -pub extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_t { + let this: &mut zshm = this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .borrow_mut(); + this.as_loaned_c_type_mut() } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index 5f00ae72b..b52666495 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -12,7 +12,10 @@ // ZettaScale Zenoh Team, // -use std::{borrow::Borrow, mem::MaybeUninit}; +use std::{ + borrow::{Borrow, BorrowMut}, + mem::MaybeUninit, +}; use zenoh::shm::{zshmmut, ZShmMut}; @@ -88,8 +91,16 @@ pub unsafe extern "C" fn z_shm_mut_loan(this_: &z_owned_shm_mut_t) -> &z_loaned_ /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows ZShmMut slice. #[no_mangle] -pub extern "C" fn z_shm_mut_loan_mut(this: &mut z_owned_shm_mut_t) -> &mut z_loaned_shm_mut_t { - this.as_rust_type_mut().as_loaned_c_type_mut() +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_shm_mut_loan_mut( + this: &mut z_owned_shm_mut_t, +) -> &mut z_loaned_shm_mut_t { + let shmmut: &mut zshmmut = this + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .borrow_mut(); + shmmut.as_loaned_c_type_mut() } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 4c04e6f9c..3f82b7760 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -83,7 +83,10 @@ pub unsafe extern "C" fn zc_shm_client_list_loan( pub unsafe extern "C" fn zc_shm_client_list_loan_mut( this: &mut zc_owned_shm_client_list_t, ) -> &mut zc_loaned_shm_client_list_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. @@ -201,8 +204,12 @@ pub unsafe extern "C" fn z_shm_client_storage_loan( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows SHM Client Storage. #[no_mangle] -pub extern "C" fn z_shm_client_storage_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_shm_client_storage_loan_mut( this: &mut z_owned_shm_client_storage_t, ) -> &mut z_loaned_shm_client_storage_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index 32530b757..d9e0097c0 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -90,10 +90,14 @@ pub unsafe extern "C" fn z_alloc_layout_loan( /// Mutably borrows Alloc Layout #[no_mangle] -pub extern "C" fn z_alloc_layout_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_alloc_layout_loan_mut( this: &mut z_owned_alloc_layout_t, ) -> &mut z_loaned_alloc_layout_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Deletes Alloc Layout diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 5625da296..5b6ad6b4e 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -127,10 +127,14 @@ pub unsafe extern "C" fn z_shm_provider_loan( /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Mutably borrows SHM Provider. #[no_mangle] -pub extern "C" fn z_shm_provider_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_shm_provider_loan_mut( this: &mut z_owned_shm_provider_t, ) -> &mut z_loaned_shm_provider_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. diff --git a/src/subscriber.rs b/src/subscriber.rs index b0f6d338f..0a0096310 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -54,10 +54,15 @@ pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_l /// Mutably borrows subscriber. #[no_mangle] -pub extern "C" fn z_subscriber_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_subscriber_loan_mut( this_: &mut z_owned_subscriber_t, ) -> &mut z_loaned_subscriber_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() + this_ + .as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Options passed to the `z_declare_subscriber()` function. diff --git a/src/transmute.rs b/src/transmute.rs index 0dce8b9a2..4ec02196f 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -441,7 +441,7 @@ macro_rules! decl_c_type { impl_owned!(owned $c_owned_type, rust $rust_owned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut_unsafe($rust_loaned_type, $c_loaned_type)); - impl_transmute!(as_c_loaned_mut($rust_owned_type, $c_loaned_type)); + impl_transmute!(as_c_loaned_mut($rust_loaned_mut_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); impl_transmute!(as_rust_mut($c_loaned_type, $rust_loaned_mut_type)); }; diff --git a/src/zbytes.rs b/src/zbytes.rs index d97c1446c..31cb15d50 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -639,10 +639,14 @@ pub unsafe extern "C" fn z_bytes_writer_loan( /// Mutably borrows writer. #[no_mangle] -pub extern "C" fn z_bytes_writer_loan_mut( +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_bytes_writer_loan_mut( this: &mut z_owned_bytes_writer_t, ) -> &mut z_loaned_bytes_writer_t { - this.as_rust_type_mut().as_loaned_c_type_mut() + this.as_rust_type_mut() + .as_mut() + .unwrap_unchecked() + .as_loaned_c_type_mut() } /// Constructs a writer in a gravestone state. From e8e45685291eef00c2c4dc88f516dc7d0341f520 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Sat, 26 Oct 2024 17:50:47 +0200 Subject: [PATCH 30/38] unised trait removed --- src/shm/buffer/zshm.rs | 12 ++++-------- src/transmute.rs | 24 ------------------------ src/zbytes.rs | 7 ++----- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs index a074ffb49..451bad5e3 100644 --- a/src/shm/buffer/zshm.rs +++ b/src/shm/buffer/zshm.rs @@ -21,8 +21,7 @@ use zenoh::shm::{zshm, zshmmut, ZShm}; use crate::{ transmute::{ - LoanedCTypeMut, LoanedCTypeMutUnsafe, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, - RustTypeRef, TakeRustType, + LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, }, z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, }; @@ -102,7 +101,7 @@ pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> *mut z_loan match shm.try_into() { Ok(val) => { let v: &mut zshmmut = val; - v.as_loaned_c_type_mut_unsafe() + v.as_loaned_c_type_mut() } Err(_) => std::ptr::null_mut(), } @@ -118,14 +117,11 @@ pub extern "C" fn z_shm_drop(this_: &mut z_moved_shm_t) { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Tries to reborrow mutably-borrowed ZShm slice as borrowed ZShmMut slice. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_try_reloan_mut( - this_: &mut z_loaned_shm_t, -) -> *mut z_loaned_shm_mut_t { +pub extern "C" fn z_shm_try_reloan_mut(this_: &mut z_loaned_shm_t) -> *mut z_loaned_shm_mut_t { match this_.as_rust_type_mut().try_into() { Ok(val) => { let v: &mut zshmmut = val; - v.as_loaned_c_type_mut_unsafe() + v.as_loaned_c_type_mut() } Err(_) => std::ptr::null_mut(), } diff --git a/src/transmute.rs b/src/transmute.rs index 4ec02196f..a23c4d6e5 100644 --- a/src/transmute.rs +++ b/src/transmute.rs @@ -31,20 +31,6 @@ pub(crate) trait LoanedCTypeRef: Sized { type LoanedCType; fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType; } -#[allow(dead_code)] -pub(crate) trait LoanedCTypeMutUnsafe: Sized { - type LoanedCType; - // Sometimes it's known that the value of type `&mut Foo` is actually - // points to the `Foo` inside the `&mut Option`. - // Therefore it's safe to convert this `&mut Foo` to - // `z_foo_loaned_mut_t*` (which is converted back to - // Rust type as `&mut Option`). - // - // Obviously this trait should be implemented only if - // `validate_equivalence!(Foo, Option)` is satisfied. - unsafe fn as_loaned_c_type_mut_unsafe(&mut self) -> &mut Self::LoanedCType; -} - #[allow(dead_code)] pub(crate) trait LoanedCTypeMut: Sized { type LoanedCType; @@ -178,15 +164,6 @@ macro_rules! impl_transmute { } } }; - (as_c_loaned_mut_unsafe ($rust_type:ty, $c_type:ty)) => { - validate_equivalence!($rust_type, $c_type); - impl $crate::transmute::LoanedCTypeMutUnsafe for $rust_type { - type LoanedCType = $c_type; - unsafe fn as_loaned_c_type_mut_unsafe(&mut self) -> &mut Self::LoanedCType { - unsafe { &mut *(self as *mut Self as *mut Self::LoanedCType) } - } - } - }; (as_c_loaned_mut ($rust_type:ty, $c_type:ty)) => { validate_equivalence!($rust_type, $c_type); impl $crate::transmute::LoanedCTypeMut for $rust_type { @@ -440,7 +417,6 @@ macro_rules! decl_c_type { $(,)?) => { impl_owned!(owned $c_owned_type, rust $rust_owned_type); impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); - impl_transmute!(as_c_loaned_mut_unsafe($rust_loaned_type, $c_loaned_type)); impl_transmute!(as_c_loaned_mut($rust_loaned_mut_type, $c_loaned_type)); impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); impl_transmute!(as_rust_mut($c_loaned_type, $rust_loaned_mut_type)); diff --git a/src/zbytes.rs b/src/zbytes.rs index 31cb15d50..b0281942c 100644 --- a/src/zbytes.rs +++ b/src/zbytes.rs @@ -200,17 +200,14 @@ pub unsafe extern "C" fn z_bytes_to_loaned_shm( /// @param this_: Data to convert. /// @param dst: An uninitialized memory location where to construct an SHM buffer. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_to_mut_loaned_shm( +pub extern "C" fn z_bytes_to_mut_loaned_shm( this: &'static mut z_loaned_bytes_t, dst: &'static mut MaybeUninit<&'static mut z_loaned_shm_t>, ) -> z_result_t { - use crate::transmute::LoanedCTypeMutUnsafe; - let payload = this.as_rust_type_mut(); match payload.as_shm_mut() { Some(s) => { - dst.write(s.as_loaned_c_type_mut_unsafe()); + dst.write(s.as_loaned_c_type_mut()); result::Z_OK } None => { From f55a58f0d04f5abec2bfe334bc00db9d0dc5d101 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Sat, 26 Oct 2024 21:14:10 +0200 Subject: [PATCH 31/38] unused unsafe removed --- src/shm/buffer/zshmmut.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs index b52666495..144de9039 100644 --- a/src/shm/buffer/zshmmut.rs +++ b/src/shm/buffer/zshmmut.rs @@ -128,7 +128,6 @@ pub extern "C" fn z_shm_mut_data(this_: &z_loaned_shm_mut_t) -> *const libc::c_u /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @return the mutable pointer to the underlying data. #[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { +pub extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { this_.as_rust_type_mut().as_mut().as_mut_ptr() } From e70a1071d895d2f1b46ed44b9e78ffe49c8345a0 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Sun, 27 Oct 2024 21:34:00 +0100 Subject: [PATCH 32/38] removed unused loan_mut --- include/zenoh_commons.h | 84 -------------------------------- include/zenoh_macros.h | 24 --------- src/closures/query_channel.rs | 28 +---------- src/closures/response_channel.rs | 28 +---------- src/closures/sample_channel.rs | 28 +---------- src/collections.rs | 18 ------- src/commons.rs | 10 ---- src/get.rs | 8 --- src/keyexpr.rs | 17 +------ src/platform/synchronization.rs | 1 + src/queryable.rs | 13 ----- src/shm/client_storage/mod.rs | 13 ----- src/shm/provider/alloc_layout.rs | 18 +------ src/shm/provider/shm_provider.rs | 17 +------ src/subscriber.rs | 17 +------ 15 files changed, 9 insertions(+), 315 deletions(-) diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 1ef001732..dbe0acd3a 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -1249,12 +1249,6 @@ ZENOHC_API void z_alloc_layout_drop(z_moved_alloc_layout_t *this_); #if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_); #endif -/** - * Mutably borrows Alloc Layout - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API z_loaned_alloc_layout_t *z_alloc_layout_loan_mut(z_owned_alloc_layout_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Creates a new Alloc Layout for SHM Provider. @@ -2427,11 +2421,6 @@ ZENOHC_API void z_fifo_handler_query_drop(struct z_moved_fifo_handler_query_t *t */ ZENOHC_API const struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan(const struct z_owned_fifo_handler_query_t *this_); -/** - * Mutably borrows handler. - */ -ZENOHC_API -struct z_loaned_fifo_handler_query_t *z_fifo_handler_query_loan_mut(struct z_owned_fifo_handler_query_t *this_); /** * Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until * the channel is dropped (normally when Queryable is dropped). @@ -2458,11 +2447,6 @@ ZENOHC_API void z_fifo_handler_reply_drop(struct z_moved_fifo_handler_reply_t *t */ ZENOHC_API const struct z_loaned_fifo_handler_reply_t *z_fifo_handler_reply_loan(const struct z_owned_fifo_handler_reply_t *this_); -/** - * Mutably borrows handler. - */ -ZENOHC_API -struct z_loaned_fifo_handler_reply_t *z_fifo_handler_reply_loan_mut(struct z_owned_fifo_handler_reply_t *this_); /** * Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until * the channel is dropped (normally when all replies are received). @@ -2488,11 +2472,6 @@ ZENOHC_API void z_fifo_handler_sample_drop(struct z_moved_fifo_handler_sample_t */ ZENOHC_API const struct z_loaned_fifo_handler_sample_t *z_fifo_handler_sample_loan(const struct z_owned_fifo_handler_sample_t *this_); -/** - * Mutably borrows handler. - */ -ZENOHC_API -struct z_loaned_fifo_handler_sample_t *z_fifo_handler_sample_loan_mut(struct z_owned_fifo_handler_sample_t *this_); /** * Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until * the channel is dropped (normally when there are no more samples to receive). @@ -3122,10 +3101,6 @@ z_result_t z_keyexpr_join(struct z_owned_keyexpr_t *this_, * Borrows `z_owned_keyexpr_t`. */ ZENOHC_API const struct z_loaned_keyexpr_t *z_keyexpr_loan(const struct z_owned_keyexpr_t *this_); -/** - * Mutably borrows `z_owned_keyexpr_t`. - */ -ZENOHC_API struct z_loaned_keyexpr_t *z_keyexpr_loan_mut(struct z_owned_keyexpr_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Returns the relation between `left` and `right` from `left`'s point of view. @@ -3507,10 +3482,6 @@ z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable */ ZENOHC_API const struct z_loaned_queryable_t *z_queryable_loan(const struct z_owned_queryable_t *this_); -/** - * Mutably borrows Queryable. - */ -ZENOHC_API struct z_loaned_queryable_t *z_queryable_loan_mut(struct z_owned_queryable_t *this_); /** * Constructs the default value for `z_query_reply_options_t`. */ @@ -3584,10 +3555,6 @@ const struct z_loaned_encoding_t *z_reply_err_encoding(const struct z_loaned_rep */ ZENOHC_API const struct z_loaned_reply_err_t *z_reply_err_loan(const struct z_owned_reply_err_t *this_); -/** - * Mutably borrows reply error. - */ -ZENOHC_API struct z_loaned_reply_err_t *z_reply_err_loan_mut(struct z_owned_reply_err_t *this_); /** * Returns reply error payload. */ @@ -3656,11 +3623,6 @@ ZENOHC_API void z_ring_handler_query_drop(struct z_moved_ring_handler_query_t *t */ ZENOHC_API const struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan(const struct z_owned_ring_handler_query_t *this_); -/** - * Mutably borrows handler. - */ -ZENOHC_API -struct z_loaned_ring_handler_query_t *z_ring_handler_query_loan_mut(struct z_owned_ring_handler_query_t *this_); /** * Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until * the channel is dropped (normally when Queryable is dropped). @@ -3686,11 +3648,6 @@ ZENOHC_API void z_ring_handler_reply_drop(struct z_moved_ring_handler_reply_t *t */ ZENOHC_API const struct z_loaned_ring_handler_reply_t *z_ring_handler_reply_loan(const struct z_owned_ring_handler_reply_t *this_); -/** - * Mutably borrows handler. - */ -ZENOHC_API -struct z_loaned_ring_handler_reply_t *z_ring_handler_reply_loan_mut(struct z_owned_ring_handler_reply_t *this_); /** * Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until * the channel is dropped (normally when all replies are received). @@ -3716,11 +3673,6 @@ ZENOHC_API void z_ring_handler_sample_drop(struct z_moved_ring_handler_sample_t */ ZENOHC_API const struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan(const struct z_owned_ring_handler_sample_t *this_); -/** - * Mutably borrows handler. - */ -ZENOHC_API -struct z_loaned_ring_handler_sample_t *z_ring_handler_sample_loan_mut(struct z_owned_ring_handler_sample_t *this_); /** * Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until * the channel is dropped (normally when there are no more replies to receive). @@ -3896,14 +3848,6 @@ void z_shm_client_storage_drop(z_moved_shm_client_storage_t *this_); ZENOHC_API const z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const z_owned_shm_client_storage_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows SHM Client Storage. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_loaned_shm_client_storage_t *z_shm_client_storage_loan_mut(z_owned_shm_client_storage_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ @@ -4140,14 +4084,6 @@ size_t z_shm_provider_garbage_collect(const z_loaned_shm_provider_t *provider); ZENOHC_API const z_loaned_shm_provider_t *z_shm_provider_loan(const z_owned_shm_provider_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_loaned_shm_provider_t *z_shm_provider_loan_mut(z_owned_shm_provider_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. */ @@ -4261,10 +4197,6 @@ ZENOHC_API size_t z_slice_len(const struct z_loaned_slice_t *this_); * Borrows slice. */ ZENOHC_API const struct z_loaned_slice_t *z_slice_loan(const struct z_owned_slice_t *this_); -/** - * Mutably borrows slice. - */ -ZENOHC_API struct z_loaned_slice_t *z_slice_loan_mut(struct z_owned_slice_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. @@ -4289,14 +4221,6 @@ z_entity_global_id_t z_source_info_id(const z_loaned_source_info_t *this_); ZENOHC_API const z_loaned_source_info_t *z_source_info_loan(const z_owned_source_info_t *this_); #endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows source info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_loaned_source_info_t *z_source_info_loan_mut(z_owned_source_info_t *this_); -#endif /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Creates source info. @@ -4430,10 +4354,6 @@ ZENOHC_API size_t z_string_len(const struct z_loaned_string_t *this_); * Borrows string. */ ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_string_t *this_); -/** - * Mutably borrows string. - */ -ZENOHC_API struct z_loaned_string_t *z_string_loan_mut(struct z_owned_string_t *this_); /** * Undeclares subscriber callback and resets it to its gravestone state. * This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value. @@ -4449,10 +4369,6 @@ const struct z_loaned_keyexpr_t *z_subscriber_keyexpr(const struct z_loaned_subs */ ZENOHC_API const struct z_loaned_subscriber_t *z_subscriber_loan(const struct z_owned_subscriber_t *this_); -/** - * Mutably borrows subscriber. - */ -ZENOHC_API struct z_loaned_subscriber_t *z_subscriber_loan_mut(struct z_owned_subscriber_t *this_); /** * Constructs the default value for `z_subscriber_options_t`. */ diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 7c0725f67..88bb66160 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -89,26 +89,14 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_condvar_t : z_condvar_loan_mut, \ z_owned_config_t : z_config_loan_mut, \ z_owned_encoding_t : z_encoding_loan_mut, \ - z_owned_fifo_handler_query_t : z_fifo_handler_query_loan_mut, \ - z_owned_fifo_handler_reply_t : z_fifo_handler_reply_loan_mut, \ - z_owned_fifo_handler_sample_t : z_fifo_handler_sample_loan_mut, \ z_owned_hello_t : z_hello_loan_mut, \ - z_owned_keyexpr_t : z_keyexpr_loan_mut, \ z_owned_mutex_t : z_mutex_loan_mut, \ z_owned_publisher_t : z_publisher_loan_mut, \ z_owned_query_t : z_query_loan_mut, \ - z_owned_queryable_t : z_queryable_loan_mut, \ - z_owned_reply_err_t : z_reply_err_loan_mut, \ z_owned_reply_t : z_reply_loan_mut, \ - z_owned_ring_handler_query_t : z_ring_handler_query_loan_mut, \ - z_owned_ring_handler_reply_t : z_ring_handler_reply_loan_mut, \ - z_owned_ring_handler_sample_t : z_ring_handler_sample_loan_mut, \ z_owned_sample_t : z_sample_loan_mut, \ z_owned_session_t : z_session_loan_mut, \ - z_owned_slice_t : z_slice_loan_mut, \ z_owned_string_array_t : z_string_array_loan_mut, \ - z_owned_string_t : z_string_loan_mut, \ - z_owned_subscriber_t : z_subscriber_loan_mut, \ ze_owned_serializer_t : ze_serializer_loan_mut \ )(&this_) @@ -479,26 +467,14 @@ inline z_loaned_closure_zid_t* z_loan_mut(z_owned_closure_zid_t& closure) { retu inline z_loaned_condvar_t* z_loan_mut(z_owned_condvar_t& this_) { return z_condvar_loan_mut(&this_); }; inline z_loaned_config_t* z_loan_mut(z_owned_config_t& this_) { return z_config_loan_mut(&this_); }; inline z_loaned_encoding_t* z_loan_mut(z_owned_encoding_t& this_) { return z_encoding_loan_mut(&this_); }; -inline z_loaned_fifo_handler_query_t* z_loan_mut(z_owned_fifo_handler_query_t& this_) { return z_fifo_handler_query_loan_mut(&this_); }; -inline z_loaned_fifo_handler_reply_t* z_loan_mut(z_owned_fifo_handler_reply_t& this_) { return z_fifo_handler_reply_loan_mut(&this_); }; -inline z_loaned_fifo_handler_sample_t* z_loan_mut(z_owned_fifo_handler_sample_t& this_) { return z_fifo_handler_sample_loan_mut(&this_); }; inline z_loaned_hello_t* z_loan_mut(z_owned_hello_t& this_) { return z_hello_loan_mut(&this_); }; -inline z_loaned_keyexpr_t* z_loan_mut(z_owned_keyexpr_t& this_) { return z_keyexpr_loan_mut(&this_); }; inline z_loaned_mutex_t* z_loan_mut(z_owned_mutex_t& this_) { return z_mutex_loan_mut(&this_); }; inline z_loaned_publisher_t* z_loan_mut(z_owned_publisher_t& this_) { return z_publisher_loan_mut(&this_); }; inline z_loaned_query_t* z_loan_mut(z_owned_query_t& this_) { return z_query_loan_mut(&this_); }; -inline z_loaned_queryable_t* z_loan_mut(z_owned_queryable_t& this_) { return z_queryable_loan_mut(&this_); }; -inline z_loaned_reply_err_t* z_loan_mut(z_owned_reply_err_t& this_) { return z_reply_err_loan_mut(&this_); }; inline z_loaned_reply_t* z_loan_mut(z_owned_reply_t& this_) { return z_reply_loan_mut(&this_); }; -inline z_loaned_ring_handler_query_t* z_loan_mut(z_owned_ring_handler_query_t& this_) { return z_ring_handler_query_loan_mut(&this_); }; -inline z_loaned_ring_handler_reply_t* z_loan_mut(z_owned_ring_handler_reply_t& this_) { return z_ring_handler_reply_loan_mut(&this_); }; -inline z_loaned_ring_handler_sample_t* z_loan_mut(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan_mut(&this_); }; inline z_loaned_sample_t* z_loan_mut(z_owned_sample_t& this_) { return z_sample_loan_mut(&this_); }; inline z_loaned_session_t* z_loan_mut(z_owned_session_t& this_) { return z_session_loan_mut(&this_); }; -inline z_loaned_slice_t* z_loan_mut(z_owned_slice_t& this_) { return z_slice_loan_mut(&this_); }; inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { return z_string_array_loan_mut(&this_); }; -inline z_loaned_string_t* z_loan_mut(z_owned_string_t& this_) { return z_string_loan_mut(&this_); }; -inline z_loaned_subscriber_t* z_loan_mut(z_owned_subscriber_t& this_) { return z_subscriber_loan_mut(&this_); }; inline ze_loaned_serializer_t* z_loan_mut(ze_owned_serializer_t& this_) { return ze_serializer_loan_mut(&this_); }; diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs index ecec642a3..5bcd40214 100644 --- a/src/closures/query_channel.rs +++ b/src/closures/query_channel.rs @@ -25,9 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_query_t, z_owned_closure_query_t, z_owned_query_t, }; decl_c_type!( @@ -105,18 +103,6 @@ pub unsafe extern "C" fn z_fifo_handler_query_loan( .as_loaned_c_type_ref() } -/// Mutably borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_query_loan_mut( - this: &mut z_owned_fifo_handler_query_t, -) -> &mut z_loaned_fifo_handler_query_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), @@ -226,18 +212,6 @@ pub unsafe extern "C" fn z_ring_handler_query_loan( .as_loaned_c_type_ref() } -/// Mutably borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_query_loan_mut( - this: &mut z_owned_ring_handler_query_t, -) -> &mut z_loaned_ring_handler_query_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until /// the channel is dropped (normally when Queryable is dropped). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state). diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs index 4e027e94b..a848f14c1 100644 --- a/src/closures/response_channel.rs +++ b/src/closures/response_channel.rs @@ -25,9 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_reply_t, z_owned_closure_reply_t, z_owned_reply_t, }; decl_c_type!( @@ -105,18 +103,6 @@ pub unsafe extern "C" fn z_fifo_handler_reply_loan( .as_loaned_c_type_ref() } -/// Mutably borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_reply_loan_mut( - this: &mut z_owned_fifo_handler_reply_t, -) -> &mut z_loaned_fifo_handler_reply_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). @@ -222,18 +208,6 @@ pub unsafe extern "C" fn z_ring_handler_reply_loan( .as_loaned_c_type_ref() } -/// Mutably borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_reply_loan_mut( - this: &mut z_owned_ring_handler_reply_t, -) -> &mut z_loaned_ring_handler_reply_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until /// the channel is dropped (normally when all replies are received). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs index 3fefc7b32..a5e1ea1aa 100644 --- a/src/closures/sample_channel.rs +++ b/src/closures/sample_channel.rs @@ -25,9 +25,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t}, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_sample_t, z_owned_closure_sample_t, z_owned_sample_t, }; decl_c_type!( @@ -105,18 +103,6 @@ pub unsafe extern "C" fn z_fifo_handler_sample_loan( .as_loaned_c_type_ref() } -/// Mutably borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_sample_loan_mut( - this: &mut z_owned_fifo_handler_sample_t, -) -> &mut z_loaned_fifo_handler_sample_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more samples to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). @@ -226,18 +212,6 @@ pub unsafe extern "C" fn z_ring_handler_sample_loan( .as_loaned_c_type_ref() } -/// Mutably borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_sample_loan_mut( - this: &mut z_owned_ring_handler_sample_t, -) -> &mut z_loaned_ring_handler_sample_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until /// the channel is dropped (normally when there are no more replies to receive). /// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). diff --git a/src/collections.rs b/src/collections.rs index 7a1f6df7a..a41ba7aaa 100644 --- a/src/collections.rs +++ b/src/collections.rs @@ -341,12 +341,6 @@ pub extern "C" fn z_slice_loan(this_: &z_owned_slice_t) -> &z_loaned_slice_t { this_.as_rust_type_ref().as_loaned_c_type_ref() } -/// Mutably borrows slice. -#[no_mangle] -pub extern "C" fn z_slice_loan_mut(this_: &mut z_owned_slice_t) -> &mut z_loaned_slice_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() -} - /// Constructs an owned copy of a slice. #[no_mangle] pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: &z_loaned_slice_t) { @@ -491,12 +485,6 @@ impl Deref for CStringOwned { } } -impl DerefMut for CStringOwned { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - impl Deref for CStringView { type Target = CString; fn deref(&self) -> &Self::Target { @@ -598,12 +586,6 @@ pub extern "C" fn z_string_loan(this_: &z_owned_string_t) -> &z_loaned_string_t this_.as_rust_type_ref().as_loaned_c_type_ref() } -/// Mutably borrows string. -#[no_mangle] -pub extern "C" fn z_string_loan_mut(this_: &mut z_owned_string_t) -> &mut z_loaned_string_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() -} - /// Borrows view string. #[no_mangle] pub extern "C" fn z_view_string_loan(this_: &z_view_string_t) -> &z_loaned_string_t { diff --git a/src/commons.rs b/src/commons.rs index e0e1d66f9..eb983fbec 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -615,16 +615,6 @@ pub extern "C" fn z_source_info_loan(this_: &z_owned_source_info_t) -> &z_loaned this_.as_rust_type_ref().as_loaned_c_type_ref() } -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows source info. -#[no_mangle] -pub extern "C" fn z_source_info_loan_mut( - this_: &mut z_owned_source_info_t, -) -> &mut z_loaned_source_info_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() -} - #[cfg(feature = "unstable")] /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. diff --git a/src/get.rs b/src/get.rs index 0d1243917..b55026865 100644 --- a/src/get.rs +++ b/src/get.rs @@ -74,14 +74,6 @@ pub extern "C" fn z_reply_err_loan(this_: &z_owned_reply_err_t) -> &z_loaned_rep this_.as_rust_type_ref().as_loaned_c_type_ref() } -/// Mutably borrows reply error. -#[no_mangle] -pub extern "C" fn z_reply_err_loan_mut( - this_: &mut z_owned_reply_err_t, -) -> &mut z_loaned_reply_err_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() -} - /// Frees the memory and resets the reply error it to its default value. #[no_mangle] pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { diff --git a/src/keyexpr.rs b/src/keyexpr.rs index e75c0bd06..5286a69c4 100644 --- a/src/keyexpr.rs +++ b/src/keyexpr.rs @@ -26,9 +26,7 @@ pub use crate::opaque_types::{ }; use crate::{ result::{self, z_result_t, Z_OK}, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_session_t, z_view_string_from_substr, z_view_string_t, }; @@ -136,19 +134,6 @@ pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_ .as_loaned_c_type_ref() } -/// Mutably borrows `z_owned_keyexpr_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_keyexpr_loan_mut( - this_: &mut z_owned_keyexpr_t, -) -> &mut z_loaned_keyexpr_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Borrows `z_view_keyexpr_t`. #[no_mangle] #[allow(clippy::missing_safety_doc)] diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs index 958d11f74..54fb2ef00 100644 --- a/src/platform/synchronization.rs +++ b/src/platform/synchronization.rs @@ -64,6 +64,7 @@ pub unsafe extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z #[no_mangle] pub extern "C" fn z_mutex_lock(this_: &'static mut z_loaned_mutex_t) -> result::z_result_t { let this = this_.as_rust_type_mut(); + match this.0.lock() { Ok(new_lock) => { let old_lock = this.1.replace(new_lock); diff --git a/src/queryable.rs b/src/queryable.rs index b66833833..a544cf27b 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -59,19 +59,6 @@ pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loa .as_loaned_c_type_ref() } -/// Mutably borrows Queryable. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_queryable_loan_mut( - this_: &mut z_owned_queryable_t, -) -> &mut z_loaned_queryable_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; decl_c_type!( owned(z_owned_query_t, Option), diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs index 3f82b7760..c90e366ca 100644 --- a/src/shm/client_storage/mod.rs +++ b/src/shm/client_storage/mod.rs @@ -200,16 +200,3 @@ pub unsafe extern "C" fn z_shm_client_storage_loan( .unwrap_unchecked() .as_loaned_c_type_ref() } - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows SHM Client Storage. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_client_storage_loan_mut( - this: &mut z_owned_shm_client_storage_t, -) -> &mut z_loaned_shm_client_storage_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs index d9e0097c0..29597f6be 100644 --- a/src/shm/provider/alloc_layout.rs +++ b/src/shm/provider/alloc_layout.rs @@ -28,11 +28,9 @@ use crate::{ context::{zc_threadsafe_context_t, Context, ThreadsafeContext}, result::z_result_t, shm::protocol_implementations::posix::posix_shm_provider::PosixAllocLayout, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_alloc_layout_t, z_loaned_shm_provider_t, z_moved_alloc_layout_t, - z_owned_alloc_layout_t, + z_owned_alloc_layout_t, LoanedCTypeRef, }; pub type DynamicAllocLayout = @@ -88,18 +86,6 @@ pub unsafe extern "C" fn z_alloc_layout_loan( .as_loaned_c_type_ref() } -/// Mutably borrows Alloc Layout -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_alloc_layout_loan_mut( - this: &mut z_owned_alloc_layout_t, -) -> &mut z_loaned_alloc_layout_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Deletes Alloc Layout #[no_mangle] pub extern "C" fn z_alloc_layout_drop(this_: &mut z_moved_alloc_layout_t) { diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs index 5b6ad6b4e..011459c35 100644 --- a/src/shm/provider/shm_provider.rs +++ b/src/shm/provider/shm_provider.rs @@ -37,9 +37,7 @@ use crate::{ protocol_implementations::posix::posix_shm_provider::PosixShmProvider, provider::types::z_buf_layout_alloc_result_t, }, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_loaned_shm_provider_t, z_moved_shm_provider_t, z_owned_shm_mut_t, z_owned_shm_provider_t, }; @@ -124,19 +122,6 @@ pub unsafe extern "C" fn z_shm_provider_loan( .as_loaned_c_type_ref() } -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows SHM Provider. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_provider_loan_mut( - this: &mut z_owned_shm_provider_t, -) -> &mut z_loaned_shm_provider_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Deletes SHM Provider. #[no_mangle] diff --git a/src/subscriber.rs b/src/subscriber.rs index 0a0096310..378947b00 100644 --- a/src/subscriber.rs +++ b/src/subscriber.rs @@ -25,9 +25,7 @@ pub use crate::opaque_types::{z_loaned_subscriber_t, z_moved_subscriber_t, z_own use crate::{ keyexpr::*, result, - transmute::{ - LoanedCTypeMut, LoanedCTypeRef, RustTypeMut, RustTypeMutUninit, RustTypeRef, TakeRustType, - }, + transmute::{LoanedCTypeMut, LoanedCTypeRef, RustTypeMutUninit, RustTypeRef, TakeRustType}, z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t, }; decl_c_type!( @@ -52,19 +50,6 @@ pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_l .as_loaned_c_type_ref() } -/// Mutably borrows subscriber. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_subscriber_loan_mut( - this_: &mut z_owned_subscriber_t, -) -> &mut z_loaned_subscriber_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - /// Options passed to the `z_declare_subscriber()` function. #[allow(non_camel_case_types)] #[repr(C)] From 5b70018b1fc002b4149587d3010fc62a6b4bea2c Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Sun, 27 Oct 2024 21:51:06 +0100 Subject: [PATCH 33/38] doc corrected --- docs/concepts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/concepts.rst b/docs/concepts.rst index d1128518f..db240973f 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -151,8 +151,8 @@ Common operations The transition between "owned", "loaned" and "moved" structures above is performed by corresponding functions. The following operations are available: move, loan, mutable loan, take, and drop. They are performed for -"xxx" entities by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take_moved`, `z_xxx_take_loaned`, -and `z_xxx_drop`. +"xxx" entities by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take`, `z_xxx_take_loaned` +(for certain types), and `z_xxx_drop`. The generic macros `z_move`, `z_loan`, `z_loan_mut`, `z_take`, and `z_drop` are also provided. Loan operation From f214cb4c741d05c675f9c5c404caeecb3461c053 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 8 Nov 2024 10:01:56 +0100 Subject: [PATCH 34/38] doc updated --- docs/concepts.rst | 103 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/docs/concepts.rst b/docs/concepts.rst index db240973f..5273acfd0 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -193,7 +193,30 @@ structure is set to an empty "gravestone" state, like after a drop operation. The `z_take` macro accepts `z_moved_xxx_t*` pointer and calls the corresponding `z_xxx_take` functions. -There is also an API for taking ownership of a mutably loaned object: the `z_xxx_take_loaned` functions. These functions +Take from mutably loaned object operation +----------------------------------------- + +Functions `z_xxx_take_from_loaned` accept pointers to uninitialized `z_owned_xxx_t` destination structures and +`z_loaned_xxx_t*` source pointers. + +These functions move data from the source `z_loaned_xxx_t` structure into the destination one. The source +structure is set to "valid but unspecified" state: it **have** to be dropped, no other operation on it is safe, +unless if it's explicitly specified. See also section "Comparison with C++ move semantics". + +The `z_take_from_loaned` macro accepts `z_loaned_xxx_t*` pointer and calls the corresponding +`z_xxx_take_from_loaned` functions. + + + +There is also an API for taking owned object from a mutably loaned object: the `z_xxx_take_from_loaned` functions. +After this operation object is left in some "valid but unspecified" state. The logic is similar to C++ guarantee after `std::move` operation +(see https://stackoverflow.com/questions/7930105/does-moving-leave-the-object-in-a-usable-state) + +The difference from C++ is that, instead of single `std::move` zenoh-c provides different `z_move` and `z_loan_mut` operations with corresponding +`z_take` and `z_take_from_loaned`. This is made for user convenience: + + It have to be dropped +These functions are available only for types passed to callback functions as mutable references, such as `z_loaned_sample_t*`, `z_loaned_reply_t*`, `z_loaned_hello_t*`, and `z_loaned_query_t*`. @@ -209,6 +232,84 @@ Function `z_xxx_drop` accepts `z_moved_xxx_t*` pointer. It frees all resources h `z_drop` macro accepts `z_moved_xxx_t*` and calls corresponding `z_xxx_drop` function +Comparison with C++ move semantics +================================== + +The behavior of `z_move` is similar to C++ `std::move` it converts normal reference to a "rvalue reference" which is intened to be consumed by the function. +The difference is that the C++ automatically destucts the object. So the move semantics in C++ means taking the heavy data from rvalue-referenced object and +leaving it in some valid state which is later destroyed by it's destructor. + +There is no automatic destructors in C, so for the same logic we would need to require deleloper to call destructor (`z_drop`) even after `z_move` operation. +This is inconvenient, so for move move operation our requirement is more strict than for C++: if function expects `z_moved_xxx_t*` it +should left the object on passed pointer in "gravestone", i.e. state which doesn't hold any external resources and so safe to be forgotten. (The second +requirement for gravestone state is double drop safety. This decision is kind of arbitrary, but it helps to avoid segmentation faults). + +Unfortunately this strict `z_move`` semantic is not enough in 2 situations: + +First problem is that arguments of callbacks are "mutable loaned" references (e.g. `z_loaned_sample_t*`) It would be more logical to make them "moved" references to give +ownership to the callback function. But in this case the callback function would be obliged to drop the object after use. This is additional burden for the +developer and it would definitely lead to memory leaks. Also user is frequently just need to read the object, so it's would be useless job to create own instance and +use `z_take` to fill it just to e.g. read single field. + +But on the other hand sometimes it's necessary to take ownership of the object passed to callback for further processing. Therefore the take +operation from mutable reference is required. + +Second problem is the C++ API which doesn't use the moved/loaned syntax sugar, as the C++ have it's own move semantics. The C++ `std::move` can be called +on any non-const reference, so we need to support this behavior. Detailed explanation is in note below, it's ok to skip it. + +..note:: +Zenoh C++ API bypasses zenoh-c protection by simply making `reinterpret_cast` from `z_loaned_xxx_t*` to `z_owned_xxx_t*` and back when necessary. This means that +if the move constructor in C++ accepts e.g. `Sample&&`, it can't be sure if this reference points to `z_owned_sample_t` with valid gravestone state (internally in Rust this +corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_sample_t*` received from some zenoh-c function and which poits just to `Sample` inside Rust, not option-wrapped. +(It's important to notice that `Sample` and `Option` have same size and layout in memory due to Null-Pointer Optimization, so it's safe to treat + `Option` just as `Sample`, but not in other direction). + +To resolve this the `z_take_from_loaned` operation is introduced for `z_loaned_xxx_t*`. It behaves similarly to `z_take` for `z_moved_xxx_t*` but doesn't provide +guarantee that the object is kept in gravestone state. Instead it only guarantees that the object is left in state safe to be dropped, nothing more. This operation is full equivalent +to C++ move semantics: object is left in "valid but unspecified" state and it's lifetime still have to be finished with destructor. + +Zenoh guarantees that it never uses this operation inside it code. I.e. it's always safe to pass object to function with `z_loan_mut` and continue using it after return. It's better +to follow this rule in user code too and use `z_take_from_loaned` only when it's absolutely necessary. + +Examples: + +`z_move` and `z_take` usage: + +.. code-block:: c + + void consume_string(z_moved_string_t* ps) { + z_owned_string_t s; + z_take(&s, ps); + printf("%.*s\n", z_string_len(z_loan(s)), z_string_data(z_loan(s))); + z_drop(s); + } + ... + z_owned_string_t s; + z_string_copy_from_str(&s, "Hello, world!"); + consume_string(z_move(s)); + +`` + +`z_loan_mut` and `z_take_from_loaned` usage: + +.. code-block:: c + + void may_consume_string(z_loaned_string_t* ps) { + if (z_string) + + z_owned_string_t s2; + z_take_from_loaned(&s, ps); + printf("%.*s\n", z_string_len(z_loan(s)), z_string_data(z_loan(s))); + z_drop(s); + } + ... + z_owned_string_t s; + z_string_copy_from_str(&s, "Hello, world!"); + consume_string(z_loan_mut(s)); + +`` + + Name Prefixes `z_`, `zc_`, `ze_` ================================ From 4eb098d4b29ae31f8b9a7ac1931c665569044b32 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 8 Nov 2024 12:54:43 +0100 Subject: [PATCH 35/38] doc updated --- docs/concepts.rst | 50 +++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/docs/concepts.rst b/docs/concepts.rst index 5273acfd0..d6b4bc6da 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -235,41 +235,42 @@ Function `z_xxx_drop` accepts `z_moved_xxx_t*` pointer. It frees all resources h Comparison with C++ move semantics ================================== -The behavior of `z_move` is similar to C++ `std::move` it converts normal reference to a "rvalue reference" which is intened to be consumed by the function. -The difference is that the C++ automatically destucts the object. So the move semantics in C++ means taking the heavy data from rvalue-referenced object and +The behavior of `z_move` is similar to C++ `std::move`, it converts normal reference to a "rvalue reference" which is intended to be consumed by the function. +The difference is that the C++ automatically destructs the object. So the move semantics in C++ means taking the heavy data from rvalue-referenced object and leaving it in some valid state which is later destroyed by it's destructor. -There is no automatic destructors in C, so for the same logic we would need to require deleloper to call destructor (`z_drop`) even after `z_move` operation. -This is inconvenient, so for move move operation our requirement is more strict than for C++: if function expects `z_moved_xxx_t*` it +There is no automatic destructors in C, so for the same logic we would need to require developer to call destructor (`z_drop`) even after `z_move` operation. +This is inconvenient, so for move operation our requirement is more strict than for C++: if function expects `z_moved_xxx_t*` it should left the object on passed pointer in "gravestone", i.e. state which doesn't hold any external resources and so safe to be forgotten. (The second requirement for gravestone state is double drop safety. This decision is kind of arbitrary, but it helps to avoid segmentation faults). -Unfortunately this strict `z_move`` semantic is not enough in 2 situations: +Unfortunately this strict `z_move` semantic is not enough in 2 situations: -First problem is that arguments of callbacks are "mutable loaned" references (e.g. `z_loaned_sample_t*`) It would be more logical to make them "moved" references to give +First problem is that arguments of callbacks are "mutable loaned" references (e.g. `z_loaned_sample_t*`). It would be more logical to make them "moved" references to give ownership to the callback function. But in this case the callback function would be obliged to drop the object after use. This is additional burden for the -developer and it would definitely lead to memory leaks. Also user is frequently just need to read the object, so it's would be useless job to create own instance and -use `z_take` to fill it just to e.g. read single field. +developer and it would definitely lead to memory leaks. Also user is frequently just need to read the object, so it would be a useless job to create own instance and +use `z_take` to fill it just to e.g. read a single field. But on the other hand sometimes it's necessary to take ownership of the object passed to callback for further processing. Therefore the take operation from mutable reference is required. -Second problem is the C++ API which doesn't use the moved/loaned syntax sugar, as the C++ have it's own move semantics. The C++ `std::move` can be called +The second problem is that the C++ API doesn't use the moved/loaned syntax sugar, as C++ has its own move semantics. The C++ `std::move` can be called on any non-const reference, so we need to support this behavior. Detailed explanation is in note below, it's ok to skip it. ..note:: Zenoh C++ API bypasses zenoh-c protection by simply making `reinterpret_cast` from `z_loaned_xxx_t*` to `z_owned_xxx_t*` and back when necessary. This means that if the move constructor in C++ accepts e.g. `Sample&&`, it can't be sure if this reference points to `z_owned_sample_t` with valid gravestone state (internally in Rust this -corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_sample_t*` received from some zenoh-c function and which poits just to `Sample` inside Rust, not option-wrapped. +corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_sample_t*` received from some zenoh-c function and which points just to `Sample` inside Rust, not option-wrapped. (It's important to notice that `Sample` and `Option` have same size and layout in memory due to Null-Pointer Optimization, so it's safe to treat `Option` just as `Sample`, but not in other direction). To resolve this the `z_take_from_loaned` operation is introduced for `z_loaned_xxx_t*`. It behaves similarly to `z_take` for `z_moved_xxx_t*` but doesn't provide -guarantee that the object is kept in gravestone state. Instead it only guarantees that the object is left in state safe to be dropped, nothing more. This operation is full equivalent -to C++ move semantics: object is left in "valid but unspecified" state and it's lifetime still have to be finished with destructor. +guarantee that the object is kept in gravestone state. Instead it only guarantees that the object is left in state safe to be dropped, nothing more. +This operation is full equivalent to C++ move semantics: object is left in "valid but unspecified" state and it has to be +to be destructed. -Zenoh guarantees that it never uses this operation inside it code. I.e. it's always safe to pass object to function with `z_loan_mut` and continue using it after return. It's better -to follow this rule in user code too and use `z_take_from_loaned` only when it's absolutely necessary. +Zenoh guarantees that it never uses this operation inside its code. I.e. it's always safe to pass object to function with `z_loan_mut` and continue using it after return. +It's recommended to follow this rule in user code too and use `z_take_from_loaned` only in exceptional cases. Examples: @@ -287,25 +288,28 @@ Examples: z_owned_string_t s; z_string_copy_from_str(&s, "Hello, world!"); consume_string(z_move(s)); - + // no need to drop s here, passing it by z_move promises that it's dropped inside consume_string `` -`z_loan_mut` and `z_take_from_loaned` usage: +`z_loan_mut` and `z_take_from_loaned` usage .. code-block:: c void may_consume_string(z_loaned_string_t* ps) { - if (z_string) - - z_owned_string_t s2; - z_take_from_loaned(&s, ps); - printf("%.*s\n", z_string_len(z_loan(s)), z_string_data(z_loan(s))); - z_drop(s); + if (z_string_len(ps) < 42) { + // process it in place + } else { + z_owned_string_t s; + z_take_from_loaned(&s, ps); + // save s for further processing + } } ... z_owned_string_t s; z_string_copy_from_str(&s, "Hello, world!"); - consume_string(z_loan_mut(s)); + may_consume_string(z_loan_mut(s)); + // can't make any assumptions about s here, but still obliged to drop it + z_drop(s); `` From f709ed7fdd83e2547a45304b54cef1eca0d4942f Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 8 Nov 2024 13:13:10 +0100 Subject: [PATCH 36/38] doc updated --- docs/concepts.rst | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/concepts.rst b/docs/concepts.rst index d6b4bc6da..00ebe8d9a 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -241,15 +241,14 @@ leaving it in some valid state which is later destroyed by it's destructor. There is no automatic destructors in C, so for the same logic we would need to require developer to call destructor (`z_drop`) even after `z_move` operation. This is inconvenient, so for move operation our requirement is more strict than for C++: if function expects `z_moved_xxx_t*` it -should left the object on passed pointer in "gravestone", i.e. state which doesn't hold any external resources and so safe to be forgotten. (The second -requirement for gravestone state is double drop safety. This decision is kind of arbitrary, but it helps to avoid segmentation faults). +should left the object on passed pointer in "gravestone" state, i.e. state which doesn't hold any external resources and so safe to be forgotten. +(There is also a second requirement for gravestone state: double drop safety. This decision is kind of arbitrary, but it helps to avoid segmentation faults). -Unfortunately this strict `z_move` semantic is not enough in 2 situations: +Unfortunately this strict `z_move` semantic is not enough in the situations below: First problem is that arguments of callbacks are "mutable loaned" references (e.g. `z_loaned_sample_t*`). It would be more logical to make them "moved" references to give -ownership to the callback function. But in this case the callback function would be obliged to drop the object after use. This is additional burden for the -developer and it would definitely lead to memory leaks. Also user is frequently just need to read the object, so it would be a useless job to create own instance and -use `z_take` to fill it just to e.g. read a single field. +ownership to the callback function. But in this case the callback function would be obliged to take the ownership and drop the object after use even if +he needs only to read the object. But on the other hand sometimes it's necessary to take ownership of the object passed to callback for further processing. Therefore the take operation from mutable reference is required. @@ -259,15 +258,14 @@ on any non-const reference, so we need to support this behavior. Detailed explan ..note:: Zenoh C++ API bypasses zenoh-c protection by simply making `reinterpret_cast` from `z_loaned_xxx_t*` to `z_owned_xxx_t*` and back when necessary. This means that -if the move constructor in C++ accepts e.g. `Sample&&`, it can't be sure if this reference points to `z_owned_sample_t` with valid gravestone state (internally in Rust this -corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_sample_t*` received from some zenoh-c function and which points just to `Sample` inside Rust, not option-wrapped. -(It's important to notice that `Sample` and `Option` have same size and layout in memory due to Null-Pointer Optimization, so it's safe to treat - `Option` just as `Sample`, but not in other direction). +if the move constructor in C++ accepts e.g. C++ object `Reply&&`, it can't be sure if this reference points to `z_owned_reply_t` with valid gravestone state (internally in Rust this +corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_reply_t*` received from inside zenoh-c, which points just to `Reply`, not option-wrapped. +(It's important to notice that `Reply` and `Option` have same size and layout in memory due to Null-Pointer Optimization, so it's safe to treat + `Option` just as `Reply`, but not in other direction). To resolve this the `z_take_from_loaned` operation is introduced for `z_loaned_xxx_t*`. It behaves similarly to `z_take` for `z_moved_xxx_t*` but doesn't provide guarantee that the object is kept in gravestone state. Instead it only guarantees that the object is left in state safe to be dropped, nothing more. -This operation is full equivalent to C++ move semantics: object is left in "valid but unspecified" state and it has to be -to be destructed. +Unlike `z_move`, this operation is full equivalent to C++ move semantics: object is left in "valid but unspecified" state and it still has to be destructed. Zenoh guarantees that it never uses this operation inside its code. I.e. it's always safe to pass object to function with `z_loan_mut` and continue using it after return. It's recommended to follow this rule in user code too and use `z_take_from_loaned` only in exceptional cases. @@ -291,7 +289,7 @@ Examples: // no need to drop s here, passing it by z_move promises that it's dropped inside consume_string `` -`z_loan_mut` and `z_take_from_loaned` usage +`z_loan_mut` and `z_take_from_loaned` usage: .. code-block:: c From ae81556b27e53b422000a429fd797b36913a1804 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 8 Nov 2024 13:32:30 +0100 Subject: [PATCH 37/38] doc updated, renamed to take_from_loaned --- docs/concepts.rst | 28 +++++----------------------- include/zenoh_commons.h | 10 ++++++---- src/commons.rs | 2 +- src/get.rs | 2 +- src/queryable.rs | 2 +- src/scouting.rs | 2 +- tests/z_api_null_drop_test.c | 8 ++++---- 7 files changed, 19 insertions(+), 35 deletions(-) diff --git a/docs/concepts.rst b/docs/concepts.rst index 00ebe8d9a..e25d5f857 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -151,7 +151,7 @@ Common operations The transition between "owned", "loaned" and "moved" structures above is performed by corresponding functions. The following operations are available: move, loan, mutable loan, take, and drop. They are performed for -"xxx" entities by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take`, `z_xxx_take_loaned` +"xxx" entities by functions `z_xxx_move`, `z_xxx_loan`, `z_xxx_loan_mut`, `z_xxx_take`, `z_xxx_take_from_loaned` (for certain types), and `z_xxx_drop`. The generic macros `z_move`, `z_loan`, `z_loan_mut`, `z_take`, and `z_drop` are also provided. @@ -206,24 +206,6 @@ unless if it's explicitly specified. See also section "Comparison with C++ move The `z_take_from_loaned` macro accepts `z_loaned_xxx_t*` pointer and calls the corresponding `z_xxx_take_from_loaned` functions. - - -There is also an API for taking owned object from a mutably loaned object: the `z_xxx_take_from_loaned` functions. -After this operation object is left in some "valid but unspecified" state. The logic is similar to C++ guarantee after `std::move` operation -(see https://stackoverflow.com/questions/7930105/does-moving-leave-the-object-in-a-usable-state) - -The difference from C++ is that, instead of single `std::move` zenoh-c provides different `z_move` and `z_loan_mut` operations with corresponding -`z_take` and `z_take_from_loaned`. This is made for user convenience: - - It have to be dropped -These functions -are available only for types passed to callback functions as mutable references, such as `z_loaned_sample_t*`, `z_loaned_reply_t*`, -`z_loaned_hello_t*`, and `z_loaned_query_t*`. - -This feature is specifically designed for callbacks: it allows the callback to either process the passed object in place or take -ownership of it for further processing. No zenoh-c API functions take ownership of mutably loaned objects, i.e it's always safe to pass object -to function with `z_loan_mut` and continue using it after return. - Drop operation -------------- @@ -242,7 +224,6 @@ leaving it in some valid state which is later destroyed by it's destructor. There is no automatic destructors in C, so for the same logic we would need to require developer to call destructor (`z_drop`) even after `z_move` operation. This is inconvenient, so for move operation our requirement is more strict than for C++: if function expects `z_moved_xxx_t*` it should left the object on passed pointer in "gravestone" state, i.e. state which doesn't hold any external resources and so safe to be forgotten. -(There is also a second requirement for gravestone state: double drop safety. This decision is kind of arbitrary, but it helps to avoid segmentation faults). Unfortunately this strict `z_move` semantic is not enough in the situations below: @@ -253,7 +234,7 @@ he needs only to read the object. But on the other hand sometimes it's necessary to take ownership of the object passed to callback for further processing. Therefore the take operation from mutable reference is required. -The second problem is that the C++ API doesn't use the moved/loaned syntax sugar, as C++ has its own move semantics. The C++ `std::move` can be called +The second problem is that the C++ API doesn't use the zenog-c moved/loaned syntax sugar, as C++ has its own move semantics. The C++ `std::move` can be called on any non-const reference, so we need to support this behavior. Detailed explanation is in note below, it's ok to skip it. ..note:: @@ -289,7 +270,8 @@ Examples: // no need to drop s here, passing it by z_move promises that it's dropped inside consume_string `` -`z_loan_mut` and `z_take_from_loaned` usage: +`z_loan_mut` and `z_take_from_loaned` usage (this example if fictional: actually take from loaned is implemented only +for types used in callbacks at this moment: `z_loaned_sample_t*`, `z_loaned_reply_t*`, `z_loaned_hello_t*`, `z_loaned_query_t*`): .. code-block:: c @@ -298,7 +280,7 @@ Examples: // process it in place } else { z_owned_string_t s; - z_take_from_loaned(&s, ps); + z_string_take_from_loaned(&s, ps); // save s for further processing } } diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index dbe0acd3a..4d5325975 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -2538,7 +2538,7 @@ void z_hello_locators(const struct z_loaned_hello_t *this_, /** * Takes ownership of the mutably borrowed hello */ -ZENOHC_API void z_hello_take_loaned(struct z_owned_hello_t *dst, struct z_loaned_hello_t *src); +ZENOHC_API void z_hello_take_from_loaned(struct z_owned_hello_t *dst, struct z_loaned_hello_t *src); /** * Returns type of Zenoh entity that transmitted hello message. */ @@ -3459,7 +3459,7 @@ ZENOHC_API void z_query_reply_options_default(struct z_query_reply_options_t *th /** * Takes ownership of the mutably borrowed query */ -ZENOHC_API void z_query_take_loaned(struct z_owned_query_t *dst, struct z_loaned_query_t *src); +ZENOHC_API void z_query_take_from_loaned(struct z_owned_query_t *dst, struct z_loaned_query_t *src); /** * Create a default `z_query_target_t`. */ @@ -3592,7 +3592,7 @@ bool z_reply_replier_id(const struct z_loaned_reply_t *this_, /** * Takes ownership of the mutably borrowed reply */ -ZENOHC_API void z_reply_take_loaned(struct z_owned_reply_t *dst, struct z_loaned_reply_t *src); +ZENOHC_API void z_reply_take_from_loaned(struct z_owned_reply_t *dst, struct z_loaned_reply_t *src); /** * Constructs send and recieve ends of the ring channel */ @@ -3763,7 +3763,9 @@ const z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_ /** * Takes ownership of the mutably borrowed sample. */ -ZENOHC_API void z_sample_take_loaned(struct z_owned_sample_t *dst, struct z_loaned_sample_t *src); +ZENOHC_API +void z_sample_take_from_loaned(struct z_owned_sample_t *dst, + struct z_loaned_sample_t *src); /** * Returns the sample timestamp. * diff --git a/src/commons.rs b/src/commons.rs index eb983fbec..0c24bc6c1 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -221,7 +221,7 @@ pub extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loan /// Takes ownership of the mutably borrowed sample. #[no_mangle] -pub extern "C" fn z_sample_take_loaned( +pub extern "C" fn z_sample_take_from_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_sample_t, ) { diff --git a/src/get.rs b/src/get.rs index b55026865..3f3de314b 100644 --- a/src/get.rs +++ b/src/get.rs @@ -318,7 +318,7 @@ pub extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned /// Takes ownership of the mutably borrowed reply #[no_mangle] -pub extern "C" fn z_reply_take_loaned( +pub extern "C" fn z_reply_take_from_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_reply_t, ) { diff --git a/src/queryable.rs b/src/queryable.rs index a544cf27b..7172a9cec 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -94,7 +94,7 @@ pub extern "C" fn z_query_loan_mut(this_: &mut z_owned_query_t) -> &mut z_loaned /// Takes ownership of the mutably borrowed query #[no_mangle] -pub extern "C" fn z_query_take_loaned( +pub extern "C" fn z_query_take_from_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_query_t, ) { diff --git a/src/scouting.rs b/src/scouting.rs index 9e53452b1..439c35f0b 100644 --- a/src/scouting.rs +++ b/src/scouting.rs @@ -60,7 +60,7 @@ pub extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned /// Takes ownership of the mutably borrowed hello #[no_mangle] -pub extern "C" fn z_hello_take_loaned( +pub extern "C" fn z_hello_take_from_loaned( dst: &mut MaybeUninit, src: &mut z_loaned_hello_t, ) { diff --git a/tests/z_api_null_drop_test.c b/tests/z_api_null_drop_test.c index 52eace72b..79870fc4f 100644 --- a/tests/z_api_null_drop_test.c +++ b/tests/z_api_null_drop_test.c @@ -87,10 +87,10 @@ int main(void) { // TEST(z_owned_mutex_t) // TEST(z_owned_condvar_t) - TEST_TAKE_MUT(z_owned_sample_t, z_sample_take_loaned) - TEST_TAKE_MUT(z_owned_query_t, z_query_take_loaned) - TEST_TAKE_MUT(z_owned_reply_t, z_reply_take_loaned) - TEST_TAKE_MUT(z_owned_hello_t, z_hello_take_loaned) + TEST_TAKE_MUT(z_owned_sample_t, z_sample_take_from_loaned) + TEST_TAKE_MUT(z_owned_query_t, z_query_take_from_loaned) + TEST_TAKE_MUT(z_owned_reply_t, z_reply_take_from_loaned) + TEST_TAKE_MUT(z_owned_hello_t, z_hello_take_from_loaned) return 0; } \ No newline at end of file From c14a441779c152139d97acec3857f8a9352e2af7 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Fri, 8 Nov 2024 14:33:38 +0100 Subject: [PATCH 38/38] errors in doc fixed --- docs/README.md | 5 +++++ docs/concepts.rst | 23 ++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/README.md b/docs/README.md index 41f1052cb..65ec46755 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,12 @@ zenoh-c API documentation is available on [Read the Docs](https://zenoh-c.readth ------------------------------- ## How to build it +1. generate headers with all API functions/structures enabled +2. run doxygen to parse headers +3. generate documentation + ```bash +cargo check --all-features cd docs doxygen sphinx-build -b html . _build/html diff --git a/docs/concepts.rst b/docs/concepts.rst index e25d5f857..97e85c0e3 100644 --- a/docs/concepts.rst +++ b/docs/concepts.rst @@ -237,16 +237,16 @@ operation from mutable reference is required. The second problem is that the C++ API doesn't use the zenog-c moved/loaned syntax sugar, as C++ has its own move semantics. The C++ `std::move` can be called on any non-const reference, so we need to support this behavior. Detailed explanation is in note below, it's ok to skip it. -..note:: -Zenoh C++ API bypasses zenoh-c protection by simply making `reinterpret_cast` from `z_loaned_xxx_t*` to `z_owned_xxx_t*` and back when necessary. This means that -if the move constructor in C++ accepts e.g. C++ object `Reply&&`, it can't be sure if this reference points to `z_owned_reply_t` with valid gravestone state (internally in Rust this -corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_reply_t*` received from inside zenoh-c, which points just to `Reply`, not option-wrapped. -(It's important to notice that `Reply` and `Option` have same size and layout in memory due to Null-Pointer Optimization, so it's safe to treat - `Option` just as `Reply`, but not in other direction). +.. note:: + + Zenoh C++ API bypasses zenoh-c protection by simply making `reinterpret_cast` from `z_loaned_xxx_t*` to `z_owned_xxx_t*` and back when necessary. This means that + if the move constructor in C++ accepts e.g. C++ object `Reply&&`, it can't be sure if this reference points to `z_owned_reply_t` with valid gravestone state (internally in Rust this + corresponds to `Option` and gravestone state is `None`) or is it `z_loaned_reply_t*` received from inside zenoh-c, which points just to `Reply`, not option-wrapped. + (It's important to notice that `Reply` and `Option` have same size and layout in memory due to Null-Pointer Optimization, so it's safe to treat + `Option` just as `Reply`, but not in other direction). To resolve this the `z_take_from_loaned` operation is introduced for `z_loaned_xxx_t*`. It behaves similarly to `z_take` for `z_moved_xxx_t*` but doesn't provide -guarantee that the object is kept in gravestone state. Instead it only guarantees that the object is left in state safe to be dropped, nothing more. -Unlike `z_move`, this operation is full equivalent to C++ move semantics: object is left in "valid but unspecified" state and it still has to be destructed. +guarantee that the object is left in gravestone state. Instead it just leaves the object in some probably unusable but safe to drop state. Zenoh guarantees that it never uses this operation inside its code. I.e. it's always safe to pass object to function with `z_loan_mut` and continue using it after return. It's recommended to follow this rule in user code too and use `z_take_from_loaned` only in exceptional cases. @@ -268,10 +268,9 @@ Examples: z_string_copy_from_str(&s, "Hello, world!"); consume_string(z_move(s)); // no need to drop s here, passing it by z_move promises that it's dropped inside consume_string -`` -`z_loan_mut` and `z_take_from_loaned` usage (this example if fictional: actually take from loaned is implemented only -for types used in callbacks at this moment: `z_loaned_sample_t*`, `z_loaned_reply_t*`, `z_loaned_hello_t*`, `z_loaned_query_t*`): +`z_loan_mut` and `z_take_from_loaned` usage *(Notice that this example if fictional: actually take from loaned is implemented only +for types used in callbacks at this moment: `z_loaned_sample_t*`, `z_loaned_reply_t*`, `z_loaned_hello_t*`, `z_loaned_query_t*`)*: .. code-block:: c @@ -291,8 +290,6 @@ for types used in callbacks at this moment: `z_loaned_sample_t*`, `z_loaned_repl // can't make any assumptions about s here, but still obliged to drop it z_drop(s); -`` - Name Prefixes `z_`, `zc_`, `ze_` ================================