This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [RFA] Use '=' for assignment in tc-mcore.c, not '=='
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Klee Dienes <klee at apple dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 21 Nov 2002 22:13:55 +1030
- Subject: Re: [RFA] Use '=' for assignment in tc-mcore.c, not '=='
- References: <DBC0726C-FD2E-11D6-9B40-00039396EEB8@apple.com>
On Thu, Nov 21, 2002 at 03:54:35AM -0500, Klee Dienes wrote:
> This wasn't me, honest!
Urk, what a horrible mess. Let's fix it properly.
* config/tc-mcore.c (mcore_pool_count): New function.
(mcore_cons, mcore_float_cons, mcore_stringer, mcore_fill): Use it.
Index: gas/config/tc-mcore.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mcore.c,v
retrieving revision 1.28
diff -c -p -r1.28 tc-mcore.c
*** gas/config/tc-mcore.c 21 Nov 2002 09:54:12 -0000 1.28
--- gas/config/tc-mcore.c 21 Nov 2002 11:27:07 -0000
***************
*** 37,42 ****
--- 37,43 ----
/* Forward declarations for dumb compilers. */
static void mcore_s_literals PARAMS ((int));
+ static void mcore_pool_count PARAMS ((void (*) (int), int));
static void mcore_cons PARAMS ((int));
static void mcore_float_cons PARAMS ((int));
static void mcore_stringer PARAMS ((int));
*************** mcore_s_literals (ignore)
*** 228,250 ****
demand_empty_rest_of_line ();
}
static void
! mcore_cons (nbytes)
! int nbytes;
{
! if (now_seg == text_section)
! {
! char * ptr = input_line_pointer;
! int commas = 1;
! /* Count the number of commas on the line. */
! while (! is_end_of_line [(unsigned char) * ptr])
! commas += * ptr ++ == ',';
! poolspan += nbytes * commas;
}
! cons (nbytes);
/* In theory we ought to call check_literals (2,0) here in case
we need to dump the literal table. We cannot do this however,
--- 229,264 ----
demand_empty_rest_of_line ();
}
+ /* Perform FUNC (ARG), and track number of bytes added to frag. */
+
static void
! mcore_pool_count (func, arg)
! void (*func) PARAMS ((int));
! int arg;
{
! const fragS *curr_frag = frag_now;
! offsetT added = -frag_now_fix_octets ();
! (*func) (arg);
! while (curr_frag != frag_now)
! {
! added += curr_frag->fr_fix;
! curr_frag = curr_frag->fr_next;
}
! added += frag_now_fix_octets ();
! poolspan += added;
! }
!
! static void
! mcore_cons (nbytes)
! int nbytes;
! {
! if (now_seg == text_section)
! mcore_pool_count (cons, nbytes);
! else
! cons (nbytes);
/* In theory we ought to call check_literals (2,0) here in case
we need to dump the literal table. We cannot do this however,
*************** mcore_float_cons (float_type)
*** 258,282 ****
int float_type;
{
if (now_seg == text_section)
! {
! char * ptr = input_line_pointer;
! int commas = 1;
!
! #ifdef REPEAT_CONS_EXPRESSIONS
! #error REPEAT_CONS_EXPRESSIONS not handled
! #endif
!
! /* Count the number of commas on the line. */
! while (! is_end_of_line [(unsigned char) * ptr])
! commas += * ptr ++ == ',';
!
! /* We would like to compute "hex_float (float_type) * commas"
! but hex_float is not exported from read.c */
! float_type == 'f' ? 4 : (float_type == 'd' ? 8 : 12);
! poolspan += float_type * commas;
! }
!
! float_cons (float_type);
/* See the comment in mcore_cons () about calling check_literals.
It is unlikely that a switch table will be constructed using
--- 272,280 ----
int float_type;
{
if (now_seg == text_section)
! mcore_pool_count (float_cons, float_type);
! else
! float_cons (float_type);
/* See the comment in mcore_cons () about calling check_literals.
It is unlikely that a switch table will be constructed using
*************** mcore_stringer (append_zero)
*** 290,312 ****
int append_zero;
{
if (now_seg == text_section)
! {
! char * ptr = input_line_pointer;
!
! /* In theory we should compute how many bytes are going to
! be occupied by the string(s) and add this to the poolspan.
! To keep things simple however, we just add the number of
! bytes left on the current line. This will be an over-
! estimate, which is OK, and automatically allows for the
! appending a zero byte, since the real string(s) is/are
! required to be enclosed in double quotes. */
! while (! is_end_of_line [(unsigned char) * ptr])
! ptr ++;
!
! poolspan += ptr - input_line_pointer;
! }
!
! stringer (append_zero);
/* We call check_literals here in case a large number of strings are
being placed into the text section with a sequence of stringer
--- 288,296 ----
int append_zero;
{
if (now_seg == text_section)
! mcore_pool_count (stringer, append_zero);
! else
! stringer (append_zero);
/* We call check_literals here in case a large number of strings are
being placed into the text section with a sequence of stringer
*************** mcore_fill (unused)
*** 321,351 ****
int unused;
{
if (now_seg == text_section)
! {
! char * str = input_line_pointer;
! int size = 1;
! int repeat;
!
! repeat = atoi (str);
!
! /* Look to see if a size has been specified. */
! while (*str != '\n' && *str != 0 && *str != ',')
! ++ str;
!
! if (* str == ',')
! {
! size = atoi (str + 1);
!
! if (size > 8)
! size = 8;
! else if (size < 0)
! size = 0;
! }
!
! poolspan += size * repeat;
! }
!
! s_fill (unused);
check_literals (2, 0);
}
--- 305,313 ----
int unused;
{
if (now_seg == text_section)
! mcore_pool_count (s_fill, unused);
! else
! s_fill (unused);
check_literals (2, 0);
}
--
Alan Modra
IBM OzLabs - Linux Technology Centre