forked from osmocom/wireshark
MinGW-w64: Use clock_gettime()
Mingw-w64 has this function. We may have to define some extra symbols for API visibility but on my system the config check is working out of the box. POSIX systems come in many flavours, remove the "save time" if() condition in this case. Fix code to check if we have clock_gettime() on Windows as well.
This commit is contained in:
parent
2f7e3f1d82
commit
3164d4a646
|
@ -80,19 +80,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.]
|
|||
check_function_exists("getexecname" HAVE_GETEXECNAME)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check whether we have clock_gettime().
|
||||
# It's not on Windows, so don't waste time checking for it.
|
||||
# It's in newer POSIX, so some, but not all, UN*Xes have it.
|
||||
#
|
||||
if (NOT WIN32)
|
||||
#
|
||||
# POSIX - don't bother checking on Windows, as checks
|
||||
# take time.
|
||||
#
|
||||
check_function_exists("clock_gettime" HAVE_CLOCK_GETTIME)
|
||||
endif (NOT WIN32)
|
||||
|
||||
check_function_exists("clock_gettime" HAVE_CLOCK_GETTIME)
|
||||
check_function_exists("getifaddrs" HAVE_GETIFADDRS)
|
||||
check_function_exists("issetugid" HAVE_ISSETUGID)
|
||||
check_function_exists("setresgid" HAVE_SETRESGID)
|
||||
|
|
|
@ -618,15 +618,15 @@ void ImportTextDialog::on_timestampFormatLineEdit_textChanged(const QString &tim
|
|||
char time_str[100];
|
||||
QString timefmt = QString(time_format);
|
||||
|
||||
#if defined(_WIN32)
|
||||
#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);
|
||||
#elif defined(HAVE_CLOCK_GETTIME)
|
||||
// Newer POSIX API. Some UN*Xes whose C libraries lack
|
||||
// timespec_get() (C11) have this.
|
||||
clock_gettime(CLOCK_REALTIME, &timenow);
|
||||
#else
|
||||
// Fall back on gettimeofday().
|
||||
struct timeval usectimenow;
|
||||
|
|
Loading…
Reference in New Issue