diff options
| author | prife <[email protected]> | 2013-01-22 15:49:49 +0800 |
|---|---|---|
| committer | prife <[email protected]> | 2013-01-22 15:49:49 +0800 |
| commit | 7c3f2fd6c7500e4841a76fa3eec6611f0f40120b (patch) | |
| tree | 6094e37e0c0c11ffa1b2d7f2cc0755c4fa7c01a7 /bsp | |
| parent | 236099e3ecfa3636050a2131ab93b736be881e97 (diff) | |
fix sdl_fb.c to support gcc under linux
Diffstat (limited to 'bsp')
| -rwxr-xr-x | bsp/simlinux/drivers/sdl_fb.c | 28 |
1 files 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 <rtthread.h> +#ifdef _WIN32 #include <sdl.h> +#else +#include <SDL/SDL.h> +#endif #include <rtdevice.h> #include <rtgui/driver.h> @@ -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 <windows.h> #include <mmsystem.h> +#else +#include <pthread.h> +#endif + #include <stdio.h> -#include <sdl.h> #include <rtgui/event.h> #include <rtgui/kbddef.h> #include <rtgui/rtgui_server.h> #include <rtgui/rtgui_system.h> +#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 } |
