Revision 5bfb723f qemu-timer.c

b/qemu-timer.c
696 696

  
697 697
static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
698 698
{
699
    int nearest_delta_ms = (delta + 999999) / 1000000;
699
    int64_t nearest_delta_ms = delta / 1000000;
700 700
    if (nearest_delta_ms < 1) {
701 701
        nearest_delta_ms = 1;
702 702
    }
703
    /* UINT_MAX can be 32 bit */
704
    if (nearest_delta_ms > UINT_MAX) {
705
        nearest_delta_ms = UINT_MAX;
706
    }
703 707

  
704 708
    timeKillEvent(mm_timer);
705
    mm_timer = timeSetEvent(nearest_delta_ms,
709
    mm_timer = timeSetEvent((unsigned int) nearest_delta_ms,
706 710
                            mm_period,
707 711
                            mm_alarm_handler,
708 712
                            (DWORD_PTR)t,
......
757 761
                              int64_t nearest_delta_ns)
758 762
{
759 763
    HANDLE hTimer = t->timer;
760
    int nearest_delta_ms;
764
    int64_t nearest_delta_ms;
761 765
    BOOLEAN success;
762 766

  
763
    nearest_delta_ms = (nearest_delta_ns + 999999) / 1000000;
767
    nearest_delta_ms = nearest_delta_ns / 1000000;
764 768
    if (nearest_delta_ms < 1) {
765 769
        nearest_delta_ms = 1;
766 770
    }
771
    /* ULONG_MAX can be 32 bit */
772
    if (nearest_delta_ms > ULONG_MAX) {
773
        nearest_delta_ms = ULONG_MAX;
774
    }
767 775
    success = ChangeTimerQueueTimer(NULL,
768 776
                                    hTimer,
769
                                    nearest_delta_ms,
777
                                    (unsigned long) nearest_delta_ms,
770 778
                                    3600000);
771 779

  
772 780
    if (!success) {

Also available in: Unified diff