Skip to content

Calls to setpriority and getpriority have incorrect types on macOS #7

@lovesegfault

Description

@lovesegfault

When trying to compile on the latest nightly (or stable) on macOS with the latest libc I get the following errors

   Compiling scheduler v0.1.3 (file:///Users/bemeurer/src/rust-scheduler)
error[E0308]: mismatched types
  --> src/resource.rs:30:32
   |
30 |     match unsafe { setpriority(c_which as u32, who as id_t, priority) } {
   |                                ^^^^^^^^^^^^^^ expected i32, found u32
error[E0308]: mismatched types
  --> src/resource.rs:50:41
   |
50 |     let priority = unsafe { getpriority(c_which as u32, who as id_t) };
   |                                         ^^^^^^^^^^^^^^ expected i32, found u32
error: aborting due to 2 previous errors

Looking at the libc docs for both setpriority() and getpriority() we find that they both take an __priority_which_t, which is an alias to c_uint, which in turn is an alias to u32. All this indicates that the current calls are correct, and in that line the project compiles fine on Linux; just not on macOS, which seemingly expects an i32 there.

The only fix I can think of is conditional compilation through #[cfg].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions