nix icon indicating copy to clipboard operation
nix copied to clipboard

Add wrappers for some time-related syscalls

Open maxbla opened this issue 5 years ago • 5 comments
trafficstars

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.

maxbla avatar Sep 24 '20 06:09 maxbla

Check again. https://github.com/nix-rust/nix/pull/1281 just added some of those.

asomers avatar Oct 03 '20 16:10 asomers

Darn. I must have searched issues and not pull requests. Regardless, some are still not implemented (the original issue has been edited).

maxbla avatar Oct 03 '20 20:10 maxbla

Why would you ever use gettimeofday in new code, instead of clock_gettime? And why would you ever need nanosleep instead of thread::sleep?

asomers avatar Oct 10 '20 19:10 asomers

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?

maxbla avatar Oct 10 '20 21:10 maxbla

Do you think it would be worthwhile to at least implement clock_nanosleep?

Yep.

asomers avatar Oct 10 '20 21:10 asomers