Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/uu/uptime/src/uptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ pub mod options {
pub static PATH: &str = "path";
}

#[cfg(unix)]
use uucore::libc::getloadavg;

#[cfg(windows)]
extern "C" {
fn GetTickCount() -> uucore::libc::uint32_t;
}

#[derive(Debug, Error)]
pub enum UptimeError {
// io::Error wrapper
Expand Down Expand Up @@ -113,7 +107,6 @@ pub fn uu_app() -> Command {
)
}

#[cfg(unix)]
fn uptime_with_file(file_path: &OsString) -> UResult<()> {
// Uptime will print loadavg and time to stderr unless we encounter an extra operand.
let mut non_fatal_error = false;
Expand Down Expand Up @@ -235,7 +228,6 @@ fn default_uptime(matches: &ArgMatches) -> UResult<()> {
Ok(())
}

#[cfg(unix)]
fn print_loadavg() {
use uucore::libc::c_double;

Expand All @@ -256,13 +248,6 @@ fn print_loadavg() {
}
}

#[cfg(windows)]
fn print_loadavg() {
// XXX: currently this is a noop as Windows does not seem to have anything comparable to
// getloadavg()
}

#[cfg(unix)]
#[cfg(target_os = "openbsd")]
fn process_utmp_from_file(file: &str) -> usize {
let mut nusers = 0;
Expand All @@ -284,7 +269,6 @@ fn process_utmp_from_file(file: &str) -> usize {
nusers
}

#[cfg(unix)]
#[cfg(not(target_os = "openbsd"))]
fn process_utmpx() -> (Option<time_t>, usize) {
let mut nusers = 0;
Expand All @@ -305,7 +289,6 @@ fn process_utmpx() -> (Option<time_t>, usize) {
(boot_time, nusers)
}

#[cfg(unix)]
#[cfg(not(target_os = "openbsd"))]
fn process_utmpx_from_file(file: &OsString) -> (Option<time_t>, usize) {
let mut nusers = 0;
Expand All @@ -326,11 +309,6 @@ fn process_utmpx_from_file(file: &OsString) -> (Option<time_t>, usize) {
(boot_time, nusers)
}

#[cfg(windows)]
fn process_utmpx() -> (Option<time_t>, usize) {
(None, 0) // TODO: change 0 to number of users
}

fn print_nusers(nusers: usize) {
match nusers.cmp(&1) {
std::cmp::Ordering::Less => print!(" 0 users, "),
Expand All @@ -355,7 +333,6 @@ fn get_uptime_from_boot_time(boot_time: time_t) -> i64 {
now - boottime
}

#[cfg(unix)]
#[cfg(target_os = "openbsd")]
fn get_uptime() -> i64 {
use uucore::libc::clock_gettime;
Expand Down Expand Up @@ -385,7 +362,6 @@ fn get_uptime() -> i64 {
}
}

#[cfg(unix)]
#[cfg(not(target_os = "openbsd"))]
fn get_uptime(boot_time: Option<time_t>) -> i64 {
use std::fs::File;
Expand All @@ -412,11 +388,6 @@ fn get_uptime(boot_time: Option<time_t>) -> i64 {
})
}

#[cfg(windows)]
fn get_uptime(_boot_time: Option<time_t>) -> i64 {
unsafe { GetTickCount() as i64 }
}

fn print_uptime(upsecs: i64) {
let updays = upsecs / 86400;
let uphours = (upsecs - (updays * 86400)) / 3600;
Expand Down
Loading