From 34266deb829d8acd795cb0aab6bc3b8aa2651085 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 14 Mar 2016 12:02:59 -0700 Subject: [PATCH] Rune - Default output to RAS, misc * Change default output for -s from LLVM to RAS. * Add sleep() system call, fix tsleep() system call. * Add debugging to gfx2.d --- libgen/misc.c | 2 +- libruntime/thread.c | 25 ++++++++++++++++++++++--- tests/gfx2.d | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libgen/misc.c b/libgen/misc.c index c33e520..c6bdb99 100644 --- a/libgen/misc.c +++ b/libgen/misc.c @@ -11,7 +11,7 @@ string_t String_Main; runesize_t PtrSizeBits; runesize_t PtrSizeBytes; -struct BackendVector *BE = &BE_LLVM; +struct BackendVector *BE = &BE_RAS; void LibGenInterpInit(void) diff --git a/libruntime/thread.c b/libruntime/thread.c index a644571..a6950c9 100644 --- a/libruntime/thread.c +++ b/libruntime/thread.c @@ -120,6 +120,23 @@ RuneSysCall_wakeup(struct wakeup_args *args, void *rval) threadWakeupWChan(&tw->tw_List, wchan); } +struct sleep_args { + int32_t ms; +}; + +void RuneSysCall_sleep(struct sleep_args *args, void *rval); + +void +RuneSysCall_sleep(struct sleep_args *args, void *rval) +{ + ThreadWait tw; + + RUNE_INIT(&tw.tw_List); + + if (args->ms > 0) + threadSleep(&tw.tw_List, args->ms); +} + struct tsleep_args { PointerStor s; @@ -131,10 +148,12 @@ void RuneSysCall_tsleep(struct tsleep_args *args, void *rval); void RuneSysCall_tsleep(struct tsleep_args *args, void *rval) { - ThreadWait tw; + ThreadWait *tw; + uintptr_t wchan; - RUNE_INIT(&tw.tw_List); + wchan = (uintptr_t)args->s.s_Addr; + tw = &TWArray[hashptr(wchan)]; if (args->ms > 0) - threadSleep(&tw.tw_List, args->ms); + threadSleepWChan(&tw->tw_List, wchan, args->ms); } diff --git a/tests/gfx2.d b/tests/gfx2.d index f41b582..ecb0d56 100755 --- a/tests/gfx2.d +++ b/tests/gfx2.d @@ -101,6 +101,7 @@ main(int ac, char **av) Thread.tsleep(&waiting, 5000); frame->unlinkFrame(); frame = NULL; + stdout->show("main woke up"); Thread.waitThreads(); # wait until all threads have exited stdout->show("returning"); -- 2.41.0