summaryrefslogtreecommitdiff
path: root/include/error.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-08-28 18:32:46 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-08-28 18:32:46 -0700
commit6a4353c4c29274fb2df6ca712fad70b8701c9187 (patch)
tree81456594614ae6120f6b1f0746d3c146ee890539 /include/error.h
parentf8a15a8ea3cc3484f4250fd878569f15412434ab (diff)
downloadnasm-6a4353c4c29274fb2df6ca712fad70b8701c9187.tar.gz
errors: be more robust in handling unexpected fatal errors
Introduce a new error level, ERR_CRITICAL, beyond which we will minimize the amount of code that will be executed before we die; in particular don't execute any memory allocations, and if we somehow end up recursing, abort() immediately. Basically, "less than panic, more than fatal." At this point this level is used by nasm_alloc_failed(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'include/error.h')
-rw-r--r--include/error.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/error.h b/include/error.h
index fde99e01..07bd5c7d 100644
--- a/include/error.h
+++ b/include/error.h
@@ -65,6 +65,8 @@ void printf_func(1, 2) nasm_nonfatal(const char *fmt, ...);
void printf_func(2, 3) nasm_nonfatalf(errflags flags, const char *fmt, ...);
fatal_func printf_func(1, 2) nasm_fatal(const char *fmt, ...);
fatal_func printf_func(2, 3) nasm_fatalf(errflags flags, const char *fmt, ...);
+fatal_func printf_func(1, 2) nasm_critical(const char *fmt, ...);
+fatal_func printf_func(2, 3) nasm_criticalf(errflags flags, const char *fmt, ...);
fatal_func printf_func(1, 2) nasm_panic(const char *fmt, ...);
fatal_func printf_func(2, 3) nasm_panicf(errflags flags, const char *fmt, ...);
fatal_func nasm_panic_from_macro(const char *file, int line);
@@ -72,6 +74,7 @@ fatal_func nasm_panic_from_macro(const char *file, int line);
typedef void (*vefunc) (errflags severity, const char *fmt, va_list ap);
extern vefunc nasm_verror;
+fatal_func nasm_verror_critical(errflags severity, const char *fmt, va_list ap);
static inline vefunc nasm_set_verror(vefunc ve)
{
@@ -89,7 +92,8 @@ static inline vefunc nasm_set_verror(vefunc ve)
#define ERR_INFO 0x00000002 /* information for the list file */
#define ERR_WARNING 0x00000003 /* warn only: no further action */
#define ERR_NONFATAL 0x00000004 /* terminate assembly after phase */
-#define ERR_FATAL 0x00000006 /* instantly fatal: exit with error */
+#define ERR_FATAL 0x00000005 /* instantly fatal: exit with error */
+#define ERR_CRITICAL 0x00000006 /* fatal, but minimize code before exit */
#define ERR_PANIC 0x00000007 /* internal error: panic instantly
* and dump core for reference */
#define ERR_MASK 0x00000007 /* mask off the above codes */
@@ -110,7 +114,7 @@ static inline vefunc nasm_set_verror(vefunc ve)
* severity code.
*/
#define WARN_SHR 12 /* how far to shift right */
-#define WARN_IDX(x) (((errflags)(x)) >> WARN_SHR)
+#define WARN_IDX(x) (((errflags)(x)) >> WARN_SHR)
#define WARN_MASK ((~(errflags)0) << WARN_SHR)
/* This is a bitmask */