summaryrefslogtreecommitdiff
path: root/runit/runsv.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-09-16 18:50:56 +0000
committerDenis Vlasenko2007-09-16 18:50:56 +0000
commite755e827f7c8ecb21787a4369d7afdeda54d112b (patch)
tree007b1506e69ffcc25bc6ba3b0e6686d806a34264 /runit/runsv.c
parented6ac53104d811ee88c71aff45c7cad666aaee46 (diff)
downloadbusybox-e755e827f7c8ecb21787a4369d7afdeda54d112b.zip
busybox-e755e827f7c8ecb21787a4369d7afdeda54d112b.tar.gz
apply post 1.7.0 patches, set version to 1.7.11_7_1
Diffstat (limited to 'runit/runsv.c')
-rw-r--r--runit/runsv.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/runit/runsv.c b/runit/runsv.c
index baef6e1..b35c266 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -33,6 +33,34 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "libbb.h"
#include "runit_lib.h"
+#if ENABLE_MONOTONIC_SYSCALL
+#include <sys/syscall.h>
+
+/* libc has incredibly messy way of doing this,
+ * typically requiring -lrt. We just skip all this mess */
+static void gettimeofday_ns(struct timespec *ts)
+{
+ syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
+}
+#else
+static void gettimeofday_ns(struct timespec *ts)
+{
+ if (sizeof(struct timeval) == sizeof(struct timespec)
+ && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec)
+ ) {
+ /* Cheat */
+ gettimeofday((void*)ts, NULL);
+ ts->tv_nsec *= 1000;
+ } else {
+ extern void BUG_need_to_implement_gettimeofday_ns(void);
+ BUG_need_to_implement_gettimeofday_ns();
+ }
+}
+#endif
+
+/* Compare possibly overflowing unsigned counters */
+#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
+
static int selfpipe[2];
/* state */
@@ -126,14 +154,6 @@ static int rename_or_warn(const char *old, const char *new)
return 0;
}
-#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
-
-#include <sys/syscall.h>
-static void gettimeofday_ns(struct timespec *ts)
-{
- syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
-}
-
static void update_status(struct svdir *s)
{
ssize_t sz;