Mercurial > sdl-ios-xcode
view test/testlock.c @ 3380:6f381d0d6394
stefanullinger to me
I updated and wanted to compile SDL, but it does not work.
The reason is the new pre-build step.
Currently it says:
"if exist $(SolutionDir)\..\include\SDL_config.h goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy $(SolutionDir)\..\include\SDL_config_win32.h $(SolutionDir)\..\include\SDL_config.h
:SDLCONFIGOKAY
if exist $(SolutionDir)\..\include\SDL_revision.h goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >$(SolutionDir)\..\include\SDL_revision.h
:SDLREVISIONOKAY"
So ... the problem with this lines is, that they lookup the SolutionDir...
I think it should use the ProjectDir here!
I - for example - want to use SDL within my engine...
So my engine is the solutionDir...not SDL...SDL is just a sub-project.
I think you should change this, shouldn't you?!
Regards,
Stefan
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 11 Oct 2009 10:22:22 +0000 |
parents | 4436464c4f51 |
children | 0d1b16ee0bca |
line wrap: on
line source
/* Test the thread and mutex locking functions Also exercises the system's signal/thread interaction */ #include <signal.h> #include <stdio.h> #include "SDL.h" #include "SDL_mutex.h" #include "SDL_thread.h" static SDL_mutex *mutex = NULL; static Uint32 mainthread; static SDL_Thread *threads[6]; static volatile int doterminate = 0; /* * SDL_Quit() shouldn't be used with atexit() directly because * calling conventions may differ... */ static void SDL_Quit_Wrapper(void) { SDL_Quit(); } void printid(void) { printf("Process %u: exiting\n", SDL_ThreadID()); } void terminate(int sig) { signal(SIGINT, terminate); doterminate = 1; } void closemutex(int sig) { Uint32 id = SDL_ThreadID(); int i; printf("Process %u: Cleaning up...\n", id == mainthread ? 0 : id); doterminate = 1; for (i = 0; i < 6; ++i) SDL_WaitThread(threads[i], NULL); SDL_DestroyMutex(mutex); exit(sig); } int SDLCALL Run(void *data) { if (SDL_ThreadID() == mainthread) signal(SIGTERM, closemutex); while (!doterminate) { printf("Process %u ready to work\n", SDL_ThreadID()); if (SDL_mutexP(mutex) < 0) { fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); exit(1); } printf("Process %u, working!\n", SDL_ThreadID()); SDL_Delay(1 * 1000); printf("Process %u, done!\n", SDL_ThreadID()); if (SDL_mutexV(mutex) < 0) { fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError()); exit(1); } /* If this sleep isn't done, then threads may starve */ SDL_Delay(10); } if (SDL_ThreadID() == mainthread && doterminate) { printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); raise(SIGTERM); } return (0); } int main(int argc, char *argv[]) { int i; int maxproc = 6; /* Load the SDL library */ if (SDL_Init(0) < 0) { fprintf(stderr, "%s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit_Wrapper); if ((mutex = SDL_CreateMutex()) == NULL) { fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError()); exit(1); } mainthread = SDL_ThreadID(); printf("Main thread: %u\n", mainthread); atexit(printid); for (i = 0; i < maxproc; ++i) { if ((threads[i] = SDL_CreateThread(Run, NULL)) == NULL) fprintf(stderr, "Couldn't create thread!\n"); } signal(SIGINT, terminate); Run(NULL); return (0); /* Never reached */ }