aboutsummaryrefslogtreecommitdiffstats
path: root/missing_d/usleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing_d/usleep.c')
-rw-r--r--missing_d/usleep.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/missing_d/usleep.c b/missing_d/usleep.c
new file mode 100644
index 00000000..cb1c7abf
--- /dev/null
+++ b/missing_d/usleep.c
@@ -0,0 +1,17 @@
+/*
+ * usleep - round microseconds up to an integral number of seconds.
+ *
+ * The real usleep() doesn't work this way; this is a hack for systems
+ * that don't have usleep().
+ */
+
+int
+usleep(unsigned int usec)
+{
+ unsigned int seconds = usec / 1000000;
+
+ /* Round up: */
+ seconds += (usec % 1000000 > 0); /* 1 or 0 */
+
+ return sleep(seconds);
+}