This commit is contained in:
Jeremy Soller
2018-09-17 09:46:47 -06:00
parent f3a832ad12
commit 716ea87bb4
3 changed files with 39 additions and 35 deletions
+7 -6
View File
@@ -865,23 +865,24 @@ pub unsafe extern "C" fn getservent() -> *const servent {
let mut iter = r.split_whitespace();
let mut serv_name = match iter.next() {
Some(serv_name) => serv_name.as_bytes().to_vec(),
None => continue
None => continue,
};
serv_name.push(b'\0');
let port_proto = match iter.next() {
Some(port_proto) => port_proto,
None => continue
None => continue,
};
let mut split = port_proto.split("/");
let mut port = match split.next() {
Some(port) => port.as_bytes().to_vec(),
None => continue
None => continue,
};
port.push(b'\0');
SERV_PORT = Some(htons(atoi(port.as_mut_slice().as_mut_ptr() as *mut i8) as u16) as u32 as i32);
SERV_PORT =
Some(htons(atoi(port.as_mut_slice().as_mut_ptr() as *mut i8) as u16) as u32 as i32);
let mut proto = match split.next() {
Some(proto) => proto.as_bytes().to_vec(),
None => continue
None => continue,
};
proto.push(b'\0');
@@ -922,7 +923,7 @@ pub unsafe extern "C" fn getservent() -> *const servent {
if SERV_STAYOPEN == 0 {
endservent();
}
break &SERV_ENTRY as *const servent
break &SERV_ENTRY as *const servent;
}
}
+14 -11
View File
@@ -1,5 +1,5 @@
use core::{mem, ptr};
use core::sync::atomic::AtomicBool;
use core::{mem, ptr};
use header::errno;
use header::fcntl::*;
@@ -67,16 +67,19 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> {
if f.is_null() {
None
} else {
ptr::write(f, FILE {
flags: flags,
read: None,
write: None,
fd: fd,
buf: vec![0u8; BUFSIZ + UNGET],
buf_char: -1,
unget: UNGET,
lock: AtomicBool::new(false)
});
ptr::write(
f,
FILE {
flags: flags,
read: None,
write: None,
fd: fd,
buf: vec![0u8; BUFSIZ + UNGET],
buf_char: -1,
unget: UNGET,
lock: AtomicBool::new(false),
},
);
Some(f)
}
}
+18 -18
View File
@@ -50,24 +50,24 @@ pub extern "C" fn access(path: *const c_char, mode: c_int) -> c_int {
#[no_mangle]
pub extern "C" fn alarm(seconds: c_uint) -> c_uint {
// let mut timer = sys_time::itimerval {
// it_value: sys_time::timeval {
// tv_sec: seconds as time_t,
// tv_usec: 0,
// },
// ..Default::default()
// };
// let errno_backup = unsafe { platform::errno };
// let secs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
// 0
// } else {
// timer.it_value.tv_sec as c_uint + if timer.it_value.tv_usec > 0 { 1 } else { 0 }
// };
// unsafe {
// platform::errno = errno_backup;
// }
//
// secs
// let mut timer = sys_time::itimerval {
// it_value: sys_time::timeval {
// tv_sec: seconds as time_t,
// tv_usec: 0,
// },
// ..Default::default()
// };
// let errno_backup = unsafe { platform::errno };
// let secs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
// 0
// } else {
// timer.it_value.tv_sec as c_uint + if timer.it_value.tv_usec > 0 { 1 } else { 0 }
// };
// unsafe {
// platform::errno = errno_backup;
// }
//
// secs
0
}