Skip to content

Haiku operating system support聽#51

Description

@kallisti5

If your operating system isn't yet supported, please, create an issue.

馃憖

error[E0412]: cannot find type `ThreadId` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:401:13
    |
401 |     pub id: ThreadId,
    |             ^^^^^^^^ not found in this scope
    |
help: consider importing this struct
    |
161 + use std::thread::ThreadId;
    |

error[E0412]: cannot find type `ThreadSchedulePolicy` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:510:20
    |
510 |     policy: Option<ThreadSchedulePolicy>,
    |                    ^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
504 | pub struct ThreadBuilder<ThreadSchedulePolicy> {
    |                         ++++++++++++++++++++++

error[E0425]: cannot find function `thread_native_id` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:607:17
    |
607 |                 thread_native_id(),
    |                 ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_thread_priority_and_policy` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:606:49
    |
606 |             (Some(priority), Some(policy)) => f(set_thread_priority_and_policy(
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_current_thread_priority` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:391:9
    |
391 |         set_current_thread_priority(self)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^------
    |         |
    |         help: try calling `set_current_thread_priority` as a method: `self.set_current_thread_priority()`

error[E0425]: cannot find function `get_current_thread_priority` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:416:23
    |
416 |             priority: get_current_thread_priority()?,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `thread_native_id` in this scope
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:417:17
    |
417 |             id: thread_native_id(),
    |                 ^^^^^^^^^^^^^^^^ not found in this scope

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unix`
   --> /boot/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/thread-priority-3.0.0/src/lib.rs:559:31
    |
559 |     pub fn policy<VALUE: Into<unix::ThreadSchedulePolicy>>(mut self, value: VALUE) -> Self {
    |                               ^^^^ use of unresolved module or unlinked crate `unix`
    |
    = help: if you wanted to use a crate named `unix`, use `cargo add unix` to add it to your `Cargo.toml`

Some errors have detailed explanations: E0412, E0425, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `thread-priority` (lib) due to 9 previous errors

Activity

  1. kallisti5 commented on Apr 3, 2026

    @kallisti5
    Author

    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 {
  2. iddm commented on Apr 3, 2026

    @iddm
    Owner

    馃憤
    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions