diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-13 19:18:49 -0800 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-13 19:18:49 -0800 |
commit | 9f89eb38fc0e7566b8a35408b36d7c900ab5d046 (patch) | |
tree | 586f5dee0832826e2720f88ddc87d60b249d86c6 | |
parent | 3c896de5a3cb9c699c4233b1a3138d9af0f21453 (diff) | |
parent | 26572c6e37279dd947df8d85b8d553c512f42467 (diff) | |
download | nasm-9f89eb38fc0e7566b8a35408b36d7c900ab5d046.tar.gz |
Merge remote-tracking branch 'origin/master' into mkwarnings
-rw-r--r-- | Makefile.in | 5 | ||||
-rw-r--r-- | Mkfiles/msvc.mak | 5 | ||||
-rw-r--r-- | Mkfiles/openwcom.mak | 5 | ||||
-rw-r--r-- | asm/nasm.c | 6 | ||||
-rw-r--r-- | asm/preproc.c | 4 | ||||
-rw-r--r-- | include/error.h | 7 | ||||
-rw-r--r-- | nasmlib/alloc.c | 18 | ||||
-rw-r--r-- | nasmlib/errfile.c | 5 | ||||
-rw-r--r-- | rdoff/ldrdf.c | 3 |
9 files changed, 42 insertions, 16 deletions
diff --git a/Makefile.in b/Makefile.in index 8e55e83e..78eaffe2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -96,8 +96,9 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \ \ nasmlib/ver.$(O) \ - nasmlib/crc64.$(O) nasmlib/alloc.$(O) nasmlib/asprintf.$(O) \ - nasmlib/md5c.$(O) nasmlib/string.$(O) nasmlib/nctype.$(O) \ + nasmlib/alloc.$(O) nasmlib/asprintf.$(O) nasmlib/errfile.$(O) \ + nasmlib/crc64.$(O) nasmlib/md5c.$(O) \ + nasmlib/string.$(O) nasmlib/nctype.$(O) \ nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \ nasmlib/realpath.$(O) nasmlib/path.$(O) \ nasmlib/filename.$(O) \ diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index 89e392d9..9c7d60e0 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -68,8 +68,9 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \ stdlib\strnlen.$(O) stdlib\strrchrnul.$(O) \ \ nasmlib\ver.$(O) \ - nasmlib\crc64.$(O) nasmlib\alloc.$(O) nasmlib\asprintf.$(O) \ - nasmlib\md5c.$(O) nasmlib\string.$(O) nasmlib\nctype.$(O) \ + nasmlib\alloc.$(O) nasmlib\asprintf.$(O) nasmlib\errfile.$(O) \ + nasmlib\crc64.$(O) nasmlib\md5c.$(O) \ + nasmlib\string.$(O) nasmlib\nctype.$(O) \ nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \ nasmlib\realpath.$(O) nasmlib\path.$(O) \ nasmlib\filename.$(O) \ diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 1c407dea..2babe5dc 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -57,8 +57,9 @@ LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) & stdlib\strnlen.$(O) stdlib\strrchrnul.$(O) & & nasmlib\ver.$(O) & - nasmlib\crc64.$(O) nasmlib\alloc.$(O) nasmlib\asprintf.$(O) & - nasmlib\md5c.$(O) nasmlib\string.$(O) nasmlib\nctype.$(O) & + nasmlib\alloc.$(O) nasmlib\asprintf.$(O) nasmlib\errfile.$(O) & + nasmlib\crc64.$(O) nasmlib\md5c.$(O) & + nasmlib\string.$(O) nasmlib\nctype.$(O) & nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) & nasmlib\realpath.$(O) nasmlib\path.$(O) & nasmlib\filename.$(O) & @@ -121,7 +121,7 @@ const struct ofmt *ofmt = &OF_DEFAULT; const struct ofmt_alias *ofmt_alias = NULL; const struct dfmt *dfmt; -static FILE *error_file; /* Where to write error messages */ +FILE *error_file; /* Where to write error messages */ FILE *ofile = NULL; struct optimization optimizing = @@ -451,6 +451,8 @@ int main(int argc, char **argv) { timestamp(); + error_file = stderr; + iflag_set_default_cpu(&cpu); iflag_set_default_cpu(&cmd_cpu); @@ -460,8 +462,6 @@ int main(int argc, char **argv) want_usage = terminate_after_phase = false; nasm_set_verror(nasm_verror_asm); - error_file = stderr; - nasm_ctype_init(); src_init(); diff --git a/asm/preproc.c b/asm/preproc.c index af77e14b..af990e13 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -4285,7 +4285,7 @@ again: m->casesense))) m = m->next; if (!m) - nasm_warnf(ERR_PASS1|WARN_MNP, + nasm_warnf(ERR_PASS1|WARN_MACRO_PARAMS, "macro `%s' exists, " "but not taking %d parameters", mstart->text, nparam); @@ -4585,7 +4585,7 @@ static MMacro *is_mmacro(Token * tline, Token *** params_array) * After all that, we didn't find one with the right number of * parameters. Issue a warning, and fail to expand the macro. */ - nasm_warnf(ERR_PASS1|WARN_MNP, + nasm_warnf(ERR_PASS1|WARN_MACRO_PARAMS, "macro `%s' exists, but not taking %d parameters", tline->text, nparam); nasm_free(params); diff --git a/include/error.h b/include/error.h index 8d5084c8..d5b4f852 100644 --- a/include/error.h +++ b/include/error.h @@ -41,6 +41,11 @@ #include "compiler.h" /* + * File pointer for error messages + */ +extern FILE *error_file; /* Error file descriptor */ + +/* * An error reporting function should look like this. */ void printf_func(2, 3) nasm_error(int severity, const char *fmt, ...); @@ -103,7 +108,7 @@ static inline vefunc nasm_set_verror(vefunc ve) #define WARN_MASK WARN(~0) #define WARN_IDX(x) ((x) >> WARN_SHR) -#define WARN_MNP WARN( 1) /* macro-num-parameters warning */ +#define WARN_MACRO_PARAMS WARN( 1) /* macro-num-parameters warning */ #define WARN_MACRO_SELFREF WARN( 2) /* macro self-reference */ #define WARN_MACRO_DEFAULTS WARN( 3) /* macro default parameters check */ #define WARN_ORPHAN_LABELS WARN( 4) /* orphan label (no colon, and alone on line) */ diff --git a/nasmlib/alloc.c b/nasmlib/alloc.c index 2f3f9519..ad2cff3d 100644 --- a/nasmlib/alloc.c +++ b/nasmlib/alloc.c @@ -42,7 +42,23 @@ no_return nasm_alloc_failed(void) { - nasm_fatal("out of memory"); + /* If nasm_fatal() gets us back here, then croak hard */ + static bool already_here = false; + FILE *errfile; + + if (likely(!already_here)) { + already_here = true; + nasm_fatal("out of memory!"); + } + + errfile = error_file; + if (!errfile) + error_file = stderr; + + fprintf(error_file, "nasm: out of memory!\n"); + fflush(error_file); + fflush(NULL); + abort(); } void *nasm_malloc(size_t size) diff --git a/nasmlib/errfile.c b/nasmlib/errfile.c new file mode 100644 index 00000000..ee4bae8e --- /dev/null +++ b/nasmlib/errfile.c @@ -0,0 +1,5 @@ +#include "compiler.h" +#include <stdio.h> + +FILE *error_file; + diff --git a/rdoff/ldrdf.c b/rdoff/ldrdf.c index dd80d70e..49729b4f 100644 --- a/rdoff/ldrdf.c +++ b/rdoff/ldrdf.c @@ -126,9 +126,6 @@ char *generic_rec_file = NULL; /* module name to be added at the beginning of output file */ char *modname_specified = NULL; -/* error file */ -static FILE *error_file; - /* the header of the output file, built up stage by stage */ rdf_headerbuf *newheader = NULL; |