Skip to content

Commit

Permalink
Updated cyclors package to gain latest bindgen (0.68). (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmartin82 authored Sep 11, 2023
1 parent 8eecb86 commit 1b657b8
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 92 deletions.
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

0 comments on commit 1b657b8

Please sign in to comment.