19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_TIMER_OS2 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSMISC 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSERRORS 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSSEMAPHORES 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSDATETIME 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSPROCESS 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSPROFILE 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_DOSEXCEPTIONS 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <os2.h> 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_thread.h" 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_timer.h" 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_timer_c.h" 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define TIME_WRAP_VALUE (~(DWORD)0) 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The first high-resolution ticks value of the application */ 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic long long hires_start_ticks; 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The number of ticks per second of the high-resolution performance counter */ 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic ULONG hires_ticks_per_second; 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_StartTicks(void) 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosTmrQueryFreq(&hires_ticks_per_second); 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosTmrQueryTime((PQWORD)&hires_start_ticks); 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallDECLSPEC Uint32 SDLCALL SDL_GetTicks(void) 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall long long hires_now; 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ULONG ticks = ticks; 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosTmrQueryTime((PQWORD)&hires_now); 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hires_now -= hires_start_ticks; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hires_now *= 1000; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hires_now /= hires_ticks_per_second; 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* inline asm to avoid runtime inclusion */ 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall _asm { 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall push edx 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall push eax 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov eax, dword ptr hires_now 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov edx, dword ptr hires_now+4 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sub eax, dword ptr hires_start_ticks 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sbb edx, dword ptr hires_start_ticks+4 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov ebx,1000 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov ecx,edx 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mul ebx 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall push eax 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall push edx 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov eax,ecx 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mul ebx 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pop eax 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall add edx,eax 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pop eax 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov ebx, dword ptr hires_ticks_per_second 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall div ebx 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mov dword ptr ticks, eax 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pop edx 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall pop eax 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return ticks; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* High resolution sleep, originally made by Ilya Zakharevich */ 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallDECLSPEC void SDLCALL SDL_Delay(Uint32 ms) 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* This is similar to DosSleep(), but has 8ms granularity in time-critical 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall threads even on Warp3. */ 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HEV hevEvent1 = 0; /* Event semaphore handle */ 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HTIMER htimerEvent1 = 0; /* Timer handle */ 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall APIRET rc = NO_ERROR; /* Return code */ 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int ret = 1; 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ULONG priority = 0, nesting; /* Shut down the warnings */ 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PPIB pib; 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PTIB tib; 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char *e = NULL; 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall APIRET badrc; 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int switch_priority = 50; 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosCreateEventSem(NULL, /* Unnamed */ 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &hevEvent1, /* Handle of semaphore returned */ 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DC_SEM_SHARED, /* Shared needed for DosAsyncTimer */ 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FALSE); /* Semaphore is in RESET state */ 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (ms >= switch_priority) 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch_priority = 0; 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (switch_priority) 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (DosGetInfoBlocks(&tib, &pib)!=NO_ERROR) 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch_priority = 0; 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* In Warp3, to switch scheduling to 8ms step, one needs to do 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosAsyncTimer() in time-critical thread. On laters versions, 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall more and more cases of wait-for-something are covered. 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall It turns out that on Warp3fp42 it is the priority at the time 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall of DosAsyncTimer() which matters. Let's hope that this works 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall with later versions too... XXXX 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall priority = (tib->tib_ptib2->tib2_ulpri); 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((priority & 0xFF00) == 0x0300) /* already time-critical */ 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch_priority = 0; 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Make us time-critical. Just modifying TIB is not enough... */ 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* tib->tib_ptib2->tib2_ulpri = 0x0300;*/ 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We do not want to run at high priority if a signal causes us 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall to longjmp() out of this section... */ 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (DosEnterMustComplete(&nesting)) 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch_priority = 0; 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((badrc = DosAsyncTimer(ms, 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (HSEM) hevEvent1, /* Semaphore to post */ 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &htimerEvent1))) /* Timer handler (returned) */ 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall e = "DosAsyncTimer"; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (switch_priority && tib->tib_ptib2->tib2_ulpri == 0x0300) 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Nobody switched priority while we slept... Ignore errors... */ 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* tib->tib_ptib2->tib2_ulpri = priority; */ /* Get back... */ 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!(rc = DosSetPriority(PRTYS_THREAD, (priority>>8) & 0xFF, 0, 0))) 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rc = DosSetPriority(PRTYS_THREAD, 0, priority & 0xFF, 0); 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (switch_priority) 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rc = DosExitMustComplete(&nesting); /* Ignore errors */ 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* The actual blocking call is made with "normal" priority. This way we 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall should not bother with DosSleep(0) etc. to compensate for us interrupting 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall higher-priority threads. The goal is to prohibit the system spending too 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall much time halt()ing, not to run us "no matter what". */ 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!e) /* Wait for AsyncTimer event */ 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall badrc = DosWaitEventSem(hevEvent1, SEM_INDEFINITE_WAIT); 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (e) ; /* Do nothing */ 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if (badrc == ERROR_INTERRUPT) 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ret = 0; 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else if (badrc) 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall e = "DosWaitEventSem"; 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((rc = DosCloseEventSem(hevEvent1)) && !e) { /* Get rid of semaphore */ 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall e = "DosCloseEventSem"; 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall badrc = rc; 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (e) 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("[SDL_Delay] : Had error in %s(), rc is 0x%x\n", e, badrc); 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Data to handle a single periodic alarm */ 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int timer_alive = 0; 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Thread *timer = NULL; 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDLCALL RunTimer(void *unused) 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( timer_alive ) { 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_timer_running ) { 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ThreadedTimerCheck(); 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Delay(10); 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This is only called if the event thread is not running */ 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_TimerInit(void) 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall timer_alive = 1; 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall timer = SDL_CreateThread(RunTimer, NULL); 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( timer == NULL ) 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(SDL_SetTimerThreaded(1)); 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_TimerQuit(void) 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall timer_alive = 0; 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( timer ) { 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_WaitThread(timer, NULL); 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall timer = NULL; 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_StartTimer(void) 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Internal logic error: OS/2 uses threaded timer"); 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_StopTimer(void) 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_TIMER_OS2 */ 228