public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gas/config/tc-tic54x.c's use of macro_struct and formal_struct
@ 2005-03-09 10:12 Jan Beulich
  2005-03-09 12:44 ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2005-03-09 10:12 UTC (permalink / raw)
  To: twall; +Cc: binutils

As I'm intending to add one or two elements to macro_struct (to allow
.purgem to free the memory allocated by .macro) I'd like to understand
what, if any, reasons there are for this file, in function
tic54x_macro_info, to redeclare these two structures instead of using
them (or even better their typedef equivalents) from the already
included macro.h.

Thanks, Jan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gas/config/tc-tic54x.c's use of macro_struct and formal_struct
  2005-03-09 10:12 gas/config/tc-tic54x.c's use of macro_struct and formal_struct Jan Beulich
@ 2005-03-09 12:44 ` Nick Clifton
  2005-03-09 14:04   ` Timothy Wall
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2005-03-09 12:44 UTC (permalink / raw)
  To: Jan Beulich; +Cc: twall, binutils

Hi Jan,

> As I'm intending to add one or two elements to macro_struct (to allow
> .purgem to free the memory allocated by .macro) I'd like to understand
> what, if any, reasons there are for this file, in function
> tic54x_macro_info, to redeclare these two structures instead of using
> them (or even better their typedef equivalents) from the already
> included macro.h.

As far as I can tell this was an ill-advised piece of coding.  The 
typedefs from macro.h should have been used as you suggested.  Please 
feel free to contribute a patch to do just this.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gas/config/tc-tic54x.c's use of macro_struct and formal_struct
  2005-03-09 12:44 ` Nick Clifton
@ 2005-03-09 14:04   ` Timothy Wall
  0 siblings, 0 replies; 5+ messages in thread
From: Timothy Wall @ 2005-03-09 14:04 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Jan Beulich

Since it looks like I moved those structs into macro.h in the first 
place to make them publicly accessible, I'm guessing the duplicated 
code in the tic54x file pre-dates moving the structs into macro.h, and 
was never properly cleaned up.

Please contribute a patch.

T.

On Mar 9, 2005, at 7:56 AM, Nick Clifton wrote:

> Hi Jan,
>
>> As I'm intending to add one or two elements to macro_struct (to allow
>> .purgem to free the memory allocated by .macro) I'd like to understand
>> what, if any, reasons there are for this file, in function
>> tic54x_macro_info, to redeclare these two structures instead of using
>> them (or even better their typedef equivalents) from the already
>> included macro.h.
>
> As far as I can tell this was an ill-advised piece of coding.  The 
> typedefs from macro.h should have been used as you suggested.  Please 
> feel free to contribute a patch to do just this.
>
> Cheers
>   Nick
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gas/config/tc-tic54x.c's use of macro_struct and formal_struct
  2005-03-10  8:01 Jan Beulich
@ 2005-03-10  8:47 ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2005-03-10  8:47 UTC (permalink / raw)
  To: Jan Beulich; +Cc: twall, nickc, binutils

On Thu, Mar 10, 2005 at 09:01:00AM +0100, Jan Beulich wrote:
> 	* config/tc-tic54x.h (tic54x_macro_info): Change parameter type.
> 	* config/tc-tic54x.c (tic54x_macro_info): Likewise. Replace hand-
> 	crafted structure declaractions with the types from macro.h.

OK.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gas/config/tc-tic54x.c's use of macro_struct and formal_struct
@ 2005-03-10  8:01 Jan Beulich
  2005-03-10  8:47 ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2005-03-10  8:01 UTC (permalink / raw)
  To: twall, nickc; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 3232 bytes --]

>>> Timothy Wall <twall@alum.mit.edu> 09.03.05 15:04:36 >>>
>Since it looks like I moved those structs into macro.h in the first 
>place to make them publicly accessible, I'm guessing the duplicated 
>code in the tic54x file pre-dates moving the structs into macro.h, and

>was never properly cleaned up.
>
>Please contribute a patch.
>
>T.
>
>On Mar 9, 2005, at 7:56 AM, Nick Clifton wrote:
>
>> Hi Jan,
>>
>>> As I'm intending to add one or two elements to macro_struct (to
allow
>>> .purgem to free the memory allocated by .macro) I'd like to
understand
>>> what, if any, reasons there are for this file, in function
>>> tic54x_macro_info, to redeclare these two structures instead of
using
>>> them (or even better their typedef equivalents) from the already
>>> included macro.h.
>>
>> As far as I can tell this was an ill-advised piece of coding.  The 
>> typedefs from macro.h should have been used as you suggested. 
Please 
>> feel free to contribute a patch to do just this.
>>
>> Cheers
>>   Nick

Built and tested cross for tic54x-coff on i686-pc-linux-gnu.

Jan

gas/
2005-03-10  Jan Beulich  <jbeulich@novell.com>

	* config/tc-tic54x.h (tic54x_macro_info): Change parameter
type.
	* config/tc-tic54x.c (tic54x_macro_info): Likewise. Replace
hand-
	crafted structure declaractions with the types from macro.h.

