nasmlib: Factor out common code from the panic() macro

There is no reason to pass a constant and a string from each call
site.  Move that into a separate out of line function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2016-02-08 10:10:57 -08:00
parent c2f6baabc3
commit 50fe0b5904
2 changed files with 7 additions and 1 deletions

@ -92,6 +92,11 @@ no_return nasm_panic(int flags, const char *fmt, ...)
abort(); /* We should never get here */
}
no_return nasm_panic_from_macro(const char *file, int line)
{
nasm_panic(ERR_NOFILE, "Internal error at %s:%d\n", file, line);
}
void *nasm_malloc(size_t size)
{
void *p = malloc(size);

@ -78,7 +78,8 @@ typedef void (*vefunc) (int severity, const char *fmt, va_list ap);
void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...);
void nasm_set_verror(vefunc);
no_return printf_func(2, 3) nasm_panic(int flags, const char *fmt, ...);
#define panic() nasm_panic(ERR_NOFILE, "Internal error at %s:%d\n", __FILE__, __LINE__);
no_return nasm_panic_from_macro(const char *file, int line);
#define panic() nasm_panic_from_macro(__FILE__, __LINE__);
/*
* These are the error severity codes which get passed as the first