Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lovesegfault opened this issue Jul 25, 2018 · 0 comments
Open

Comments

@lovesegfault
Copy link

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].

@lovesegfault lovesegfault changed the title Calls to setpriority and getpriority has incorrect types Calls to setpriority and getpriority have incorrect types on macOS Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant