From 7c3f2fd6c7500e4841a76fa3eec6611f0f40120b Mon Sep 17 00:00:00 2001 From: prife Date: Tue, 22 Jan 2013 15:49:49 +0800 Subject: [PATCH] fix sdl_fb.c to support gcc under linux --- bsp/simlinux/drivers/sdl_fb.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/bsp/simlinux/drivers/sdl_fb.c b/bsp/simlinux/drivers/sdl_fb.c index 790797f2af..752a6fb93c 100755 --- a/bsp/simlinux/drivers/sdl_fb.c +++ b/bsp/simlinux/drivers/sdl_fb.c @@ -1,6 +1,10 @@ #include +#ifdef _WIN32 #include +#else +#include +#endif #include #include @@ -104,7 +108,7 @@ static void sdlfb_hw_init(void) //_putenv("SDL_VIDEODRIVER=windib"); //if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0) - if (SDL_Init(SDL_INIT_EVERYTHING) < 0) + if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); @@ -132,16 +136,24 @@ static void sdlfb_hw_init(void) sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO); } +#ifdef _WIN32 #include #include +#else +#include +#endif + #include -#include #include #include #include #include +#ifdef _WIN32 static DWORD WINAPI sdl_loop(LPVOID lpParam) +#else +static void *sdl_loop(void *lpParam) +#endif { int quit = 0; SDL_Event event; @@ -284,6 +296,7 @@ static DWORD WINAPI sdl_loop(LPVOID lpParam) /* start sdl thread */ void rt_hw_sdl_start(void) { +#ifdef _WIN32 HANDLE thread; DWORD thread_id; @@ -301,4 +314,15 @@ void rt_hw_sdl_start(void) return; } ResumeThread(thread); +#else + /* Linux */ + pthread_t pid; + int res; + res = pthread_create(&pid, NULL, &sdl_loop, NULL); + if (res) + { + printf("pthread create sdl thread faild, <%d>\n", res); + exit(EXIT_FAILURE); + } +#endif }