1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-12 22:10:54 +01:00

53257: use monotonic clock where appropriate

update the following features to use the monotonic clock for calculating time
deltas and intervals:

* MAILCHECK parameter
* PERIOD parameter
* SECONDS parameter
* %(nS.t.f) prompt-expansion sequence
* time built-in's elapsed time and cpu % values
* zsh/zftp ZFTP_TMOUT parameter
* zsh/zprof timings

also use CLOCK_MONOTONIC_RAW instead of CLOCK_MONOTONIC on macOS
This commit is contained in:
dana 2024-12-26 09:36:45 -06:00
parent 7798fd88ac
commit 6bb792dba8
18 changed files with 225 additions and 92 deletions

View file

@ -1022,7 +1022,6 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
#ifdef USE_GETPWUID
struct passwd *pswd;
#endif
struct timezone dummy_tz;
char *ptr;
int i, j;
#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH) || defined(FIXED_FPATH_DIR)
@ -1109,8 +1108,8 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
hatchar = '^';
termflags = TERM_UNKNOWN;
curjob = prevjob = coprocin = coprocout = -1;
gettimeofday(&shtimer, &dummy_tz); /* init $SECONDS */
srand((unsigned int)(shtimer.tv_sec + shtimer.tv_usec)); /* seed $RANDOM */
zgettime_monotonic_if_available(&shtimer); /* init $SECONDS */
srand((unsigned int)(shtimer.tv_sec + shtimer.tv_nsec)); /* seed $RANDOM */
/* Set default path */
path = (char **) zalloc(sizeof(*path) * 5);
@ -1297,7 +1296,7 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
#endif
breaks = loops = 0;
lastmailcheck = time(NULL);
lastmailcheck = zmonotime(NULL);
locallevel = sourcelevel = 0;
sfcontext = SFC_NONE;
trap_return = 0;