• Eli Zaretskii's avatar
    Fix w32 implementation of itimers: overflow and ITIMER_PROF. · 6c16c13e
    Eli Zaretskii authored
     Avoid overflow in w32 implementation of interval timers.  When
     possible, for ITIMER_PROF count only times the main thread
     actually executes.
     src/w32proc.c <struct itimer_data>: 'expire' and 'reload' are now
     ULONGLONG types.  Likewise for all the other data which was
     previously clock_t.
     (GetThreadTimes_Proc): New typedef.
     (w32_get_timer_time): New function, returns a suitable time value
     for the timer.
     (timer_loop): Enter critical section when accessing ULONGLONG
     values of the itimer_data struct, as these accesses are no longer
     atomic.  Call 'w32_get_timer_time' instead of 'clock'.
     (init_timers): Initialize s_pfn_Get_Thread_Times.
     (start_timer_thread): Don't assign itimer->caller_thread here.
     (getitimer): Assign itimer->caller_thread here.
     (setitimer): Always call getitimer to get the value of ticks_now.
ChangeLog 753 KB