public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: LittleEndian
@ 2002-04-29 16:08 Robert Dewar
  2002-04-30  5:03 ` LittleEndian Allan Sandfeld Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Dewar @ 2002-04-29 16:08 UTC (permalink / raw)
  To: gcc, mirih, snowwolf, tprince

> Why would you want such an option?  If the code contains byte-order
> dependencies, it's unlikely that a compiler option would fix it.  If you're
> trying to port binary data files, good luck.


Most often the reason people want this is that they think it will automatically
solve the endianess problem in porting code or data from one machine to another.
That's wrong of course, but people live in hope :-)

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

* Re: LittleEndian
  2002-04-29 16:08 LittleEndian Robert Dewar
@ 2002-04-30  5:03 ` Allan Sandfeld Jensen
  2002-04-30 14:03   ` LittleEndian Toon Moene
  0 siblings, 1 reply; 9+ messages in thread
From: Allan Sandfeld Jensen @ 2002-04-30  5:03 UTC (permalink / raw)
  To: Robert Dewar, gcc

On Monday 29 April 2002 23:52, Robert Dewar wrote:
> > Why would you want such an option?  If the code contains byte-order
> > dependencies, it's unlikely that a compiler option would fix it.  If
> > you're trying to port binary data files, good luck.
>
> Most often the reason people want this is that they think it will
> automatically solve the endianess problem in porting code or data from one
> machine to another. That's wrong of course, but people live in hope :-)

Sometimes it just practical if you want to retain your bitfidling algorithms 
from one architecture to another. Ofcouse personally I would prefer to have 
it as a syntax option to int. E.g. "little_endian long int" or just "le 
long". The ELF-flag would then just specify which is default.

The above would make it possible to mark the places in the code where you 
assume endianness, and as a minimum halt compilation on architectures that 
doesnt support the assumed endian.

`Allan

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

* Re: LittleEndian
  2002-04-30  5:03 ` LittleEndian Allan Sandfeld Jensen
@ 2002-04-30 14:03   ` Toon Moene
  2002-04-30 14:12     ` LittleEndian Allan Sandfeld Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Toon Moene @ 2002-04-30 14:03 UTC (permalink / raw)
  To: Allan Sandfeld Jensen; +Cc: Robert Dewar, gcc

Allan Sandfeld Jensen wrote:

> Sometimes it just practical if you want to retain your bitfidling algorithms
> from one architecture to another. Ofcouse personally I would prefer to have
> it as a syntax option to int. E.g. "little_endian long int" or just "le
> long". The ELF-flag would then just specify which is default.

Why do you want syntax to determine endianness ?  Surely it's detectable
at run time.

Here's the Fortran implementation:

      SUBROUTINE ENDIANP
      INTEGER*1 IBITS(10)
      LOGICAL LITTLE
      COMMON /ENDIAN/ LITTLE
      EQUIVALENCE (IBITS, JBITS)
      NWBITS = BIT_SIZE(JBITS)
      NBBITS = BIT_SIZE(IBITS(1))
      DO I = 1, NWBITS, NBBITS
         IBITS(I/NBBITS+1) = I
      ENDDO
      LITTLE = .TRUE.
      KBITS  = JBITS
      DO I = 1, NWBITS, NBBITS
         LITTLE = LITTLE .AND.
     ,               IAND(KBITS,2**NBBITS-1) .EQ. IBITS(I/NBBITS+1)
         KBITS = ISHFT(KBITS, -NBBITS)
      ENDDO
      END

In the routines where you need to know enddiannes, simply declare the
COMMON block:

      ....
      LOGICAL LITTLE
      COMMON /ENDIAN/ LITTLE
      ....
      IF (LITTLE) THEN
         ... ! Little endian branch
      ELSE
         ... ! Big endian branch
      ENDIF
      ...

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

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

* Re: LittleEndian
  2002-04-30 14:03   ` LittleEndian Toon Moene
@ 2002-04-30 14:12     ` Allan Sandfeld Jensen
  2002-04-30 14:52       ` LittleEndian Toon Moene
  0 siblings, 1 reply; 9+ messages in thread
From: Allan Sandfeld Jensen @ 2002-04-30 14:12 UTC (permalink / raw)
  To: gcc; +Cc: Toon Moene

On Tuesday 30 April 2002 22:30, you wrote:
> Allan Sandfeld Jensen wrote:
> > Sometimes it just practical if you want to retain your bitfidling
> > algorithms from one architecture to another. Ofcouse personally I would
> > prefer to have it as a syntax option to int. E.g. "little_endian long
> > int" or just "le long". The ELF-flag would then just specify which is
> > default.
>
> Why do you want syntax to determine endianness ?  Surely it's detectable
> at run time.
>
Because it is less code and more elegant. You write one function with one 
endianness. System that has a different can then simultate it, or simply use 
the right one if they support both, like most does by now.

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

