]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added Sys_PrintfToTerminal function for convenience, this replaces
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Oct 2011 08:31:10 +0000 (08:31 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Oct 2011 08:31:10 +0000 (08:31 +0000)
printf in a few places
changed SV_LockThreadMutex and SV_UnlockThreadMutex to macros so they
get the filename and line number for THREADDEBUG prints
fixed multiple recursive mutex locks in the console system so glx client
works again

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11471 d7cf8633-e32d-0410-b094-e92efae38249

13 files changed:
cl_input.c
cmd.c
console.c
host.c
server.h
sv_main.c
sys.h
sys_shared.c
thread_null.c
thread_pthread.c
thread_sdl.c
thread_win.c
vid_agl.c

index 6959b14f44394df66d11d557359012b13cd037b6..41c93080021108dd774764d1939d1db2fa1604be 100644 (file)
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 #include "csprogs.h"
 
 #include "quakedef.h"
 #include "csprogs.h"
+#include "thread.h"
 
 /*
 ===============================================================================
 
 /*
 ===============================================================================
diff --git a/cmd.c b/cmd.c
index d2d688f8c16a571320fa9b544ee6dd5180f17056..8efe3dc9a0e69290ebf36383366b94ed89130b1f 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -176,25 +176,9 @@ static void Cmd_Centerprint_f (void)
 static sizebuf_t       cmd_text;
 static unsigned char           cmd_text_buf[CMDBUFSIZE];
 void *cmd_text_mutex = NULL;
 static sizebuf_t       cmd_text;
 static unsigned char           cmd_text_buf[CMDBUFSIZE];
 void *cmd_text_mutex = NULL;
-qboolean cmd_text_mutex_locked = false;
 
 
-static void Cbuf_LockThreadMutex(void)
-{
-       if (cmd_text_mutex)
-       {
-               Thread_LockMutex(cmd_text_mutex);
-               cmd_text_mutex_locked = true;
-       }
-}
-
-static void Cbuf_UnlockThreadMutex(void)
-{
-       if (cmd_text_mutex)
-       {
-               cmd_text_mutex_locked = false;
-               Thread_UnlockMutex(cmd_text_mutex);
-       }
-}
+#define Cbuf_LockThreadMutex() (cmd_text_mutex ? Thread_LockMutex(cmd_text_mutex),1 : 0)
+#define Cbuf_UnlockThreadMutex() (cmd_text_mutex ? Thread_UnlockMutex(cmd_text_mutex),1 : 0)
 
 /*
 ============
 
 /*
 ============
@@ -213,7 +197,7 @@ void Cbuf_AddText (const char *text)
        if (cmd_text.cursize + l >= cmd_text.maxsize)
                Con_Print("Cbuf_AddText: overflow\n");
        else
        if (cmd_text.cursize + l >= cmd_text.maxsize)
                Con_Print("Cbuf_AddText: overflow\n");
        else
-               SZ_Write(&cmd_text, (const unsigned char *)text, (int)strlen (text));
+               SZ_Write(&cmd_text, (const unsigned char *)text, l);
        Cbuf_UnlockThreadMutex();
 }
 
        Cbuf_UnlockThreadMutex();
 }
 
@@ -229,32 +213,18 @@ FIXME: actually change the command buffer to do less copying
 */
 void Cbuf_InsertText (const char *text)
 {
 */
 void Cbuf_InsertText (const char *text)
 {
-       char    *temp;
-       int             templen;
-
+       size_t l = strlen(text);
        Cbuf_LockThreadMutex();
        Cbuf_LockThreadMutex();
-
-       // copy off any commands still remaining in the exec buffer
-       templen = cmd_text.cursize;
-       if (templen)
-       {
-               temp = (char *)Mem_Alloc (tempmempool, templen);
-               memcpy (temp, cmd_text.data, templen);
-               SZ_Clear (&cmd_text);
-       }
+       // we need to memmove the existing text and stuff this in before it...
+       if (cmd_text.cursize + l >= (size_t)cmd_text.maxsize)
+               Con_Print("Cbuf_InsertText: overflow\n");
        else
        else
-               temp = NULL;
-
-       // add the entire text of the file
-       Cbuf_AddText (text);
-
-       // add the copied off data
-       if (temp != NULL)
        {
        {
-               SZ_Write (&cmd_text, (const unsigned char *)temp, templen);
-               Mem_Free (temp);
+               // we don't have a SZ_Prepend, so...
+               memmove(cmd_text.data + l, cmd_text.data, cmd_text.cursize);
+               cmd_text.cursize += l;
+               memcpy(cmd_text.data, text, l);
        }
        }
-
        Cbuf_UnlockThreadMutex();
 }
 
        Cbuf_UnlockThreadMutex();
 }
 
@@ -316,9 +286,6 @@ void Cbuf_Execute (void)
        qboolean quotes;
        char *comment;
 
        qboolean quotes;
        char *comment;
 
-       SV_LockThreadMutex();
-       Cbuf_LockThreadMutex();
-
        // LordHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes
        cmd_tokenizebufferpos = 0;
 
        // LordHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes
        cmd_tokenizebufferpos = 0;
 
@@ -409,9 +376,6 @@ void Cbuf_Execute (void)
                        break;
                }
        }
                        break;
                }
        }
