Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kxppl-0002gq-50 for qemu-devel@nongnu.org; Wed, 05 Nov 2008 16:22:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kxppk-0002ge-KG for qemu-devel@nongnu.org; Wed, 05 Nov 2008 16:22:36 -0500 Received: from [199.232.76.173] (port=52059 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kxppk-0002gb-EH for qemu-devel@nongnu.org; Wed, 05 Nov 2008 16:22:36 -0500 Received: from savannah.gnu.org ([199.232.41.3]:49068 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kxppk-0005JZ-6j for qemu-devel@nongnu.org; Wed, 05 Nov 2008 16:22:36 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Kxppj-0001im-Br for qemu-devel@nongnu.org; Wed, 05 Nov 2008 21:22:35 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Kxppi-0001ii-Uf for qemu-devel@nongnu.org; Wed, 05 Nov 2008 21:22:35 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Wed, 05 Nov 2008 21:22:34 +0000 Subject: [Qemu-devel] [5637] Fix windows build after init_host_timer changes. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5637 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5637 Author: aliguori Date: 2008-11-05 21:22:34 +0000 (Wed, 05 Nov 2008) Log Message: ----------- Fix windows build after init_host_timer changes. host_alarm_timer fires in a separate thread. The windows build current uses SetEvent() and WaitEvent() to then notify the main thread. This is functionally equivalent to what we're doing in Unix with pipe(). So let's just #ifdef the pipe() code on Windows since it doesn't build there anyway. Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/vl.c Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-11-05 21:04:35 UTC (rev 5636) +++ trunk/vl.c 2008-11-05 21:22:34 UTC (rev 5637) @@ -885,7 +885,9 @@ #define MIN_TIMER_REARM_US 250 static struct qemu_alarm_timer *alarm_timer; +#ifndef _WIN32 static int alarm_timer_rfd, alarm_timer_wfd; +#endif #ifdef _WIN32 @@ -1306,14 +1308,14 @@ qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock))) { CPUState *env = next_cpu; - static const char byte = 0; #ifdef _WIN32 struct qemu_alarm_win32 *data = ((struct qemu_alarm_timer*)dwUser)->priv; SetEvent(data->host_alarm); +#else + static const char byte = 0; + write(alarm_timer_wfd, &byte, sizeof(byte)); #endif - - write(alarm_timer_wfd, &byte, sizeof(byte)); alarm_timer->flags |= ALARM_FLAG_EXPIRED; if (env) { @@ -1601,6 +1603,34 @@ #endif /* !defined(_WIN32) */ +static void try_to_rearm_timer(void *opaque) +{ + struct qemu_alarm_timer *t = opaque; +#ifndef _WIN32 + ssize_t len; + + /* Drain the notify pipe */ + do { + char buffer[512]; + len = read(alarm_timer_rfd, buffer, sizeof(buffer)); + } while ((len == -1 && errno == EINTR) || len > 0); +#endif + + /* vm time timers */ + if (vm_running && likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER))) + qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], + qemu_get_clock(vm_clock)); + + /* real time timers */ + qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], + qemu_get_clock(rt_clock)); + + if (t->flags & ALARM_FLAG_EXPIRED) { + alarm_timer->flags &= ~ALARM_FLAG_EXPIRED; + qemu_rearm_alarm_timer(alarm_timer); + } +} + #ifdef _WIN32 static int win32_start_timer(struct qemu_alarm_timer *t) @@ -1643,7 +1673,7 @@ return -1; } - qemu_add_wait_object(data->host_alarm, NULL, NULL); + qemu_add_wait_object(data->host_alarm, try_to_rearm_timer, t); return 0; } @@ -1689,36 +1719,12 @@ #endif /* _WIN32 */ -static void try_to_rearm_timer(void *opaque) -{ - struct qemu_alarm_timer *t = opaque; - ssize_t len; - - /* Drain the notify pipe */ - do { - char buffer[512]; - len = read(alarm_timer_rfd, buffer, sizeof(buffer)); - } while ((len == -1 && errno == EINTR) || len > 0); - - /* vm time timers */ - if (vm_running && likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER))) - qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], - qemu_get_clock(vm_clock)); - - /* real time timers */ - qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], - qemu_get_clock(rt_clock)); - - if (t->flags & ALARM_FLAG_EXPIRED) { - alarm_timer->flags &= ~ALARM_FLAG_EXPIRED; - qemu_rearm_alarm_timer(alarm_timer); - } -} - static int init_timer_alarm(void) { struct qemu_alarm_timer *t = NULL; int i, err = -1; + +#ifndef _WIN32 int fds[2]; err = pipe(fds); @@ -1735,6 +1741,7 @@ alarm_timer_rfd = fds[0]; alarm_timer_wfd = fds[1]; +#endif for (i = 0; alarm_timers[i].name; i++) { t = &alarm_timers[i]; @@ -1749,16 +1756,20 @@ goto fail; } +#ifndef _WIN32 qemu_set_fd_handler2(alarm_timer_rfd, NULL, try_to_rearm_timer, NULL, t); +#endif alarm_timer = t; return 0; fail: +#ifndef _WIN32 close(fds[0]); close(fds[1]); +#endif return err; }