From 8b15d0e641bde8db440db186f0988fe3cadf761f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Sun, 12 Dec 2021 22:19:40 +0000 Subject: [PATCH] The function timespec_get() is C17 so assume we have it --- ui/qt/import_text_dialog.cpp | 16 +--------------- wsutil/wslog.c | 5 ----- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/ui/qt/import_text_dialog.cpp b/ui/qt/import_text_dialog.cpp index 2e4b914e9c..74faf4f590 100644 --- a/ui/qt/import_text_dialog.cpp +++ b/ui/qt/import_text_dialog.cpp @@ -618,22 +618,8 @@ void ImportTextDialog::on_timestampFormatLineEdit_textChanged(const QString &tim char time_str[100]; QString timefmt = QString(time_format); -#if defined(HAVE_CLOCK_GETTIME) - // Newer POSIX API. Some UN*Xes whose C libraries lack - // timespec_get() (C11) have this. - clock_gettime(CLOCK_REALTIME, &timenow); -#elif defined(_WIN32) - // At least some Windows C libraries have this. - // Some UN*X C libraries do, as well, but they might not - // show it unless you're requesting C11 - or C++17. timespec_get(&timenow, TIME_UTC); -#else - // Fall back on gettimeofday(). - struct timeval usectimenow; - gettimeofday(&usectimenow, NULL); - timenow.tv_sec = usectimenow.tv_sec; - timenow.tv_nsec = usectimenow.tv_usec*1000; -#endif + /* On windows strftime/wcsftime does not support %s yet, this works on all OSs */ timefmt.replace(QString("%s"), QString::number(timenow.tv_sec)); /* subsecond example as usec */ diff --git a/wsutil/wslog.c b/wsutil/wslog.c index 5f048b4bf3..47d6227d7d 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -906,13 +906,8 @@ static void log_write_do_work(FILE *fp, gboolean use_color, static inline ws_log_time_t *get_timestamp(ws_log_time_t *ts) { assert(ts); -#if defined(HAVE_CLOCK_GETTIME) - if (clock_gettime(CLOCK_REALTIME, (struct timespec *)ts) == 0) - return ts; -#elif defined(_WIN32) if (timespec_get((struct timespec *)ts, TIME_UTC) == TIME_UTC) return ts; -#endif ts->tv_sec = time(NULL); ts->tv_nsec = -1; return ts;