9 #include "khlib_time.h"
12 khlib_timespec_of_float(double n
)
18 fractional
= modf(n
, &integral
);
19 t
.tv_sec
= (int) integral
;
20 t
.tv_nsec
= (int) (1E9
* fractional
);
26 khlib_sleep(struct timespec
*t
)
28 struct timespec remainder
;
30 if (nanosleep(t
, &remainder
) < 0) {
33 "nanosleep interrupted. Remainder: "
34 "{ tv_sec = %ld, tv_nsec = %ld }",
35 remainder
.tv_sec
, remainder
.tv_nsec
);
36 /* No big deal if we occasionally sleep less,
37 * so not attempting to correct after an interruption.
40 khlib_fatal("nanosleep: %s\n", strerror(errno
));
This page took 0.067926 seconds and 4 git commands to generate.