nix
nix copied to clipboard
Add wrappers for some time-related syscalls
gettimeofday, ~clock_gettime~, ~clock_settime~, ~clock_getres~, nanosleep and clock_nanosleep seem to be supported by various *nixes (at least Linux and FreeBSD), but bindings are not included in this crate.
I'd be happy to open a PR adding these bindings.
Check again. https://github.com/nix-rust/nix/pull/1281 just added some of those.
Darn. I must have searched issues and not pull requests. Regardless, some are still not implemented (the original issue has been edited).
Why would you ever use gettimeofday in new code, instead of clock_gettime? And why would you ever need nanosleep instead of thread::sleep?
My use case is rather niche - I'm instrumenting syscalls, which is quite possibly the only reason to use the first two functions in new code. clock_nanosleep could use a clock other than CLOCK_MONATONIC, which is what std frequently uses (std uses plain nanosleep for thread::sleep).
Do you think it would be worthwhile to at least implement clock_nanosleep?
Do you think it would be worthwhile to at least implement
clock_nanosleep?
Yep.