public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/23815] New: Add -byteswapio flag
@ 2005-09-11  5:14 rrr6399 at futuretek dot com
  2005-09-12 14:29 ` [Bug fortran/23815] " pinskia at gcc dot gnu dot org
  2005-09-12 19:22 ` falk at debian dot org
  0 siblings, 2 replies; 35+ messages in thread
From: rrr6399 at futuretek dot com @ 2005-09-11  5:14 UTC (permalink / raw)
  To: gcc-bugs

It is pretty typical that aero engineers involved in CFD (computational
fluid dynamics) need to ship around large (50-1000 MB) binary files between
various big-endian and little-endian machines without having to reformat them. 

Typically they generate files that are all big-endian using a compiler switch to
avoid having to byte swap as well. So it'd be great to have a compiler switch
that reversed the byte order of integers (2, 4, 8 byte) and floating point
numbers (4, 8 byte) when they are read from or written to an unformatted file.

For instance if you had an 4 byte int stored as an array of chars,
you might swap it using this simple approach:
 for (i = 0; i < 4; i++ ) {
   swappedBytes[i] = bytes[3-i];
 }

or if you want to do the bit shifting thing, you do do it this way:

    return (((buf [ 3 ] & 0xff) << 24) | ((buf [ 2 ] & 0xff) << 16) |
           ((buf [ 1 ] & 0xff) << 8) | (buf [ 0 ] & 0xff));

(I grabbed this code from converToInt() in: 
gcc-4.1-20050909/libjava/classpath/gnu/CORBA/CDR/LittleEndianInputStream.java)

-- 
           Summary: Add -byteswapio flag
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P1
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rrr6399 at futuretek dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23815


^ permalink raw reply	[flat|nested] 35+ messages in thread
[parent not found: <bug-23815-7128@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2006-02-09 20:03 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-11  5:14 [Bug fortran/23815] New: Add -byteswapio flag rrr6399 at futuretek dot com
2005-09-12 14:29 ` [Bug fortran/23815] " pinskia at gcc dot gnu dot org
2005-09-12 19:22 ` falk at debian dot org
     [not found] <bug-23815-7128@http.gcc.gnu.org/bugzilla/>
2005-10-11 13:25 ` tobi at gcc dot gnu dot org
2005-10-11 18:40 ` tkoenig at gcc dot gnu dot org
2005-10-11 19:01 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2005-10-11 19:20 ` rrr6399 at futuretek dot com
2005-10-11 19:37 ` tkoenig at gcc dot gnu dot org
2005-11-02 17:16 ` pinskia at gcc dot gnu dot org
2005-11-02 18:17 ` rrr6399 at futuretek dot com
2005-11-02 21:20 ` tkoenig at gcc dot gnu dot org
2005-11-05 22:21 ` tkoenig at gcc dot gnu dot org
2005-11-10 22:39 ` tkoenig at gcc dot gnu dot org
2005-11-10 22:53 ` tkoenig at gcc dot gnu dot org
2005-11-11  4:52 ` kargl at gcc dot gnu dot org
2005-11-11 13:26 ` rrr6399 at futuretek dot com
2005-11-11 23:53 ` tkoenig at gcc dot gnu dot org
2005-11-12  0:02 ` tkoenig at gcc dot gnu dot org
2005-11-18 21:17 ` tkoenig at gcc dot gnu dot org
2005-11-27 22:15 ` tkoenig at gcc dot gnu dot org
2005-11-27 22:27 ` tkoenig at gcc dot gnu dot org
2005-11-27 22:42 ` sgk at troutmask dot apl dot washington dot edu
2005-12-06 21:45 ` tkoenig at gcc dot gnu dot org
2005-12-10 13:09 ` tkoenig at gcc dot gnu dot org
2005-12-10 20:02 ` tkoenig at gcc dot gnu dot org
2005-12-10 20:12 ` tkoenig at gcc dot gnu dot org
2005-12-13 21:11 ` tkoenig at gcc dot gnu dot org
2006-01-09 22:53 ` tkoenig at gcc dot gnu dot org
2006-01-15 21:07 ` tkoenig at gcc dot gnu dot org
2006-01-27 20:40 ` tkoenig at gcc dot gnu dot org
2006-02-06 20:12 ` tkoenig at gcc dot gnu dot org
2006-02-08 20:14 ` tkoenig at gcc dot gnu dot org
2006-02-08 20:15 ` tkoenig at gcc dot gnu dot org
2006-02-09 15:12 ` tobi at gcc dot gnu dot org
2006-02-09 20:03 ` tkoenig at gcc dot gnu dot org

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