diff mbox

[RFA] Fix c_readstr for BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case

Message ID 2F5293F1-0EE1-4181-A233-46C48FB81766@dell.com
State New
Headers show

Commit Message

Paul Koning Nov. 23, 2010, 3:12 p.m. UTC
c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size.  The attached patch corrects this.

Checked on pdp11.  I'm running a bootstrap and make check on Linux for completeness.

Ok to commit?

	paul

ChangeLog:

2010-11-23  Paul Koning  <ni1d@arrl.net>

	* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
	WORDS_BIG_ENDIAN.

Comments

Paul Koning Nov. 30, 2010, 5:27 p.m. UTC | #1
Ping...

I have since run bootstrap and check on i686-pc-linux-gnu, no regressions.

	paul

Begin forwarded message:

> From: Paul Koning <paul_koning@dell.com>
> Date: November 23, 2010 10:12:17 AM EST
> To: gcc-patches <gcc-patches@gcc.gnu.org>
> Subject: [RFA] Fix c_readstr for BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case
> 
> c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size.  The attached patch corrects this.
> 
> Checked on pdp11.  I'm running a bootstrap and make check on Linux for completeness.
> 
> Ok to commit?
> 
> 	paul
> 
> ChangeLog:
> 
> 2010-11-23  Paul Koning  <ni1d@arrl.net>
> 
> 	* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
> 	WORDS_BIG_ENDIAN. 
> 
> Index: builtins.c
> ===================================================================
> --- builtins.c	(revision 166480)
> +++ builtins.c	(working copy)
> @@ -609,7 +609,7 @@
>       if (WORDS_BIG_ENDIAN)
> 	j = GET_MODE_SIZE (mode) - i - 1;
>       if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN
> -	  && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
> +	  && GET_MODE_SIZE (mode) >= UNITS_PER_WORD)
> 	j = j + UNITS_PER_WORD - 2 * (j % UNITS_PER_WORD) - 1;
>       j *= BITS_PER_UNIT;
>       gcc_assert (j < 2 * HOST_BITS_PER_WIDE_INT);
>
Paul Koning Dec. 27, 2010, 2:14 p.m. UTC | #2
Ping...

	paul

Begin forwarded message:

> From: Paul Koning <paul_koning@dell.com>
> Date: November 23, 2010 10:12:17 AM EST
> To: gcc-patches <gcc-patches@gcc.gnu.org>
> Subject: [RFA] Fix c_readstr for BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case
> 
> c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size.  The attached patch corrects this.
> 
> Checked on pdp11; also a bootstrap and make check on Linux-intel
> 
> Ok to commit?
> 
> 	paul
> 
> ChangeLog:
> 
> 2010-11-23  Paul Koning  <ni1d@arrl.net>
> 
> 	* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
> 	WORDS_BIG_ENDIAN. 
> 
> Index: builtins.c
> ===================================================================
> --- builtins.c	(revision 166480)
> +++ builtins.c	(working copy)
> @@ -609,7 +609,7 @@
>       if (WORDS_BIG_ENDIAN)
> 	j = GET_MODE_SIZE (mode) - i - 1;
>       if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN
> -	  && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
> +	  && GET_MODE_SIZE (mode) >= UNITS_PER_WORD)
> 	j = j + UNITS_PER_WORD - 2 * (j % UNITS_PER_WORD) - 1;
>       j *= BITS_PER_UNIT;
>       gcc_assert (j < 2 * HOST_BITS_PER_WIDE_INT);
>
Paul Koning Jan. 6, 2011, 1:55 a.m. UTC | #3
Ping^2...

	paul

Begin forwarded message:

> From: Paul Koning <paul_koning@dell.com>
> Date: November 23, 2010 10:12:17 AM EST
> To: gcc-patches <gcc-patches@gcc.gnu.org>
> Subject: [RFA] Fix c_readstr for BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case
> 
> c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size.  The attached patch corrects this.
> 
> Checked on pdp11; also a bootstrap and make check on Linux-intel
> 
> Ok to commit?
> 
> 	paul
> 
> ChangeLog:
> 
> 2010-11-23  Paul Koning  <ni1d@arrl.net>
> 
> 	* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
> 	WORDS_BIG_ENDIAN. 
> 
> Index: builtins.c
> ===================================================================
> --- builtins.c	(revision 166480)
> +++ builtins.c	(working copy)
> @@ -609,7 +609,7 @@
>      if (WORDS_BIG_ENDIAN)
> 	j = GET_MODE_SIZE (mode) - i - 1;
>      if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN
> -	  && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
> +	  && GET_MODE_SIZE (mode) >= UNITS_PER_WORD)
> 	j = j + UNITS_PER_WORD - 2 * (j % UNITS_PER_WORD) - 1;
>      j *= BITS_PER_UNIT;
>      gcc_assert (j < 2 * HOST_BITS_PER_WIDE_INT);
>
Richard Henderson Jan. 24, 2011, 5:23 p.m. UTC | #4
On 11/23/2010 07:12 AM, Paul Koning wrote:
> c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size.  The attached patch corrects this.
> 
> Checked on pdp11.  I'm running a bootstrap and make check on Linux for completeness.
> 
> Ok to commit?
> 
> 	paul
> 
> ChangeLog:
> 
> 2010-11-23  Paul Koning  <ni1d@arrl.net>
> 
> 	* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
> 	WORDS_BIG_ENDIAN. 

Ok.


r~
Paul Koning Jan. 24, 2011, 5:46 p.m. UTC | #5
On Jan 24, 2011, at 12:23 PM, Richard Henderson wrote:

> On 11/23/2010 07:12 AM, Paul Koning wrote:
>> c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size.  The attached patch corrects this.
>> 
>> Checked on pdp11.  I'm running a bootstrap and make check on Linux for completeness.
>> 
>> Ok to commit?
>> 
>> 	paul
>> 
>> ChangeLog:
>> 
>> 2010-11-23  Paul Koning  <ni1d@arrl.net>
>> 
>> 	* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
>> 	WORDS_BIG_ENDIAN. 
> 
> Ok.

Thanks.  Committed.

	paul
diff mbox

Patch

Index: builtins.c
===================================================================
--- builtins.c	(revision 166480)
+++ builtins.c	(working copy)
@@ -609,7 +609,7 @@ 
       if (WORDS_BIG_ENDIAN)
 	j = GET_MODE_SIZE (mode) - i - 1;
       if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN
-	  && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
+	  && GET_MODE_SIZE (mode) >= UNITS_PER_WORD)
 	j = j + UNITS_PER_WORD - 2 * (j % UNITS_PER_WORD) - 1;
       j *= BITS_PER_UNIT;
       gcc_assert (j < 2 * HOST_BITS_PER_WIDE_INT);