diff --git a/src/header/netdb/mod.rs b/src/header/netdb/mod.rs index a7010eaef8..c0a41b96d4 100644 --- a/src/header/netdb/mod.rs +++ b/src/header/netdb/mod.rs @@ -1046,7 +1046,7 @@ pub unsafe extern "C" fn freeaddrinfo(res: *mut addrinfo) { } else if bai.ai_addrlen == mem::size_of::() as socklen_t { unsafe { Box::from_raw(bai.ai_addr as *mut sockaddr_in6) }; } else { - eprintln!("freeaddrinfo: unknown ai_addrlen {}", bai.ai_addrlen); + todo_skip!(0, "freeaddrinfo: unknown ai_addrlen {}", bai.ai_addrlen); } } ai = bai.ai_next; diff --git a/src/header/pthread/cond.rs b/src/header/pthread/cond.rs index ab08b6cca5..49467238da 100644 --- a/src/header/pthread/cond.rs +++ b/src/header/pthread/cond.rs @@ -29,7 +29,7 @@ pub unsafe extern "C" fn pthread_cond_init( if attr.clock != CLOCK_REALTIME { // As monotonic clock always smaller than realtime clock, this always result in instant timeout. - println!("TODO: pthread_cond_init with monotonic clock"); + todo_skip!(0, "pthread_cond_init with monotonic clock"); } unsafe { cond.cast::().write(RlctCond::new()) }; diff --git a/src/header/sgtty/mod.rs b/src/header/sgtty/mod.rs index 7d5890468a..7d63a33a94 100644 --- a/src/header/sgtty/mod.rs +++ b/src/header/sgtty/mod.rs @@ -4,6 +4,6 @@ use crate::{header::sys_ioctl::sgttyb, platform::types::c_int}; #[unsafe(no_mangle)] pub extern "C" fn gtty(fd: c_int, out: *mut sgttyb) -> c_int { - eprintln!("unimplemented: gtty({}, {:p})", fd, out); + todo_skip!(0, "gtty({}, {:p})", fd, out); -1 } diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index 0f04dee481..9ffc6fbb70 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -542,7 +542,7 @@ pub unsafe extern "C" fn fileno(stream: *mut FILE) -> c_int { #[unsafe(no_mangle)] pub unsafe extern "C" fn flockfile(file: *mut FILE) { if let Err(e) = unsafe { (*file).lock.lock() } { - println!("RELIBC: flockfile error {}", e) + todo_error!(0, e, "flockfile error") } } @@ -819,7 +819,7 @@ pub unsafe extern "C" fn ftrylockfile(file: *mut FILE) -> c_int { #[unsafe(no_mangle)] pub unsafe extern "C" fn funlockfile(file: *mut FILE) { if let Err(e) = unsafe { (*file).lock.unlock() } { - println!("RELIBC: funlockfile error {}", e) + todo_error!(0, e, "RELIBC: funlockfile error") } } diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index 9633d03de1..f6698fe7da 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -116,7 +116,7 @@ pub unsafe extern "C" fn a64l(s: *const c_char) -> c_long { /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn abort() -> ! { - eprintln!("Abort"); + log::error!("Abort"); intrinsics::abort(); } diff --git a/src/header/sys_ioctl/redox/drm.rs b/src/header/sys_ioctl/redox/drm.rs index eab2f428a0..ff47ccb814 100644 --- a/src/header/sys_ioctl/redox/drm.rs +++ b/src/header/sys_ioctl/redox/drm.rs @@ -115,7 +115,13 @@ pub(super) unsafe fn ioctl(fd: c_int, func: u8, buf: IoctlBuffer) -> Result unsafe { dev.read_write_ioctl::(buf, MODE_GET_FB2) }, _ => { - eprintln!("unimplemented DRM ioctl({}, 0x{:02x}, {:?})", fd, func, buf); + todo_skip!( + 0, + "unimplemented DRM ioctl({}, 0x{:02x}, {:?})", + fd, + func, + buf + ); Err(Errno(EINVAL)) } } diff --git a/src/header/sys_ioctl/redox/mod.rs b/src/header/sys_ioctl/redox/mod.rs index bfcdb1efdd..d7924b4108 100644 --- a/src/header/sys_ioctl/redox/mod.rs +++ b/src/header/sys_ioctl/redox/mod.rs @@ -135,7 +135,7 @@ unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Result { - eprintln!("TODO: ioctl TIOCSCTTY"); + todo_skip!(0, "ioctl TIOCSCTTY"); } TIOCGPGRP => { let pgrp = unsafe { &mut *(out as *mut pid_t) }; @@ -154,19 +154,19 @@ unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Result { - eprintln!("TODO: ioctl TIOCGPTLCK"); + todo_skip!(0, "ioctl TIOCGPTLCK"); } TIOCSPTLCK => { - eprintln!("TODO: ioctl TIOCSPTLCK"); + todo_skip!(0, "ioctl TIOCSPTLCK"); } TCSBRK => { - eprintln!("TODO: ioctl TCSBRK"); + todo_skip!(0, "ioctl TCSBRK"); } TCXONC => { - eprintln!("TODO: ioctl TCXONC"); + todo_skip!(0, "ioctl TCXONC"); } SIOCATMARK => { - eprintln!("TODO: ioctl SIOCATMARK"); + todo_skip!(0, "ioctl SIOCATMARK"); } _ => { // See https://docs.kernel.org/userspace-api/ioctl/ioctl-decoding.html for details diff --git a/src/header/wchar/mod.rs b/src/header/wchar/mod.rs index c13079b7c8..04217e88ff 100644 --- a/src/header/wchar/mod.rs +++ b/src/header/wchar/mod.rs @@ -409,7 +409,7 @@ pub unsafe extern "C" fn vswprintf( ) -> c_int { //TODO: implement vswprintf. This is not as simple as wprintf, since the output is not UTF-8 // but instead is a wchar array. - eprintln!("vswprintf not implemented"); + todo_skip!(0, "vswprintf not implemented"); -1 } diff --git a/src/macros.rs b/src/macros.rs index 4885401138..5f2d0429d2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -57,9 +57,9 @@ macro_rules! todo_skip { // Recoverable error todo!(issue, fmt, err) #[macro_export] macro_rules! todo_error { - ($issue:expr, $($arg:tt)*, $err:expr) => { + ($issue:expr, $err:expr, $($arg:tt)*) => { if $issue != 0 { - log::error!("TODO ({}{}): {}: {:?}", crate::macros::ISSUE_URL, $issue, format_args!($($arg)*), $err) + log::error!("TODO ({}{}): {}: {}", crate::macros::ISSUE_URL, $issue, format_args!($($arg)*), $err) } else { log::error!("TODO: {}: {:?}", format_args!($($arg)*), $err) } diff --git a/src/platform/logger.rs b/src/platform/logger.rs index 5f6f689890..413e989c93 100644 --- a/src/platform/logger.rs +++ b/src/platform/logger.rs @@ -36,8 +36,8 @@ pub unsafe fn init() { #[cfg(feature = "no_trace")] if trace_warn { - log::error!( - "the 'no_trace' feature is enabled but LOG_LEVEL=TRACE, there will be no trace logs" + log::warn!( + "The 'no_trace' feature is enabled but RELIBC_LOG_LEVEL=TRACE, there will be no trace logs" ); } } diff --git a/src/platform/redox/epoll.rs b/src/platform/redox/epoll.rs index 4a1b706950..f552362648 100644 --- a/src/platform/redox/epoll.rs +++ b/src/platform/redox/epoll.rs @@ -27,12 +27,11 @@ fn epoll_to_event_flags(epoll: c_uint) -> syscall::EventFlags { event_flags |= syscall::EventFlags::EVENT_WRITE; } - /*TODO: support more EPOLL flags + /*TODO: support more EPOLL flags */ let unsupported = !(EPOLLIN | EPOLLOUT); if epoll & unsupported != 0 { - eprintln!("epoll unsupported flags 0x{:X}", epoll & unsupported); + log::trace!("epoll unsupported flags 0x{:X}", epoll & unsupported); } - */ event_flags } diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 7003047142..02a46a0d40 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -218,11 +218,7 @@ impl Pal for Sys { } unsafe fn clock_settime(clk_id: clockid_t, tp: *const timespec) -> Result<()> { - // TODO - eprintln!( - "relibc clock_settime({}, {:p}): not implemented", - clk_id, tp - ); + todo_skip!(0, "clock_settime({}, {:p}): not implemented", clk_id, tp); Err(Errno(ENOSYS)) } @@ -511,11 +507,7 @@ impl Pal for Sys { fn getgroups(list: Out<[gid_t]>) -> Result { // TODO - eprintln!( - "relibc getgroups({}, {:p}): not implemented", - list.len(), - list - ); + todo_skip!(0, "getgroups({}, {:p}): not implemented", list.len(), list); Err(Errno(ENOSYS)) } @@ -536,8 +528,7 @@ impl Pal for Sys { } fn getpriority(which: c_int, who: id_t) -> Result { - // TODO - eprintln!("getpriority({}, {}): not implemented", which, who); + todo_skip!(0, "getpriority({}, {}): not implemented", which, who); Err(Errno(ENOSYS)) } @@ -599,11 +590,7 @@ impl Pal for Sys { } fn getrlimit(resource: c_int, mut rlim: Out) -> Result<()> { - //TODO - eprintln!( - "relibc getrlimit({}, {:p}): not implemented", - resource, rlim - ); + todo_skip!(0, "getrlimit({}, {:p}): not implemented", resource, rlim); rlim.write(rlimit { rlim_cur: RLIM_INFINITY, rlim_max: RLIM_INFINITY, @@ -612,17 +599,12 @@ impl Pal for Sys { } unsafe fn setrlimit(resource: c_int, rlim: *const rlimit) -> Result<()> { - // TODO - eprintln!( - "relibc setrlimit({}, {:p}): not implemented", - resource, rlim - ); + todo_skip!(0, "setrlimit({}, {:p}): not implemented", resource, rlim); Err(Errno(EPERM)) } fn getrusage(who: c_int, r_usage: Out) -> Result<()> { - //TODO - eprintln!("relibc getrusage({}, {:p}): not implemented", who, r_usage); + todo_skip!(0, "getrusage({}, {:p}): not implemented", who, r_usage); Ok(()) } @@ -825,9 +807,12 @@ impl Pal for Sys { } unsafe fn msync(addr: *mut c_void, len: usize, flags: c_int) -> Result<()> { - eprintln!( - "relibc msync({:p}, 0x{:x}, 0x{:x}): not implemented", - addr, len, flags + todo_skip!( + 0, + "msync({:p}, 0x{:x}, 0x{:x}): not implemented", + addr, + len, + flags ); Err(Errno(ENOSYS)) /* TODO @@ -862,9 +847,12 @@ impl Pal for Sys { } unsafe fn madvise(addr: *mut c_void, len: usize, flags: c_int) -> Result<()> { - eprintln!( - "relibc madvise({:p}, 0x{:x}, 0x{:x}): not implemented", - addr, len, flags + todo_skip!( + 0, + "madvise({:p}, 0x{:x}, 0x{:x}): not implemented", + addr, + len, + flags ); Err(Errno(ENOSYS)) } @@ -1112,7 +1100,7 @@ impl Pal for Sys { unsafe fn setgroups(size: size_t, list: *const gid_t) -> Result<()> { // TODO - eprintln!("relibc setgroups({}, {:p}): not implemented", size, list); + todo_skip!(0, "setgroups({}, {:p}): not implemented", size, list); Err(Errno(ENOSYS)) } @@ -1123,9 +1111,12 @@ impl Pal for Sys { fn setpriority(which: c_int, who: id_t, prio: c_int) -> Result<()> { // TODO - eprintln!( - "relibc setpriority({}, {}, {}): not implemented", - which, who, prio + todo_skip!( + 0, + "setpriority({}, {}, {}): not implemented", + which, + who, + prio ); Err(Errno(ENOSYS)) } diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index b0ff66b74d..2854d283d9 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -105,7 +105,7 @@ impl PalSignal for Sys { // TODO: setitimer is no longer part of POSIX and should not be implemented in Redox // Change the platform-independent implementation to use POSIX timers. // For Redox, the timer should probably use "/scheme/time" - eprintln!("relibc: setitimer not implemented"); + todo_skip!(0, "setitimer not implemented"); Err(Errno(ENOSYS)) } diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index 670980f3db..aa47416f65 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -67,7 +67,7 @@ unsafe fn bind_or_connect( } } AF_UNIX => { - eprintln!("bind/connect with AF_UNIX were replaced with SYS_CALL."); + log::warn!("bind/connect with AF_UNIX were replaced with SYS_CALL."); return Err(Errno(EAFNOSUPPORT)); } _ => return Err(Errno(EAFNOSUPPORT)), @@ -576,9 +576,10 @@ impl PalSocket for Sys { CallFlags::empty(), &[SocketCall::Unbind as u64], ) { - eprintln!( - "bind: CRITICAL: failed to unbind socket after a failed transaction: {:?}", - unbind_error + todo_error!( + 0, + unbind_error, + "bind: CRITICAL: failed to unbind socket after a failed transaction" ); } @@ -745,9 +746,14 @@ impl PalSocket for Sys { _ => (), } - eprintln!( + todo_skip!( + 0, "getsockopt({}, {}, {}, {:p}, {:p})", - socket, level, option_name, option_value, option_len_ptr + socket, + level, + option_name, + option_value, + option_len_ptr ); Err(Errno(ENOSYS)) } @@ -1042,9 +1048,14 @@ impl PalSocket for Sys { _ => (), } - eprintln!( + todo_skip!( + 0, "setsockopt({}, {}, {}, {:p}, {}) - unknown option", - socket, level, option_name, option_value, option_len + socket, + level, + option_name, + option_value, + option_len ); Ok(()) } @@ -1113,7 +1124,8 @@ impl PalSocket for Sys { Ok(()) } _ => unsafe { - eprintln!( + todo_skip!( + 0, "socketpair({}, {}, {}, {:p})", domain, kind, diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 8681145c7d..4a1ffc8498 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -109,8 +109,8 @@ pub unsafe fn futex_wait_ptr( Ok(()) | Err(Errno(EINTR)) => FutexWaitResult::Waited, Err(Errno(EAGAIN)) => FutexWaitResult::Stale, Err(Errno(ETIMEDOUT)) if deadline_opt.is_some() => FutexWaitResult::TimedOut, - Err(other) => { - eprintln!("futex failed: {}", other.0); + Err(err) => { + todo_error!(0, err, "futex failed"); FutexWaitResult::Waited } } diff --git a/src/sync/pthread_mutex.rs b/src/sync/pthread_mutex.rs index c616905b2f..f6482e3f38 100644 --- a/src/sync/pthread_mutex.rs +++ b/src/sync/pthread_mutex.rs @@ -62,15 +62,15 @@ impl RlctMutex { }) } pub fn prioceiling(&self) -> Result { - println!("TODO: Implement pthread_getprioceiling"); + todo_skip!(0, "pthread_getprioceiling: not implemented"); Ok(0) } pub fn replace_prioceiling(&self, _: c_int) -> Result { - println!("TODO: Implement pthread_setprioceiling"); + todo_skip!(0, "pthread_setprioceiling: not implemented"); Ok(0) } pub fn make_consistent(&self) -> Result<(), Errno> { - println!("TODO: Implement robust mutexes"); + todo_skip!(0, "pthread robust mutexes: not implemented"); Ok(()) } fn lock_inner(&self, deadline: Option<×pec>) -> Result<(), Errno> {