Repository navigation
Haiku operating system support聽#51
Copy link
Copy link
Open
Description
Activity
I spent a few minutes poking at adding Haiku support. Since threads on Haiku are a bit different, there may be some larger restructuring needed.
/Data/Code/thread-priority> git diff diff --git a/src/lib.rs b/src/lib.rs index 70e9a23..aedaaf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,6 +155,7 @@ target_os = "vxworks", target_os = "netbsd", target_os = "android", + target_os = "haiku", target_arch = "wasm32", ))] pub mod unix; @@ -172,6 +173,7 @@ use std::time::Duration; target_os = "vxworks", target_os = "netbsd", target_os = "android", + target_os = "haiku", target_arch = "wasm32", ))] pub use unix::*; diff --git a/src/unix.rs b/src/unix.rs index 3d11edd..eb32b2a 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -8,13 +8,16 @@ use std::convert::TryFrom; #[cfg(target_os = "android")] use libc::SCHED_NORMAL as SCHED_OTHER; -#[cfg(not(target_os = "android"))] +#[cfg(not(target_os = "android", target_os = "haiku"))] use libc::SCHED_OTHER; #[cfg(target_os = "vxworks")] use libc::SCHED_SPORADIC; #[cfg(any(target_os = "linux", target_os = "android"))] use libc::{SCHED_BATCH, SCHED_IDLE}; +#[cfg(not(target_os = "haiku"))] use libc::{SCHED_FIFO, SCHED_RR}; +#[cfg(any(target_os = "haiku"))] +use libs::{B_IDLE_PRIORITY, B_LOW_PRIORITY, B_NORMAL_PRIORITY, B_URGENT_PRIORITY, B_REAL_TIME_PRIORITY} use crate::{Error, ThreadPriority, ThreadPriorityValue}; use std::mem::MaybeUninit; @@ -53,6 +56,8 @@ fn errno() -> libc::c_int { *libc::__errno_location() } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] { *libc::__error() + } else if #[cfg(target_os = "haiku")] { + *libc::__errnop() } else if #[cfg(target_os = "vxworks")] { libc::errnoGet() } else { @@ -71,6 +76,8 @@ fn set_errno(number: libc::c_int) { *libc::__errno_location() = number; } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))] { *libc::__error() = number; + } else if #[cfg(target_os = "haiku")] { + *libc::__errnop() = number } else if #[cfg(target_os = "vxworks")] { let _ = libc::errnoSet(number); } else {
馃憤
Hi! Thank you for your contribution! :-)If you don't mind, I think you are already halfway to adding the support. Could you create a PR? I have no means of testing it, though. Will you also be able to give some hints on how to test it as easily as possible? Also, perhaps, in CI as well?
Metadata
Metadata
Assignees
Labels
No labels
馃憖