Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
time_now_ms.c
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2025 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
17
18#include <stdint.h>
19#include <time.h>
20
22 int64_t ms;
23#if defined(CLOCK_REALTIME) && !defined(_WIN32)
24 struct timespec ts;
25 if (clock_gettime(CLOCK_REALTIME, &ts) == 0) {
26 ms = (int64_t)ts.tv_sec * 1000 + (int64_t)(ts.tv_nsec / 1000000);
27 } else {
28 time_t s = time(NULL);
29 ms = (int64_t)s * 1000;
30 }
31#else
32 time_t s = time(NULL);
33 ms = (int64_t)s * 1000;
34#endif
36 break;
37}
@ OP_TIME_NOW_MS
Definition bytecode.h:144
uint32_t s
Definition rol.c:31
push_value(vm, make_int(ms))
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Definition value.c:51