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

Commitca0c6b3

Browse files
committed
uptime: make it compile on Android & Redox
1 parentd642e6c commitca0c6b3

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

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

81+
// TODO implement functionality
82+
#[cfg(any(target_os ="android", target_os ="redox"))]
83+
pubfnget_uptime(_boot_time:Option<time_t>) ->UResult<i64>{
84+
Err(UptimeError::SystemUptime)?
85+
}
86+
8187
/// Get the system uptime
8288
///
8389
/// # Arguments
@@ -88,7 +94,7 @@ pub fn get_uptime(_boot_time: Option<time_t>) -> UResult<i64> {
8894
///
8995
/// Returns a UResult with the uptime in seconds if successful, otherwise an UptimeError.
9096
#[cfg(unix)]
91-
#[cfg(not(target_os ="openbsd"))]
97+
#[cfg(not(any(target_os ="openbsd", target_os ="android", target_os ="redox")))]
9298
pubfnget_uptime(boot_time:Option<time_t>) ->UResult<i64>{
9399
usecrate::utmpx::Utmpx;
94100
use libc::BOOT_TIME;
@@ -187,7 +193,7 @@ pub fn get_formatted_uptime(boot_time: Option<time_t>) -> UResult<String> {
187193
///
188194
/// Returns the number of users currently logged in if successful, otherwise 0.
189195
#[cfg(unix)]
190-
#[cfg(not(target_os ="openbsd"))]
196+
#[cfg(not(any(target_os ="openbsd", target_os ="android", target_os ="redox")))]
191197
// see: https://gitlab.com/procps-ng/procps/-/blob/4740a0efa79cade867cfc7b32955fe0f75bf5173/library/uptime.c#L63-L115
192198
pubfnget_nusers() ->usize{
193199
usecrate::utmpx::Utmpx;
@@ -234,6 +240,12 @@ pub fn get_nusers(file: &str) -> usize {
234240
nusers
235241
}
236242

243+
// TODO implement functionality
244+
#[cfg(any(target_os ="android", target_os ="redox"))]
245+
pubfnget_nusers() ->usize{
246+
0
247+
}
248+
237249
/// Get the number of users currently logged in
238250
///
239251
/// # Returns
@@ -333,6 +345,7 @@ pub fn get_formatted_nusers() -> String {
333345
/// Returns a UResult with the load average if successful, otherwise an UptimeError.
334346
/// The load average is a tuple of three floating point numbers representing the 1-minute, 5-minute, and 15-minute load averages.
335347
#[cfg(unix)]
348+
#[cfg(not(any(target_os ="android", target_os ="redox")))]
336349
pubfnget_loadavg() ->UResult<(f64,f64,f64)>{
337350
usecrate::libc::c_double;
338351
use libc::getloadavg;
@@ -348,6 +361,12 @@ pub fn get_loadavg() -> UResult<(f64, f64, f64)> {
348361
}
349362
}
350363

364+
// TODO implement functionality
365+
#[cfg(any(target_os ="android", target_os ="redox"))]
366+
pubfnget_loadavg() ->UResult<(f64,f64,f64)>{
367+
Err(UptimeError::SystemLoadavg)?
368+
}
369+
351370
/// Get the system load average
352371
/// Windows does not have an equivalent to the load average on Unix-like systems.
353372
///

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp