Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to manual trait impls for sigevent #1394

Merged
merged 1 commit into from
Jun 11, 2019
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
51 changes: 42 additions & 9 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,6 @@ s! {
pub int_n_sign_posn: ::c_char,
}

pub struct sigevent {
pub sigev_value: ::sigval,
pub sigev_signo: ::c_int,
pub sigev_notify: ::c_int,
pub sigev_notify_function: fn(::sigval),
pub sigev_notify_attributes: *mut pthread_attr_t,
pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */],
}

pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
Expand Down Expand Up @@ -962,6 +953,15 @@ s_no_extra_traits! {
pub nl_pid: u32,
pub nl_groups: u32
}

pub struct sigevent {
pub sigev_value: ::sigval,
pub sigev_signo: ::c_int,
pub sigev_notify: ::c_int,
pub sigev_notify_function: fn(::sigval),
pub sigev_notify_attributes: *mut pthread_attr_t,
pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */],
}
}

cfg_if! {
Expand Down Expand Up @@ -1255,6 +1255,39 @@ cfg_if! {
self.nl_groups.hash(state);
}
}

impl PartialEq for sigevent {
fn eq(&self, other: &sigevent) -> bool {
self.sigev_value == other.sigev_value
&& self.sigev_signo == other.sigev_signo
&& self.sigev_notify == other.sigev_notify
&& self.sigev_notify_function == other.sigev_notify_function
&& self.sigev_notify_attributes
== other.sigev_notify_attributes
}
}
impl Eq for sigevent {}
impl ::fmt::Debug for sigevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigevent")
.field("sigev_value", &self.sigev_value)
.field("sigev_signo", &self.sigev_signo)
.field("sigev_notify", &self.sigev_notify)
.field("sigev_notify_function", &self.sigev_notify_function)
.field("sigev_notify_attributes",
&self.sigev_notify_attributes)
.finish()
}
}
impl ::hash::Hash for sigevent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sigev_value.hash(state);
self.sigev_signo.hash(state);
self.sigev_notify.hash(state);
self.sigev_notify_function.hash(state);
self.sigev_notify_attributes.hash(state);
}
}
}
}

Expand Down
49 changes: 41 additions & 8 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,6 @@ s! {
pub int_n_sign_posn: ::c_char,
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
__unused1: *mut ::c_void, //actually a function pointer
pub sigev_notify_attributes: *mut ::pthread_attr_t
}

pub struct proc_taskinfo {
pub pti_virtual_size: u64,
pub pti_resident_size: u64,
Expand Down Expand Up @@ -612,6 +604,14 @@ s_no_extra_traits!{
pub ut_host: [::c_char; _UTX_HOSTSIZE],
ut_pad: [u32; 16],
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
__unused1: *mut ::c_void, //actually a function pointer
pub sigev_notify_attributes: *mut ::pthread_attr_t
}
}

cfg_if! {
Expand Down Expand Up @@ -1159,6 +1159,39 @@ cfg_if! {
self.ut_pad.hash(state);
}
}

impl PartialEq for sigevent {
fn eq(&self, other: &sigevent) -> bool {
self.sigev_notify == other.sigev_notify
&& self.sigev_signo == other.sigev_signo
&& self.sigev_value == other.sigev_value
&& self.sigev_notify_attributes
== other.sigev_notify_attributes
}
}

impl Eq for sigevent {}

impl ::fmt::Debug for sigevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigevent")
.field("sigev_notify", &self.sigev_notify)
.field("sigev_signo", &self.sigev_signo)
.field("sigev_value", &self.sigev_value)
.field("sigev_notify_attributes",
&self.sigev_notify_attributes)
.finish()
}
}

impl ::hash::Hash for sigevent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sigev_notify.hash(state);
self.sigev_signo.hash(state);
self.sigev_value.hash(state);
self.sigev_notify_attributes.hash(state);
}
}
}
}

Expand Down
52 changes: 39 additions & 13 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ s! {
pub mq_curmsgs: ::c_long,
}

pub struct sigevent {
pub sigev_notify: ::c_int,
// The union is 8-byte in size, so it is aligned at a 8-byte offset.
#[cfg(target_pointer_width = "64")]
__unused1: ::c_int,
pub sigev_signo: ::c_int, //actually a union
// pad the union
#[cfg(target_pointer_width = "64")]
__unused2: ::c_int,
pub sigev_value: ::sigval,
__unused3: *mut ::c_void //actually a function pointer
}

pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
Expand Down Expand Up @@ -234,6 +221,20 @@ s_no_extra_traits! {
pub f_asyncreads: ::c_long,
pub f_mntfromname: [::c_char; 90],
}

