Hi, Right now, the logic in libgfortran for the detection of REAL(KIND=16) is in kinds-override.h:
/* What are the C types corresponding to the real(kind=10) and
real(kind=16) types? We currently rely on the following assumptions:
-- if real(kind=10) exists, i.e. if HAVE_GFC_REAL_10 is defined,
then it is necessarily the "long double" type
-- if real(kind=16) exists, then:
* if HAVE_GFC_REAL_10, real(kind=16) is "__float128"
* otherwise, real(kind=16) is "long double"
To allow to change this in the future, we create the
GFC_REAL_16_IS_FLOAT128 macro that is used throughout libgfortran. */
Well, this may not be true of all platforms, and it’s possible to have other
combinations. On the aarch64-apple-darwin port, I’m currently playing with
enabling a binary128 floating-point mode, and that target has double == long
double… so the assumptions above are not true.
Funnily, we already have more fine-grained logic in the mk-kinds-h.sh script,
where we actually check the Fortran kind corresponding to C’s long double. We
just have to use it, and emit the GFC_REAL_16_IS_FLOAT128 /
GFC_REAL_16_IS_LONG_DOUBLE macros there.
Bootstrapped and regtested on x86_64-linux, checked that no symbols were
introduced or removed.
(and tested on a port to aarch64-apple-darwin).
OK to commit?
FX
libgfortran.patch
Description: Binary data
