diff options
author | Jes Sorensen <Jes.Sorensen@redhat.com> | 2010-06-10 11:42:18 +0200 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2010-06-12 08:49:14 +0300 |
commit | 716ec9fb3e58a4e88588b60847b1c89388adeb4d (patch) | |
tree | 0cba52ec626d08e2bf471f4fd8e2a336db78674b /os-win32.c | |
parent | 97c15c8013182bde68e86fa4fa2f583ccd3b57b1 (diff) | |
download | qemu-716ec9fb3e58a4e88588b60847b1c89388adeb4d.tar.gz qemu-716ec9fb3e58a4e88588b60847b1c89388adeb4d.tar.bz2 qemu-716ec9fb3e58a4e88588b60847b1c89388adeb4d.zip |
vl.c: Move host_main_loop_wait() to OS specific files.
Move host_main_loop_wait() to OS specific files. Create
qemu-os-posix.h and provide empty inline for the POSIX case.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'os-win32.c')
-rw-r--r-- | os-win32.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/os-win32.c b/os-win32.c index 5a464cc88a..1f7e28bad2 100644 --- a/os-win32.c +++ b/os-win32.c @@ -109,3 +109,46 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque) if (found) w->num--; } + +void os_host_main_loop_wait(int *timeout) +{ + int ret, ret2, i; + PollingEntry *pe; + + /* XXX: need to suppress polling by better using win32 events */ + ret = 0; + for(pe = first_polling_entry; pe != NULL; pe = pe->next) { + ret |= pe->func(pe->opaque); + } + if (ret == 0) { + int err; + WaitObjects *w = &wait_objects; + + ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout); + if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) { + if (w->func[ret - WAIT_OBJECT_0]) + w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]); + + /* Check for additional signaled events */ + for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) { + + /* Check if event is signaled */ + ret2 = WaitForSingleObject(w->events[i], 0); + if(ret2 == WAIT_OBJECT_0) { + if (w->func[i]) + w->func[i](w->opaque[i]); + } else if (ret2 == WAIT_TIMEOUT) { + } else { + err = GetLastError(); + fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err); + } + } + } else if (ret == WAIT_TIMEOUT) { + } else { + err = GetLastError(); + fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err); + } + } + + *timeout = 0; +} |