Mercurial > sdl-ios-xcode
view test/testlock.c @ 1169:4b3e2294782d
Date: Sun, 06 Nov 2005 18:23:03 +0900
From: Hayashi Naoyuki <titan@culzean.org>
To: "A list for developers using the SDL library. \(includes SDL-announce\)" <sdl@libsdl.org>
Subject: Re: [SDL] Dynamic X11...
1. Compilation produce the following error on Tru64 UNIX.
cc: Severe: SDL_x11dyn.h, line 31: Cannot find file
<X11/extensions/extutil.h> specified in #include directive. (noinclfilef)
#include <X11/extensions/extutil.h>
Because Tru64 UNIX doesn't have extutil.h, this error is caused.
2. Compilation with --enable-x11-shared=no produce the following error.
cc: Error: SDL_x11sym.h, line 115: In this statement,
"Xutf8TextListToTextProperty" is not declared. (undeclared)
SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display*,char**,int,XICCEncodingStyle,XTextProperty*))
Though it doesn't have Xutf8TextListToTextProperty,
"pXutf8TextListToTextProperty = Xutf8TextListToTextProperty;"
in SDL_x11dyn.c,117-119
#define SDL_X11_SYM(r,fn,arg) p##fn = fn;
#include "SDL_x11sym.h"
#undef SDL_X11_SYM
-- Hayashi Naoyuki Key fingerprint = 60A0 D5D3 F58B 3633 2E52 0147 D17F 5578 3FDF F5B6
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 06 Nov 2005 17:05:12 +0000 |
parents | be9c9c8f6d53 |
children | 14717b52abc0 |
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 <stdlib.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]; /* * 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) { printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); raise(SIGTERM); } void closemutex(int sig) { Uint32 id = SDL_ThreadID(); int i; printf("Process %u: Cleaning up...\n", id == mainthread ? 0 : id); for ( i=0; i<6; ++i ) SDL_KillThread(threads[i]); SDL_DestroyMutex(mutex); exit(sig); } int Run(void *data) { if ( SDL_ThreadID() == mainthread ) signal(SIGTERM, closemutex); while ( 1 ) { 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); } 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 */ }