21 #include "../../SDL_internal.h"
26 #include "../../core/os2/SDL_os2.h"
28 #define INCL_DOSERRORS
30 #define INCL_DOSPROFILE
31 #define INCL_DOSSEMAPHORES
32 #define INCL_DOSDATETIME
33 #define INCL_DOSPROCESS
34 #define INCL_DOSEXCEPTIONS
40 typedef unsigned long long ULLONG;
42 static ULONG ulTmrFreq = 0;
43 static ULLONG ullTmrStart;
50 ulRC = DosTmrQueryFreq(&ulTmrFreq);
51 if (ulRC != NO_ERROR) {
52 debug_os2(
"DosTmrQueryFreq() failed, rc = %u", ulRC);
54 ulRC = DosTmrQueryTime((PQWORD)&ullTmrStart);
57 debug_os2(
"DosTmrQueryTime() failed, rc = %u", ulRC);
61 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, (PULONG)&ullTmrStart,
sizeof(ULONG));
79 DosTmrQueryTime((PQWORD)&ullTmrNow);
80 ulResult = (ullTmrNow - ullTmrStart) * 1000 / ulTmrFreq;
82 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, (PULONG)&ullTmrNow,
sizeof(ULONG));
83 ulResult = (ULONG)ullTmrNow - (ULONG)ullTmrStart;
94 if (ulTmrFreq == 0 || (DosTmrQueryTime(&qwTmrNow) != NO_ERROR))
97 return *((
Uint64 *)&qwTmrNow);
103 return (ulTmrFreq == 0)? 1000 : (
Uint64)ulTmrFreq;
109 HTIMER hTimer = NULLHANDLE;
111 #ifdef _SWITCH_PRIORITY
114 BOOL fSetPriority = ms < 50;
115 ULONG ulSavePriority;
125 ulRC = DosCreateEventSem(
NULL, &hevTimer, DC_SEM_SHARED,
FALSE);
126 if (ulRC != NO_ERROR) {
127 debug_os2(
"DosAsyncTimer() failed, rc = %u", ulRC);
132 #ifdef _SWITCH_PRIORITY
134 if (DosGetInfoBlocks(&tib, &pib) != NO_ERROR)
135 fSetPriority =
FALSE;
137 ulSavePriority = tib->tib_ptib2->tib2_ulpri;
138 if (((ulSavePriority & 0xFF00) == 0x0300) ||
139 (DosEnterMustComplete( &ulNesting) != NO_ERROR))
140 fSetPriority =
FALSE;
142 DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
148 DosResetEventSem(hevTimer, &ulRC);
149 ulRC = DosAsyncTimer(ms, (HSEM)hevTimer, &hTimer);
151 #ifdef _SWITCH_PRIORITY
153 if (DosSetPriority(PRTYS_THREAD, (ulSavePriority >> 8) & 0xFF, 0, 0) == NO_ERROR)
154 DosSetPriority(PRTYS_THREAD, 0, ulSavePriority & 0xFF, 0);
155 DosExitMustComplete(&ulNesting);
159 if (ulRC != NO_ERROR) {
160 debug_os2(
"DosAsyncTimer() failed, rc = %u", ulRC);
162 DosWaitEventSem(hevTimer, SEM_INDEFINITE_WAIT);
165 if (ulRC != NO_ERROR)
168 DosCloseEventSem(hevTimer);
#define SDL_GetPerformanceCounter
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
Uint64 SDL_GetPerformanceFrequency(void)
Get the count per second of the high resolution counter.