Add a hack so that when exit() is called on Android, we instead longjmp to main() and return from there.

git-svn-id: https://svn.eduke32.com/eduke32@5706 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-05-02 18:29:38 +00:00
parent 1fcf91d933
commit 93349bd8e0
2 changed files with 24 additions and 0 deletions

View file

@ -1005,6 +1005,11 @@ FORCE_INLINE void *xaligned_malloc(const bsize_t alignment, const bsize_t size)
# define Bexit exit
#endif
#ifdef __ANDROID__
void eduke32_exit_return(int) ATTRIBUTE((noreturn));
# define exit(x) eduke32_exit_return(x)
#endif
#if defined _WIN32 && !defined NO_ALIGNED_MALLOC
# define Baligned_free _aligned_free
#else

View file

@ -378,12 +378,31 @@ int sdlayer_mobilefilter(void *userdata, SDL_Event *event)
}
#endif
#ifdef __ANDROID__
# include <setjmp.h>
static jmp_buf eduke32_exit_jmp_buf;
static int eduke32_return_value;
void eduke32_exit_return(int retval)
{
eduke32_return_value = retval;
longjmp(eduke32_exit_jmp_buf, 1);
}
#endif
#ifdef _WIN32
int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int32_t nCmdShow)
#else
int32_t main(int32_t argc, char *argv[])
#endif
{
#ifdef __ANDROID__
if (setjmp(eduke32_exit_jmp_buf))
{
return eduke32_return_value;
}
#endif
int32_t r;
#ifdef USE_OPENGL