qemu-timer: move timeBeginPeriod/timeEndPeriod to os-win32

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 <jacob.kroon@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Paolo Bonzini
2013-02-20 14:43:31 +01:00
committed by Stefan Weil
parent 1046127d1f
commit 0727b86754
2 changed files with 17 additions and 18 deletions

View File

@ -23,6 +23,7 @@
* THE SOFTWARE.
*/
#include <windows.h>
#include <mmsystem.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
@ -67,9 +68,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. */