2025-03-15 22:58:46 +00:00
|
|
|
/* Copyright The GNU Toolchain Authors. */
|
|
|
|
|
|
|
|
/* This file is part of the GNU COBOL runtime library (libgcobol).
|
|
|
|
|
|
|
|
libgcobol is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
libgcobol is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/* You must include "config.h" before this file. */
|
|
|
|
|
|
|
|
#if __LDBL_MANT_DIG__ == 113 && __LDBL_MIN_EXP__ == -16381
|
|
|
|
// Use long double, l suffix on calls, l or L suffix in literals
|
|
|
|
# define GCOB_FP128 long double
|
|
|
|
# define GCOB_FP128_LITERAL(lit) (lit ## l)
|
|
|
|
# define FP128_FUNC(funcname) funcname ## l
|
libgcobol: Handle long double as an alternate IEEE754 quad [PR119244]
I think there should be consistency in what we use, so like
libgcobol-fp.h specifies, IEEE quad long double should have highest
priority, then _Float128 with *f128 APIs, then libquadmath.
And when we decide to use say long double, we shouldn't mix that with
strfromf128/strtof128.
Additionally, given that the *l vs. *f128 vs. *q API decision is done
solely in libgcobol and not in the compiler (which is different from
the Fortran case where compiled code emits say sinq or sinf128 calls),
I think libgcobol.spec should only have -lquadmath in any form only in
the case when using libquadmath for everything. In the Fortran case
it is for backwards compatibility purposes, if something has been
compiled with older gfortran which used say sinq and link is done by
gfortran which has been configured against new glibc with *f128, linking
would fail otherwise.
2025-04-15 Jakub Jelinek <jakub@redhat.com>
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR cobol/119244
* acinclude.m4 (LIBGCOBOL_CHECK_FLOAT128): Ensure
libgcob_cv_have_float128 is not yes on targets with IEEE quad
long double. Don't check for --as-needed nor set LIBQUADSPEC
on targets which USE_IEC_60559.
* libgcobol-fp.h (FP128_FMT, strtofp128, strfromfp128): Define.
* intrinsic.cc (strtof128): Don't redefine.
(WEIRD_TRANSCENDENT_RETURN_VALUE): Use GCOB_FP128_LITERAL macro.
(__gg__numval_f): Use strtofp128 instead of strtof128.
* libgcobol.cc (strtof128): Don't redefine.
(format_for_display_internal): Use strfromfp128 instead of
strfromf128 or quadmath_snprintf and use FP128_FMT in the format
string.
(get_float128, __gg__compare_2, __gg__move, __gg__move_literala):
Use strtofp128 instead of strtof128.
* configure: Regenerate.
2025-04-15 07:55:55 +02:00
|
|
|
# define FP128_FMT "L"
|
|
|
|
# define strtofp128(nptr, endptr) strtold(nptr, endptr)
|
|
|
|
# define strfromfp128(str, n, format, fp) snprintf(str, n, format, fp)
|
2025-03-15 22:58:46 +00:00
|
|
|
#elif __FLT128_MANT_DIG__ == 113 && __FLT128_MIN_EXP__ == -16381 \
|
|
|
|
&& defined(USE_IEC_60559)
|
|
|
|
// Use _Float128, f128 suffix on calls, f128 or F128 suffix on literals
|
|
|
|
# define GCOB_FP128 _Float128
|
|
|
|
# define GCOB_FP128_LITERAL(lit) (lit ## f128)
|
|
|
|
# define FP128_FUNC(funcname) funcname ## f128
|
libgcobol: Handle long double as an alternate IEEE754 quad [PR119244]
I think there should be consistency in what we use, so like
libgcobol-fp.h specifies, IEEE quad long double should have highest
priority, then _Float128 with *f128 APIs, then libquadmath.
And when we decide to use say long double, we shouldn't mix that with
strfromf128/strtof128.
Additionally, given that the *l vs. *f128 vs. *q API decision is done
solely in libgcobol and not in the compiler (which is different from
the Fortran case where compiled code emits say sinq or sinf128 calls),
I think libgcobol.spec should only have -lquadmath in any form only in
the case when using libquadmath for everything. In the Fortran case
it is for backwards compatibility purposes, if something has been
compiled with older gfortran which used say sinq and link is done by
gfortran which has been configured against new glibc with *f128, linking
would fail otherwise.
2025-04-15 Jakub Jelinek <jakub@redhat.com>
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR cobol/119244
* acinclude.m4 (LIBGCOBOL_CHECK_FLOAT128): Ensure
libgcob_cv_have_float128 is not yes on targets with IEEE quad
long double. Don't check for --as-needed nor set LIBQUADSPEC
on targets which USE_IEC_60559.
* libgcobol-fp.h (FP128_FMT, strtofp128, strfromfp128): Define.
* intrinsic.cc (strtof128): Don't redefine.
(WEIRD_TRANSCENDENT_RETURN_VALUE): Use GCOB_FP128_LITERAL macro.
(__gg__numval_f): Use strtofp128 instead of strtof128.
* libgcobol.cc (strtof128): Don't redefine.
(format_for_display_internal): Use strfromfp128 instead of
strfromf128 or quadmath_snprintf and use FP128_FMT in the format
string.
(get_float128, __gg__compare_2, __gg__move, __gg__move_literala):
Use strtofp128 instead of strtof128.
* configure: Regenerate.
2025-04-15 07:55:55 +02:00
|
|
|
# define FP128_FMT ""
|
|
|
|
# define strtofp128(nptr, endptr) strtof128(nptr, endptr)
|
|
|
|
# define strfromfp128(str, n, format, fp) strfromf128(str, n, format, fp)
|
2025-03-15 22:58:46 +00:00
|
|
|
#elif __FLT128_MANT_DIG__ == 113 && __FLT128_MIN_EXP__ == -16381
|
|
|
|
// Use __float128, q suffix on calls, q or Q suffix on literals
|
|
|
|
# define GCOB_FP128 __float128
|
|
|
|
# define GCOB_FP128_LITERAL(lit) (lit ## q)
|
|
|
|
# define FP128_FUNC(funcname) funcname ## q
|
libgcobol: Handle long double as an alternate IEEE754 quad [PR119244]
I think there should be consistency in what we use, so like
libgcobol-fp.h specifies, IEEE quad long double should have highest
priority, then _Float128 with *f128 APIs, then libquadmath.
And when we decide to use say long double, we shouldn't mix that with
strfromf128/strtof128.
Additionally, given that the *l vs. *f128 vs. *q API decision is done
solely in libgcobol and not in the compiler (which is different from
the Fortran case where compiled code emits say sinq or sinf128 calls),
I think libgcobol.spec should only have -lquadmath in any form only in
the case when using libquadmath for everything. In the Fortran case
it is for backwards compatibility purposes, if something has been
compiled with older gfortran which used say sinq and link is done by
gfortran which has been configured against new glibc with *f128, linking
would fail otherwise.
2025-04-15 Jakub Jelinek <jakub@redhat.com>
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR cobol/119244
* acinclude.m4 (LIBGCOBOL_CHECK_FLOAT128): Ensure
libgcob_cv_have_float128 is not yes on targets with IEEE quad
long double. Don't check for --as-needed nor set LIBQUADSPEC
on targets which USE_IEC_60559.
* libgcobol-fp.h (FP128_FMT, strtofp128, strfromfp128): Define.
* intrinsic.cc (strtof128): Don't redefine.
(WEIRD_TRANSCENDENT_RETURN_VALUE): Use GCOB_FP128_LITERAL macro.
(__gg__numval_f): Use strtofp128 instead of strtof128.
* libgcobol.cc (strtof128): Don't redefine.
(format_for_display_internal): Use strfromfp128 instead of
strfromf128 or quadmath_snprintf and use FP128_FMT in the format
string.
(get_float128, __gg__compare_2, __gg__move, __gg__move_literala):
Use strtofp128 instead of strtof128.
* configure: Regenerate.
2025-04-15 07:55:55 +02:00
|
|
|
# define FP128_FMT "Q"
|
|
|
|
# define strtofp128(nptr, endptr) strtoflt128(nptr, endptr)
|
|
|
|
# define strfromfp128(str, n, format, fp) quadmath_snprintf(str, n, format, fp)
|
2025-03-15 22:58:46 +00:00
|
|
|
#else
|
|
|
|
# error "libgcobol requires 128b floating point"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_QUADMATH
|
|
|
|
/* We will assume that unless we found the 128 to/from string and some
|
|
|
|
representative trig functions, we need libquadmath to support those. */
|
|
|
|
# include "quadmath.h"
|
|
|
|
#endif
|