#include <dlfcn.h> 
#include <sys/time.h> 
#include <time.h> 

/* Go back one hour: 3600 seconds */
#define OFFSET_IN_SECONDS -3600 

int gettimeofday(struct timeval *tp, struct timezone *tzp)
{
    int ret;
    ret = __gettimeofday(tp, tzp);
    tp->tv_sec += OFFSET_IN_SECONDS;
    return ret;
}

int (*oclock_gettime) (clockid_t clk_id, struct timespec * tp) = NULL;

int clock_gettime(clockid_t clk_id, struct timespec *tp)
{
    static int firstTime = 1;
    int ret;
    if (firstTime) {
	firstTime = 0;
	oclock_gettime = dlsym(RTLD_NEXT, "clock_gettime");
    }
    ret = oclock_gettime(clk_id, tp);
    tp->tv_sec += OFFSET_IN_SECONDS;
    return ret;
}