Skip to content

Commit 5837b5a

Browse files
committed
Adapt to RIOT-OS post-4c3e92f1 (the thread_state_t introduction)
1 parent 443ff99 commit 5837b5a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/thread.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,27 @@ mod status_converted {
2929
3030
use riot_sys as raw;
3131

32-
pub const STATUS_NOT_FOUND: i32 = raw::STATUS_NOT_FOUND as i32;
33-
pub const STATUS_STOPPED: i32 = raw::STATUS_STOPPED as i32;
34-
pub const STATUS_SLEEPING: i32 = raw::STATUS_SLEEPING as i32;
35-
pub const STATUS_MUTEX_BLOCKED: i32 = raw::STATUS_MUTEX_BLOCKED as i32;
36-
pub const STATUS_RECEIVE_BLOCKED: i32 = raw::STATUS_RECEIVE_BLOCKED as i32;
37-
pub const STATUS_SEND_BLOCKED: i32 = raw::STATUS_SEND_BLOCKED as i32;
38-
pub const STATUS_REPLY_BLOCKED: i32 = raw::STATUS_REPLY_BLOCKED as i32;
39-
pub const STATUS_FLAG_BLOCKED_ANY: i32 = raw::STATUS_FLAG_BLOCKED_ANY as i32;
40-
pub const STATUS_FLAG_BLOCKED_ALL: i32 = raw::STATUS_FLAG_BLOCKED_ALL as i32;
41-
pub const STATUS_MBOX_BLOCKED: i32 = raw::STATUS_MBOX_BLOCKED as i32;
42-
pub const STATUS_RUNNING: i32 = raw::STATUS_RUNNING as i32;
43-
pub const STATUS_PENDING: i32 = raw::STATUS_PENDING as i32;
32+
// STATUS_NOT_FOUND is not added here as it's not a proper status but rather a sentinel value,
33+
// which moreover can't be processed in its current form by bindgen and would need to be copied
34+
// over in here by manual expansion of the macro definition.
35+
pub const STATUS_STOPPED: i32 = raw::thread_state_t_STATUS_STOPPED as i32;
36+
pub const STATUS_SLEEPING: i32 = raw::thread_state_t_STATUS_SLEEPING as i32;
37+
pub const STATUS_MUTEX_BLOCKED: i32 = raw::thread_state_t_STATUS_MUTEX_BLOCKED as i32;
38+
pub const STATUS_RECEIVE_BLOCKED: i32 = raw::thread_state_t_STATUS_RECEIVE_BLOCKED as i32;
39+
pub const STATUS_SEND_BLOCKED: i32 = raw::thread_state_t_STATUS_SEND_BLOCKED as i32;
40+
pub const STATUS_REPLY_BLOCKED: i32 = raw::thread_state_t_STATUS_REPLY_BLOCKED as i32;
41+
pub const STATUS_FLAG_BLOCKED_ANY: i32 = raw::thread_state_t_STATUS_FLAG_BLOCKED_ANY as i32;
42+
pub const STATUS_FLAG_BLOCKED_ALL: i32 = raw::thread_state_t_STATUS_FLAG_BLOCKED_ALL as i32;
43+
pub const STATUS_MBOX_BLOCKED: i32 = raw::thread_state_t_STATUS_MBOX_BLOCKED as i32;
44+
pub const STATUS_RUNNING: i32 = raw::thread_state_t_STATUS_RUNNING as i32;
45+
pub const STATUS_PENDING: i32 = raw::thread_state_t_STATUS_PENDING as i32;
4446
}
4547

4648
#[derive(Debug)]
4749
pub enum Status {
4850
// I would not rely on any properties of the assigned values, but it might make the conversion
4951
// points easier on the generated code if it can be reasoned down to a simple check of whether
5052
// it's in range.
51-
NotFound = status_converted::STATUS_NOT_FOUND as isize,
5253
Stopped = status_converted::STATUS_STOPPED as isize,
5354
Sleeping = status_converted::STATUS_SLEEPING as isize,
5455
MutexBlocked = status_converted::STATUS_MUTEX_BLOCKED as isize,
@@ -79,7 +80,6 @@ impl Status {
7980

8081
fn from_int(status: i32) -> Self {
8182
match status {
82-
status_converted::STATUS_NOT_FOUND => Status::NotFound,
8383
status_converted::STATUS_STOPPED => Status::Stopped,
8484
status_converted::STATUS_SLEEPING => Status::Sleeping,
8585
status_converted::STATUS_MUTEX_BLOCKED => Status::MutexBlocked,

0 commit comments

Comments
 (0)