summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-02-08 10:10:57 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-02-08 10:10:57 -0800
commit50fe0b5904bce8b00eeb4f6ec7a9ac080e1a823c (patch)
treece8b1f4f7f3cf360f0e7255e02ac6135d107a5fa
parentc2f6baabc35632e566e47447114d47f192b46dee (diff)
downloadnasm-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.c5
-rw-r--r--nasmlib.h3
2 files changed, 7 insertions, 1 deletions
diff --git a/nasmlib.c b/nasmlib.c
index 3c26546a..656350d5 100644
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -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);
diff --git a/nasmlib.h b/nasmlib.h
index f480c062..dfce1dd9 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -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