aboutsummaryrefslogtreecommitdiff
path: root/runit
diff options
context:
space:
mode:
Diffstat (limited to 'runit')
-rw-r--r--runit/runsv.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/runit/runsv.c b/runit/runsv.c
index 7e22862cd..d395d4528 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -58,11 +58,19 @@ static void gettimeofday_ns(struct timespec *ts)
58#else 58#else
59static void gettimeofday_ns(struct timespec *ts) 59static void gettimeofday_ns(struct timespec *ts)
60{ 60{
61 BUILD_BUG_ON(sizeof(struct timeval) != sizeof(struct timespec)); 61 if (sizeof(struct timeval) == sizeof(struct timespec)
62 BUILD_BUG_ON(sizeof(((struct timeval*)ts)->tv_usec) != sizeof(ts->tv_nsec)); 62 && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec)
63 /* Cheat */ 63 ) {
64 gettimeofday((void*)ts, NULL); 64 /* Cheat */
65 ts->tv_nsec *= 1000; 65 gettimeofday((void*)ts, NULL);
66 ts->tv_nsec *= 1000;
67 } else {
68 /* For example, musl has "incompatible" layouts */
69 struct timeval tv;
70 gettimeofday(&tv, NULL);
71 ts->tv_sec = tv.tv_sec;
72 ts->tv_nsec = tv.tv_usec * 1000;
73 }
66} 74}
67#endif 75#endif
68 76