-
-       SV_UnlockThreadMutex();
-       Cbuf_UnlockThreadMutex();
 }
 
 /*
 }
 
 /*
@@ -1701,8 +1665,6 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src, qboolean lockmutex)
        cmd_function_t *cmd;
        cmdalias_t *a;
 
        cmd_function_t *cmd;
        cmdalias_t *a;
 
-       if (lockmutex)
-               Cbuf_LockThreadMutex();
        oldpos = cmd_tokenizebufferpos;
        cmd_source = src;
        found = false;
        oldpos = cmd_tokenizebufferpos;
        cmd_source = src;
        found = false;
@@ -1778,8 +1740,6 @@ command_found:
 
 done:
        cmd_tokenizebufferpos = oldpos;
 
 done:
        cmd_tokenizebufferpos = oldpos;
-       if (lockmutex)
-               Cbuf_UnlockThreadMutex();
 }
 
 
 }
 
 
index 537cdc72019ced668af841aa9e8fbed16c153b2b..769ae2f6adfff44981d27f9af678f5784615fcd8 100644 (file)
--- a/console.c
+++ b/console.c
@@ -814,7 +814,6 @@ static void Con_PrintToHistory(const char *txt, int mask)
        if(!con.text) // FIXME uses a non-abstracted property of con
                return;
 
        if(!con.text) // FIXME uses a non-abstracted property of con
                return;
 
-       if (con_mutex) Thread_LockMutex(con_mutex);
        for(; *txt; ++txt)
        {
                if(cr_pending)
        for(; *txt; ++txt)
        {
                if(cr_pending)
@@ -845,7 +844,6 @@ static void Con_PrintToHistory(const char *txt, int mask)
                                break;
                }
        }
                                break;
                }
        }
-       if (con_mutex) Thread_UnlockMutex(con_mutex);
 }
 
 /*! The translation table between the graphical font and plain ASCII  --KB */
 }
 
 /*! The translation table between the graphical font and plain ASCII  --KB */
