-perform a proper exit, i.e. make sure that the deinit code can run, by throwing a special exception and actually catching it in the main function.

This commit is contained in:
Christoph Oelckers 2019-10-26 10:30:08 +02:00
parent 0d878a8604
commit 1c29169492
5 changed files with 29 additions and 20 deletions

View file

@ -652,11 +652,18 @@ static FORCE_INLINE int32_t Blrintf(const float x)
# define ERRprintf(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
#endif
#ifdef DEBUGGINGAIDS
# define Bexit(status) do { initprintf("exit(%d) at %s:%d in %s()\n", status, __FILE__, __LINE__, EDUKE32_FUNCTION); exit(status); } while (0)
#else
# define Bexit(a) exit(a)// throw(1)
#endif
class ExitEvent : public std::exception
{
int reason;
public:
ExitEvent(int a) { reason = a; }
int Reason() const { return reason; }
};
inline void Bexit(int a)
{
throw ExitEvent(a);
}
////////// Standard library monkey patching //////////