Skip to content

Commit

Permalink
conditional for zp_time_t struct for x86_64-apple
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Feb 27, 2024
1 parent c333956 commit 7f34076
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ usize_is_size_t = true
"target_arch = aarch64" = "TARGET_ARCH_AARCH64"
"target_arch = x86_64" = "TARGET_ARCH_X86_64"
"target_arch = arm" = "TARGET_ARCH_ARM"
"target_vendor = apple" = "TARGET_VENDOR_APPLE"

[export]
include = []
Expand Down
7 changes: 7 additions & 0 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,16 @@ typedef struct zp_task_t {
typedef struct zp_task_attr_t {
size_t _0;
} zp_task_attr_t;
#if (defined(TARGET_ARCH_X86_64) && defined(TARGET_VENDOR_APPLE))
typedef struct zp_time_t {
uint64_t _0[1];
} zp_time_t;
#endif
#if !(defined(TARGET_ARCH_X86_64) && defined(TARGET_VENDOR_APPLE))
typedef struct zp_time_t {
uint64_t _0[2];
} zp_time_t;
#endif
ZENOHC_API extern const unsigned int Z_ROUTER;
ZENOHC_API extern const unsigned int Z_PEER;
ZENOHC_API extern const unsigned int Z_CLIENT;
Expand Down
6 changes: 6 additions & 0 deletions src/platform/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ use std::{
use crate::{impl_guarded_transmute, GuardedTransmute};

// TODO: properly define size/alignment for every architecture
#[cfg(all(target_arch = "x86_64", target_vendor = "apple"))]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct zp_time_t([u64; 1]);

#[cfg(not(all(target_arch = "x86_64", target_vendor = "apple")))]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct zp_time_t([u64; 2]);
Expand Down

0 comments on commit 7f34076

Please sign in to comment.