@@ -1535,7 +1533,7 @@ static float Con_WordWidthFunc(void *passthrough, const char *w, size_t *length,
                return DrawQ_TextWidth(w, *length, ti->fontsize, ti->fontsize, false, ti->font);
        else
        {
                return DrawQ_TextWidth(w, *length, ti->fontsize, ti->fontsize, false, ti->font);
        else
        {
-               printf("Con_WordWidthFunc: can't get here (maxWidth should never be %f)\n", maxWidth);
+               Sys_PrintfToTerminal("Con_WordWidthFunc: can't get here (maxWidth should never be %f)\n", maxWidth);
                // Note: this is NOT a Con_Printf, as it could print recursively
                return 0;
        }
                // Note: this is NOT a Con_Printf, as it could print recursively
                return 0;
        }
diff --git a/host.c b/host.c
index 88eed4bde5161cff7c3be4c527c15d4ad895397a..d316fcc4e193201a6666b0e10765b4a1678e69f0 100644 (file)
--- a/host.c
+++ b/host.c
@@ -755,11 +755,13 @@ void Host_Main(void)
                // otherwise we execute them on client frames
                if (sv.active ? sv_timer > 0 : cl_timer > 0)
                {
                // otherwise we execute them on client frames
                if (sv.active ? sv_timer > 0 : cl_timer > 0)
                {
+                       SV_LockThreadMutex();
                        // process console commands
 //                     R_TimeReport("preconsole");
                        CL_VM_PreventInformationLeaks();
                        Cbuf_Execute();
 //                     R_TimeReport("console");
                        // process console commands
 //                     R_TimeReport("preconsole");
                        CL_VM_PreventInformationLeaks();
                        Cbuf_Execute();
 //                     R_TimeReport("console");
+                       SV_UnlockThreadMutex();
                }
 
                //Con_Printf("%6.0f %6.0f\n", cl_timer * 1000000.0, sv_timer * 1000000.0);
                }
 
                //Con_Printf("%6.0f %6.0f\n", cl_timer * 1000000.0, sv_timer * 1000000.0);
@@ -1312,6 +1314,10 @@ void Host_Shutdown(void)
        // be quiet while shutting down
        S_StopAllSounds();
 
        // be quiet while shutting down
        S_StopAllSounds();
 
+       // end the server thread
+       if (svs.threaded)
+               SV_StopThread();
+
        // disconnect client from server if active
        CL_Disconnect();
 
        // disconnect client from server if active
        CL_Disconnect();
 
@@ -1320,10 +1326,6 @@ void Host_Shutdown(void)
        Host_ShutdownServer ();
        SV_UnlockThreadMutex();
 
        Host_ShutdownServer ();
        SV_UnlockThreadMutex();
 
-       // end the server thread
-       if (svs.threaded)
-               SV_StopThread();
-
        // Shutdown menu
        if(MR_Shutdown)
                MR_Shutdown();
        // Shutdown menu
        if(MR_Shutdown)
                MR_Shutdown();
index 64153e565c4adeba6e163acaa7d599a10bef0284..5d399607ca1ea7717ded40dce8dbd944f0e160a3 100644 (file)
--- a/server.h
+++ b/server.h
@@ -589,8 +589,8 @@ void SV_GetEntityMatrix(prvm_prog_t *prog, prvm_edict_t *ent, matrix4x4_t *out,
 
 void SV_StartThread(void);
 void SV_StopThread(void);
 
 void SV_StartThread(void);
 void SV_StopThread(void);
-void SV_LockThreadMutex(void);
-void SV_UnlockThreadMutex(void);
+#define SV_LockThreadMutex() (svs.threaded ? Thread_LockMutex(svs.threadmutex),1 : 0)
+#define SV_UnlockThreadMutex() (svs.threaded ? Thread_UnlockMutex(svs.threadmutex),1 : 0)
 
 void VM_CustomStats_Clear(void);
 void VM_SV_UpdateCustomStats(client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
 
 void VM_CustomStats_Clear(void);
 void VM_SV_UpdateCustomStats(client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
index 26d856950a1e7ac76e50fe26b4f69b3a5ebd3bd9..c99273b1add0f9a448ba8e24f3a3c7de40d58be9 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -4009,15 +4009,3 @@ void SV_StopThread(void)
        Thread_DestroyMutex(svs.threadmutex);
        svs.threaded = false;
 }
        Thread_DestroyMutex(svs.threadmutex);
        svs.threaded = false;
 }
-
-void SV_LockThreadMutex(void)
-{
-       if (svs.threaded)
-               Thread_LockMutex(svs.threadmutex);
-}
-
-void SV_UnlockThreadMutex(void)
-{
-       if (svs.threaded)
-               Thread_UnlockMutex(svs.threadmutex);
-}
diff --git a/sys.h b/sys.h
index 908c9e5f2f5509d9f1a0a55dfb2ef7309ee7eac6..913b3cdbeed430b7c948734abb0f7a2c497f2f3d 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -72,6 +72,7 @@ void Sys_Error (const char *error, ...) DP_FUNC_PRINTF(1);
 
 /// (may) output text to terminal which launched program
 void Sys_PrintToTerminal(const char *text);
 
 /// (may) output text to terminal which launched program
 void Sys_PrintToTerminal(const char *text);
+void Sys_PrintfToTerminal(const char *fmt, ...);
 
 /// INFO: This is only called by Host_Shutdown so we dont need testing for recursion
 void Sys_Shutdown (void);
 
 /// INFO: This is only called by Host_Shutdown so we dont need testing for recursion
 void Sys_Shutdown (void);
index 34fd2f7ae6098feaf904f51d573f46ee5be4259d..cb826f17b6a53dd0e04af91249459479ece8b450 100644 (file)
@@ -434,10 +434,22 @@ void Sys_Sleep(int microseconds)
        if(sys_debugsleep.integer)
        {
                t = Sys_DirtyTime() - t;
        if(sys_debugsleep.integer)
        {
                t = Sys_DirtyTime() - t;
-               printf("%d %d # debugsleep\n", microseconds, (unsigned int)(t * 1000000));
+               Sys_PrintfToTerminal("%d %d # debugsleep\n", microseconds, (unsigned int)(t * 1000000));
        }
 }
 
        }
 }
 
