Skip to content

Commit

Permalink
Auto merge of #2429 - GrayJack:haiku-utmpx, r=JohnTitor
Browse files Browse the repository at this point in the history
Haiku: Add the utmpx structure

Add the utmpx structure like defined on the [haiku headers](https://github.com/haiku/haiku/blob/8f16317a5b6db5c672f331814273e5857555020f/headers/posix/utmpx.h#L13)

> P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks!
  • Loading branch information
bors committed Oct 12, 2021
2 parents 032d105 + f6ac7ad commit acc47b2
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,63 @@ s_no_extra_traits! {
__unused1: *mut ::c_void, // actually a function pointer
pub sigev_notify_attributes: *mut ::pthread_attr_t,
}

pub struct utmpx {
pub ut_type: ::c_short,
pub ut_tv: ::timeval,
pub ut_id: [::c_char; 8],
pub ut_pid: ::pid_t,
pub ut_user: [::c_char; 32],
pub ut_line: [::c_char; 16],
pub ut_host: [::c_char; 128],
__ut_reserved: [::c_char; 64],
}
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for utmpx {
fn eq(&self, other: &utmpx) -> bool {
self.ut_type == other.ut_type
&& self.ut_tv == other.ut_tv
&& self.ut_id == other.ut_id
&& self.ut_pid == other.ut_pid
&& self.ut_user == other.ut_user
&& self.ut_line == other.ut_line
&& self.ut_host.iter().zip(other.ut_host.iter()).all(|(a,b)| a == b)
&& self.__ut_reserved == other.__ut_reserved
}
}

impl Eq for utmpx {}

impl ::fmt::Debug for utmpx {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("utmpx")
.field("ut_type", &self.ut_type)
.field("ut_tv", &self.ut_tv)
.field("ut_id", &self.ut_id)
.field("ut_pid", &self.ut_pid)
.field("ut_user", &self.ut_user)
.field("ut_line", &self.ut_line)
.field("ut_host", &self.ut_host)
.field("__ut_reserved", &self.__ut_reserved)
.finish()
}
}

impl ::hash::Hash for utmpx {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.ut_type.hash(state);
self.ut_tv.hash(state);
self.ut_id.hash(state);
self.ut_pid.hash(state);
self.ut_user.hash(state);
self.ut_line.hash(state);
self.ut_host.hash(state);
self.__ut_reserved.hash(state);
}
}
impl PartialEq for sockaddr_un {
fn eq(&self, other: &sockaddr_un) -> bool {
self.sun_len == other.sun_len
Expand Down

0 comments on commit acc47b2

Please sign in to comment.