pub struct sigevent {
pub sigev_notify: ::c_int,
// The union is 8-byte in size, so it is aligned at a 8-byte offset.
#[cfg(target_pointer_width = "64")]
__unused1: ::c_int,
pub sigev_signo: ::c_int, //actually a union
// pad the union
#[cfg(target_pointer_width = "64")]
__unused2: ::c_int,
pub sigev_value: ::sigval,
__unused3: *mut ::c_void //actually a function pointer
}

}

cfg_if! {
Expand Down Expand Up @@ -408,6 +409,31 @@ cfg_if! {
self.f_mntfromname.hash(state);
}
}

impl PartialEq for sigevent {
fn eq(&self, other: &sigevent) -> bool {
self.sigev_notify == other.sigev_notify
&& self.sigev_signo == other.sigev_signo
&& self.sigev_value == other.sigev_value
}
}
impl Eq for sigevent {}
impl ::fmt::Debug for sigevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigevent")
.field("sigev_notify", &self.sigev_notify)
.field("sigev_signo", &self.sigev_signo)
.field("sigev_value", &self.sigev_value)
.finish()
}
}
impl ::hash::Hash for sigevent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sigev_notify.hash(state);
self.sigev_signo.hash(state);
self.sigev_value.hash(state);
}
}
}
}

Expand Down
54 changes: 42 additions & 12 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ s! {
pub ip6: *mut ::in6_addr,
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
//The rest of the structure is actually a union. We expose only
//sigev_notify_thread_id because it's the most useful union member.
pub sigev_notify_thread_id: ::lwpid_t,
#[cfg(target_pointer_width = "64")]
__unused1: ::c_int,
__unused2: [::c_long; 7]
}

pub struct statvfs {
pub f_bavail: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
Expand Down Expand Up @@ -151,6 +139,18 @@ s_no_extra_traits! {
pub mq_curmsgs: ::c_long,
__reserved: [::c_long; 4]
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
//The rest of the structure is actually a union. We expose only
//sigev_notify_thread_id because it's the most useful union member.
pub sigev_notify_thread_id: ::lwpid_t,
#[cfg(target_pointer_width = "64")]
__unused1: ::c_int,
__unused2: [::c_long; 7]
}
}

cfg_if! {
Expand Down Expand Up @@ -274,6 +274,36 @@ cfg_if! {
self.mq_curmsgs.hash(state);
}
}

impl PartialEq for sigevent {
fn eq(&self, other: &sigevent) -> bool {
self.sigev_notify == other.sigev_notify
&& self.sigev_signo == other.sigev_signo
&& self.sigev_value == other.sigev_value
&& self.sigev_notify_thread_id
== other.sigev_notify_thread_id
}
}
impl Eq for sigevent {}
impl ::fmt::Debug for sigevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigevent")
.field("sigev_notify", &self.sigev_notify)
.field("sigev_signo", &self.sigev_signo)
.field("sigev_value", &self.sigev_value)
.field("sigev_notify_thread_id",
&self.sigev_notify_thread_id)
.finish()
}
}
impl ::hash::Hash for sigevent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sigev_notify.hash(state);
self.sigev_signo.hash(state);
self.sigev_value.hash(state);
self.sigev_notify_thread_id.hash(state);
}
}
}
}

Expand Down
46 changes: 38 additions & 8 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ s! {
pub mq_curmsgs: ::c_long,
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
__unused1: *mut ::c_void, //actually a function pointer
pub sigev_notify_attributes: *mut ::c_void
}

pub struct sigset_t {
__bits: [u32; 4],
}
Expand Down Expand Up @@ -356,6 +348,14 @@ s_no_extra_traits! {
__ss_pad2: i64,
__ss_pad3: [u8; 112],
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
__unused1: *mut ::c_void, //actually a function pointer
pub sigev_notify_attributes: *mut ::c_void
}
}

cfg_if! {
Expand Down Expand Up @@ -658,6 +658,36 @@ cfg_if! {
self.__ss_pad3.hash(state);
}
}

impl PartialEq for sigevent {
fn eq(&self, other: &sigevent) -> bool {
self.sigev_notify == other.sigev_notify
&& self.sigev_signo == other.sigev_signo
&& self.sigev_value == other.sigev_value
&& self.sigev_notify_attributes
== other.sigev_notify_attributes
}
}
impl Eq for sigevent {}
impl ::fmt::Debug for sigevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigevent")
.field("sigev_notify", &self.sigev_notify)
.field("sigev_signo", &self.sigev_signo)
.field("sigev_value", &self.sigev_value)
.field("sigev_notify_attributes",
&self.sigev_notify_attributes)
.finish()
}
}
impl ::hash::Hash for sigevent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sigev_notify.hash(state);
self.sigev_signo.hash(state);
self.sigev_value.hash(state);
self.sigev_notify_attributes.hash(state);
}
}
}
}

Expand Down
Loading