@@ -39,23 +39,29 @@ use crate::sys::stat::Mode;
39
39
use std:: mem;
40
40
41
41
libc_bitflags ! {
42
+ /// Used with [`mq_open`].
42
43
pub struct MQ_OFlag : libc:: c_int {
44
+ /// Open the message queue for receiving messages.
43
45
O_RDONLY ;
46
+ /// Open the queue for sending messages.
44
47
O_WRONLY ;
48
+ /// Open the queue for both receiving and sending messages
45
49
O_RDWR ;
50
+ /// Create a message queue.
46
51
O_CREAT ;
52
+ /// If set along with `O_CREAT`, `mq_open` will fail if the message
53
+ /// queue name exists.
47
54
O_EXCL ;
55
+ /// `mq_send` and `mq_receive` should fail with `EAGAIN` rather than
56
+ /// wait for resources that are not currently available.
48
57
O_NONBLOCK ;
58
+ /// Set the close-on-exec flag for the message queue descriptor.
49
59
O_CLOEXEC ;
50
60
}
51
61
}
52
62
53
- libc_bitflags ! {
54
- pub struct FdFlag : libc:: c_int {
55
- FD_CLOEXEC ;
56
- }
57
- }
58
-
63
+ /// A message-queue attribute, optionally used with [`mq_setattr`] and
64
+ /// [`mq_getattr`] and optionally [`mq_open`],
59
65
#[ repr( C ) ]
60
66
#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
61
67
pub struct MqAttr {
@@ -72,14 +78,24 @@ pub struct MqdT(mqd_t);
72
78
73
79
// x32 compatibility
74
80
// See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
81
+ /// Size of a message queue attribute member
75
82
#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "32" ) ) ]
76
83
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
77
84
pub type mq_attr_member_t = i64 ;
85
+ /// Size of a message queue attribute member
78
86
#[ cfg( not( all( target_arch = "x86_64" , target_pointer_width = "32" ) ) ) ]
79
87
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
80
88
pub type mq_attr_member_t = libc:: c_long ;
81
89
82
90
impl MqAttr {
91
+ /// Create a new message queue attribute
92
+ ///
93
+ /// # Arguments
94
+ ///
95
+ /// - `mq_flags`: Either `0` or `O_NONBLOCK`.
96
+ /// - `mq_maxmsg`: Maximum number of messages on the queue.
97
+ /// - `mq_msgsize`: Maximum message size in bytes.
98
+ /// - `mq_curmsgs`: Number of messages currently in the queue.
83
99
pub fn new ( mq_flags : mq_attr_member_t ,
84
100
mq_maxmsg : mq_attr_member_t ,
85
101
mq_msgsize : mq_attr_member_t ,
@@ -97,6 +113,7 @@ impl MqAttr {
97
113
}
98
114
}
99
115
116
+ /// The current flags, either `0` or `O_NONBLOCK`.
100
117
pub const fn flags ( & self ) -> mq_attr_member_t {
101
118
self . mq_attr . mq_flags
102
119
}
0 commit comments