Skip to content

Commit 64ab364

Browse files
committed
Add extra traits for apple datatypes
1 parent 5bb41f3 commit 64ab364

File tree

1 file changed

+127
-7
lines changed

1 file changed

+127
-7
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 127 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,6 @@ s! {
482482
}
483483

484484
s_no_extra_traits!{
485-
// FIXME: https://github.com/rust-lang/libc/issues/1243
486-
#[allow(missing_debug_implementations)]
487485
#[cfg_attr(libc_packedN, repr(packed(4)))]
488486
pub struct kevent {
489487
pub ident: ::uintptr_t,
@@ -494,8 +492,6 @@ s_no_extra_traits!{
494492
pub udata: *mut ::c_void,
495493
}
496494

497-
// FIXME: https://github.com/rust-lang/libc/issues/1243
498-
#[allow(missing_debug_implementations)]
499495
#[cfg_attr(libc_packedN, repr(packed(4)))]
500496
pub struct semid_ds {
501497
// Note the manpage shows different types than the system header.
@@ -509,8 +505,6 @@ s_no_extra_traits!{
509505
pub sem_pad3: [::int32_t; 4],
510506
}
511507

512-
// FIXME: https://github.com/rust-lang/libc/issues/1243
513-
#[allow(missing_debug_implementations)]
514508
#[cfg_attr(libc_packedN, repr(packed(4)))]
515509
pub struct shmid_ds {
516510
pub shm_perm: ipc_perm,
@@ -640,6 +634,133 @@ cfg_if! {
640634

641635
cfg_if! {
642636
if #[cfg(feature = "extra_traits")] {
637+
impl PartialEq for kevent {
638+
fn eq(&self, other: &kevent) -> bool {
639+
self.ident == other.ident
640+
&& self.filter == other.filter
641+
&& self.flags == other.flags
642+
&& self.fflags == other.fflags
643+
&& self.data == other.data
644+
&& self.udata == other.udata
645+
}
646+
}
647+
impl Eq for kevent {}
648+
impl ::fmt::Debug for kevent {
649+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
650+
f.debug_struct("kevent")
651+
.field("ident", unsafe { &self.ident })
652+
.field("filter", unsafe { &self.filter })
653+
.field("flags", unsafe { &self.flags })
654+
.field("fflags", unsafe { &self.fflags })
655+
.field("data", unsafe { &self.data })
656+
.field("udata", unsafe { &self.udata })
657+
.finish()
658+
}
659+
}
660+
impl ::hash::Hash for kevent {
661+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
662+
unsafe {
663+
self.ident.hash(state);
664+
self.filter.hash(state);
665+
self.flags.hash(state);
666+
self.fflags.hash(state);
667+
self.data.hash(state);
668+
self.udata.hash(state);
669+
}
670+
}
671+
}
672+
673+
impl PartialEq for semid_ds {
674+
fn eq(&self, other: &semid_ds) -> bool {
675+
unsafe {
676+
self.sem_perm == other.sem_perm
677+
&& self.sem_base == other.sem_base
678+
&& self.sem_nsems == other.sem_nsems
679+
&& self.sem_otime == other.sem_otime
680+
&& self.sem_pad1 == other.sem_pad1
681+
&& self.sem_ctime == other.sem_ctime
682+
&& self.sem_pad2 == other.sem_pad2
683+
&& self.sem_pad3 == other.sem_pad3
684+
}
685+
}
686+
}
687+
impl Eq for semid_ds {}
688+
impl ::fmt::Debug for semid_ds {
689+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
690+
f.debug_struct("semid_ds")
691+
.field("sem_perm", unsafe { &self.sem_perm })
692+
.field("sem_base", unsafe { &self.sem_base })
693+
.field("sem_nsems", unsafe { &self.sem_nsems })
694+
.field("sem_otime", unsafe { &self.sem_otime })
695+
.field("sem_pad1", unsafe { &self.sem_pad1 })
696+
.field("sem_ctime", unsafe { &self.sem_ctime })
697+
.field("sem_pad2", unsafe { &self.sem_pad2 })
698+
.field("sem_pad3", unsafe { &self.sem_pad3 })
699+
.finish()
700+
}
701+
}
702+
impl ::hash::Hash for semid_ds {
703+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
704+
unsafe {
705+
self.sem_perm.hash(state);
706+
self.sem_base.hash(state);
707+
self.sem_nsems.hash(state);
708+
self.sem_otime.hash(state);
709+
self.sem_pad1.hash(state);
710+
self.sem_ctime.hash(state);
711+
self.sem_pad2.hash(state);
712+
self.sem_pad3.hash(state);
713+
}
714+
}
715+
}
716+
717+
impl PartialEq for shmid_ds {
718+
fn eq(&self, other: &shmid_ds) -> bool {
719+
unsafe {
720+
self.shm_perm == other.shm_perm
721+
&& self.shm_segsz == other.shm_segsz
722+
&& self.shm_lpid == other.shm_lpid
723+
&& self.shm_cpid == other.shm_cpid
724+
&& self.shm_nattch == other.shm_nattch
725+
&& self.shm_atime == other.shm_atime
726+
&& self.shm_dtime == other.shm_dtime
727+
&& self.shm_ctime == other.shm_ctime
728+
&& self.shm_internal == other.shm_internal
729+
}
730+
}
731+
}
732+
impl Eq for shmid_ds {}
733+
impl ::fmt::Debug for shmid_ds {
734+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
735+
f.debug_struct("shmid_ds")
736+
.field("shm_perm", unsafe { &self.shm_perm })
737+
.field("shm_segsz", unsafe { &self.shm_segsz })
738+
.field("shm_lpid", unsafe { &self.shm_lpid })
739+
.field("shm_cpid", unsafe { &self.shm_cpid })
740+
.field("shm_nattch", unsafe { &self.shm_nattch })
741+
.field("shm_atime", unsafe { &self.shm_atime })
742+
.field("shm_dtime", unsafe { &self.shm_dtime })
743+
.field("shm_ctime", unsafe { &self.shm_ctime })
744+
.field("shm_internal", unsafe { &self.shm_internal })
745+
.finish()
746+
}
747+
}
748+
impl ::hash::Hash for shmid_ds {
749+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
750+
unsafe {
751+
self.shm_perm.hash(state);
752+
self.shm_segsz.hash(state);
753+
self.shm_lpid.hash(state);
754+
self.shm_cpid.hash(state);
755+
self.shm_nattch.hash(state);
756+
self.shm_atime.hash(state);
757+
self.shm_dtime.hash(state);
758+
self.shm_ctime.hash(state);
759+
self.shm_internal.hash(state);
760+
}
761+
}
762+
}
763+
643764
impl PartialEq for proc_threadinfo {
644765
fn eq(&self, other: &proc_threadinfo) -> bool {
645766
self.pth_user_time == other.pth_user_time
@@ -676,7 +797,6 @@ cfg_if! {
676797
.finish()
677798
}
678799
}
679-
680800
impl ::hash::Hash for proc_threadinfo {
681801
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
682802
self.pth_user_time.hash(state);

0 commit comments

Comments
 (0)