summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-08-23 13:03:35 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-08-23 13:03:35 +0000
commitdb8092dc4c678051e1d4e3935a901dbeeef95562 (patch)
tree9abbc0a4bb0fdbe3f645d62bc422147e4a4c80db /libgfortran
parentb73aff3657492d5425e780ec650f2c00658a73de (diff)
downloadgcc-db8092dc4c678051e1d4e3935a901dbeeef95562.tar.gz
re PR libfortran/23138 ([mingw32] real(16) values are printed incorrectly)
PR libfortran/23138 * acinclude.m4 (LIBGFOR_CHECK_MINGW_SNPRINTF): New check. * configure.ac: Use LIBGFOR_CHECK_MINGW_SNPRINTF. * libgfortran.h: If HAVE_MINGW_SNPRINTF is true, use __mingw_snprintf instead of snprintf. * config.h.in: Regenerate. * configure: Regenerate. From-SVN: r127739
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog10
-rw-r--r--libgfortran/acinclude.m416
-rw-r--r--libgfortran/config.h.in3
-rwxr-xr-xlibgfortran/configure77
-rw-r--r--libgfortran/configure.ac3
-rw-r--r--libgfortran/libgfortran.h10
6 files changed, 119 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 2fabcb28a3f..e9832a0e24e 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,13 @@
+2007-08-23 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR libfortran/23138
+ * acinclude.m4 (LIBGFOR_CHECK_MINGW_SNPRINTF): New check.
+ * configure.ac: Use LIBGFOR_CHECK_MINGW_SNPRINTF.
+ * libgfortran.h: If HAVE_MINGW_SNPRINTF is true, use __mingw_snprintf
+ instead of snprintf.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+
2007-08-22 Bernhard Fischer <rep.dot.nop@gmail.com>
* libgfortran/Makefile.am (AM_CPPFLAGS): Commentary typo fix.
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index 1270a98c04e..40ce53560b3 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -386,3 +386,19 @@ AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])
fi
])
+
+dnl Check whether we have a mingw that provides a __mingw_snprintf function
+AC_DEFUN([LIBGFOR_CHECK_MINGW_SNPRINTF], [
+ AC_CACHE_CHECK([whether __mingw_snprintf is present], have_mingw_snprintf, [
+ AC_TRY_LINK([
+#include <stdio.h>
+extern int __mingw_snprintf (char *, size_t, const char *, ...);
+],[
+__mingw_snprintf (NULL, 0, "%d\n", 1);
+],
+ eval "have_mingw_snprintf=yes", eval "have_mingw_snprintf=no")
+ ])
+ if test x"$have_mingw_snprintf" = xyes; then
+ AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.])
+ fi
+])
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index 4099c39894f..877fc5a6e01 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -522,6 +522,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define if you have __mingw_snprintf. */
+#undef HAVE_MINGW_SNPRINTF
+
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
diff --git a/libgfortran/configure b/libgfortran/configure
index c68cb7436b7..f71c5900f2e 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -31797,6 +31797,83 @@ _ACEOF
fi
+# Check whether __mingw_snprintf() is present
+
+ echo "$as_me:$LINENO: checking whether __mingw_snprintf is present" >&5
+echo $ECHO_N "checking whether __mingw_snprintf is present... $ECHO_C" >&6
+if test "${have_mingw_snprintf+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ if test x$gcc_no_link = xyes; then
+ { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
+echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdio.h>
+extern int __mingw_snprintf (char *, size_t, const char *, ...);
+
+int
+main ()
+{
+
+__mingw_snprintf (NULL, 0, "%d\n", 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "have_mingw_snprintf=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "have_mingw_snprintf=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:$LINENO: result: $have_mingw_snprintf" >&5
+echo "${ECHO_T}$have_mingw_snprintf" >&6
+ if test x"$have_mingw_snprintf" = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MINGW_SNPRINTF 1
+_ACEOF
+
+ fi
+
+
# Check for GNU libc feenableexcept
echo "$as_me:$LINENO: checking for feenableexcept in -lm" >&5
echo $ECHO_N "checking for feenableexcept in -lm... $ECHO_C" >&6
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 8709e16472b..8aa3b637785 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -383,6 +383,9 @@ LIBGFOR_CHECK_FOR_BROKEN_FPCLASSIFY
# Check whether the system has a working stat()
LIBGFOR_CHECK_WORKING_STAT
+# Check whether __mingw_snprintf() is present
+LIBGFOR_CHECK_MINGW_SNPRINTF
+
# Check for GNU libc feenableexcept
AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index ce6d28e9f95..6c687f7b12b 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -70,6 +70,16 @@ typedef off_t gfc_offset;
#endif
+/* On mingw, work around the buggy Windows snprintf() by using the one
+ mingw provides, __mingw_snprintf(). We also provide a prototype for
+ __mingw_snprintf(), because the mingw headers currently don't have one. */
+#if HAVE_MINGW_SNPRINTF
+extern int __mingw_snprintf (char *, size_t, const char *, ...);
+#undef snprintf
+#define snprintf __mingw_snprintf
+#endif
+
+
/* For a library, a standard prefix is a requirement in order to partition
the namespace. IPREFIX is for symbols intended to be internal to the
library. */