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
This commit is contained in:
Francois-Xavier Coudert 2007-08-23 13:03:35 +00:00 committed by François-Xavier Coudert
parent b73aff3657
commit db8092dc4c
6 changed files with 119 additions and 0 deletions

View File

@ -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.

View File

@ -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
])

View File

@ -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

77
libgfortran/configure vendored
View File

@ -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

View File

@ -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])])

View File

@ -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. */