Fix w32 implementation of itimers: overflow and ITIMER_PROF.
authorEli Zaretskii <eliz@gnu.org>
Sat, 27 Oct 2012 11:21:26 +0000 (13:21 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 27 Oct 2012 11:21:26 +0000 (13:21 +0200)
commit6c16c13ed185acf16dc8f1c6ba458f1e59328e84
tree879877acff6356de8e86be0679b04859d4d50451
parentcaa5e5a44dd23b77dfc38f7dd8b63af241149410
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