Skip to content

Commit

Permalink
Attempt to detect presence of C99 size specifiers on systems with old…
Browse files Browse the repository at this point in the history
…/cut-down

libc.
  • Loading branch information
gmcgarry committed Apr 27, 2008
1 parent 12c0c51 commit 95ca965
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 10 deletions.
5 changes: 4 additions & 1 deletion config.h.in
Expand Up @@ -36,7 +36,10 @@
/* Define to 1 if you have the `basename' function. */
#undef HAVE_BASENAME

/* Define to 1 if your compiler supports GNU GCC-style variadic macros */
/* Define to 1 if printf supports C99 size specifiers */
#undef HAVE_C99_FORMAT

/* Define to 1 if your compiler supports C99 variadic macros */
#undef HAVE_CPP_VARARG_MACRO_GCC

/* Define to 1 if you have the `ffs' function. */
Expand Down
78 changes: 71 additions & 7 deletions configure
Expand Up @@ -4085,8 +4085,8 @@ echo "${ECHO_T}no" >&6
fi
echo "$as_me:$LINENO: checking for GNU GCC variadic macro support" >&5
echo $ECHO_N "checking for GNU GCC variadic macro support... $ECHO_C" >&6
echo "$as_me:$LINENO: checking for C99 variadic macro support" >&5
echo $ECHO_N "checking for C99 variadic macro support... $ECHO_C" >&6
if test "${ac_have_variadic+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
Expand Down Expand Up @@ -4139,11 +4139,6 @@ _ACEOF
fi
# Checks for libraries.
# Checks for header files.
# AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
Expand Down Expand Up @@ -4632,6 +4627,75 @@ fi
done
echo "$as_me:$LINENO: checking for C99 printf size specifiers" >&5
echo $ECHO_N "checking for C99 printf size specifiers... $ECHO_C" >&6
if test "${ac_have_c99_format+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
ac_have_c99_format=yes
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
char buf[64];
if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
exit(1);
else if (strcmp(buf, "12345"))
exit(2);
;
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_have_c99_format=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_have_c99_format=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $ac_have_c99_format" >&5
echo "${ECHO_T}$ac_have_c99_format" >&6
if test $ac_have_c99_format = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_C99_FORMAT 1
_ACEOF
fi
# Checks for libraries.
# Checks for header files.
# AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
Expand Down
21 changes: 19 additions & 2 deletions configure.ac
Expand Up @@ -218,17 +218,34 @@ fi

AC_CHECK_PROG(strip,strip,yes,no)

AC_CACHE_CHECK([for GNU GCC variadic macro support], ac_have_variadic, [
AC_CACHE_CHECK([for C99 variadic macro support], ac_have_variadic, [
AC_COMPILE_IFELSE([
#define macro(...) func(__VA_ARGS__)
int func(int a, ...);
int test() { return macro(1, 2, 3); }
], [ ac_have_variadic=yes ], [ ac_have_variadic=no ])])
if test $ac_have_variadic = yes ; then
AC_DEFINE([HAVE_CPP_VARARG_MACRO_GCC], 1,
[Define to 1 if your compiler supports GNU GCC-style variadic macros])
[Define to 1 if your compiler supports C99 variadic macros])
fi

AC_CACHE_CHECK([for C99 printf size specifiers], ac_have_c99_format, [
AC_RUN_IFELSE([
AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
char buf[64];
if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
exit(1);
else if (strcmp(buf, "12345"))
exit(2);
]])],
[ ac_have_c99_format=yes ],
[ ac_have_c99_format=no ],
[ ac_have_c99_format=yes ])
])
if test $ac_have_c99_format = yes; then
AC_DEFINE([HAVE_C99_FORMAT], 1,
[Define to 1 if printf supports C99 size specifiers])
fi

# Checks for libraries.

Expand Down

0 comments on commit 95ca965

Please sign in to comment.