Skip to content
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
17 changes: 0 additions & 17 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,6 @@ fn test_solarish(target: &str) {
// expose stat.Xtim.tv_nsec fields
Some(field.ident().trim_end_matches("e_nsec").to_string() + ".tv_nsec")
}
// epoll_event.data is a union in C; our `u64` field lives at `data.u64`
"epoll_event" if field.ident() == "u64" => Some("data.u64".to_string()),
_ => None,
}
});
Expand Down Expand Up @@ -4322,10 +4320,6 @@ fn test_linux(target: &str) {
Some(f.replace("e_nsec", ".tv_nsec"))
}

// FIXME(linux): epoll_event.data is actually a union in C, but in Rust
// it is only a u64 because we only expose one field
// http://man7.org/linux/man-pages/man2/epoll_wait.2.html
("epoll_event", "u64") => Some("data.u64".to_string()),
// The following structs have a field called `type` in C,
// but `type` is a Rust keyword, so these fields are translated
// to `type_` in Rust.
Expand Down Expand Up @@ -5176,8 +5170,6 @@ fn test_linux(target: &str) {
("sigaction", "sa_sigaction") => true,
// __timeval type is a patch which doesn't exist in glibc
("utmpx", "ut_tv") => true,
// sigval is actually a union, but we pretend it's a struct
("sigevent", "sigev_value") => true,
// this one is an anonymous union
("ff_effect", "u") => true,
// `__exit_status` type is a patch which is absent in musl
Expand Down Expand Up @@ -5706,9 +5698,6 @@ fn test_haiku(target: &str) {

"Elf64_Phdr" => true,

// is an union
"cpuid_info" => true,

_ => false,
}
});
Expand Down Expand Up @@ -5792,10 +5781,8 @@ fn test_haiku(target: &str) {
("stat", "st_crtime_nsec") => true,

// these are actually unions, but we cannot represent it well
("sem_t", "named_sem_id") => true,
("sigaction", "sa_sigaction") => true,
("fpu_state", "_fpreg") => true,
("cpu_topology_node_info", "data") => true,
// these fields have a simplified data definition in libc
("fpu_state", "_xmm") => true,
("savefpu", "_fp_ymm") => true,
Expand Down Expand Up @@ -6191,10 +6178,6 @@ fn test_qurt(target: &str) {
// These are compatibility stubs in libc, not from QuRT headers
"stat" | "tm" | "timespec" | "timeval" | "itimerspec" | "dirent" | "DIR"
| "termios" | "rlimit" | "rusage" | "flock" | "div_t" | "ldiv_t" | "lldiv_t" => true,
// sigaction: sa_handler/sa_sigaction are a union in C but separate fields in Rust
"sigaction" => true,
// sem_t is typedef of anonymous struct in C (no struct tag)
"sem_t" => true,
_ => false,
}
});
Expand Down
19 changes: 13 additions & 6 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,6 @@ s! {
sa_userdata: *mut c_void,
}

pub struct sem_t {
pub type_: i32,
pub named_sem_id: i32, // actually a union with unnamed_sem (i32)
padding: Padding<[i32; 2]>,
}

pub struct ucred {
pub pid: crate::pid_t,
pub uid: crate::uid_t,
Expand Down Expand Up @@ -499,6 +493,19 @@ s! {
}
}

s_no_extra_traits! {
pub struct sem_t {
pub type_: i32,
pub named_sem_id: __c_anonymous_sem_t_u,
padding: Padding<[i32; 2]>,
}

pub union __c_anonymous_sem_t_u {
pub named_sem_id: i32,
pub unnamed_sem: i32,
}
}

pub const EXIT_FAILURE: c_int = 1;
pub const EXIT_SUCCESS: c_int = 0;
pub const RAND_MAX: c_int = 2147483647;
Expand Down
21 changes: 15 additions & 6 deletions src/unix/solarish/illumos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ s! {
pub fi_name: [c_char; crate::FILNAME_MAX as usize],
}

#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))]
pub struct epoll_event {
pub events: u32,
pub u64: u64,
}

pub struct utmpx {
pub ut_user: [c_char; _UTX_USERSIZE],
pub ut_id: [c_char; _UTX_IDSIZE],
Expand All @@ -69,6 +63,21 @@ s! {
}
}

s_no_extra_traits! {
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))]
pub struct epoll_event {
pub events: u32,
pub data: epoll_data,
}

pub union epoll_data {
pub ptr: *mut c_void,
pub fd: c_int,
pub u32: u32,
pub u64: u64,
}
Comment on lines +67 to +78

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Illumos maintainers @jclulow @pfmooney this is a useful change but technically breaking, do you want it in 0.2?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deciding against this, see #5351 (review)

}

pub const _UTX_USERSIZE: usize = 32;
pub const _UTX_LINESIZE: usize = 32;
pub const _UTX_PADSIZE: usize = 5;
Expand Down