diff --git a/libc-test/build.rs b/libc-test/build.rs index b13a8369849c..41d0550c4d0e 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -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, } }); @@ -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. @@ -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 @@ -5706,9 +5698,6 @@ fn test_haiku(target: &str) { "Elf64_Phdr" => true, - // is an union - "cpuid_info" => true, - _ => false, } }); @@ -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, @@ -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, } }); diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index da8f5968cc8d..a98e4b17bcce 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -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, @@ -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; diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 7b8ce2c29315..4898b4b5a451 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -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], @@ -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, + } +} + pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 5;