* Re: LittleEndian
  2002-04-30 14:12     ` LittleEndian Allan Sandfeld Jensen
@ 2002-04-30 14:52       ` Toon Moene
  0 siblings, 0 replies; 9+ messages in thread
From: Toon Moene @ 2002-04-30 14:52 UTC (permalink / raw)
  To: Allan Sandfeld Jensen; +Cc: gcc

Allan Sandfeld Jensen wrote:

> Because it is less code and more elegant. You write one function with one
> endianness. System that has a different can then simultate it, or simply use
> the right one if they support both, like most does by now.

Sure - I hope everyone gets it right for a Canadian Cross, then.

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

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

* Re: LittleEndian
@ 2002-04-30  5:20 Robert Dewar
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 2002-04-30  5:20 UTC (permalink / raw)
  To: dewar, gcc, snowwolf

> The above would make it possible to mark the places in the code where you 
> assume endianness, and as a minimum halt compilation on architectures that 
> doesnt support the assumed endian.

Any architecture can support either endianness in the weak sense of
supporting it for loads/stores. I agree with the utility of being
able to mark individual declarations. We did this in Realia COBOL
(COMP-4 was big endian, IBM compatible, COMP-5 was little endian,
Intel compatible, and a compiler flag determined whether plain
COMP was COMP-4 or COMP-5).

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

* Re: LittleEndian
  2002-04-29  8:22 ` LittleEndian Tim Prince
@ 2002-04-29 14:52   ` Allan Sandfeld Jensen
  0 siblings, 0 replies; 9+ messages in thread
From: Allan Sandfeld Jensen @ 2002-04-29 14:52 UTC (permalink / raw)
  To: tprince, Miri, 'gcc@gcc.gnu.org'

On Monday 29 April 2002 17:03, Tim Prince wrote:
> On Monday 29 April 2002 00:06, Miri wrote:
> > Hi,
> >
> > I?m trying to port code from SUN-Solaris (Sparc) to  Linux using GCC
> > 3.0.4. I tried to compile  to littleEndian using ?mlittle-endian ? but
> > its seems that the new compiler not supports that option (writes that its
> > not in spec file).
> >
> > Can you please help or give me a hint.
> >
> > Thank you
> >
> > Miri
>
> Why would you want such an option?  If the code contains byte-order
> dependencies, it's unlikely that a compiler option would fix it.  If you're
> trying to port binary data files, good luck.

Because sparc supports both endians, and the ELF format already contains the 
necessary infomation to protect against wrongfull linking. 


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

* Re: LittleEndian
  2002-04-28 23:32 LittleEndian Miri
@ 2002-04-29  8:22 ` Tim Prince
  2002-04-29 14:52   ` LittleEndian Allan Sandfeld Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Tim Prince @ 2002-04-29  8:22 UTC (permalink / raw)
  To: Miri, 'gcc@gcc.gnu.org'

On Monday 29 April 2002 00:06, Miri wrote:
> Hi,
>
> I?m trying to port code from SUN-Solaris (Sparc) to  Linux using GCC 3.0.4.
> I tried to compile  to littleEndian using ?mlittle-endian ? but its seems
> that the new compiler not supports that option (writes that its not in spec
> file).
>
> Can you please help or give me a hint.
>
> Thank you
>
> Miri
Why would you want such an option?  If the code contains byte-order 
dependencies, it's unlikely that a compiler option would fix it.  If you're 
trying to port binary data files, good luck.
-- 
Tim Prince

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

* LittleEndian
@ 2002-04-28 23:32 Miri
  2002-04-29  8:22 ` LittleEndian Tim Prince
  0 siblings, 1 reply; 9+ messages in thread
From: Miri @ 2002-04-28 23:32 UTC (permalink / raw)
  To: 'gcc@gcc.gnu.org'

Hi,

I’m trying to port code from SUN-Solaris (Sparc) to  Linux using GCC 3.0.4.
I tried to compile  to littleEndian using –mlittle-endian – but its seems
that the new compiler not supports that option (writes that its not in spec
file).

Can you please help or give me a hint.

Thank you

Miri

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

end of thread, other threads:[~2002-04-30 21:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-29 16:08 LittleEndian Robert Dewar
2002-04-30  5:03 ` LittleEndian Allan Sandfeld Jensen
2002-04-30 14:03   ` LittleEndian Toon Moene
2002-04-30 14:12     ` LittleEndian Allan Sandfeld Jensen
2002-04-30 14:52       ` LittleEndian Toon Moene
  -- strict thread matches above, loose matches on Subject: below --
2002-04-30  5:20 LittleEndian Robert Dewar
2002-04-28 23:32 LittleEndian Miri
2002-04-29  8:22 ` LittleEndian Tim Prince
2002-04-29 14:52   ` LittleEndian Allan Sandfeld Jensen

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