Logo
Explore Help
Sign In
fluencelabs/musl
1
0
Fork 0
You've already forked musl
mirror of https://github.com/fluencelabs/musl synced 2025-06-24 20:21:59 +00:00
Code Issues Projects Releases Wiki Activity
Files
bac03cdde1137c16b4c194e137310e2748661dcc
musl/src/time/gettimeofday.c

14 lines
266 B
C
Raw Normal View History

some preliminaries for vdso clock support 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.
2011-07-23 23:45:33 -04:00
#include <time.h>
initial check-in, version 0.5.0
2011-02-12 00:22:29 -05:00
#include <sys/time.h>
#include "syscall.h"
int gettimeofday(struct timeval *tv, void *tz)
{
some preliminaries for vdso clock support 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.
2011-07-23 23:45:33 -04:00
struct timespec ts;
if (!tv) return 0;
clock_gettime(CLOCK_REALTIME, &ts);
tv->tv_sec = ts.tv_sec;
tv->tv_usec = (int)ts.tv_nsec / 1000;
initial check-in, version 0.5.0
2011-02-12 00:22:29 -05:00
return 0;
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.2 Page: 493ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API