mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-05 08:51:28 +00:00
[sys] Use a jump buffer to exit to main
This allows tracy to clean up properly. However, Sys_Quit will use the jump buffer (sys_exit_jmpbuf) only if it has been set, so the use of Sys_setjmp is optional.
This commit is contained in:
parent
df51e1a18d
commit
d908016606
10 changed files with 39 additions and 0 deletions
|
@ -206,6 +206,8 @@ typedef intptr_t sys_jmpbuf[5];
|
|||
#define Sys_setjmp(jmpbuf) __builtin_setjmp(jmpbuf)
|
||||
void Sys_longjmp (sys_jmpbuf jmpbuf) __attribute__((noreturn));
|
||||
|
||||
extern sys_jmpbuf sys_exit_jmpbuf;
|
||||
|
||||
///@}
|
||||
|
||||
#endif//__QF_sys_h
|
||||
|
|
|
@ -540,11 +540,16 @@ Sys_Init_Cvars (void)
|
|||
Cvar_Register (&sys_sleep_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static sys_jmpbuf sys_exit_cmpbuf;
|
||||
sys_jmpbuf sys_exit_jmpbuf;
|
||||
VISIBLE void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Sys_Shutdown ();
|
||||
|
||||
if (memcmp (sys_exit_cmpbuf, sys_exit_jmpbuf, sizeof (sys_exit_cmpbuf))) {
|
||||
Sys_longjmp (sys_exit_jmpbuf);
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,10 @@ main (int argc, const char **argv)
|
|||
{
|
||||
double time, oldtime, newtime;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
COM_InitArgv (argc, argv);
|
||||
|
|
|
@ -66,6 +66,10 @@ main (int argc, const char **argv)
|
|||
double time, oldtime, newtime;
|
||||
int i;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
// dedicated server ONLY!
|
||||
|
|
|
@ -163,6 +163,10 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
if (hPrevInstance)
|
||||
return 0;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
startup ();
|
||||
|
||||
global_hInstance = hInstance;
|
||||
|
|
|
@ -49,6 +49,10 @@ main (int argc, const char **argv)
|
|||
double time, oldtime, newtime;
|
||||
int i;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
// dedicated server ONLY!
|
||||
|
|
|
@ -65,6 +65,10 @@ main (int argc, const char **argv)
|
|||
{
|
||||
double time, oldtime, newtime;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
||||
COM_InitArgv (argc, argv);
|
||||
|
|
|
@ -127,6 +127,10 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
|||
if (hPrevInstance)
|
||||
return 0;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
startup ();
|
||||
|
||||
global_hInstance = hInstance;
|
||||
|
|
|
@ -112,6 +112,10 @@ main (int argc, const char **argv)
|
|||
{
|
||||
double time, oldtime, newtime;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
startup ();
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
|
|
@ -70,6 +70,10 @@ main (int argc, const char **argv)
|
|||
{
|
||||
double time, oldtime, newtime;
|
||||
|
||||
if (Sys_setjmp (sys_exit_jmpbuf)) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
startup ();
|
||||
|
||||
memset (&host_parms, 0, sizeof (host_parms));
|
||||
|
|
Loading…
Reference in a new issue