# SDL: os/2: Don't try to be clever with the 32-bit GetTicks fallback.

**URL:** <https://discourse.libsdl.org/t/sdl-os-2-dont-try-to-be-clever-with-the-32-bit-getticks-fallback/33248>\
**Category:** SDL Commits\
**Created:** [November 1, 2021, 6:30pm UTC](https://discourse.libsdl.org/t/sdl-os-2-dont-try-to-be-clever-with-the-32-bit-getticks-fallback/33248 "2021-11-01T18:30:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [November 1, 2021, 6:30pm UTC](https://discourse.libsdl.org/t/sdl-os-2-dont-try-to-be-clever-with-the-32-bit-getticks-fallback/33248/1 "2021-11-01T18:30:29Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/2379c52849693c6933f8216ba8725d564871784a>

```diff
From 2379c52849693c6933f8216ba8725d564871784a Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 25 Oct 2021 11:04:42 -0400
Subject: [PATCH] os/2: Don't try to be clever with the 32-bit GetTicks
 fallback.

---
 src/timer/os2/SDL_systimer.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/timer/os2/SDL_systimer.c b/src/timer/os2/SDL_systimer.c
index ae71b816af..14f7b815ee 100644
--- a/src/timer/os2/SDL_systimer.c
+++ b/src/timer/os2/SDL_systimer.c
@@ -42,10 +42,6 @@ typedef unsigned long long ULLONG;
 static ULONG ulTmrFreq = 0;
 static ULLONG ullTmrStart = 0;
 
-/* 32-bit counter fallback...not used if DosTmrQuery* is functioning. */
-static ULONG ulPrevTmr = 0;
-static Uint64 ui64TmrStartOffset = 0; /* Used if 32-bit counter overflows. */
-
 void
 SDL_TicksInit(void)
 {
@@ -64,7 +60,6 @@ SDL_TicksInit(void)
     ulTmrFreq = 0; /* Error - use DosQuerySysInfo() for timer. */
     DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulTmrStart, sizeof (ULONG));
     ullTmrStart = (ULLONG) ulTmrStart;
- ulPrevTmr = ulTmrStart;
 }
 
 void
@@ -86,15 +81,10 @@ SDL_GetTicks64(void)
         DosTmrQueryTime((PQWORD)&ullTmrNow);
         ui64Result = (ullTmrNow - ullTmrStart) * 1000 / ulTmrFreq;
     } else {
+ /* note that this counter rolls over to 0 every ~49 days. Fix your system so DosTmrQueryTime works if you need to avoid this. */
         ULONG ulTmrNow;
         DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulTmrNow, sizeof (ULONG));
- if ( ((ULLONG) ulTmrNow) < ulPrevTmr ) { /* have we overflowed the 32-bit counter since last check? */
- /* Note that this is incorrect if you went more than ~98 days between calls to SDL_GetTicks64(). */
- /* One could query QSV_TIME_HIGH and QSV_TIME_LOW here to verify, but it's probably not worth it. */
- ui64TmrStartOffset += 0xFFFFFFFF;
- }
- ui64Result = (((Uint64) ulTmrNow) - ullTmrStart) + ui64TmrStartOffset;
- ulPrevTmr = ulTmrNow;
+ ui64Result = (((Uint64) ulTmrNow) - ullTmrStart);
     }
 
     return ui64Result;
@@ -105,9 +95,9 @@ SDL_GetPerformanceCounter(void)
 {
     QWORD qwTmrNow;
 
- if (ulTmrFreq == 0 || (DosTmrQueryTime(&qwTmrNow) != NO_ERROR))
+ if (ulTmrFreq == 0 || (DosTmrQueryTime(&qwTmrNow) != NO_ERROR)) {
         return SDL_GetTicks64();
-
+ }
     return *((Uint64 *)&qwTmrNow);
 }
 

```
