diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2025-03-25 15:10:12 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2025-04-03 14:33:59 +0100 |
commit | b6aafe9a5b1452f3bafae5889aebad0b3de408a3 (patch) | |
tree | 4a83aa4fdf1414ca4e93b845fc3f3114ba322c02 | |
parent | 66a41a0a9626a9b2f8de3cdb6ba82561b50cd9e8 (diff) | |
download | gcc-b6aafe9a5b1452f3bafae5889aebad0b3de408a3.zip gcc-b6aafe9a5b1452f3bafae5889aebad0b3de408a3.tar.gz gcc-b6aafe9a5b1452f3bafae5889aebad0b3de408a3.tar.bz2 |
libgcobol: Provide fallbacks for C32 strfromf32/64 functions.
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.
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 <iain@sandoe.co.uk>
-rw-r--r-- | libgcobol/config.h.in | 6 | ||||
-rwxr-xr-x | libgcobol/configure | 13 | ||||
-rw-r--r-- | libgcobol/configure.ac | 3 | ||||
-rw-r--r-- | libgcobol/libgcobol.cc | 24 |
4 files changed, 44 insertions, 2 deletions
diff --git a/libgcobol/config.h.in b/libgcobol/config.h.in index b201266..5dd2b50 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 44190d7..e12b72e 100755 --- a/libgcobol/configure +++ b/libgcobol/configure @@ -2520,6 +2520,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 @@ -12906,7 +12908,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12909 "configure" +#line 12911 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13012,7 +13014,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 13015 "configure" +#line 13017 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16385,6 +16387,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 383b413..34c0235 100644 --- a/libgcobol/configure.ac +++ b/libgcobol/configure.ac @@ -218,6 +218,9 @@ AC_SUBST(enable_static) # 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 d8f4ded..c163e2c 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) |