Browse Source

[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())
master
Glenn Strauss 5 months ago
parent
commit
1ccc1d4ff5
  1. 5
      src/log.c
  2. 5
      src/log.h

5
src/log.c

@ -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;

5
src/log.h

@ -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);

Loading…
Cancel
Save