Skip to content

Commit 7acbb1f

Browse files
authored
Merge pull request #7 from AzureMarker/tweak/more-standard-thread-functions
Use more standard pthread functions
2 parents 4affb62 + acdce9e commit 7acbb1f

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

src/unix/newlib/horizon/mod.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ s! {
5151
pub sun_family: ::sa_family_t,
5252
pub sun_path: [::c_char; 104usize],
5353
}
54+
55+
pub struct sched_param {
56+
pub sched_priority: ::c_int,
57+
}
5458
}
5559

5660
pub const SIGEV_NONE: ::c_int = 1;
@@ -151,6 +155,10 @@ pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void;
151155
pub const GRND_NONBLOCK: ::c_uint = 0x1;
152156
pub const GRND_RANDOM: ::c_uint = 0x2;
153157

158+
// For pthread get/setschedparam
159+
pub const SCHED_FIFO: ::c_int = 1;
160+
pub const SCHED_RR: ::c_int = 2;
161+
154162
// Horizon OS works doesn't or can't hold any of this information
155163
safe_f! {
156164
pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool {
@@ -194,11 +202,39 @@ extern "C" {
194202
value: *mut ::c_void,
195203
) -> ::c_int;
196204

197-
pub fn pthread_attr_setpriority(attr: *mut ::pthread_attr_t, priority: ::c_int) -> ::c_int;
205+
pub fn pthread_attr_getschedparam(
206+
attr: *const ::pthread_attr_t,
207+
param: *mut sched_param,
208+
) -> ::c_int;
209+
210+
pub fn pthread_attr_setschedparam(
211+
attr: *mut ::pthread_attr_t,
212+
param: *const sched_param,
213+
) -> ::c_int;
214+
215+
pub fn pthread_attr_getidealprocessor_np(
216+
attr: *const ::pthread_attr_t,
217+
ideal_processor: *mut ::c_int,
218+
) -> ::c_int;
198219

199-
pub fn pthread_attr_setaffinity(attr: *mut ::pthread_attr_t, affinity: ::c_int) -> ::c_int;
220+
pub fn pthread_attr_setidealprocessor_np(
221+
attr: *mut ::pthread_attr_t,
222+
ideal_processor: ::c_int,
223+
) -> ::c_int;
200224

201-
pub fn pthread_getpriority() -> ::c_int;
225+
pub fn pthread_getschedparam(
226+
native: ::pthread_t,
227+
policy: *mut ::c_int,
228+
param: *mut ::sched_param,
229+
) -> ::c_int;
230+
231+
pub fn pthread_setschedparam(
232+
native: ::pthread_t,
233+
policy: ::c_int,
234+
param: *const ::sched_param,
235+
) -> ::c_int;
236+
237+
pub fn pthread_getprocessorid_np() -> ::c_int;
202238

203239
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
204240

0 commit comments

Comments
 (0)