* f/target.c HOST_BYTES_BIG_ENDIAN
@ 2002-08-22 5:16 Alan Modra
2002-08-22 6:34 ` Hans-Peter Nilsson
0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2002-08-22 5:16 UTC (permalink / raw)
To: gcc, gcc-patches; +Cc: Hans-Peter Nilsson
HOST_BYTES_BIG_ENDIAN and HOST_BITS_BIG_ENDIAN are referenced in
f/target.c when cross-compiling, but are not defined anywhere.
This makes g77 spit the dummy when cross-compiling from a
big-endian host to a big-endian target.
Since arbitrarily assuming host bytes and bits are little endian is
arguably worse than assuming host and target match, may I suggest
the following patch?
gcc/f/ChangeLog
* target.c (ffetarget_memcpy_): Don't test endian macros when
NATIVE_CROSS. Default host endian values to target values.
Index: gcc/f/target.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/target.c,v
retrieving revision 1.19
diff -u -p -r1.19 target.c
--- gcc/f/target.c 17 Jun 2002 21:21:01 -0000 1.19
+++ gcc/f/target.c 22 Aug 2002 12:04:18 -0000
@@ -2520,10 +2520,10 @@ ffetarget_verify_character1 (mallocPool
void *
ffetarget_memcpy_ (void *dst, void *src, size_t len)
{
-#ifdef CROSS_COMPILE
+#if defined (CROSS_COMPILE) && !defined (NATIVE_CROSS)
int host_words_big_endian =
#ifndef HOST_WORDS_BIG_ENDIAN
- 0
+ WORDS_BIG_ENDIAN
#else
HOST_WORDS_BIG_ENDIAN
#endif
@@ -2531,7 +2531,7 @@ ffetarget_memcpy_ (void *dst, void *src,
int host_bytes_big_endian =
#ifndef HOST_BYTES_BIG_ENDIAN
- 0
+ BYTES_BIG_ENDIAN
#else
HOST_BYTES_BIG_ENDIAN
#endif
@@ -2539,7 +2539,7 @@ ffetarget_memcpy_ (void *dst, void *src,
int host_bits_big_endian =
#ifndef HOST_BITS_BIG_ENDIAN
- 0
+ BITS_BIG_ENDIAN
#else
HOST_BITS_BIG_ENDIAN
#endif
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-22 5:16 f/target.c HOST_BYTES_BIG_ENDIAN Alan Modra
@ 2002-08-22 6:34 ` Hans-Peter Nilsson
2002-08-22 16:22 ` Alan Modra
0 siblings, 1 reply; 8+ messages in thread
From: Hans-Peter Nilsson @ 2002-08-22 6:34 UTC (permalink / raw)
To: Alan Modra; +Cc: gcc, gcc-patches
On Thu, 22 Aug 2002, Alan Modra wrote:
> HOST_BYTES_BIG_ENDIAN and HOST_BITS_BIG_ENDIAN are referenced in
> f/target.c when cross-compiling, but are not defined anywhere.
That sounds strange (for a BE host). f/target.c does include
config.h which includes auto-host.h... There doesn't seem to be
anything magic about NATIVE_CROSS. What am I missing?
brgds, H-P
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-22 6:34 ` Hans-Peter Nilsson
@ 2002-08-22 16:22 ` Alan Modra
2002-08-22 19:32 ` Hans-Peter Nilsson
0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2002-08-22 16:22 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: gcc, gcc-patches
On Thu, Aug 22, 2002 at 09:33:58AM -0400, Hans-Peter Nilsson wrote:
> On Thu, 22 Aug 2002, Alan Modra wrote:
>
> > HOST_BYTES_BIG_ENDIAN and HOST_BITS_BIG_ENDIAN are referenced in
> > f/target.c when cross-compiling, but are not defined anywhere.
>
> That sounds strange (for a BE host). f/target.c does include
> config.h which includes auto-host.h...
HOST_WORDS_BIG_ENDIAN is the only HOST_*_BIG_ENDIAN macro defined.
grep the source.
> There doesn't seem to be
> anything magic about NATIVE_CROSS. What am I missing?
Belts and braces. Strictly speaking, it's not necessary with the
other changes.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-22 16:22 ` Alan Modra
@ 2002-08-22 19:32 ` Hans-Peter Nilsson
2002-08-22 20:31 ` Alan Modra
2002-08-23 13:19 ` Toon Moene
0 siblings, 2 replies; 8+ messages in thread
From: Hans-Peter Nilsson @ 2002-08-22 19:32 UTC (permalink / raw)
To: Alan Modra; +Cc: gcc, gcc-patches
On Fri, 23 Aug 2002, Alan Modra wrote:
> On Thu, Aug 22, 2002 at 09:33:58AM -0400, Hans-Peter Nilsson wrote:
> > On Thu, 22 Aug 2002, Alan Modra wrote:
> >
> > > HOST_BYTES_BIG_ENDIAN and HOST_BITS_BIG_ENDIAN are referenced in
> > > f/target.c when cross-compiling, but are not defined anywhere.
> >
> > That sounds strange (for a BE host). f/target.c does include
> > config.h which includes auto-host.h...
>
> HOST_WORDS_BIG_ENDIAN is the only HOST_*_BIG_ENDIAN macro defined.
> grep the source.
Bummer. I added tests for macros that are not there. So only a
subset of the host <=> target mismatch situation is detectable:
HOST_WORDS_BIG_ENDIAN <=> BYTES_BIG_ENDIAN. The semantics for
the host vs. target macros are a little different;
HOST_WORDS_BIG_ENDIAN implies the hostness *BYTES*_BIG_ENDIAN
but also the host *WORDS*_BIG_ENDIAN. And apparently nothing
else has a need to test these host endian details so it doesn't
seem worthwhile to actually autoconf for it. Ugh.
Your patch is wrong; don't use the *target* BITS_BIG_ENDIAN (et
al) when the HOST_ one isn't defined. I suggest to remove that
test; check instead that HOST_WORDS_BIG_ENDIAN matches both
BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN. I see there's also a
HOST_FLOAT_WORDS_BIG_ENDIAN FWIW.
(Heh, it seems few people use big-endian hosts for
cross-compiling fortran.)
> > There doesn't seem to be
> > anything magic about NATIVE_CROSS. What am I missing?
>
> Belts and braces. Strictly speaking, it's not necessary with the
> other changes.
Well it's confusing. I think there should be no NATIVE_CROSS
test. (Actually it's the wrong direction of the belts and
braces; belts and braces would have been to remove the #ifdef
CROSS_COMPILE and *always* test for endian mismatch. ;-)
brgds, H-P
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-22 19:32 ` Hans-Peter Nilsson
@ 2002-08-22 20:31 ` Alan Modra
2002-08-23 13:42 ` Hans-Peter Nilsson
2002-08-23 13:19 ` Toon Moene
1 sibling, 1 reply; 8+ messages in thread
From: Alan Modra @ 2002-08-22 20:31 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: gcc
On Thu, Aug 22, 2002 at 10:32:07PM -0400, Hans-Peter Nilsson wrote:
> Your patch is wrong; don't use the *target* BITS_BIG_ENDIAN (et
> al) when the HOST_ one isn't defined. I suggest to remove that
> test; check instead that HOST_WORDS_BIG_ENDIAN matches both
> BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN.
Please, can you fix your code then?
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-22 19:32 ` Hans-Peter Nilsson
2002-08-22 20:31 ` Alan Modra
@ 2002-08-23 13:19 ` Toon Moene
1 sibling, 0 replies; 8+ messages in thread
From: Toon Moene @ 2002-08-23 13:19 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: Alan Modra, gcc, gcc-patches
Hans-Peter Nilsson wrote:
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-22 20:31 ` Alan Modra
@ 2002-08-23 13:42 ` Hans-Peter Nilsson
2002-08-23 20:27 ` Alan Modra
0 siblings, 1 reply; 8+ messages in thread
From: Hans-Peter Nilsson @ 2002-08-23 13:42 UTC (permalink / raw)
To: Alan Modra; +Cc: gcc, gcc-patches
(gcc-patches@ added for archival purposes.)
On Fri, 23 Aug 2002, Alan Modra wrote:
> On Thu, Aug 22, 2002 at 10:32:07PM -0400, Hans-Peter Nilsson wrote:
> > Your patch is wrong; don't use the *target* BITS_BIG_ENDIAN (et
> > al) when the HOST_ one isn't defined. I suggest to remove that
> > test; check instead that HOST_WORDS_BIG_ENDIAN matches both
> > BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN.
>
> Please, can you fix your code then?
Fair enough; here. I've just sanity tested that this compiles
on a i686-pc-linux-gnu, with "make" on top of a previously
compiled tree. Could you please test if it works for you?
* target.c (ffetarget_memcpy_): Don't test nonexistent
HOST_BYTES_BIG_ENDIAN, HOST_BITS_BIG_ENDIAN. Check
HOST_WORDS_BIG_ENDIAN against both WORDS_BIG_ENDIAN and
BYTES_BIG_ENDIAN. Check HOST_FLOAT_WORDS_BIG_ENDIAN against
FLOAT_WORDS_BIG_ENDIAN.
Index: target.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/target.c,v
retrieving revision 1.19
diff -p -c -r1.19 target.c
*** target.c 17 Jun 2002 21:21:01 -0000 1.19
--- target.c 23 Aug 2002 20:30:19 -0000
*************** void *
*** 2521,2526 ****
--- 2521,2530 ----
ffetarget_memcpy_ (void *dst, void *src, size_t len)
{
#ifdef CROSS_COMPILE
+
+ /* HOST_WORDS_BIG_ENDIAN corresponds to both WORDS_BIG_ENDIAN and
+ BYTES_BIG_ENDIAN (i.e. a difference in the two latter is not
+ representable on the host). */
int host_words_big_endian =
#ifndef HOST_WORDS_BIG_ENDIAN
0
*************** ffetarget_memcpy_ (void *dst, void *src,
*** 2529,2547 ****
#endif
;
! int host_bytes_big_endian =
! #ifndef HOST_BYTES_BIG_ENDIAN
! 0
! #else
! HOST_BYTES_BIG_ENDIAN
! #endif
! ;
!
! int host_bits_big_endian =
! #ifndef HOST_BITS_BIG_ENDIAN
0
#else
! HOST_BITS_BIG_ENDIAN
#endif
;
--- 2533,2543 ----
#endif
;
! int host_float_words_big_endian =
! #ifndef HOST_FLOAT_WORDS_BIG_ENDIAN
0
#else
! HOST_FLOAT_WORDS_BIG_ENDIAN
#endif
;
*************** ffetarget_memcpy_ (void *dst, void *src,
*** 2555,2562 ****
for instance in g77.f-torture/execute/980628-[4-6].f and alpha2.f.
Still, we compile *some* code. FIXME: Rewrite handling of numbers. */
if (!WORDS_BIG_ENDIAN != !host_words_big_endian
! || !BYTES_BIG_ENDIAN != !host_bytes_big_endian
! || !BITS_BIG_ENDIAN != !host_bits_big_endian)
sorry ("data initializer on host with different endianness");
#endif /* CROSS_COMPILE */
--- 2551,2558 ----
for instance in g77.f-torture/execute/980628-[4-6].f and alpha2.f.
Still, we compile *some* code. FIXME: Rewrite handling of numbers. */
if (!WORDS_BIG_ENDIAN != !host_words_big_endian
! || !BYTES_BIG_ENDIAN != !host_words_big_endian
! || !FLOAT_WORDS_BIG_ENDIAN != !host_float_words_big_endian)
sorry ("data initializer on host with different endianness");
#endif /* CROSS_COMPILE */
brgds, H-P
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: f/target.c HOST_BYTES_BIG_ENDIAN
2002-08-23 13:42 ` Hans-Peter Nilsson
@ 2002-08-23 20:27 ` Alan Modra
0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2002-08-23 20:27 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: gcc, gcc-patches
On Fri, Aug 23, 2002 at 04:42:46PM -0400, Hans-Peter Nilsson wrote:
> Fair enough; here. I've just sanity tested that this compiles
> on a i686-pc-linux-gnu, with "make" on top of a previously
> compiled tree. Could you please test if it works for you?
It does. Thanks.
> * target.c (ffetarget_memcpy_): Don't test nonexistent
> HOST_BYTES_BIG_ENDIAN, HOST_BITS_BIG_ENDIAN. Check
> HOST_WORDS_BIG_ENDIAN against both WORDS_BIG_ENDIAN and
> BYTES_BIG_ENDIAN. Check HOST_FLOAT_WORDS_BIG_ENDIAN against
> FLOAT_WORDS_BIG_ENDIAN.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-08-23 20:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-22 5:16 f/target.c HOST_BYTES_BIG_ENDIAN Alan Modra
2002-08-22 6:34 ` Hans-Peter Nilsson
2002-08-22 16:22 ` Alan Modra
2002-08-22 19:32 ` Hans-Peter Nilsson
2002-08-22 20:31 ` Alan Modra
2002-08-23 13:42 ` Hans-Peter Nilsson
2002-08-23 20:27 ` Alan Modra
2002-08-23 13:19 ` Toon Moene
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).