aboutsummaryrefslogtreecommitdiffstats
path: root/c/libc.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/libc.c')
-rw-r--r--c/libc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/c/libc.c b/c/libc.c
index 9da63bc..a48a64c 100644
--- a/c/libc.c
+++ b/c/libc.c
@@ -1,6 +1,15 @@
/* gbos libc C helpers (compiled once, linked into every program). */
#include "gbos.h"
+/* sleep for approximately 'ms' milliseconds (cooperative; other procs run).
+ The kernel counts in 1/64-second units (~15.6 ms), so we round ms to that. */
+void msleep(unsigned int ms) {
+ unsigned int u = ms >> 4; /* ~ms/15.6, close enough for a delay */
+ if (u > 255) u = 255;
+ if (u == 0 && ms) u = 1;
+ gsleep((unsigned char)u);
+}
+
/* print an unsigned int in decimal */
void putu(unsigned int n) {
char buf[5];