Skip to content

Commit 748085d

Browse files
committed
Add extra traits for apple datatypes
1 parent e9c737d commit 748085d

File tree

1 file changed

+117
-7
lines changed

1 file changed

+117
-7
lines changed

src/unix/bsd/apple/mod.rs

+117-7
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,123 @@ 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", &self.ident)
652+
.field("filter", &self.filter)
653+
.field("flags", &self.flags)
654+
.field("fflags", &self.fflags)
655+
.field("data", &self.data)
656+
.field("udata", &self.udata)
657+
.finish()
658+
}
659+
}
660+
impl ::hash::Hash for kevent {
661+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
662+
self.ident.hash(state);
663+
self.filter.hash(state);
664+
self.flags.hash(state);
665+
self.fflags.hash(state);
666+
self.data.hash(state);
667+
self.udata.hash(state);
668+
}
669+
}
670+
671+
impl PartialEq for semid_ds {
672+
fn eq(&self, other: &semid_ds) -> bool {
673+
self.sem_perm == other.sem_perm
674+
&& self.sem_base == other.sem_base
675+
&& self.sem_nsems == other.sem_nsems
676+
&& self.sem_otime == other.sem_otime
677+
&& self.sem_pad1 == other.sem_pad1
678+
&& self.sem_ctime == other.sem_ctime
679+
&& self.sem_pad2 == other.sem_pad2
680+
&& self.sem_pad3 == other.sem_pad3
681+
}
682+
}
683+
impl Eq for semid_ds {}
684+
impl ::fmt::Debug for semid_ds {
685+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
686+
f.debug_struct("semid_ds")
687+
.field("sem_perm", &self.sem_perm)
688+
.field("sem_base", &self.sem_base)
689+
.field("sem_nsems", &self.sem_nsems)
690+
.field("sem_otime", &self.sem_otime)
691+
.field("sem_pad1", &self.sem_pad1)
692+
.field("sem_ctime", &self.sem_ctime)
693+
.field("sem_pad2", &self.sem_pad2)
694+
.field("sem_pad3", &self.sem_pad3)
695+
.finish()
696+
}
697+
}
698+
impl ::hash::Hash for semid_ds {
699+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
700+
self.sem_perm.hash(state);
701+
self.sem_base.hash(state);
702+
self.sem_nsems.hash(state);
703+
self.sem_otime.hash(state);
704+
self.sem_pad1.hash(state);
705+
self.sem_ctime.hash(state);
706+
self.sem_pad2.hash(state);
707+
self.sem_pad3.hash(state);
708+
}
709+
}
710+
711+
impl PartialEq for shmid_ds {
712+
fn eq(&self, other: &shmid_ds) -> bool {
713+
self.shm_perm == other.shm_perm
714+
&& self.shm_segsz == other.shm_segsz
715+
&& self.shm_lpid == other.shm_lpid
716+
&& self.shm_cpid == other.shm_cpid
717+
&& self.shm_nattch == other.shm_nattch
718+
&& self.shm_atime == other.shm_atime
719+
&& self.shm_dtime == other.shm_dtime
720+
&& self.shm_ctime == other.shm_ctime
721+
&& self.shm_internal == other.shm_internal
722+
}
723+
}
724+
impl Eq for shmid_ds {}
725+
impl ::fmt::Debug for shmid_ds {
726+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
727+
f.debug_struct("shmid_ds")
728+
.field("shm_perm", &self.shm_perm)
729+
.field("shm_segsz", &self.shm_segsz)
730+
.field("shm_lpid", &self.shm_lpid)
731+
.field("shm_cpid", &self.shm_cpid)
732+
.field("shm_nattch", &self.shm_nattch)
733+
.field("shm_atime", &self.shm_atime)
734+
.field("shm_dtime", &self.shm_dtime)
735+
.field("shm_ctime", &self.shm_ctime)
736+
.field("shm_internal", &self.shm_internal)
737+
.finish()
738+
}
739+
}
740+
impl ::hash::Hash for shmid_ds {
741+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
742+
self.shm_perm.hash(state);
743+
self.shm_segsz.hash(state);
744+
self.shm_lpid.hash(state);
745+
self.shm_cpid.hash(state);
746+
self.shm_nattch.hash(state);
747+
self.shm_atime.hash(state);
748+
self.shm_dtime.hash(state);
749+
self.shm_ctime.hash(state);
750+
self.shm_internal.hash(state);
751+
}
752+
}
753+
643754
impl PartialEq for proc_threadinfo {
644755
fn eq(&self, other: &proc_threadinfo) -> bool {
645756
self.pth_user_time == other.pth_user_time
@@ -676,7 +787,6 @@ cfg_if! {
676787
.finish()
677788
}
678789
}
679-
680790
impl ::hash::Hash for proc_threadinfo {
681791
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
682792
self.pth_user_time.hash(state);

0 commit comments

Comments
 (0)