From a0137d3d825f4d562b55d4358d66e005c10eea01 Mon Sep 17 00:00:00 2001 From: John Criswell Date: Mon, 13 Oct 2003 16:22:01 +0000 Subject: [PATCH] Added a macro and code that checks for the %a format string in sprintf(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9089 91177308-0d34-0410-b5e6-96231b3b80d8 --- autoconf/aclocal.m4 | 29 ++++++ autoconf/configure.ac | 3 + configure | 151 +++++++++++++++++--------------- include/Config/config.h.in | 3 + include/llvm/Config/config.h.in | 3 + 5 files changed, 120 insertions(+), 69 deletions(-) diff --git a/autoconf/aclocal.m4 b/autoconf/aclocal.m4 index 51040fb5239..da725af8a46 100644 --- a/autoconf/aclocal.m4 +++ b/autoconf/aclocal.m4 @@ -6166,4 +6166,33 @@ AC_DEFUN([AC_CONFIG_MAKEFILE], [AC_CONFIG_COMMANDS($1,${SHELL} ${srcdir}/autoconf/install-sh -c ${srcdir}/$1 $1,${srcdir}/autoconf/mkinstalldirs `dirname $1`) ]) +# +# Determine if the printf() functions have the %a format character. +# This is modified from: +# http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_slist.html +AC_DEFUN([AC_C_PRINTF_A], +[ + AC_LANG_SAVE + AC_LANG_C + AC_RUN_IFELSE( + AC_LANG_PROGRAM([#include + #include ], + [[[ + volatile double A, B; + char Buffer[100]; + A = 1; + A /= 10.0; + sprintf(Buffer, "%a", A); + B = atof(Buffer); + if (A != B) + return (1); + if (A != 0x1.999999999999ap-4) + return (1); + return (0);]]]), + ac_c_printf_a=yes,ac_c_printf_a=no) + AC_LANG_RESTORE + if test "$ac_c_printf_a" = "yes"; then + AC_DEFINE([HAVE_PRINTF_A],[1],[Define to have the %a format string]) + fi +]) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 85a319fc7e0..62e6740b524 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -455,6 +455,9 @@ AC_CHECK_TYPES([uint64_t],,AC_MSG_ERROR([Type uint64_t required but not found])) AC_HEADER_TIME AC_STRUCT_TM +dnl Check for various C features +AC_C_PRINTF_A + dnl Check for C++ extensions AC_CXX_HAVE_EXT_HASH_MAP AC_CXX_HAVE_EXT_HASH_SET diff --git a/configure b/configure index 5b994942975..6991656c946 100755 --- a/configure +++ b/configure @@ -20702,6 +20702,87 @@ _ACEOF fi + + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + #include +int +main () +{ + + volatile double A, B; + char Buffer[100]; + A = 1; + A /= 10.0; + sprintf(Buffer, "%a", A); + B = atof(Buffer); + if (A != B) + return (1); + if (A != 0x1.999999999999ap-4) + return (1); + return (0); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./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 + ac_c_printf_a=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_c_printf_a=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$ac_c_printf_a" = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_PRINTF_A 1 +_ACEOF + + fi + + echo "$as_me:$LINENO: checking whether the compiler implements namespaces" >&5 echo $ECHO_N "checking whether the compiler implements namespaces... $ECHO_C" >&6 if test "${ac_cv_cxx_namespaces+set}" = set; then @@ -22420,8 +22501,7 @@ _ACEOF - -for ac_func in getcwd gettimeofday strcspn strdup strerror strspn strstr strtod strtol strtoq strtoll strsignal +for ac_func in getcwd gettimeofday strcspn strdup strerror strspn strstr strtod strtol strtoq strtoll do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -22504,73 +22584,6 @@ _ACEOF fi done -echo "$as_me:$LINENO: checking whether sys_siglist is declared" >&5 -echo $ECHO_N "checking whether sys_siglist is declared... $ECHO_C" >&6 -if test "${ac_cv_have_decl_sys_siglist+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#if HAVE_SIGNAL_H -#include -#endif - -int -main () -{ -#ifndef sys_siglist - char *p = (char *) sys_siglist; -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (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 - ac_cv_have_decl_sys_siglist=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_have_decl_sys_siglist=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_have_decl_sys_siglist" >&5 -echo "${ECHO_T}$ac_cv_have_decl_sys_siglist" >&6 -if test $ac_cv_have_decl_sys_siglist = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_SYS_SIGLIST 1 -_ACEOF - - -else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_SYS_SIGLIST 0 -_ACEOF - - -fi - - echo "$as_me:$LINENO: checking for mmap" >&5 diff --git a/include/Config/config.h.in b/include/Config/config.h.in index d02683b2b12..14fd178c6f4 100644 --- a/include/Config/config.h.in +++ b/include/Config/config.h.in @@ -226,3 +226,6 @@ /* Define to `unsigned' if does not define. */ #undef size_t + +/* Define to have the %a format string in printf() */ +#undef HAVE_PRINTF_A diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index d02683b2b12..14fd178c6f4 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -226,3 +226,6 @@ /* Define to `unsigned' if does not define. */ #undef size_t + +/* Define to have the %a format string in printf() */ +#undef HAVE_PRINTF_A -- 2.34.1