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; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2005-09-12 19:22 UTC | newest]
Thread overview: 3+ 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
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).