Allow for overriding time-related libc functions

If using the libc for Noux programs, the default implementation of these
functions cannot be used because they rely on a dedicated
timeout-scheduler thread. Noux programs, however, are expected to
contain only the main thread. By turning the functions into weak
symbols, the noux libc-plugin can provide custom implementations.
This commit is contained in:
Norman Feske 2012-02-22 11:08:34 +01:00
parent fe2addf5b0
commit 1a833ebd30
2 changed files with 4 additions and 2 deletions

View File

@ -16,7 +16,8 @@
#include <sys/time.h>
extern "C" int clock_gettime(clockid_t clk_id, struct timespec *tp)
extern "C" __attribute__((weak))
int clock_gettime(clockid_t clk_id, struct timespec *tp)
{
if (clk_id != CLOCK_MONOTONIC)
PWRN("Unsupported clk_id, using CLOCK_MONOTONIC instead.");

View File

@ -15,7 +15,8 @@
#include <sys/time.h>
extern "C" int gettimeofday(struct timeval *tv, struct timezone *tz)
extern "C" __attribute__((weak))
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
Genode::Alarm::Time time = Genode::Timeout_thread::alarm_timer()->time();