diff options
author | H. Peter Anvin <hpa@zytor.com> | 2016-02-08 10:10:57 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2016-02-08 10:10:57 -0800 |
commit | 50fe0b5904bce8b00eeb4f6ec7a9ac080e1a823c (patch) | |
tree | ce8b1f4f7f3cf360f0e7255e02ac6135d107a5fa | |
parent | c2f6baabc35632e566e47447114d47f192b46dee (diff) | |
download | nasm-50fe0b5904bce8b00eeb4f6ec7a9ac080e1a823c.tar.gz |
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>
-rw-r--r-- | nasmlib.c | 5 | ||||
-rw-r--r-- | nasmlib.h | 3 |
2 files changed, 7 insertions, 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 |