diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-20 19:59:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-20 19:59:26 +0000 |
commit | 661738cceee4e479ded272a63e3082035b860351 (patch) | |
tree | cd7d5d6345777cef2c47561274ab04e7364762a7 /src/mqueue.rs | |
parent | de43d7641b351ff2582206798b68baeed42c3117 (diff) | |
parent | 7cdae09e2957f8578c9b8cd88934c669a2f3a13b (diff) | |
download | nix-661738cceee4e479ded272a63e3082035b860351.zip |
Merge #1366
1366: x32 port r=asomers a=nabijaczleweli
I played pretty loose with the statfs bit, hoping for CI to tell me if I broke something.
Co-authored-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Diffstat (limited to 'src/mqueue.rs')
-rw-r--r-- | src/mqueue.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mqueue.rs b/src/mqueue.rs index 122705a5..0215de5a 100644 --- a/src/mqueue.rs +++ b/src/mqueue.rs @@ -5,7 +5,7 @@ use crate::Result; use crate::errno::Errno; -use libc::{self, c_char, c_long, mqd_t, size_t}; +use libc::{self, c_char, mqd_t, size_t}; use std::ffi::CString; use crate::sys::stat::Mode; use std::mem; @@ -34,11 +34,18 @@ pub struct MqAttr { mq_attr: libc::mq_attr, } +// x32 compatibility +// See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +pub type mq_attr_member_t = i64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +pub type mq_attr_member_t = libc::c_long; + impl MqAttr { - pub fn new(mq_flags: c_long, - mq_maxmsg: c_long, - mq_msgsize: c_long, - mq_curmsgs: c_long) + pub fn new(mq_flags: mq_attr_member_t, + mq_maxmsg: mq_attr_member_t, + mq_msgsize: mq_attr_member_t, + mq_curmsgs: mq_attr_member_t) -> MqAttr { let mut attr = mem::MaybeUninit::<libc::mq_attr>::uninit(); @@ -52,7 +59,7 @@ impl MqAttr { } } - pub fn flags(&self) -> c_long { + pub fn flags(&self) -> mq_attr_member_t { self.mq_attr.mq_flags } } @@ -150,7 +157,7 @@ pub fn mq_setattr(mqd: mqd_t, newattr: &MqAttr) -> Result<MqAttr> { /// Returns the old attributes pub fn mq_set_nonblock(mqd: mqd_t) -> Result<MqAttr> { let oldattr = mq_getattr(mqd)?; - let newattr = MqAttr::new(c_long::from(MQ_OFlag::O_NONBLOCK.bits()), + let newattr = MqAttr::new(mq_attr_member_t::from(MQ_OFlag::O_NONBLOCK.bits()), oldattr.mq_attr.mq_maxmsg, oldattr.mq_attr.mq_msgsize, oldattr.mq_attr.mq_curmsgs); |