From a5ea6b096e9e9f9913ad860a847e3757580dd9e4 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 1 Dec 2022 10:13:57 +1000 Subject: clock millis, time: now use monotonic raw time if possible Instead of using all time, these commands now use a monotonically increasing system timer so that they are not affected by time (e.g. ntp) adjustments. (But not on Windows since it doesn't work reliably) Fixes #240 Signed-off-by: Steve Bennett --- jim.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'jim.h') diff --git a/jim.h b/jim.h index 07dfbeb..4162e5e 100644 --- a/jim.h +++ b/jim.h @@ -665,6 +665,16 @@ JIM_EXPORT char *Jim_StrDupLen(const char *s, int l); JIM_EXPORT char **Jim_GetEnviron(void); JIM_EXPORT void Jim_SetEnviron(char **env); JIM_EXPORT int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template, int unlink_file); +#ifndef CLOCK_REALTIME +# define CLOCK_REALTIME 0 +#endif +#ifndef CLOCK_MONOTONIC +# define CLOCK_MONOTONIC 1 +#endif +#ifndef CLOCK_MONOTONIC_RAW +# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC +#endif +JIM_EXPORT jim_wide Jim_GetTimeUsec(unsigned type); /* evaluation */ JIM_EXPORT int Jim_Eval(Jim_Interp *interp, const char *script); -- cgit v1.1