mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-30 09:14:59 +02:00
Add compat to monotime_double().
Apply all of the portability changes in monotime() to monotime() double. Fixes build on at least older FreeBSD systems.
This commit is contained in:
parent
7b40ef6c2e
commit
2c48bd344d
20
misc.c
20
misc.c
@ -912,12 +912,26 @@ monotime(void)
|
|||||||
double
|
double
|
||||||
monotime_double(void)
|
monotime_double(void)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_CLOCK_GETTIME) && \
|
||||||
|
(defined(CLOCK_MONOTONIC) || defined(CLOCK_BOOTTIME))
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
static int gettime_failed = 0;
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
|
if (!gettime_failed) {
|
||||||
fatal("clock_gettime: %s", strerror(errno));
|
#if defined(CLOCK_BOOTTIME)
|
||||||
|
if (clock_gettime(CLOCK_BOOTTIME, &ts) == 0)
|
||||||
|
return (ts.tv_sec + (double)ts.tv_nsec / 1000000000);
|
||||||
|
#endif
|
||||||
|
#if defined(CLOCK_MONOTONIC)
|
||||||
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
||||||
|
return (ts.tv_sec + (double)ts.tv_nsec / 1000000000);
|
||||||
|
#endif
|
||||||
|
debug3("clock_gettime: %s", strerror(errno));
|
||||||
|
gettime_failed = 1;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_CLOCK_GETTIME && (CLOCK_MONOTONIC || CLOCK_BOOTTIME */
|
||||||
|
|
||||||
return (ts.tv_sec + (double)ts.tv_nsec / 1000000000);
|
return (double)time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user