From e14ae58ab7059b64d8ca074814ca7c5090b5e637 Mon Sep 17 00:00:00 2001 From: Leif Ekblad Date: Sun, 22 Dec 2024 21:26:38 +0100 Subject: [PATCH] Must clear done bit on restart of RDOS timer. --- bld/clib/rdos/c/timer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bld/clib/rdos/c/timer.c b/bld/clib/rdos/c/timer.c index 34eb50df1a..b37ce9309c 100644 --- a/bld/clib/rdos/c/timer.c +++ b/bld/clib/rdos/c/timer.c @@ -99,8 +99,8 @@ static void UpdateTimers( ) if( timer->Active.CompletedBitmap[i] & mask ) { if( ( timer->Req.DoneBitmap[i] & mask ) == 0 ) { timer->Req.DoneBitmap[i] |= mask; - FCurrIndex = 32 * i + bit - 4; - FCurrEntry = &timer->Req.EntryArr[FCurrIndex]; + FCurrIndex = 32 * i + bit; + FCurrEntry = &timer->Req.EntryArr[FCurrIndex - 4]; ( *FCurrEntry->callback )( FCurrEntry->param ); FCurrEntry = 0; FCurrIndex = 0; @@ -198,9 +198,18 @@ static int StopTimer( int index ) static int RestartCurrTimer( long long timeout ) { + int i; + int bit; + int mask; + if( FCurrEntry == 0 ) return( 0 ); + i = FCurrIndex / 32; + bit = FCurrIndex % 32; + mask = 1 << bit; + timer->Req.DoneBitmap[i] &= ~mask; + FCurrEntry->timeout = timeout; __locked_set_bit( timer->Req.ReqBitmap, FCurrIndex ); return( 1 );