aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/sys/sleep.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-07-05 15:45:37 -0700
committerH. Peter Anvin <hpa@zytor.com>2010-07-05 15:45:37 -0700
commit0a984adcbd5130e790a774e0d78d66465ecc6c0a (patch)
tree469e7e367aa7b683a4b3419444aa8153e4f98ac3 /com32/lib/sys/sleep.c
parenta393bcdefd525c43fce16a9f50a03402533b55f4 (diff)
downloadsyslinux-0a984adcbd5130e790a774e0d78d66465ecc6c0a.tar.gz
syslinux-0a984adcbd5130e790a774e0d78d66465ecc6c0a.tar.xz
syslinux-0a984adcbd5130e790a774e0d78d66465ecc6c0a.zip
com32: add proper sleep()/msleep() functions and make Lua use them
Add proper sleep() and msleep() functions, which among other things call syslinux_idle(), and make Lua use them. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/lib/sys/sleep.c')
-rw-r--r--com32/lib/sys/sleep.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/com32/lib/sys/sleep.c b/com32/lib/sys/sleep.c
new file mode 100644
index 00000000..8a51c1c0
--- /dev/null
+++ b/com32/lib/sys/sleep.c
@@ -0,0 +1,22 @@
+/*
+ * sys/sleep.c
+ */
+
+#include <unistd.h>
+#include <sys/times.h>
+#include <syslinux/idle.h>
+
+unsigned int msleep(unsigned int msec)
+{
+ clock_t start = times(NULL);
+
+ while (times(NULL) - start < msec)
+ syslinux_idle();
+
+ return 0;
+}
+
+unsigned int sleep(unsigned int seconds)
+{
+ return msleep(seconds * 1000);
+}