Skip to content

Commit baaaea3

Browse files
authored
Rollup merge of #63846 - DevQps:32626-document-time-system-calls, r=rkruppe
Added table containing the system calls used by Instant and SystemTime. # Description See #32626 for a discussion on documenting system calls used by Instant and SystemTime. ## Changes - Added a table containing the system calls used by each platform. EDIT: If I can format this table better (due to the large links) please let me know. I'd also be happy to learn a quick command to generate the docs on my host machine! Currently I am using: `python x.py doc --stage 0 src/libstd` but that gives me some `unrecognized intrinsic` errors. Advice is always welcome :) closes #32626
2 parents 4576668 + b3b6713 commit baaaea3

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/libstd/time.rs

+46
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,30 @@ pub use core::time::Duration;
5959
/// println!("{}", now.elapsed().as_secs());
6060
/// }
6161
/// ```
62+
///
63+
/// # Underlying System calls
64+
/// Currently, the following system calls are being used to get the current time using `now()`:
65+
///
66+
/// | Platform | System call |
67+
/// |:---------:|:--------------------------------------------------------------------:|
68+
/// | Cloud ABI | [clock_time_get (Monotonic Clock)] |
69+
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
70+
/// | UNIX | [clock_time_get (Monotonic Clock)] |
71+
/// | Darwin | [mach_absolute_time] |
72+
/// | VXWorks | [clock_gettime (Monotonic Clock)] |
73+
/// | WASI | [__wasi_clock_time_get (Monotonic Clock)] |
74+
/// | Windows | [QueryPerformanceCounter] |
75+
///
76+
/// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter
77+
/// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time
78+
/// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode
79+
/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get
80+
/// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime
81+
/// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html
82+
/// [clock_time_get (Monotonic Clock)]: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt
83+
///
84+
/// **Disclaimer:** These system calls might change over time.
85+
///
6286
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6387
#[stable(feature = "time2", since = "1.8.0")]
6488
pub struct Instant(time::Instant);
@@ -114,6 +138,28 @@ pub struct Instant(time::Instant);
114138
/// }
115139
/// }
116140
/// ```
141+
///
142+
/// # Underlying System calls
143+
/// Currently, the following system calls are being used to get the current time using `now()`:
144+
///
145+
/// | Platform | System call |
146+
/// |:---------:|:--------------------------------------------------------------------:|
147+
/// | Cloud ABI | [clock_time_get (Realtime Clock)] |
148+
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
149+
/// | UNIX | [clock_gettime (Realtime Clock)] |
150+
/// | DARWIN | [gettimeofday] |
151+
/// | VXWorks | [clock_gettime (Realtime Clock)] |
152+
/// | WASI | [__wasi_clock_time_get (Realtime Clock)] |
153+
/// | Windows | [GetSystemTimeAsFileTime] |
154+
///
155+
/// [clock_time_get (Realtime Clock)]: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt
156+
/// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html
157+
/// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime
158+
/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get
159+
/// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime
160+
///
161+
/// **Disclaimer:** These system calls might change over time.
162+
///
117163
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
118164
#[stable(feature = "time2", since = "1.8.0")]
119165
pub struct SystemTime(time::SystemTime);

0 commit comments

Comments
 (0)