diff --git a/repos/libports/include/SDL/SDL_config_genode.h b/repos/libports/include/SDL/SDL_config_genode.h index 9035755cb..069c2009e 100644 --- a/repos/libports/include/SDL/SDL_config_genode.h +++ b/repos/libports/include/SDL/SDL_config_genode.h @@ -53,8 +53,8 @@ /* Enable thread support */ #define SDL_THREAD_PTHREAD 1 -/* Enable dummy timer support */ -#define SDL_TIMER_DUMMY 1 +/* Enable timer support */ +#define SDL_TIMER_UNIX 1 /* Enable video drivers */ #define SDL_VIDEO_DRIVER_GENODE_FB 1 diff --git a/repos/libports/lib/mk/sdl.mk b/repos/libports/lib/mk/sdl.mk index 18b3143d9..50aec58c9 100644 --- a/repos/libports/lib/mk/sdl.mk +++ b/repos/libports/lib/mk/sdl.mk @@ -14,7 +14,6 @@ INC_DIR += $(SDL_PORT_DIR)/include/SDL SRC_CC = video/SDL_genode_fb_video.cc \ video/SDL_genode_fb_events.cc \ audio/SDL_genodeaudio.cc \ - timer/SDL_systimer.cc \ loadso/SDL_loadso.cc INC_DIR += $(REP_DIR)/include/SDL \ @@ -45,7 +44,8 @@ INC_DIR += $(SDL_DIR)/src/thread SRC_C += cpuinfo/SDL_cpuinfo.c # timer subsystem -SRC_C += timer/SDL_timer.c +SRC_C += timer/SDL_timer.c \ + timer/unix/SDL_systimer.c INC_DIR += $(SDL_DIR)/src/timer # video subsystem diff --git a/repos/libports/src/lib/sdl/timer/SDL_systimer.cc b/repos/libports/src/lib/sdl/timer/SDL_systimer.cc deleted file mode 100644 index af40044d6..000000000 --- a/repos/libports/src/lib/sdl/timer/SDL_systimer.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* - * \brief Genode-specific timer backend - * \author Christian Prochaska - * \date 2012-03-13 - * - * based on the dummy SDL timer - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#include - -extern "C" { - -#include - -#include "SDL_config.h" - -#include "SDL_timer.h" -#include "SDL_timer_c.h" - - -static unsigned long start_ms = 0; - -static Timer::Connection _timer; - - -void SDL_StartTicks(void) -{ - start_ms = _timer.elapsed_ms(); -} - - -Uint32 SDL_GetTicks (void) -{ - return _timer.elapsed_ms() - start_ms; -} - - -void SDL_Delay (Uint32 ms) -{ - _timer.msleep(ms); -} - - -#include "SDL_thread.h" - - -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static SDL_Thread *timer = NULL; - -static int RunTimer(void *unused) -{ - while ( timer_alive ) { - if ( SDL_timer_running ) { - SDL_ThreadedTimerCheck(); - } - SDL_Delay(1); - } - return(0); -} - - -/* This is only called if the event thread is not running */ -int SDL_SYS_TimerInit(void) -{ - timer_alive = 1; - timer = SDL_CreateThread(RunTimer, NULL); - if ( timer == NULL ) - return(-1); - return(SDL_SetTimerThreaded(1)); -} - - -void SDL_SYS_TimerQuit(void) -{ - timer_alive = 0; - if ( timer ) { - SDL_WaitThread(timer, NULL); - timer = NULL; - } -} - - -int SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: threaded timer in use"); - return(-1); -} - - -void SDL_SYS_StopTimer(void) -{ - return; -} - -}