[core] log_clock_gettime->clock_gettime for 64-bit

map log_clock_gettime() directly to clock_gettime() for 64-bit time_t
(on systems with clock_gettime())
This commit is contained in:
Glenn Strauss 2021-07-12 17:10:57 -04:00
parent 87b09d144e
commit 1ccc1d4ff5
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,8 @@
unix_time64_t log_epoch_secs = 0;
unix_time64_t log_monotonic_secs = 0;
#if !defined(HAVE_CLOCK_GETTIME) || !HAS_TIME_BITS64
int log_clock_gettime (const int clockid, unix_timespec64_t * const ts) {
#ifdef HAVE_CLOCK_GETTIME
#if HAS_TIME_BITS64
@ -63,6 +65,9 @@ int log_clock_gettime_realtime (unix_timespec64_t *ts) {
#endif
}
#endif /* !defined(HAVE_CLOCK_GETTIME) || !HAS_TIME_BITS64 */
/* retry write on EINTR or when not all data was written */
ssize_t write_all(int fd, const void * const buf, size_t count) {
ssize_t written = 0;

View File

@ -8,8 +8,13 @@
extern unix_time64_t log_epoch_secs;
extern unix_time64_t log_monotonic_secs;
#if defined(HAVE_CLOCK_GETTIME) && HAS_TIME_BITS64
#define log_clock_gettime(clockid,ts) clock_gettime((clockid),(ts))
#define log_clock_gettime_realtime(ts) clock_gettime(CLOCK_REALTIME,(ts))
#else
int log_clock_gettime(int clockid, unix_timespec64_t *ts);
int log_clock_gettime_realtime (unix_timespec64_t *ts);
#endif
ssize_t write_all(int fd, const void* buf, size_t count);