[binutils-gdb] gas: drop function pointer parameter from macro_init()
Jan Beulich
jbeulich@sourceware.org
Fri Mar 17 09:07:23 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3da593e8de13861b637c50dc9c291a229bac6b2f
commit 3da593e8de13861b637c50dc9c291a229bac6b2f
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Mar 17 10:05:05 2023 +0100
gas: drop function pointer parameter from macro_init()
With the removal of gasp (about 20 years ago) the need for this kind-
of-hook has disappeared. Go a step beyond merely moving the to be called
function: Inline its contents right at the sole call site.
Diff:
---
gas/as.c | 24 +-----------------------
gas/macro.c | 29 ++++++++++++++---------------
gas/macro.h | 3 +--
3 files changed, 16 insertions(+), 40 deletions(-)
diff --git a/gas/as.c b/gas/as.c
index 593eaec7f14..57641802d72 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1167,28 +1167,6 @@ dump_statistics (void)
obj_print_statistics (stderr);
#endif
}
-
-/* The interface between the macro code and gas expression handling. */
-
-static size_t
-macro_expr (const char *emsg, size_t idx, sb *in, offsetT *val)
-{
- expressionS ex;
-
- sb_terminate (in);
-
- temp_ilp (in->ptr + idx);
- expression_and_evaluate (&ex);
- idx = input_line_pointer - in->ptr;
- restore_ilp ();
-
- if (ex.X_op != O_constant)
- as_bad ("%s", emsg);
-
- *val = ex.X_add_number;
-
- return idx;
-}
/* Here to attempt 1 pass over each input file.
We scan argv[*] looking for filenames or exactly "" which is
@@ -1336,7 +1314,7 @@ gas_init (void)
#ifdef TC_I960
macro_strip_at = flag_mri;
#endif
- macro_init (flag_macro_alternate, flag_mri, macro_strip_at, macro_expr);
+ macro_init (flag_macro_alternate, flag_mri, macro_strip_at);
dwarf2_init ();
diff --git a/gas/macro.c b/gas/macro.c
index fae94ae42c1..fec806d91ea 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -62,10 +62,6 @@ static int macro_mri;
static int macro_strip_at;
-/* Function to use to parse an expression. */
-
-static size_t (*macro_expr) (const char *, size_t, sb *, offsetT *);
-
/* Number of macro expansions that have been done. */
static int macro_number;
@@ -82,8 +78,7 @@ macro_del_f (void *ent)
/* Initialize macro processing. */
void
-macro_init (int alternate, int mri, int strip_at,
- size_t (*exp) (const char *, size_t, sb *, offsetT *))
+macro_init (int alternate, int mri, int strip_at)
{
macro_hash = htab_create_alloc (16, hash_string_tuple, eq_string_tuple,
macro_del_f, notes_calloc, NULL);
@@ -91,7 +86,6 @@ macro_init (int alternate, int mri, int strip_at,
macro_alternate = alternate;
macro_mri = mri;
macro_strip_at = strip_at;
- macro_expr = exp;
}
void
@@ -412,16 +406,21 @@ get_any_string (size_t idx, sb *in, sb *out)
}
else if (in->ptr[idx] == '%' && macro_alternate)
{
- offsetT val;
+ /* Turn the following expression into a string. */
+ expressionS ex;
char buf[64];
- /* Turns the next expression into a string. */
- /* xgettext: no-c-format */
- idx = (*macro_expr) (_("% operator needs absolute expression"),
- idx + 1,
- in,
- &val);
- sprintf (buf, "%" PRId64, (int64_t) val);
+ sb_terminate (in);
+
+ temp_ilp (in->ptr + idx + 1);
+ expression_and_evaluate (&ex);
+ idx = input_line_pointer - in->ptr;
+ restore_ilp ();
+
+ if (ex.X_op != O_constant)
+ as_bad (_("%% operator needs absolute expression"));
+
+ sprintf (buf, "%" PRId64, (int64_t) ex.X_add_number);
sb_add_string (out, buf);
}
else if (in->ptr[idx] == '"'
diff --git a/gas/macro.h b/gas/macro.h
index 2ec0ec451d5..e879b08007c 100644
--- a/gas/macro.h
+++ b/gas/macro.h
@@ -83,8 +83,7 @@ extern htab_t macro_hash;
extern int buffer_and_nest (const char *, const char *, sb *,
size_t (*) (sb *));
-extern void macro_init (int, int, int,
- size_t (*) (const char *, size_t, sb *, offsetT *));
+extern void macro_init (int, int, int);
extern void macro_end (void);
extern void macro_set_alternate (int);
extern void macro_mri_mode (int);
More information about the Binutils-cvs
mailing list