diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-10 18:42:25 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-10 18:43:46 -0700 |
commit | b021c53fd4dc009a144db2312d195dd925f0e6fd (patch) | |
tree | 4c5a792eecbcf3adfc6fb237bee27451b3b857fe /lib/stat-time.h | |
parent | 8b55a44258e3a217dec66acb8398e7d00059de4b (diff) | |
download | gnulib-b021c53fd4dc009a144db2312d195dd925f0e6fd.tar.gz |
timespec: fix resolution confusion
In normal usage, clock resolution is given in seconds, but the
code was mistakenly using inverse seconds and calling it
“resolution”. Fix this, partly by renaming two identifiers.
The old names will be kept for a bit, to ease transition.
* lib/timespec.h (TIMESPEC_HZ, LOG10_TIMESPEC_HZ):
New constants, replacing TIMESPEC_RESOLUTION and
LOG10_TIMESPEC_RESOLUTION, which are now obsolescent.
All uses changed.
Diffstat (limited to 'lib/stat-time.h')
-rw-r--r-- | lib/stat-time.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/stat-time.h b/lib/stat-time.h index 8e787bd3b2..69ebe85df1 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -213,7 +213,7 @@ stat_time_normalize (int result, struct stat *st _GL_UNUSED) #if defined __sun && defined STAT_TIMESPEC if (result == 0) { - long int timespec_resolution = 1000000000; + long int timespec_hz = 1000000000; short int const ts_off[] = { offsetof (struct stat, st_atim), offsetof (struct stat, st_mtim), offsetof (struct stat, st_ctim) }; @@ -221,11 +221,11 @@ stat_time_normalize (int result, struct stat *st _GL_UNUSED) for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) { struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); - long int q = ts->tv_nsec / timespec_resolution; - long int r = ts->tv_nsec % timespec_resolution; + long int q = ts->tv_nsec / timespec_hz; + long int r = ts->tv_nsec % timespec_hz; if (r < 0) { - r += timespec_resolution; + r += timespec_hz; q--; } ts->tv_nsec = r; |