From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-18 09:30:17
|
Commit-ID: cd7893d02ddba6c10935a36cda6e9d41eac3ac2a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=cd7893d02ddba6c10935a36cda6e9d41eac3ac2a Author: H. Peter Anvin <hp...@li...> AuthorDate: Thu, 18 Feb 2016 01:25:46 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Thu, 18 Feb 2016 01:25:46 -0800 Remove additional function pointers that never change Remove additional cached function pointers which point to static variables which are never actually changed. Just refer to the global variable instead. Signed-off-by: H. Peter Anvin <hp...@li...> --- eval.c | 22 +++++++--------------- eval.h | 7 ------- nasm.c | 4 +--- nasm.h | 1 + parser.c | 12 +++--------- parser.h | 1 - 6 files changed, 12 insertions(+), 35 deletions(-) diff --git a/eval.c b/eval.c index 1709933..f1fb05e 100644 --- a/eval.c +++ b/eval.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2012 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -54,7 +54,6 @@ #define TEMPEXPR_DELTA 8 static scanner scan; /* Address of scanner routine */ -static lfunc labelfunc; /* Address of label routine */ static expr **tempexprs = NULL; static int ntempexprs; @@ -68,7 +67,6 @@ static struct tokenval *tokval; /* The current token */ static int i; /* The t_type of tokval */ static void *scpriv; -static struct location *location; /* Pointer to current line's segment,offset */ static int *opflags; static struct eval_hints *hint; @@ -890,11 +888,11 @@ static expr *expr6(int critical) case TOKEN_HERE: case TOKEN_BASE: /* - * If !location->known, this indicates that no + * If !location.known, this indicates that no * symbol, Here or Base references are valid because we * are in preprocess-only mode. */ - if (!location->known) { + if (!location.known) { nasm_error(ERR_NONFATAL, "%s not supported in preprocess-only mode", (i == TOKEN_HERE ? "`$'" : @@ -906,13 +904,13 @@ static expr *expr6(int critical) type = EXPR_SIMPLE; /* might get overridden by UNKNOWN */ if (i == TOKEN_BASE) { - label_seg = in_abs_seg ? abs_seg : location->segment; + label_seg = in_abs_seg ? abs_seg : location.segment; label_ofs = 0; } else if (i == TOKEN_HERE) { - label_seg = in_abs_seg ? abs_seg : location->segment; - label_ofs = in_abs_seg ? abs_offset : location->offset; + label_seg = in_abs_seg ? abs_seg : location.segment; + label_ofs = in_abs_seg ? abs_offset : location.offset; } else { - if (!labelfunc(tokval->t_charptr, &label_seg, &label_ofs)) { + if (!lookup_label(tokval->t_charptr, &label_seg, &label_ofs)) { scope = local_scope(tokval->t_charptr); if (critical == 2) { nasm_error(ERR_NONFATAL, "symbol `%s%s' undefined", @@ -951,12 +949,6 @@ static expr *expr6(int critical) } } -void eval_global_info(lfunc lookup_label, struct location * locp) -{ - labelfunc = lookup_label; - location = locp; -} - expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, int *fwref, int critical, struct eval_hints *hints) { diff --git a/eval.h b/eval.h index 41949d4..7af17eb 100644 --- a/eval.h +++ b/eval.h @@ -39,13 +39,6 @@ #define NASM_EVAL_H /* - * Called once to tell the evaluator what output format is - * providing segment-base details, and what function can be used to - * look labels up. - */ -void eval_global_info(lfunc lookup_label, struct location * locp); - -/* * The evaluator itself. */ expr *evaluate(scanner sc, void *scprivate, struct tokenval *tv, diff --git a/nasm.c b/nasm.c index 4c9c163..01e0628 100644 --- a/nasm.c +++ b/nasm.c @@ -116,7 +116,7 @@ int64_t global_offset_changed; /* referenced in labels.c */ int64_t prev_offset_changed; int32_t stall_count; -static struct location location; +struct location location; int in_abs_seg; /* Flag we are in ABSOLUTE seg */ int32_t abs_seg; /* ABSOLUTE segment basis */ int32_t abs_offset; /* ABSOLUTE offset */ @@ -364,8 +364,6 @@ int main(int argc, char **argv) if (ofmt->stdmac) preproc->extra_stdmac(ofmt->stdmac); - parser_global_info(&location); - eval_global_info(ofmt, lookup_label, &location); /* define some macros dependent of command-line */ define_macros_late(); diff --git a/nasm.h b/nasm.h index 44b356d..808f832 100644 --- a/nasm.h +++ b/nasm.h @@ -220,6 +220,7 @@ struct location { int32_t segment; int known; }; +extern struct location location; /* * Expression-evaluator datatype. Expressions, within the diff --git a/parser.c b/parser.c index d2ad1d2..c5d6050 100644 --- a/parser.c +++ b/parser.c @@ -61,12 +61,6 @@ static int is_comma_next(void); static int i; static struct tokenval tokval; -static struct location *location; /* Pointer to current line's segment,offset */ - -void parser_global_info(struct location * locp) -{ - location = locp; -} static int prefix_slot(int prefix) { @@ -431,14 +425,14 @@ restart_parse: } if (i != TOKEN_INSN || tokval.t_integer != I_EQU) { /* - * FIXME: location->segment could be NO_SEG, in which case + * FIXME: location.segment could be NO_SEG, in which case * it is possible we should be passing 'abs_seg'. Look into this. * Work out whether that is *really* what we should be doing. * Generally fix things. I think this is right as it is, but * am still not certain. */ - ldef(result->label, in_abs_seg ? abs_seg : location->segment, - location->offset, NULL, true, false); + ldef(result->label, in_abs_seg ? abs_seg : location.segment, + location.offset, NULL, true, false); } } diff --git a/parser.h b/parser.h index 9b2b6d6..e148c7f 100644 --- a/parser.h +++ b/parser.h @@ -39,7 +39,6 @@ #ifndef NASM_PARSER_H #define NASM_PARSER_H -void parser_global_info(struct location *locp); insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef); void cleanup_insn(insn *instruction); |