mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Make important improvements
- Fix preadv() and pwritev() for old distros - Introduce _npassert() and _unassert() macros - Prove that file locks work properly on Windows - Support fcntl(F_DUPFD_CLOEXEC) on more systems
This commit is contained in:
parent
1ad2f530f9
commit
3f49889841
130 changed files with 1225 additions and 431 deletions
56
examples/clock_getres.c
Normal file
56
examples/clock_getres.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
|
||||
int n;
|
||||
int shown[64];
|
||||
|
||||
void show(int clock) {
|
||||
int i;
|
||||
struct timespec ts;
|
||||
if (clock == 127) return;
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (shown[i] == clock) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
shown[n++] = clock;
|
||||
if (clock_getres(clock, &ts) != -1) {
|
||||
kprintf("%s %'ld ns\n", DescribeClockName(clock), _timespec_tonanos(ts));
|
||||
} else {
|
||||
kprintf("%s %s\n", DescribeClockName(clock), _strerrno(errno));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
show(CLOCK_REALTIME);
|
||||
show(CLOCK_REALTIME_FAST);
|
||||
show(CLOCK_REALTIME_PRECISE);
|
||||
show(CLOCK_MONOTONIC);
|
||||
show(CLOCK_MONOTONIC_RAW);
|
||||
show(CLOCK_MONOTONIC_FAST);
|
||||
show(CLOCK_MONOTONIC_PRECISE);
|
||||
show(CLOCK_PROCESS_CPUTIME_ID);
|
||||
show(CLOCK_THREAD_CPUTIME_ID);
|
||||
show(CLOCK_PROF);
|
||||
show(CLOCK_BOOTTIME);
|
||||
show(CLOCK_REALTIME_ALARM);
|
||||
show(CLOCK_BOOTTIME_ALARM);
|
||||
show(CLOCK_TAI);
|
||||
show(CLOCK_UPTIME);
|
||||
show(CLOCK_UPTIME_PRECISE);
|
||||
show(CLOCK_UPTIME_FAST);
|
||||
show(CLOCK_SECOND);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue