1 diff -urN busybox-1.7.0/networking/isrv.c busybox-1.7.0-gettimeofday_ns/networking/isrv.c
2 --- busybox-1.7.0/networking/isrv.c 2007-08-24 11:49:41.000000000 +0100
3 +++ busybox-1.7.0-gettimeofday_ns/networking/isrv.c 2007-09-06 17:39:55.000000000 +0100
8 -/* Even if _POSIX_MONOTONIC_CLOCK is defined, this
9 - * may require librt */
10 -#if 0 /*def _POSIX_MONOTONIC_CLOCK*/
11 -static time_t monotonic_time(void)
14 - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
19 -#define monotonic_time() (time(NULL))
22 /* Opaque structure */
26 /* this peer is gone */
27 remove_peer(state, peer);
29 - TIMEO_TBL[peer] = monotonic_time();
30 + TIMEO_TBL[peer] = monotonic_sec();
38 - time_t t = monotonic_time();
39 + time_t t = monotonic_sec();
42 handle_timeout(state, do_timeout);
43 diff -urN busybox-1.7.0/runit/runsv.c busybox-1.7.0-gettimeofday_ns/runit/runsv.c
44 --- busybox-1.7.0/runit/runsv.c 2007-08-24 11:50:01.000000000 +0100
45 +++ busybox-1.7.0-gettimeofday_ns/runit/runsv.c 2007-09-06 17:39:55.000000000 +0100
48 #include "runit_lib.h"
50 +#if ENABLE_MONOTONIC_SYSCALL
51 +#include <sys/syscall.h>
53 +/* libc has incredibly messy way of doing this,
54 + * typically requiring -lrt. We just skip all this mess */
55 +static void gettimeofday_ns(struct timespec *ts)
57 + syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
60 +static void gettimeofday_ns(struct timespec *ts)
62 + if (sizeof(struct timeval) == sizeof(struct timespec)
63 + && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec)
66 + gettimeofday((void*)ts, NULL);
67 + ts->tv_nsec *= 1000;
69 + extern void BUG_need_to_implement_gettimeofday_ns(void);
70 + BUG_need_to_implement_gettimeofday_ns();
75 +/* Compare possibly overflowing unsigned counters */
76 +#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
78 static int selfpipe[2];
85 -#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
87 -#include <sys/syscall.h>
88 -static void gettimeofday_ns(struct timespec *ts)
90 - syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
93 static void update_status(struct svdir *s)