Closed Userzxcvbvnm closed 6 months ago
Using wasi-sdk it generates a warning:
foo.c:14:60: warning: format specifies type 'long' but the argument has type 'time_t' (aka 'long long') [-Wformat]
14 | printf("Current time: %ld seconds, %ld nanoseconds\n", ts.tv_sec, ts.tv_nsec);
| ~~~ ^~~~~~~~~
| %lld
which when fixed causes the program to print:
Enter function main
Enter function clock_time_get_00002_obtwo
Current time: 0 seconds, 571458 nanoseconds
which is the expected behavior of Wasmtime. The monotonic clock is relative to an arbitrary point and Wasmtime chooses instance creation as the relative point.
Test Case
The c program is as follows:
Steps to Reproduce
(1)compiler it into Wasm binaries by
./wasi-sdk-21.0/bin/clang --target=wasm32-unkown-wasi --sysroot=./wasi-sdk-21.0/share/wasi-sysroot test.c -o test.wasm
Expected Results
Print:
And this is what other Wasm runtimes print, including wasmer, wamr and wasmedge.
Actual Results
Print:
Versions and Environment
Wasmtime version or commit: 19.0.2
Operating system: Ubuntu 20.04
Architecture: amd64