Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24ec87a

Browse files
committed
uptime: make it compile on Android & Redox
1 parent3e3fa60 commit24ec87a

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

‎src/uu/uptime/src/uptime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use uucore::format_usage;
2020

2121
use uucore::locale::{get_message, get_message_with_args};
2222
#[cfg(unix)]
23-
#[cfg(not(target_os ="openbsd"))]
23+
#[cfg(not(any(target_os ="openbsd", target_os ="redox", target_os ="android")))]
2424
use uucore::utmpx::*;
2525

2626
pubmod options{
@@ -233,7 +233,7 @@ fn print_loadavg() {
233233
}
234234

235235
#[cfg(unix)]
236-
#[cfg(not(target_os ="openbsd"))]
236+
#[cfg(not(any(target_os ="openbsd", target_os ="redox", target_os ="android")))]
237237
fnprocess_utmpx(file:Option<&OsString>) ->(Option<time_t>,usize){
238238
letmut nusers =0;
239239
letmut boot_time =None;

‎src/uucore/src/lib/features/uptime.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ pub fn get_uptime(_boot_time: Option<time_t>) -> UResult<i64> {
8080
}
8181
}
8282

83+
// TODO implement functionality
84+
#[cfg(any(target_os ="android", target_os ="redox"))]
85+
pubfnget_uptime(_boot_time:Option<time_t>) ->UResult<i64>{
86+
Err(UptimeError::SystemUptime)?
87+
}
88+
8389
/// Get the system uptime
8490
///
8591
/// # Arguments
@@ -90,7 +96,7 @@ pub fn get_uptime(_boot_time: Option<time_t>) -> UResult<i64> {
9096
///
9197
/// Returns a UResult with the uptime in seconds if successful, otherwise an UptimeError.
9298
#[cfg(unix)]
93-
#[cfg(not(target_os ="openbsd"))]
99+
#[cfg(not(any(target_os ="openbsd", target_os ="android", target_os ="redox")))]
94100
pubfnget_uptime(boot_time:Option<time_t>) ->UResult<i64>{
95101
usecrate::utmpx::Utmpx;
96102
use libc::BOOT_TIME;
@@ -192,7 +198,7 @@ pub fn get_formatted_uptime(boot_time: Option<time_t>) -> UResult<String> {
192198
///
193199
/// Returns the number of users currently logged in if successful, otherwise 0.
194200
#[cfg(unix)]
195-
#[cfg(not(target_os ="openbsd"))]
201+
#[cfg(not(any(target_os ="openbsd", target_os ="android", target_os ="redox")))]
196202
// see: https://gitlab.com/procps-ng/procps/-/blob/4740a0efa79cade867cfc7b32955fe0f75bf5173/library/uptime.c#L63-L115
197203
pubfnget_nusers() ->usize{
198204
usecrate::utmpx::Utmpx;
@@ -239,6 +245,12 @@ pub fn get_nusers(file: &str) -> usize {
239245
nusers
240246
}
241247

248+
// TODO implement functionality
249+
#[cfg(any(target_os ="android", target_os ="redox"))]
250+
pubfnget_nusers() ->usize{
251+
0
252+
}
253+
242254
/// Get the number of users currently logged in
243255
///
244256
/// # Returns
@@ -337,6 +349,7 @@ pub fn get_formatted_nusers() -> String {
337349
/// Returns a UResult with the load average if successful, otherwise an UptimeError.
338350
/// The load average is a tuple of three floating point numbers representing the 1-minute, 5-minute, and 15-minute load averages.
339351
#[cfg(unix)]
352+
#[cfg(not(any(target_os ="android", target_os ="redox")))]
340353
pubfnget_loadavg() ->UResult<(f64,f64,f64)>{
341354
usecrate::libc::c_double;
342355
use libc::getloadavg;
@@ -352,6 +365,12 @@ pub fn get_loadavg() -> UResult<(f64, f64, f64)> {
352365
}
353366
}
354367

368+
// TODO implement functionality
369+
#[cfg(any(target_os ="android", target_os ="redox"))]
370+
pubfnget_loadavg() ->UResult<(f64,f64,f64)>{
371+
Err(UptimeError::SystemLoadavg)?
372+
}
373+
355374
/// Get the system load average
356375
/// Windows does not have an equivalent to the load average on Unix-like systems.
357376
///

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp