From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPbIz-0000fs-8v for qemu-devel@nongnu.org; Tue, 09 Apr 2013 12:21:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPbIx-0000uI-EW for qemu-devel@nongnu.org; Tue, 09 Apr 2013 12:21:57 -0400 Received: from mail-qc0-x22f.google.com ([2607:f8b0:400d:c01::22f]:38843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPbIx-0000tp-Ad for qemu-devel@nongnu.org; Tue, 09 Apr 2013 12:21:55 -0400 Received: by mail-qc0-f175.google.com with SMTP id j3so1222284qcs.34 for ; Tue, 09 Apr 2013 09:21:55 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5164401C.30008@redhat.com> Date: Tue, 09 Apr 2013 18:21:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1361367811-13288-1-git-send-email-pbonzini@redhat.com> <1361367811-13288-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1361367811-13288-3-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-timer: move timeBeginPeriod/timeEndPeriod to os-win32 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: jacob.kroon@gmail.com Cc: Stefan Weil , qemu-devel@nongnu.org Il 20/02/2013 14:43, Paolo Bonzini ha scritto: > These are needed for any of the Win32 alarm timer implementations. > They are not tied to mmtimer exclusively. > > Jacob tested this patch with both mmtimer and Win32 timers. > > Cc: qemu-stable@nongnu.org > Tested-by: Jacob Kroon > Signed-off-by: Paolo Bonzini > --- > Jacob, this is the same as "patch 1" you tested. Stefan, can you pick up this patch again, together with Fabien's series? Paolo > os-win32.c | 10 ++++++++++ > qemu-timer.c | 26 ++++++-------------------- > 2 files changed, 16 insertions(+), 20 deletions(-) > > diff --git a/os-win32.c b/os-win32.c > index 3d43604..a0740ef 100644 > --- a/os-win32.c > +++ b/os-win32.c > @@ -23,6 +23,7 @@ > * THE SOFTWARE. > */ > #include > +#include > #include > #include > #include > @@ -67,9 +67,19 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type) > return TRUE; > } > > +static TIMECAPS mm_tc; > + > +static void os_undo_timer_resolution(void) > +{ > + timeEndPeriod(mm_tc.wPeriodMin); > +} > + > void os_setup_early_signal_handling(void) > { > SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE); > + timeGetDevCaps(&mm_tc, sizeof(mm_tc)); > + timeBeginPeriod(mm_tc.wPeriodMin); > + atexit(os_undo_timer_resolution); > } > > /* Look for support files in the same directory as the executable. */ > diff --git a/qemu-timer.c b/qemu-timer.c > index 8fb5c75..50109a1 100644 > --- a/qemu-timer.c > +++ b/qemu-timer.c > @@ -623,29 +622,15 @@ static void CALLBACK mm_alarm_handler(UINT uTimerID, UINT uMsg, > > static int mm_start_timer(struct qemu_alarm_timer *t) > { > timeGetDevCaps(&mm_tc, sizeof(mm_tc)); > - > - timeBeginPeriod(mm_tc.wPeriodMin); > - > - mm_timer = timeSetEvent(mm_tc.wPeriodMin, /* interval (ms) */ > - mm_tc.wPeriodMin, /* resolution */ > - mm_alarm_handler, /* function */ > - (DWORD_PTR)t, /* parameter */ > - TIME_ONESHOT | TIME_CALLBACK_FUNCTION); > - > - if (!mm_timer) { > - fprintf(stderr, "Failed to initialize win32 alarm timer\n"); > - timeEndPeriod(mm_tc.wPeriodMin); > - return -1; > - } > - > return 0; > } > > static void mm_stop_timer(struct qemu_alarm_timer *t) > { > - timeKillEvent(mm_timer); > - timeEndPeriod(mm_tc.wPeriodMin); > + if (mm_timer) { > + timeKillEvent(mm_timer); > + } > } > > static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta) > @@ -657,7 +641,9 @@ static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta) > nearest_delta_ms = mm_tc.wPeriodMax; > } > > - timeKillEvent(mm_timer); > + if (mm_timer) { > + timeKillEvent(mm_timer); > + } > mm_timer = timeSetEvent((UINT)nearest_delta_ms, > mm_tc.wPeriodMin, > mm_alarm_handler, >