]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgcobol: Provide fallbacks for C32 strfromf32/64 functions.
authorIain Sandoe <iain@sandoe.co.uk>
Tue, 25 Mar 2025 15:10:12 +0000 (15:10 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Thu, 3 Apr 2025 13:33:59 +0000 (14:33 +0100)
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>
libgcobol/config.h.in
libgcobol/configure
libgcobol/configure.ac
libgcobol/libgcobol.cc

index b201266e0610a8369482b3b5def48a06ef2a0dc5..5dd2b5071ff19a451167cf6fd87ed4daebe0969b 100644 (file)
 /* 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
 
index 44190d7e2fe0ffbea9c7d41d7cae6b57945b4816..e12b72e0817cdde14adbae47c6163fd52e69b46e 100755 (executable)
@@ -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
index 383b4134b130600f4c739b64638ac291a73e008f..34c0235c56b95a12778e3edcf1cf72739357a4cc 100644 (file)
@@ -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
index d8f4deda863af6585e808022db35a5527a8d556b..c163e2c92f2b11bdb5e8d5d2bb7ed0ec6a177985 100644 (file)
 
 #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)