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

Commit3277839

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

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn get_formatted_time() -> String {
4949
/// # Returns
5050
///
5151
/// Returns a UResult with the uptime in seconds if successful, otherwise an UptimeError.
52-
#[cfg(target_os ="openbsd")]
52+
#[cfg(any(target_os ="openbsd", target_os ="android", target_os ="redox"))]
5353
pubfnget_uptime(_boot_time:Option<time_t>) ->UResult<i64>{
5454
use libc::CLOCK_BOOTTIME;
5555
use libc::clock_gettime;
@@ -88,7 +88,7 @@ pub fn get_uptime(_boot_time: Option<time_t>) -> UResult<i64> {
8888
///
8989
/// Returns a UResult with the uptime in seconds if successful, otherwise an UptimeError.
9090
#[cfg(unix)]
91-
#[cfg(not(target_os ="openbsd"))]
91+
#[cfg(not(any(target_os ="openbsd", target_os ="android", target_os ="redox")))]
9292
pubfnget_uptime(boot_time:Option<time_t>) ->UResult<i64>{
9393
usecrate::utmpx::Utmpx;
9494
use libc::BOOT_TIME;
@@ -187,7 +187,7 @@ pub fn get_formatted_uptime(boot_time: Option<time_t>) -> UResult<String> {
187187
///
188188
/// Returns the number of users currently logged in if successful, otherwise 0.
189189
#[cfg(unix)]
190-
#[cfg(not(target_os ="openbsd"))]
190+
#[cfg(not(any(target_os ="openbsd", target_os ="android", target_os ="redox")))]
191191
// see: https://gitlab.com/procps-ng/procps/-/blob/4740a0efa79cade867cfc7b32955fe0f75bf5173/library/uptime.c#L63-L115
192192
pubfnget_nusers() ->usize{
193193
usecrate::utmpx::Utmpx;
@@ -234,6 +234,12 @@ pub fn get_nusers(file: &str) -> usize {
234234
nusers
235235
}
236236

237+
// TODO implement functionality
238+
#[cfg(any(target_os ="android", target_os ="redox"))]
239+
pubfnget_nusers() ->usize{
240+
0
241+
}
242+
237243
/// Get the number of users currently logged in
238244
///
239245
/// # Returns
@@ -333,6 +339,7 @@ pub fn get_formatted_nusers() -> String {
333339
/// Returns a UResult with the load average if successful, otherwise an UptimeError.
334340
/// The load average is a tuple of three floating point numbers representing the 1-minute, 5-minute, and 15-minute load averages.
335341
#[cfg(unix)]
342+
#[cfg(not(any(target_os ="android", target_os ="redox")))]
336343
pubfnget_loadavg() ->UResult<(f64,f64,f64)>{
337344
usecrate::libc::c_double;
338345
use libc::getloadavg;
@@ -348,6 +355,12 @@ pub fn get_loadavg() -> UResult<(f64, f64, f64)> {
348355
}
349356
}
350357

358+
// TODO implement functionality
359+
#[cfg(any(target_os ="android", target_os ="redox"))]
360+
pubfnget_loadavg() ->UResult<(f64,f64,f64)>{
361+
Err(UptimeError::SystemLoadavg)?
362+
}
363+
351364
/// Get the system load average
352365
/// Windows does not have an equivalent to the load average on Unix-like systems.
353366
///

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp