On 07.01.22 22:48, Jakub Jelinek wrote:
On Fri, Jan 07, 2022 at 10:40:50PM +0100, Thomas Koenig wrote:
One thing that one has to watch out for is a big-endian IBM long double
file, so the byte swapping will have to be done before assigning
the value.
I've tried to handle that right, i.e. on unformatted read with
byte-swapping and r16 <-> r17 conversions first do byte-swapping
and then r16 <-> r17 conversions, while for unformatted writes
first r16 <-> r17 conversions and then byte-swapping.
I have tried to unravel the different cases here, I count six
(lumping together the environment variables, the CONVERT specifier
and -fconvert, and leaving out the byte swapping)
Compiler Convert Read action Write action
IEEE None None None
IEEE IEEE None None
IEEE IBM IBM->IEEE IEEE->IBM
IBM None None None
IBM IEEE IEEE->IBM IBM->IEEE
IBM IBM None None
From this table, it is clear that the compiler has to inform
the library about the option it is using, I think it is best
encoded in the number passed to _gfortran_set_convert.
Old programs should continue to run with the new library, so
the absence of a call to _gfortran_set_convert, or a call
which sets byte swapping, should have the old meaning, i.e
IBM long double. A program which uses IEEE long double should
then call _gfortran_set_convert with a suitable argument to
let the library know what to do, just in case.
I think this is what I will start working on.
Best regards
Thomas