Skip to content
Snippets Groups Projects
Verified Commit 8a042a22 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Implement pread, add more poll constants

parent 869eb160
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,10 @@ use platform::{Pal, Sys};
pub const POLLIN: c_short = 0x001;
pub const POLLPRI: c_short = 0x002;
pub const POLLOUT: c_short = 0x004;
pub const POLLERR: c_short = 0x008;
pub const POLLHUP: c_short = 0x010;
pub const POLLNVAL: c_short = 0x020;
pub type nfds_t = c_ulong;
......
......@@ -387,9 +387,25 @@ pub unsafe extern "C" fn pipe(fildes: *mut c_int) -> c_int {
Sys::pipe(slice::from_raw_parts_mut(fildes, 2))
}
// #[no_mangle]
#[no_mangle]
pub extern "C" fn pread(fildes: c_int, buf: *mut c_void, nbyte: size_t, offset: off_t) -> ssize_t {
unimplemented!();
//TODO: better pread using system calls
let previous = lseek(fildes, offset, SEEK_SET);
if previous == -1 {
return -1;
}
let res = read(fildes, buf, nbyte);
if res < 0 {
return res;
}
if lseek(fildes, previous, SEEK_SET) == -1 {
return -1;
}
res
}
// #[no_mangle]
......
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