From 25846bccc17f273f965fa5d0f6558ad26d23bb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Birch=20Moltu?= Date: Sun, 31 Mar 2019 23:24:56 +0200 Subject: [PATCH 1/2] Add mq_timedsend() and mq_timedreceive() for Linux --- src/unix/linux_like/linux/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 3b7bc292..f2be2b4f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2294,10 +2294,20 @@ extern { msg_ptr: *mut ::c_char, msg_len: ::size_t, msq_prio: *mut ::c_uint) -> ::ssize_t; + pub fn mq_timedreceive(mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msq_prio: *mut ::c_uint, + abs_timeout: *const ::timespec) -> ::ssize_t; pub fn mq_send(mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msq_prio: ::c_uint) -> ::c_int; + pub fn mq_timedsend(mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msq_prio: ::c_uint, + abs_timeout: *const ::timespec) -> ::c_int; pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, From bbcfd3cce2754d13fbf824ed6db3efe7a1ae319f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Birch=20Moltu?= Date: Sun, 31 Mar 2019 23:25:46 +0200 Subject: [PATCH 2/2] Add posix message queue types and functions for solarish --- src/unix/solarish/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 49f76ea5..df20f560 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -31,6 +31,7 @@ pub type pthread_t = ::c_uint; pub type pthread_key_t = ::c_uint; pub type blksize_t = ::c_int; pub type nl_item = ::c_int; +pub type mqd_t = *mut ::c_void; pub type id_t = ::c_int; pub type idtype_t = ::c_uint; @@ -331,6 +332,14 @@ s! { pub if_name: *mut ::c_char, } + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + _pad: [::c_int; 4] + } + pub struct port_event { pub portev_events: ::c_int, pub portev_source: ::c_ushort, @@ -1937,6 +1946,31 @@ extern { pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mq_receive(mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msq_prio: *mut ::c_uint) -> ::ssize_t; + pub fn mq_timedreceive(mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msq_prio: *mut ::c_uint, + abs_timeout: *const ::timespec) -> ::ssize_t; + pub fn mq_send(mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msq_prio: ::c_uint) -> ::c_int; + pub fn mq_timedsend(mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msq_prio: ::c_uint, + abs_timeout: *const ::timespec) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_setattr(mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr) -> ::c_int; pub fn port_create() -> ::c_int; pub fn port_associate(port: ::c_int, source: ::c_int, object: ::uintptr_t, events: ::c_int, user: *mut ::c_void) -> ::c_int;