From 412c201eca5db1f4b585bb21dbd518355e27f4fb Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 14 May 2010 16:36:24 +0200 Subject: [PATCH] Move thread-sdl.[ch] into the target tree. --- firmware/SOURCES | 1 + firmware/target/hosted/sdl/system-sdl.c | 6 +++--- {uisimulator => firmware/target/hosted}/sdl/thread-sdl.c | 8 ++++---- {uisimulator => firmware/target/hosted}/sdl/thread-sdl.h | 15 +++++---------- uisimulator/common/io.c | 4 ++-- uisimulator/sdl/SOURCES | 1 - uisimulator/sdl/timefuncs.h | 7 ------- uisimulator/uisimulator.make | 6 ++---- 8 files changed, 17 insertions(+), 31 deletions(-) rename {uisimulator => firmware/target/hosted}/sdl/thread-sdl.c (99%) rename {uisimulator => firmware/target/hosted}/sdl/thread-sdl.h (69%) delete mode 100644 uisimulator/sdl/timefuncs.h diff --git a/firmware/SOURCES b/firmware/SOURCES index 60a3661cd..b9611e0cb 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -21,6 +21,7 @@ timer.c #ifdef HAVE_SDL target/hosted/sdl/kernel-sdl.c target/hosted/sdl/system-sdl.c +target/hosted/sdl/thread-sdl.c target/hosted/sdl/timer-sdl.c #endif panic.c diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c index bc3e34054..c4e5d85d6 100644 --- a/firmware/target/hosted/sdl/system-sdl.c +++ b/firmware/target/hosted/sdl/system-sdl.c @@ -65,7 +65,7 @@ void sys_poweroff(void) { /* Order here is relevent to prevent deadlocks and use of destroyed sync primitives by kernel threads */ - thread_sdl_shutdown(); + sim_thread_shutdown(); sim_kernel_shutdown(); SDL_Quit(); } @@ -130,12 +130,12 @@ void system_init(void) void system_exception_wait(void) { - thread_sdl_exception_wait(); + sim_thread_exception_wait(); } void system_reboot(void) { - thread_sdl_exception_wait(); + sim_thread_exception_wait(); } void sys_handle_argv(int argc, char *argv[]) diff --git a/uisimulator/sdl/thread-sdl.c b/firmware/target/hosted/sdl/thread-sdl.c similarity index 99% rename from uisimulator/sdl/thread-sdl.c rename to firmware/target/hosted/sdl/thread-sdl.c index 46c1e9883..fbe2621d4 100644 --- a/uisimulator/sdl/thread-sdl.c +++ b/firmware/target/hosted/sdl/thread-sdl.c @@ -64,7 +64,7 @@ static volatile bool threads_exit = false; extern long start_tick; -void thread_sdl_shutdown(void) +void sim_thread_shutdown(void) { int i; @@ -177,7 +177,7 @@ void init_threads(void) return; } -void thread_sdl_exception_wait(void) +void sim_thread_exception_wait(void) { while (1) { @@ -188,7 +188,7 @@ void thread_sdl_exception_wait(void) } /* A way to yield and leave the threading system for extended periods */ -void thread_sdl_thread_lock(void *me) +void sim_thread_lock(void *me) { SDL_LockMutex(m); cores[CURRENT_CORE].running = (struct thread_entry *)me; @@ -197,7 +197,7 @@ void thread_sdl_thread_lock(void *me) thread_exit(); } -void * thread_sdl_thread_unlock(void) +void * sim_thread_unlock(void) { struct thread_entry *current = cores[CURRENT_CORE].running; SDL_UnlockMutex(m); diff --git a/uisimulator/sdl/thread-sdl.h b/firmware/target/hosted/sdl/thread-sdl.h similarity index 69% rename from uisimulator/sdl/thread-sdl.h rename to firmware/target/hosted/sdl/thread-sdl.h index f221aa5a7..9384e6060 100644 --- a/uisimulator/sdl/thread-sdl.h +++ b/firmware/target/hosted/sdl/thread-sdl.h @@ -22,16 +22,11 @@ #ifndef __THREADSDL_H__ #define __THREADSDL_H__ -#include "SDL_thread.h" - -extern SDL_Thread *gui_thread; /* The "main" thread */ -void thread_sdl_thread_lock(void *me); -void * thread_sdl_thread_unlock(void); -void thread_sdl_exception_wait(void); -bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */ -void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */ -void thread_sdl_lock(void); /* Sync with SDL threads */ -void thread_sdl_unlock(void); /* Sync with SDL threads */ +/* extra thread functions that only apply when running on hosting platforms */ +void sim_thread_lock(void *me); +void * sim_thread_unlock(void); +void sim_thread_exception_wait(void); +void sim_thread_shutdown(void); /* Shut down all kernel threads gracefully */ #endif /* #ifndef __THREADSDL_H__ */ diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index cddb19c9a..bdcc7e6ca 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c @@ -233,7 +233,7 @@ static ssize_t io_trigger_and_wait(int cmd) { /* Allow other rockbox threads to run */ io.accum = 0; - mythread = thread_sdl_thread_unlock(); + mythread = sim_thread_unlock(); } switch (cmd) @@ -249,7 +249,7 @@ static ssize_t io_trigger_and_wait(int cmd) /* Regain our status as current */ if (mythread != NULL) { - thread_sdl_thread_lock(mythread); + sim_thread_lock(mythread); } return result; diff --git a/uisimulator/sdl/SOURCES b/uisimulator/sdl/SOURCES index be9a7a4c0..19d97181d 100644 --- a/uisimulator/sdl/SOURCES +++ b/uisimulator/sdl/SOURCES @@ -8,4 +8,3 @@ lcd-charcells.c lcd-remote-bitmap.c #endif lcd-sdl.c -thread-sdl.c diff --git a/uisimulator/sdl/timefuncs.h b/uisimulator/sdl/timefuncs.h deleted file mode 100644 index de17fcdc7..000000000 --- a/uisimulator/sdl/timefuncs.h +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -/* struct tm defined */ -struct tm *get_time(void); -int set_time(const struct tm *tm); -bool valid_time(const struct tm *tm); diff --git a/uisimulator/uisimulator.make b/uisimulator/uisimulator.make index 121f31e0f..05b973f60 100644 --- a/uisimulator/uisimulator.make +++ b/uisimulator/uisimulator.make @@ -8,11 +8,9 @@ # INCLUDES += -I$(ROOTDIR)/uisimulator/sdl -I$(ROOTDIR)/uisimulator/common \ + -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) -SIMINCLUDES += -I$(ROOTDIR)/uisimulator/sdl -I$(ROOTDIR)/uisimulator/common \ - -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) - -SIMFLAGS += $(SIMINCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) +SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) SIMSRC += $(call preprocess, $(ROOTDIR)/uisimulator/sdl/SOURCES) SIMSRC += $(call preprocess, $(ROOTDIR)/uisimulator/common/SOURCES) -- 2.11.4.GIT