Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Updated cyclors package to gain latest bindgen (0.68). #148

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 48 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 19 additions & 6 deletions zenoh-plugin-dds/src/dds_mgt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use zenoh::publication::CongestionControl;
use zenoh::Session;
use zenoh_core::SyncResolve;

const MAX_SAMPLES: u32 = 32;
const MAX_SAMPLES: usize = 32;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) enum RouteStatus {
Expand Down Expand Up @@ -191,6 +191,11 @@ impl DDSRawSample {
}

fn data_as_slice(&self) -> &[u8] {
#[cfg(not(target_os = "windows"))]
unsafe {
slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len)
}
#[cfg(target_os = "windows")]
unsafe {
slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len as usize)
}
Expand All @@ -204,7 +209,15 @@ impl DDSRawSample {
return iox_chunk.as_slice();
}
}
&slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len as usize)[4..]
#[cfg(not(target_os = "windows"))]
{
&slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len)[4..]
}
#[cfg(target_os = "windows")]
{
&slice::from_raw_parts(self.data.iov_base as *const u8, self.data.iov_len as usize)
[4..]
}
}
}

Expand Down Expand Up @@ -278,17 +291,17 @@ unsafe extern "C" fn on_data(dr: dds_entity_t, arg: *mut std::os::raw::c_void) {
let _ = dds_get_instance_handle(dp, &mut dpih);

#[allow(clippy::uninit_assumed_init)]
let mut si = MaybeUninit::<[dds_sample_info_t; MAX_SAMPLES as usize]>::uninit();
let mut samples: [*mut ::std::os::raw::c_void; MAX_SAMPLES as usize] =
[std::ptr::null_mut(); MAX_SAMPLES as usize];
let mut si = MaybeUninit::<[dds_sample_info_t; MAX_SAMPLES]>::uninit();
let mut samples: [*mut ::std::os::raw::c_void; MAX_SAMPLES] =
[std::ptr::null_mut(); MAX_SAMPLES];
samples[0] = std::ptr::null_mut();

let n = dds_take(
dr,
samples.as_mut_ptr() as *mut *mut raw::c_void,
si.as_mut_ptr() as *mut dds_sample_info_t,
MAX_SAMPLES.into(),
MAX_SAMPLES,
MAX_SAMPLES as u32,
);
let si = si.assume_init();

Expand Down
Loading
Loading