public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH 1/4] gas: drop function pointer parameter from macro_init()
Date: Wed, 8 Mar 2023 17:07:35 +0100	[thread overview]
Message-ID: <a513b979-d455-eea6-ba19-1af0dff5d4e2@suse.com> (raw)
In-Reply-To: <bdf364c0-c333-095b-47e0-24948906071e@suse.com>

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.

--- 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;
-}
 \f
 /* Here to attempt 1 pass over each input file.
    We scan argv[*] looking for filenames or exactly "" which is
@@ -1333,7 +1311,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 ();
 
--- 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
   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 *
 	}
       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] == '"'
--- 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);


  reply	other threads:[~2023-03-08 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 16:05 [PATCH 0/4] gas: tidy macro interfacing after removal of gasp Jan Beulich
2023-03-08 16:07 ` Jan Beulich [this message]
2023-03-08 16:08 ` [PATCH 2/4] gas: isolate macro_strip_at to macro.c Jan Beulich
2023-03-08 16:08 ` [PATCH 3/4] gas: use flag_mri directly in macro processing Jan Beulich
2023-03-08 16:09 ` [PATCH 4/4] gas: expose flag_macro_alternate globally Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a513b979-d455-eea6-ba19-1af0dff5d4e2@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).