summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-12 01:09:29 +0000
committerbors <bors@rust-lang.org>2021-10-12 01:09:29 +0000
commitacc47b21be7fcd25d5351333787d81903642bbdf (patch)
tree8a62454a8bec9689ddd047d1766f64b959d17d08
parent032d105348914d1d0c325512ae9ce551311180b4 (diff)
parentf6ac7ad1cb87d382268c059a6d5041f63f1a0922 (diff)
downloadrust-libc-acc47b21be7fcd25d5351333787d81903642bbdf.tar.gz
Auto merge of #2429 - GrayJack:haiku-utmpx, r=JohnTitor
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!
-rw-r--r--src/unix/haiku/mod.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs
index a2c0507315..19d5bb9a1a 100644
--- a/src/unix/haiku/mod.rs
+++ b/src/unix/haiku/mod.rs
@@ -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