]> git.proxmox.com Git - wasi-libc.git/commit - Makefile
Emulate `clock`, `times`, and `getrusage` using the monotonic clock.
authorDan Gohman <dev@sunfishcode.online>
Mon, 22 Mar 2021 16:33:30 +0000 (09:33 -0700)
committerDan Gohman <dev@sunfishcode.online>
Tue, 23 Mar 2021 17:34:46 +0000 (10:34 -0700)
commitb9b64a695a35273f92574acc6270f0e059be3dca
tree9bffe9dbf3e9db02482f0ef0884b87ddac7b9f2e
parent322bd4ff9e4417356e3c5de5b514afd3aa851f65
Emulate `clock`, `times`, and `getrusage` using the monotonic clock.

Upcoming WASI snapshots omit the `PROCESS_CPUTIME` clock, since WASI has
no inherent concept of processes, and since implementations which don't
use a process for each instance don't have a way to implement it
efficiently.

However, `clock`, `times`, and `getrusage` are useful functions, so
provide optional emulated version of them, using the `MONOTONIC` clock.
This means these implementations will measure not just the program's
own CPU time, but also time spent suspended while other programs are
running.

Due to this difference in behavior, put these implementations behind
a flag. Users must pass `-D_WASI_EMULATED_PROCESS_CLOCK` and link with
`-lwasi-emulated-process-clocks` to enable them.
15 files changed:
Makefile
expected/wasm32-wasi/defined-symbols.txt
expected/wasm32-wasi/include-all.c
expected/wasm32-wasi/predefined-macros.txt
libc-bottom-half/clocks/clock.c [new file with mode: 0644]
libc-bottom-half/clocks/getrusage.c [new file with mode: 0644]
libc-bottom-half/clocks/times.c [new file with mode: 0644]
libc-bottom-half/cloudlibc/src/libc/sys/resource/getrusage.c [deleted file]
libc-bottom-half/cloudlibc/src/libc/sys/times/times.c [deleted file]
libc-bottom-half/cloudlibc/src/libc/time/clock.c [deleted file]
libc-top-half/musl/include/sys/param.h
libc-top-half/musl/include/sys/resource.h
libc-top-half/musl/include/sys/times.h
libc-top-half/musl/include/time.h
libc-top-half/musl/src/conf/sysconf.c