diff --git a/lib/libc/sys/clock_gettime.c b/lib/libc/sys/clock_gettime.c index ec8ec13a754..b2a41445524 100644 --- a/lib/libc/sys/clock_gettime.c +++ b/lib/libc/sys/clock_gettime.c @@ -48,7 +48,11 @@ __clock_gettime(clockid_t clock_id, struct timespec *ts) error = __vdso_clock_gettime(clock_id, ts); else error = ENOSYS; - if (error == ENOSYS) + if (error == ENOSYS) { error = __sys_clock_gettime(clock_id, ts); + } else if (error != 0) { + errno = error; + error = -1; + } return (error); } diff --git a/lib/libc/sys/gettimeofday.c b/lib/libc/sys/gettimeofday.c index 22177b15a5c..d955aaa907e 100644 --- a/lib/libc/sys/gettimeofday.c +++ b/lib/libc/sys/gettimeofday.c @@ -44,7 +44,11 @@ __gettimeofday(struct timeval *tv, struct timezone *tz) int error; error = __vdso_gettimeofday(tv, tz); - if (error == ENOSYS) + if (error == ENOSYS) { error = __sys_gettimeofday(tv, tz); + } else if (error != 0) { + errno = error; + error = -1; + } return (error); }