don't fail if BR2_USE_UPDATES tries to update non-checkout
[buildroot.git] / package / busybox / busybox-1.7.0-gettimeofday_ns.patch
blob8c4a8f300cad099e138a40c9a4ede7c4eb403afe
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
4 @@ -21,20 +21,6 @@
6 /* Helpers */
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)
13 - struct timespec ts;
14 - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
15 - time(&ts.tv_sec);
16 - return ts.tv_sec;
18 -#else
19 -#define monotonic_time() (time(NULL))
20 -#endif
22 /* Opaque structure */
24 struct isrv_state_t {
25 @@ -258,7 +244,7 @@
26 /* this peer is gone */
27 remove_peer(state, peer);
28 } else if (TIMEOUT) {
29 - TIMEO_TBL[peer] = monotonic_time();
30 + TIMEO_TBL[peer] = monotonic_sec();
34 @@ -335,7 +321,7 @@
35 break;
37 if (timeout) {
38 - time_t t = monotonic_time();
39 + time_t t = monotonic_sec();
40 if (t != CURTIME) {
41 CURTIME = t;
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
46 @@ -33,6 +33,34 @@
47 #include "libbb.h"
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);
59 +#else
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)
64 + ) {
65 + /* Cheat */
66 + gettimeofday((void*)ts, NULL);
67 + ts->tv_nsec *= 1000;
68 + } else {
69 + extern void BUG_need_to_implement_gettimeofday_ns(void);
70 + BUG_need_to_implement_gettimeofday_ns();
71 + }
73 +#endif
75 +/* Compare possibly overflowing unsigned counters */
76 +#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
78 static int selfpipe[2];
80 /* state */
81 @@ -126,14 +154,6 @@
82 return 0;
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)
95 ssize_t sz;