1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00

native: add time syscalls

This commit is contained in:
Ludwig Ortmann 2014-11-18 19:59:30 +01:00
parent 4de10a2ecb
commit 00092e8308
3 changed files with 24 additions and 3 deletions

View File

@ -139,7 +139,7 @@ void schedule_timer(void)
null_timer.it_interval.tv_usec = 0;
null_timer.it_value.tv_sec = 0;
null_timer.it_value.tv_usec = 0;
if (setitimer(ITIMER_REAL, &null_timer, NULL) == -1) {
if (real_setitimer(ITIMER_REAL, &null_timer, NULL) == -1) {
err(EXIT_FAILURE, "schedule_timer: setitimer");
}
return;
@ -172,7 +172,7 @@ void schedule_timer(void)
}
_native_syscall_enter();
if (setitimer(ITIMER_REAL, &result, NULL) == -1) {
if (real_setitimer(ITIMER_REAL, &result, NULL) == -1) {
err(EXIT_FAILURE, "schedule_timer: setitimer");
}
else {
@ -283,7 +283,7 @@ unsigned long hwtimer_arch_now(void)
t.tv_nsec = mts.tv_nsec;
#else
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1) {
if (real_clock_gettime(CLOCK_MONOTONIC, &t) == -1) {
err(EXIT_FAILURE, "hwtimer_arch_now: clock_gettime");
}

View File

@ -45,6 +45,8 @@
#endif // BSD/Linux
#include <netdb.h>
#include <ifaddrs.h>
#include <time.h>
#include <sys/time.h>
#include "kernel_types.h"
@ -109,6 +111,8 @@ extern int (*real_pause)(void);
extern int (*real_pipe)(int[2]);
/* The ... is a hack to save includes: */
extern int (*real_select)(int nfds, ...);
extern int (*real_setitimer)(int which, const struct itimerval
*restrict value, struct itimerval *restrict ovalue);
extern int (*real_setsockopt)(int socket, ...);
extern int (*real_socket)(int domain, int type, int protocol);
extern int (*real_printf)(const char *format, ...);
@ -117,6 +121,11 @@ extern long int (*real_random)(void);
extern const char* (*real_gai_strerror)(int errcode);
extern FILE* (*real_fopen)(const char *path, const char *mode);
#ifdef __MACH__
#else
extern int (*real_clock_gettime)(clockid_t clk_id, struct timespec *tp);
#endif
/**
* data structures
*/

View File

@ -79,6 +79,8 @@ int (*real_open)(const char *path, int oflag, ...);
int (*real_pause)(void);
int (*real_pipe)(int[2]);
int (*real_select)(int nfds, ...);
int (*real_setitimer)(int which, const struct itimerval
*restrict value, struct itimerval *restrict ovalue);
int (*real_setsockopt)(int socket, ...);
int (*real_socket)(int domain, int type, int protocol);
int (*real_unlink)(const char *);
@ -86,6 +88,11 @@ long int (*real_random)(void);
const char* (*real_gai_strerror)(int errcode);
FILE* (*real_fopen)(const char *path, const char *mode);
#ifdef __MACH__
#else
int (*real_clock_gettime)(clockid_t clk_id, struct timespec *tp);
#endif
void _native_syscall_enter(void)
{
_native_in_syscall++;
@ -390,6 +397,7 @@ void _native_init_syscalls(void)
*(void **)(&real_fork) = dlsym(RTLD_NEXT, "fork");
*(void **)(&real_dup2) = dlsym(RTLD_NEXT, "dup2");
*(void **)(&real_select) = dlsym(RTLD_NEXT, "select");
*(void **)(&real_setitimer) = dlsym(RTLD_NEXT, "setitimer");
*(void **)(&real_setsockopt) = dlsym(RTLD_NEXT, "setsockopt");
*(void **)(&real_socket) = dlsym(RTLD_NEXT, "socket");
*(void **)(&real_unlink) = dlsym(RTLD_NEXT, "unlink");
@ -404,4 +412,8 @@ void _native_init_syscalls(void)
*(void **)(&real_feof) = dlsym(RTLD_NEXT, "feof");
*(void **)(&real_ferror) = dlsym(RTLD_NEXT, "ferror");
*(void **)(&real_clearerr) = dlsym(RTLD_NEXT, "clearerr");
#ifdef __MACH__
#else
*(void **)(&real_clock_gettime) = dlsym(RTLD_NEXT, "clock_gettime");
#endif
}