diff options
Diffstat (limited to 'c/libc.c')
| -rw-r--r-- | c/libc.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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]; |