+void Sys_PrintfToTerminal(const char *fmt, ...)
+{
+       va_list argptr;
+       char msg[MAX_INPUTLINE];
+
+       va_start(argptr,fmt);
+       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
+       va_end(argptr);
+
+       Sys_PrintToTerminal(msg);
+}
+
 static const char *Sys_FindInPATH(const char *name, char namesep, const char *PATH, char pathsep, char *buf, size_t bufsize)
 {
        const char *p = PATH;
 static const char *Sys_FindInPATH(const char *name, char namesep, const char *PATH, char pathsep, char *buf, size_t bufsize)
 {
        const char *p = PATH;
index 8a75e2461a4641f5f62fd76fb75a9f1a8f60ed96..58b22bd57f567c0fa600344226d7659b35f68fd8 100644 (file)
@@ -18,7 +18,7 @@ qboolean Thread_HasThreads(void)
 void *_Thread_CreateMutex(const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 void *_Thread_CreateMutex(const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p create %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p create %s:%i\n" , mutex, filename, fileline);
 #endif
        return NULL;
 }
 #endif
        return NULL;
 }
@@ -26,14 +26,14 @@ void *_Thread_CreateMutex(const char *filename, int fileline)
 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p destroy %s:%i\n", mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p destroy %s:%i\n", mutex, filename, fileline);
 #endif
 }
 
 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 #endif
 }
 
 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p lock %s:%i\n"   , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p lock %s:%i\n"   , mutex, filename, fileline);
 #endif
        return -1;
 }
 #endif
        return -1;
 }
@@ -41,7 +41,7 @@ int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p unlock %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p unlock %s:%i\n" , mutex, filename, fileline);
 #endif
        return -1;
 }
 #endif
        return -1;
 }
index 69558da5cb959411c2c145a4a3092d92dd333dfe..c9a1166331b3a52f6de3d17ba0dd1485119c31a0 100644 (file)
@@ -21,7 +21,7 @@ void *_Thread_CreateMutex(const char *filename, int fileline)
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) Z_Malloc(sizeof(pthread_mutex_t));
 #ifdef THREADDEBUG
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) Z_Malloc(sizeof(pthread_mutex_t));
 #ifdef THREADDEBUG
-       printf("%p create %s:%i\n" , mutexp, filename, fileline);
+       Sys_PrintfToTerminal("%p create %s:%i\n" , mutexp, filename, fileline);
 #endif
        pthread_mutex_init(mutexp, NULL);
        return mutexp;
 #endif
        pthread_mutex_init(mutexp, NULL);
        return mutexp;
@@ -31,7 +31,7 @@ void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
 #ifdef THREADDEBUG
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
 #ifdef THREADDEBUG
-       printf("%p destroy %s:%i\n", mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p destroy %s:%i\n", mutex, filename, fileline);
 #endif
        pthread_mutex_destroy(mutexp);
        Z_Free(mutexp);
 #endif
        pthread_mutex_destroy(mutexp);
        Z_Free(mutexp);
@@ -41,7 +41,7 @@ int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
 #ifdef THREADDEBUG
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
 #ifdef THREADDEBUG
-       printf("%p lock %s:%i\n"   , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p lock %s:%i\n"   , mutex, filename, fileline);
 #endif
        return pthread_mutex_lock(mutexp);
 }
 #endif
        return pthread_mutex_lock(mutexp);
 }
@@ -50,7 +50,7 @@ int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
 #ifdef THREADDEBUG
 {
        pthread_mutex_t *mutexp = (pthread_mutex_t *) mutex;
 #ifdef THREADDEBUG
-       printf("%p unlock %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p unlock %s:%i\n" , mutex, filename, fileline);
 #endif
        return pthread_mutex_unlock(mutexp);
 }
 #endif
        return pthread_mutex_unlock(mutexp);
 }
