Hi Iain,

>> On 9 Apr 2025, at 09:00, Rainer Orth <r...@cebitec.uni-bielefeld.de> wrote:
>> 
>> Jakub Jelinek <ja...@redhat.com> writes:
>> 
>>> On Sun, Apr 06, 2025 at 09:02:07AM +0100, Iain Sandoe wrote:
>>>> 
>>>> +
>>>> +#if !defined (HAVE_STRTOF128)
>>>> +# if USE_QUADMATH
>>>> +#  define strtof128 strtoflt128
>>>> +# else
>>>> +#  error "no available string to float 128"
>>>> +# endif
>>>> +#endif
>>> 
>>> If there is no strtof128 and not using libquadmath, there is always
>>> the possibility to use strtold if long double is IEEE quad.
>>> But that can be fixed incrementally.
>>> 
>>> As for strfromf128, there is always the possibility to use snprintf
>>> with %.36LE format specifier if long double is IEEE quad.
>> 
>> That's what's needed on Solaris/SPARC which has _Float128, 128-bit long
>> double, but no __float128 (yet, patch WIP).
>
> OK - so you have the case:
>  - long double == ieee753 128b float
>  - no support for the io/transcendental functions in libc?

Right: SPARC has 128-bit long double as per the psABI (both 32 and
64-bit), but there are some SPARC targets that don't heed that.  C23
isn't supported on Solaris yet, don't know about plans either.

>> I guess it would be better to move that strtof128 and strfromf128
>> handling to libgcobol-fp.h to avoid duplication.
>
> I think that the right solution is probably to define something in
> libgcobol-fp.h that
> shortens the tests, because IIRC we have to adapt the format string on the 
> basis
> of which case we have so some of the work cannot be completely moved to the
> header.

I think we can do something like define strfromf128 as quadmath_snprintf
if libquadmath is in use, snprintf for targets with 128-bit long double,
and use the libc version if available.

I think the format string differences can be handled by defining, say,
FP128_FMT as one of "Q" (libquadmath), "" (C23), or "L" (128-bit long
double) and constructing the final format string using string
concatenation.

I've got an incremental patch doing that, but something is still wrong ATM.

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Reply via email to