these changes also make it so clock_gettime(CLOCK_REALTIME, &ts) works even on pre-2.6 kernels, emulated via the gettimeofday syscall. there is no cost for the fallback check, as it falls under the error case that already must be checked for storing the error code in errno, but which would normally be hidden inside __syscall_ret.
14 lines
244 B
C
14 lines
244 B
C
#include <time.h>
|
|
#include <sys/time.h>
|
|
#include "syscall.h"
|
|
|
|
int __clock_gettime(clockid_t, struct timespec *);
|
|
|
|
time_t time(time_t *t)
|
|
{
|
|
struct timespec ts;
|
|
__clock_gettime(CLOCK_REALTIME, &ts);
|
|
if (t) *t = ts.tv_sec;
|
|
return ts.tv_sec;
|
|
}
|