---
/home/jbeulich/src/binutils/mainline/2005-03-08/gas/config/tc-tic54x.c	2005-03-04
15:51:46.000000000 +0100
+++ 2005-03-08/gas/config/tc-tic54x.c	2005-03-10 08:44:11.847979016
+0100
@@ -2700,29 +2700,10 @@ tic54x_macro_start ()
 }
 
 void
-tic54x_macro_info (info)
-     void *info;
+tic54x_macro_info (macro)
+     const macro_entry *macro;
 {
-  struct formal_struct
-  {
-    struct formal_struct *next;	/* Next formal in list  */
-    sb name;			/* Name of the formal  */
-    sb def;			/* The default value  */
-    sb actual;			/* The actual argument (changed
on
-                                   each expansion) */
-    int index;			/* The index of the formal
-                                   0 .. formal_count - 1 */
-  } *entry;
-  struct macro_struct
-  {
-    sb sub;			/* Substitution text.  */
-    int formal_count;		/* Number of formal args.  */
-    struct formal_struct *formals;	/* Pointer to list of
-                                           formal_structs.  */
-    struct hash_control *formal_hash; /* Hash table of formals.  */
-  } *macro;
-
-  macro = (struct macro_struct *) info;
+  const formal_entry *entry;
 
   /* Put the formal args into the substitution symbol table.  */
   for (entry = macro->formals; entry; entry = entry->next)
---
/home/jbeulich/src/binutils/mainline/2005-03-08/gas/config/tc-tic54x.h	2001-11-13
15:22:41.000000000 +0100
+++ 2005-03-08/gas/config/tc-tic54x.h	2005-03-10 08:43:54.707584752
+0100
@@ -97,7 +97,8 @@ extern void tic54x_macro_start (void);
 #define md_macro_end() tic54x_macro_end()
 extern void tic54x_macro_end (void);
 #define md_macro_info(args) tic54x_macro_info(args)
-extern void tic54x_macro_info PARAMS((void *macro));
+struct macro_struct;
+extern void tic54x_macro_info PARAMS((const struct macro_struct *));
 #define tc_frob_label(sym) tic54x_define_label (sym)
 extern void tic54x_define_label PARAMS((symbolS *));
 


[-- Attachment #2: binutils-mainline-tic54x-macro-structs.patch --]
[-- Type: text/plain, Size: 2222 bytes --]

Built and tested cross for tic54x-coff on i686-pc-linux-gnu.

Jan

gas/
2005-03-10  Jan Beulich  <jbeulich@novell.com>

	* config/tc-tic54x.h (tic54x_macro_info): Change parameter type.
	* config/tc-tic54x.c (tic54x_macro_info): Likewise. Replace hand-
	crafted structure declaractions with the types from macro.h.

--- /home/jbeulich/src/binutils/mainline/2005-03-08/gas/config/tc-tic54x.c	2005-03-04 15:51:46.000000000 +0100
+++ 2005-03-08/gas/config/tc-tic54x.c	2005-03-10 08:44:11.847979016 +0100
@@ -2700,29 +2700,10 @@ tic54x_macro_start ()
 }
 
 void
-tic54x_macro_info (info)
-     void *info;
+tic54x_macro_info (macro)
+     const macro_entry *macro;
 {
-  struct formal_struct
-  {
-    struct formal_struct *next;	/* Next formal in list  */
-    sb name;			/* Name of the formal  */
-    sb def;			/* The default value  */
-    sb actual;			/* The actual argument (changed on
-                                   each expansion) */
-    int index;			/* The index of the formal
-                                   0 .. formal_count - 1 */
-  } *entry;
-  struct macro_struct
-  {
-    sb sub;			/* Substitution text.  */
-    int formal_count;		/* Number of formal args.  */
-    struct formal_struct *formals;	/* Pointer to list of
-                                           formal_structs.  */
-    struct hash_control *formal_hash; /* Hash table of formals.  */
-  } *macro;
-
-  macro = (struct macro_struct *) info;
+  const formal_entry *entry;
 
   /* Put the formal args into the substitution symbol table.  */
   for (entry = macro->formals; entry; entry = entry->next)
--- /home/jbeulich/src/binutils/mainline/2005-03-08/gas/config/tc-tic54x.h	2001-11-13 15:22:41.000000000 +0100
+++ 2005-03-08/gas/config/tc-tic54x.h	2005-03-10 08:43:54.707584752 +0100
@@ -97,7 +97,8 @@ extern void tic54x_macro_start (void);
 #define md_macro_end() tic54x_macro_end()
 extern void tic54x_macro_end (void);
 #define md_macro_info(args) tic54x_macro_info(args)
-extern void tic54x_macro_info PARAMS((void *macro));
+struct macro_struct;
+extern void tic54x_macro_info PARAMS((const struct macro_struct *));
 #define tc_frob_label(sym) tic54x_define_label (sym)
 extern void tic54x_define_label PARAMS((symbolS *));
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-03-10  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-09 10:12 gas/config/tc-tic54x.c's use of macro_struct and formal_struct Jan Beulich
2005-03-09 12:44 ` Nick Clifton
2005-03-09 14:04   ` Timothy Wall
2005-03-10  8:01 Jan Beulich
2005-03-10  8:47 ` Alan Modra

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).