index d857445a1a4a07b4492418e8d288ace4e842cae0..f817c9879140654ba0ecf6a53c32926204f33674 100644 (file)
@@ -21,7 +21,7 @@ void *_Thread_CreateMutex(const char *filename, int fileline)
 {
        void *mutex = SDL_CreateMutex();
 #ifdef THREADDEBUG
 {
        void *mutex = SDL_CreateMutex();
 #ifdef THREADDEBUG
-       printf("%p create %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p create %s:%i\n" , mutex, filename, fileline);
 #endif
        return mutex;
 }
 #endif
        return mutex;
 }
@@ -29,7 +29,7 @@ void *_Thread_CreateMutex(const char *filename, int fileline)
 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p destroy %s:%i\n", mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p destroy %s:%i\n", mutex, filename, fileline);
 #endif
        SDL_DestroyMutex((SDL_mutex *)mutex);
 }
 #endif
        SDL_DestroyMutex((SDL_mutex *)mutex);
 }
@@ -37,7 +37,7 @@ void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p lock %s:%i\n"   , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p lock %s:%i\n"   , mutex, filename, fileline);
 #endif
        return SDL_LockMutex((SDL_mutex *)mutex);
 }
 #endif
        return SDL_LockMutex((SDL_mutex *)mutex);
 }
@@ -45,7 +45,7 @@ int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p unlock %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p unlock %s:%i\n" , mutex, filename, fileline);
 #endif
        return SDL_UnlockMutex((SDL_mutex *)mutex);
 }
 #endif
        return SDL_UnlockMutex((SDL_mutex *)mutex);
 }
index a882f80d00f14d1f7df1deec61a4a82ed08863c3..a6ae7b3c13b6957488d82b161c1673b0751bc33a 100644 (file)
@@ -20,7 +20,7 @@ void *_Thread_CreateMutex(const char *filename, int fileline)
 {
        void *mutex = (void *)CreateMutex(NULL, FALSE, NULL);
 #ifdef THREADDEBUG
 {
        void *mutex = (void *)CreateMutex(NULL, FALSE, NULL);
 #ifdef THREADDEBUG
-       printf("%p create %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p create %s:%i\n" , mutex, filename, fileline);
 #endif
        return mutex;
 }
 #endif
        return mutex;
 }
@@ -28,7 +28,7 @@ void *_Thread_CreateMutex(const char *filename, int fileline)
 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p destroy %s:%i\n", mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p destroy %s:%i\n", mutex, filename, fileline);
 #endif
        CloseHandle(mutex);
 }
 #endif
        CloseHandle(mutex);
 }
@@ -36,7 +36,7 @@ void _Thread_DestroyMutex(void *mutex, const char *filename, int fileline)
 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p lock %s:%i\n"   , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p lock %s:%i\n"   , mutex, filename, fileline);
 #endif
        return (WaitForSingleObject(mutex, INFINITE) == WAIT_FAILED) ? -1 : 0;
 }
 #endif
        return (WaitForSingleObject(mutex, INFINITE) == WAIT_FAILED) ? -1 : 0;
 }
@@ -44,7 +44,7 @@ int _Thread_LockMutex(void *mutex, const char *filename, int fileline)
 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
 int _Thread_UnlockMutex(void *mutex, const char *filename, int fileline)
 {
 #ifdef THREADDEBUG
-       printf("%p unlock %s:%i\n" , mutex, filename, fileline);
+       Sys_PrintfToTerminal("%p unlock %s:%i\n" , mutex, filename, fileline);
 #endif
        return (ReleaseMutex(mutex) == FALSE) ? -1 : 0;
 }
 #endif
        return (ReleaseMutex(mutex) == FALSE) ? -1 : 0;
 }
index d21ffc063193ab1078fc0f3c9624fae4bf358e4f..87559d36f19a980d4cf2b7f1336af3f9959087e5 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -312,7 +312,7 @@ int VID_GetGamma(unsigned short *ramps, int rampsize)
 
 void signal_handler(int sig)
 {
 
 void signal_handler(int sig)
 {
-       printf("Received signal %d, exiting...\n", sig);
+       Sys_PrintfToTerminal("Received signal %d, exiting...\n", sig);
        VID_RestoreSystemGamma();
        Sys_Quit(1);
 }
        VID_RestoreSystemGamma();
        Sys_Quit(1);
 }