Skip to content

Commit

Permalink
fix rebase problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Folkert de Vries committed Nov 19, 2024
1 parent f550a24 commit b3d2389
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 54 deletions.
65 changes: 26 additions & 39 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl ::Clone for fpos64_t {

// PUB_STRUCT

fn s_fmt_tmp() {
s! {
pub struct group {
pub gr_name: *mut ::c_char,
pub gr_passwd: *mut ::c_char,
Expand Down Expand Up @@ -907,7 +907,7 @@ fn s_fmt_tmp() {
}
}

fn s_no_extra_traits_fmt_tmp() {
s_no_extra_traits! {
pub struct sysinfo {
pub uptime: ::c_ulong,
pub loads: [::c_ulong; 3],
Expand Down Expand Up @@ -1048,8 +1048,8 @@ fn s_no_extra_traits_fmt_tmp() {
}
}

fn cfg_if_fmt_tmp() {
if cfg_tmp!([feature = "extra_traits"]) {
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for sysinfo {
fn eq(&self, other: &sysinfo) -> bool {
self.uptime == other.uptime
Expand Down Expand Up @@ -3357,10 +3357,10 @@ pub const HUGETLB_FLAG_ENCODE_SHIFT: u32 = 26;
pub const MAP_HUGE_SHIFT: u32 = 26;

// intentionally not public, only used for fd_set
fn cfg_if_fmt_tmp() {
if cfg_tmp!([target_pointer_width = "32"]) {
cfg_if! {
if #[cfg(target_pointer_width = "32")] {
const ULONG_SIZE: usize = 32;
} else if cfg_tmp!([target_pointer_width = "64"]) {
} else if #[cfg(target_pointer_width = "64")] {
const ULONG_SIZE: usize = 64;
} else {
// Unknown target_pointer_width
Expand All @@ -3369,7 +3369,7 @@ fn cfg_if_fmt_tmp() {

// END_PUB_CONST

fn f_fmt_tmp() {
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
Expand Down Expand Up @@ -3462,70 +3462,57 @@ fn f_fmt_tmp() {
}
}

/* FMT-CONST */
pub const fn CMSG_ALIGN(len: ::size_t) -> ::size_t {
pub {const} fn CMSG_ALIGN(len: ::size_t) -> ::size_t {
(len + ::mem::size_of::<::size_t>() - 1) & !(::mem::size_of::<::size_t>() - 1)
}

/* FMT-CONST */
pub const fn CMSG_SPACE(len: ::c_uint) -> ::c_uint {
pub {const} fn CMSG_SPACE(len: ::c_uint) -> ::c_uint {
(CMSG_ALIGN(len as ::size_t) + CMSG_ALIGN(::mem::size_of::<cmsghdr>())) as ::c_uint
}

/* FMT-CONST */
pub const fn CMSG_LEN(len: ::c_uint) -> ::c_uint {
pub {const} fn CMSG_LEN(len: ::c_uint) -> ::c_uint {
(CMSG_ALIGN(::mem::size_of::<cmsghdr>()) + len as ::size_t) as ::c_uint
}
}

fn safe_f_fmt_tmp() {
/* FMT-CONST */
pub const fn WIFSTOPPED(status: ::c_int) -> bool {
safe_f! {
pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
(status & 0xff) == 0x7f
}

/* FMT-CONST */
pub const fn WSTOPSIG(status: ::c_int) -> ::c_int {
pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
(status >> 8) & 0xff
}

/* FMT-CONST */
pub const fn WIFCONTINUED(status: ::c_int) -> bool {
pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0xffff
}

/* FMT-CONST */
pub const fn WIFSIGNALED(status: ::c_int) -> bool {
pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
((status & 0x7f) + 1) as i8 >= 2
}

/* FMT-CONST */
pub const fn WTERMSIG(status: ::c_int) -> ::c_int {
pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
status & 0x7f
}

/* FMT-CONST */
pub const fn WIFEXITED(status: ::c_int) -> bool {
pub {const} fn WIFEXITED(status: ::c_int) -> bool {
(status & 0x7f) == 0
}

/* FMT-CONST */
pub const fn WEXITSTATUS(status: ::c_int) -> ::c_int {
pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
(status >> 8) & 0xff
}

/* FMT-CONST */
pub const fn WCOREDUMP(status: ::c_int) -> bool {
pub {const} fn WCOREDUMP(status: ::c_int) -> bool {
(status & 0x80) != 0
}

/* FMT-CONST */
pub const fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
(cmd << 8) | (type_ & 0x00ff)
}

/* FMT-CONST */
pub const fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
let major = major as ::dev_t;
let minor = minor as ::dev_t;
let mut dev = 0;
Expand Down Expand Up @@ -4468,14 +4455,14 @@ extern "C" {
) -> ::c_int;
}

fn cfg_if_fmt_tmp() {
if cfg_tmp!([target_arch = "aarch64"]) {
cfg_if! {
if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else if cfg_tmp!([any(target_arch = "x86_64")]) {
} else if #[cfg(any(target_arch = "x86_64"))] {
mod x86_64;
pub use self::x86_64::*;
} else if cfg_tmp!([any(target_arch = "riscv64")]) {
} else if #[cfg(any(target_arch = "riscv64"))] {
mod riscv64;
pub use self::riscv64::*;
} else {
Expand Down
164 changes: 149 additions & 15 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,26 +1412,160 @@ s_no_extra_traits! {
pub offset_to_priv: ::__u32,
pub hdr: ::tpacket_bd_header_u,
}
}

s! {
// linux/ptp_clock.h
pub struct ptp_sys_offset {
pub n_samples: ::c_uint,
pub rsv: [::c_uint; 3],
pub ts: [ptp_clock_time; 2 * PTP_MAX_SAMPLES as usize + 1],
#[cfg_attr(
all(
any(target_env = "musl", target_env = "ohos"),
target_pointer_width = "32"
),
repr(align(4))
)]
#[cfg_attr(
all(
any(target_env = "musl", target_env = "ohos"),
target_pointer_width = "64"
),
repr(align(8))
)]
#[cfg_attr(
all(
not(any(target_env = "musl", target_env = "ohos")),
target_arch = "x86"
),
repr(align(4))
)]
#[cfg_attr(
all(
not(any(target_env = "musl", target_env = "ohos")),
not(target_arch = "x86")
),
repr(align(8))
)]
pub struct pthread_cond_t {
#[doc(hidden)]
size: [u8; ::__SIZEOF_PTHREAD_COND_T],
}

pub struct ptp_pin_desc {
pub name: [::c_char; 64],
pub index: ::c_uint,
pub func: ::c_uint,
pub chan: ::c_uint,
pub rsv: [::c_uint; 5],
#[cfg_attr(
all(
target_pointer_width = "32",
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
target_arch = "csky",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "x86_64",
target_arch = "x86"
)
),
repr(align(4))
)]
#[cfg_attr(
any(
target_pointer_width = "64",
not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
target_arch = "csky",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "x86_64",
target_arch = "x86"
))
),
repr(align(8))
)]
pub struct pthread_mutex_t {
#[doc(hidden)]
size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
}

#[cfg_attr(
all(
target_pointer_width = "32",
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
target_arch = "csky",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "x86_64",
target_arch = "x86"
)
),
repr(align(4))
)]
#[cfg_attr(
any(
target_pointer_width = "64",
not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "x86_64",
target_arch = "x86"
))
),
repr(align(8))
)]
pub struct pthread_rwlock_t {
size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
}

#[cfg_attr(
all(
target_pointer_width = "32",
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
target_arch = "csky",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "x86_64",
target_arch = "x86"
)
),
repr(align(4))
)]
#[cfg_attr(
any(
target_pointer_width = "64",
not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "arm",
target_arch = "hexagon",
target_arch = "m68k",
target_arch = "csky",
target_arch = "powerpc",
target_arch = "sparc",
target_arch = "x86_64",
target_arch = "x86"
))
),
repr(align(8))
)]
pub struct pthread_barrier_t {
size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T],
}
}

s_no_extra_traits! {
// linux/net_tstamp.h
#[allow(missing_debug_implementations)]
pub struct sock_txtime {
Expand Down

0 comments on commit b3d2389

Please sign in to comment.