Since you say it tests okay, I say it's "Okay for trunk". I am new to this, as you know, and I am still trying to figure out how to make all of this work. Nor have Jim and I figured out how to handle our joint responsibility.
Hence delays. > -----Original Message----- > From: Iain Sandoe <iains....@gmail.com> > Sent: Wednesday, April 2, 2025 14:24 > To: GCC Patches <gcc-patches@gcc.gnu.org> > Cc: James K. Lowden <jklow...@cobolworx.com>; Robert Dubner > <rdub...@symas.com> > Subject: [ping][PATCH] libgcobol: Provide fallbacks for C32 strfromf32/64 > [PR119296]. > > Hi folks, > it would be great to reduce the in-flight patch stack a bit :) > > > On 25 Mar 2025, at 16:40, Iain Sandoe <iains....@gmail.com> wrote: > > > > This is on top of the C++-ify configure and random_r patches. > > Tested on x86_64,aarch64-Linux and x86_64-darwin, OK for trunk? > > thanks > > Iain > > > > --- 8< --- > > > > strfrom{f,d,l,fN) are all C23 and might not be available in general. > > This uses snprintf() to provide fall-backs where the libc does not > > yet have support. > > > > PR cobol/119296 > > > > libgcobol/ChangeLog: > > > > * config.h.in: Regenerate. > > * configure: Regenerate. > > * configure.ac: Check for availability of strfromf32 and > > strfromf64. > > * libgcobol.cc (strfromf32, strfromf64): New. > > > > Signed-off-by: Iain Sandoe <i...@sandoe.co.uk> > > --- > > libgcobol/config.h.in | 6 ++++++ > > libgcobol/configure | 13 +++++++++++-- > > libgcobol/configure.ac | 3 +++ > > libgcobol/libgcobol.cc | 24 ++++++++++++++++++++++++ > > 4 files changed, 44 insertions(+), 2 deletions(-) > > > > diff --git a/libgcobol/config.h.in b/libgcobol/config.h.in > > index e7e1492b579..d61ff7ad497 100644 > > --- a/libgcobol/config.h.in > > +++ b/libgcobol/config.h.in > > @@ -36,6 +36,12 @@ > > /* Define to 1 if you have the <stdlib.h> header file. */ > > #undef HAVE_STDLIB_H > > > > +/* Define to 1 if you have the `strfromf32' function. */ > > +#undef HAVE_STRFROMF32 > > + > > +/* Define to 1 if you have the `strfromf64' function. */ > > +#undef HAVE_STRFROMF64 > > + > > /* Define to 1 if you have the <strings.h> header file. */ > > #undef HAVE_STRINGS_H > > > > diff --git a/libgcobol/configure b/libgcobol/configure > > index acf78646d5b..23474881f35 100755 > > --- a/libgcobol/configure > > +++ b/libgcobol/configure > > @@ -2696,6 +2696,8 @@ as_fn_append ac_func_list " random_r" > > as_fn_append ac_func_list " srandom_r" > > as_fn_append ac_func_list " initstate_r" > > as_fn_append ac_func_list " setstate_r" > > +as_fn_append ac_func_list " strfromf32" > > +as_fn_append ac_func_list " strfromf64" > > # Check that the precious variables saved in the cache have kept the > same > > # value. > > ac_cache_corrupted=false > > @@ -11621,7 +11623,7 @@ else > > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > > lt_status=$lt_dlunknown > > cat > conftest.$ac_ext <<_LT_EOF > > -#line 11624 "configure" > > +#line 11626 "configure" > > #include "confdefs.h" > > > > #if HAVE_DLFCN_H > > @@ -11727,7 +11729,7 @@ else > > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > > lt_status=$lt_dlunknown > > cat > conftest.$ac_ext <<_LT_EOF > > -#line 11730 "configure" > > +#line 11732 "configure" > > #include "confdefs.h" > > > > #if HAVE_DLFCN_H > > @@ -17699,6 +17701,13 @@ done > > > > > > > > +# These are C23, and might not be available in libc. > > + > > + > > + > > + > > + > > + > > if test "${multilib}" = "yes"; then > > multilib_arg="--enable-multilib" > > else > > diff --git a/libgcobol/configure.ac b/libgcobol/configure.ac > > index 0356f9e9c67..6e1ea3700d0 100644 > > --- a/libgcobol/configure.ac > > +++ b/libgcobol/configure.ac > > @@ -198,6 +198,9 @@ AC_SUBST(extra_ldflags_libgcobol) > > # These are GLIBC > > AC_CHECK_FUNCS_ONCE(random_r srandom_r initstate_r setstate_r) > > > > +# These are C23, and might not be available in libc. > > +AC_CHECK_FUNCS_ONCE(strfromf32 strfromf64) > > + > > if test "${multilib}" = "yes"; then > > multilib_arg="--enable-multilib" > > else > > diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc > > index 6aeaaa2c142..85f016e9735 100644 > > --- a/libgcobol/libgcobol.cc > > +++ b/libgcobol/libgcobol.cc > > @@ -68,6 +68,30 @@ > > > > #include "exceptl.h" > > > > +#if !defined (HAVE_STRFROMF32) > > +# if __FLT_MANT_DIG__ == 24 && __FLT_MAX_EXP__ == 128 > > +static int > > +strfromf32 (char *s, size_t n, const char *f, float v) > > +{ > > + return snprintf (s, n, f, (double) v); > > +} > > +# else > > +# error "It looks like float on this platform is not IEEE754" > > +# endif > > +#endif > > + > > +#if !defined (HAVE_STRFROMF64) > > +# if __DBL_MANT_DIG__ == 53 && __DBL_MAX_EXP__ == 1024 > > +static int > > +strfromf64 (char *s, size_t n, const char *f, double v) > > +{ > > + return snprintf (s, n, f, v); > > +} > > +# else > > +# error "It looks like double on this platform is not IEEE754" > > +# endif > > +#endif > > + > > // This couldn't be defined in symbols.h because it conflicts with a > LEVEL66 > > // in parse.h > > #define LEVEL66 (66) > > -- > > 2.39.2 (Apple Git-143) > >