diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index c33aa9677..eceaef4bd 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -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 diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 04d09306b..9d1a2dd13 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -378,12 +378,31 @@ int sdlayer_mobilefilter(void *userdata, SDL_Event *event) } #endif +#ifdef __ANDROID__ +# include +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