Fix w32 implementation of itimers: overflow and ITIMER_PROF.
commitd7ef9678754509d426df5f6f2086ca03f7d68b1c
authorEli Zaretskii <eliz@gnu.org>
Sat, 27 Oct 2012 11:21:26 +0000 (27 13:21 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 27 Oct 2012 11:21:26 +0000 (27 13:21 +0200)
treed550f37e6bd32d4be6879abe4bb8b7ad766c32ad
parent770668ad20f0f14582583c388dfada0fa8eb8be6
Fix w32 implementation of itimers: overflow and ITIMER_PROF.

 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.
src/ChangeLog
src/w32proc.c