diff options
author | H. Peter Anvin <hpa@zytor.com> | 2018-12-10 23:28:01 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2018-12-10 23:28:01 -0800 |
commit | 026b62f264b86372cc596e5a035f87385931486a (patch) | |
tree | 3d40e9239e47e8db93d9140efc6140bc7dc1d8de /asm/srcfile.c | |
parent | 1aa794527fbc772cbc0a4c89d53bbd5d83af914a (diff) | |
download | nasm-026b62f264b86372cc596e5a035f87385931486a.tar.gz |
srcfile: simplify and make most functions inline
Simplify the srcfile subsystem by making it official that any pointer
passed to src_get() needs to have been obtained from the srcfile
subsystem itself.
Move a lot of the srcfile operations into inline code; often they
amount to a single machine instruction...
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'asm/srcfile.c')
-rw-r--r-- | asm/srcfile.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/asm/srcfile.c b/asm/srcfile.c index 158f83d2..f548da65 100644 --- a/asm/srcfile.c +++ b/asm/srcfile.c @@ -44,8 +44,7 @@ #include "hashtbl.h" #include "srcfile.h" -static const char *file_name = NULL; -static int32_t line_number = 0; +struct src_location _src_here; static struct hash_table filename_hash; @@ -79,45 +78,23 @@ const char *src_set_fname(const char *newname) } } - oldname = file_name; - file_name = newname; + oldname = _src_here.filename; + _src_here.filename = newname; return oldname; } -int32_t src_set_linnum(int32_t newline) -{ - int32_t oldline = line_number; - line_number = newline; - return oldline; -} - void src_set(int32_t line, const char *fname) { src_set_fname(fname); src_set_linnum(line); } -const char *src_get_fname(void) -{ - return file_name; -} - -int32_t src_get_linnum(void) -{ - return line_number; -} - -int32_t src_get(int32_t *xline, const char **xname) +struct src_location src_update(struct src_location whence) { - const char *xn = *xname; - int32_t xl = *xline; + struct src_location oldhere = _src_here; - *xline = line_number; - *xname = file_name; + src_set_fname(whence.filename); + src_set_linnum(whence.lineno); - /* XXX: Is the strcmp() really needed here? */ - if (!file_name || !xn || (xn != file_name && strcmp(xn, file_name))) - return -2; - else - return line_number - xl; + return oldhere; } |