Merge branch 'doc-locale-and-sched' into 'master'
Doc locale and sched See merge request redox-os/relibc!775
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
//! locale implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/locale.h.html
|
||||
//! `locale.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/locale.h.html>.
|
||||
|
||||
use core::ptr;
|
||||
|
||||
use crate::platform::types::*;
|
||||
use crate::platform::types::{c_char, c_int};
|
||||
|
||||
const EMPTY_PTR: *const c_char = "\0" as *const _ as *const c_char;
|
||||
// Can't use &str because of the mutability
|
||||
static mut C_LOCALE: [c_char; 2] = [b'C' as c_char, 0];
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/locale.h.html>.
|
||||
#[repr(C)]
|
||||
pub struct lconv {
|
||||
currency_symbol: *const c_char,
|
||||
@@ -54,11 +57,13 @@ static mut CURRENT_LOCALE: lconv = lconv {
|
||||
thousands_sep: EMPTY_PTR,
|
||||
};
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/localeconv.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn localeconv() -> *mut lconv {
|
||||
&raw mut CURRENT_LOCALE as *mut _
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/setlocale.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn setlocale(_option: c_int, _val: *const c_char) -> *mut c_char {
|
||||
// TODO actually implement
|
||||
|
||||
+24
-2
@@ -1,40 +1,60 @@
|
||||
//! sched.h implementation for Redox, following https://pubs.opengroup.org/onlinepubs/7908799/xsh/sched.h.html
|
||||
//! `sched.h` implementation.
|
||||
//!
|
||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sched.h.html>.
|
||||
|
||||
use crate::{
|
||||
error::ResultExt,
|
||||
header::time::timespec,
|
||||
platform::{Pal, Sys, types::*},
|
||||
platform::{
|
||||
Pal, Sys,
|
||||
types::{c_int, pid_t},
|
||||
},
|
||||
};
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sched.h.html>.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct sched_param {
|
||||
pub sched_priority: c_int,
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sched.h.html>.
|
||||
pub const SCHED_FIFO: c_int = 0;
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sched.h.html>.
|
||||
pub const SCHED_RR: c_int = 1;
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sched.h.html>.
|
||||
pub const SCHED_OTHER: c_int = 2;
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_get_priority_max.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn sched_get_priority_max(policy: c_int) -> c_int {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_get_priority_max.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn sched_get_priority_min(policy: c_int) -> c_int {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_getparam.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn sched_getparam(pid: pid_t, param: *mut sched_param) -> c_int {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_rr_get_interval.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn sched_rr_get_interval(pid: pid_t, time: *const timespec) -> c_int {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_setparam.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn sched_setparam(pid: pid_t, param: *const sched_param) -> c_int {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_setscheduler.html>.
|
||||
// #[unsafe(no_mangle)]
|
||||
pub extern "C" fn sched_setscheduler(
|
||||
pid: pid_t,
|
||||
@@ -43,6 +63,8 @@ pub extern "C" fn sched_setscheduler(
|
||||
) -> c_int {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sched_yield.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn sched_yield() -> c_int {
|
||||
Sys::sched_yield().map(|()| 0).or_minus_one_errno()
|
||||
|
||||
Reference in New Issue
Block a user