Skip to content
Snippets Groups Projects
Verified Commit 7bcfa9cf authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Fix Linux.

parent d1da8679
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,8 @@ macro_rules! assert_equal_size(
let a = [0_u8; core::mem::align_of::<$export>()];
let b: [u8; core::mem::align_of::<Wrapped>()] = core::mem::transmute(a);
};
#[cfg(feature = "check_against_libc_crate")]
// TODO: Turn into a macro?
#[cfg(all(target_os = "redox", feature = "check_against_libc_crate"))]
const _: () = unsafe {
let export = $export { __relibc_internal_align: 0 };
let _: libc::$export = core::mem::transmute(export.__relibc_internal_size);
......
......@@ -49,8 +49,11 @@ struct linux_statfs {
f_spare: [c_long; 4],
}
// TODO
const ERRNO_MAX: usize = 4095;
pub fn e_raw(sys: usize) -> Result<usize, usize> {
if (sys as isize) < 0 && (sys as isize) >= -256 {
if sys > ERRNO_MAX.wrapping_neg() {
Err(sys.wrapping_neg())
} else {
Ok(sys)
......@@ -61,7 +64,7 @@ pub fn e(sys: usize) -> usize {
Ok(value) => value,
Err(errcode) => {
unsafe {
errno = errcode;
errno = errcode as c_int;
}
!0
}
......@@ -140,6 +143,10 @@ impl Pal for Sys {
}
loop {}
}
fn exit_thread() -> ! {
// TODO
Self::exit(0)
}
fn fchdir(fildes: c_int) -> c_int {
e(unsafe { syscall!(FCHDIR, fildes) }) as c_int
......@@ -220,7 +227,7 @@ impl Pal for Sys {
}
fn futex(addr: *mut c_int, op: c_int, val: c_int, val2: usize) -> Result<c_long, crate::pthread::Errno> {
e_raw(unsafe { syscall!(FUTEX, addr, op, val, val2, 0, 0)}).map(|r| r as c_long).map_err(|e| Errno(e as c_int))
e_raw(unsafe { syscall!(FUTEX, addr, op, val, val2, 0, 0)}).map(|r| r as c_long).map_err(|e| crate::pthread::Errno(e as c_int))
}
fn futimens(fd: c_int, times: *const timespec) -> c_int {
......@@ -437,13 +444,13 @@ impl Pal for Sys {
out("r14") _,
out("r15") _,
);
let tid = e_raw(pid)?;
let tid = e_raw(pid).map_err(|err| crate::pthread::Errno(err as c_int))?;
Ok(crate::pthread::OsTid { thread_id: tid })
}
unsafe fn rlct_kill(os_tid: crate::pthread::OsTid, signal: usize) -> Result<(), crate::pthread::Errno> {
let tgid = Self::getpid();
e_raw(unsafe { syscall!(TGKILL, pid, os_tid.thread_id, signal) })
e_raw(unsafe { syscall!(TGKILL, tgid, os_tid.thread_id, signal) }).map(|_| ()).map_err(|err| crate::pthread::Errno(err as c_int))
}
fn current_os_tid() -> crate::pthread::OsTid {
crate::pthread::OsTid {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment