From e2eb0a6e5e5c29803f9c11195faf0140e8d6e87d Mon Sep 17 00:00:00 2001 From: BaoshanPang <pangbw@gmail.com> Date: Wed, 15 Jan 2020 11:31:59 -0800 Subject: [PATCH] add functions for message queue --- libc-test/build.rs | 1 + src/vxworks/mod.rs | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c269d80d..47e0a647 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2006,6 +2006,7 @@ fn test_vxworks(target: &str) { "errno.h", "sys/mman.h", "pathLib.h", + "mqueue.h", } /* Fix me */ cfg.skip_const(move |name| match name { diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 0b90f66b..f0c11802 100755 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -100,6 +100,9 @@ pub type _Vx_ticks64_t = ::c_ulonglong; pub type sa_family_t = ::c_uchar; +// mqueue.h +pub type mqd_t = ::c_int; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum _Vx_semaphore {} impl ::Copy for _Vx_semaphore {} @@ -379,6 +382,13 @@ s! { pub dli_sname: *const ::c_char, pub dli_saddr: *mut ::c_void, } + + pub struct mq_attr { + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_flags: ::c_long, + pub mq_curmsgs: ::c_long, + } } s_no_extra_traits! { @@ -1972,6 +1982,43 @@ extern "C" { pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int; pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int; pub fn randSecure() -> c_int; + + // mqueue.h + 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, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_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, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_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; } //Dummy functions, these don't really exist in VxWorks. -- GitLab