From: Magnus Jacobsson Date: Sun, 16 Jan 2022 16:10:59 +0000 (+0100) Subject: sparse: add a graphviz_exit function to general.h if STANDALONE X-Git-Tag: 3.0.0~50^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=325fc2ae5b6b106595b87cd354a1539ef931b60c;p=graphviz sparse: add a graphviz_exit function to general.h if STANDALONE An previous commit added the same function to cgraph/exit.h, but that library is not supposed to be used when STANDALONE is defined. Towards https://gitlab.com/graphviz/graphviz/-/issues/2178. --- diff --git a/lib/sparse/general.h b/lib/sparse/general.h index f2b0d3fdd..f481e33e7 100644 --- a/lib/sparse/general.h +++ b/lib/sparse/general.h @@ -65,6 +65,26 @@ __declspec(dllimport) extern unsigned char Verbose; extern unsigned char Verbose; #endif +#ifdef __GNUC__ +// FIXME: use _Noreturn for all compilers when we move to C11 +#define NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define NORETURN __declspec(noreturn) +#else +#define NORETURN /* nothing */ +#endif + +static inline NORETURN void graphviz_exit(int status) { +#ifdef __MINGW32__ + // workaround for https://gitlab.com/graphviz/graphviz/-/issues/2178 + fflush(stdout); + fflush(stderr); +#endif + exit(status); +} + +#undef NORETURN + #else /* STANDALONE */ #define CALLOC gcalloc #define MALLOC gmalloc