@ -21,21 +21,36 @@ fi])# PGAC_C_SIGNED
# -----------------------
# -----------------------
# Select the format archetype to be used by gcc to check printf-type functions.
# Select the format archetype to be used by gcc to check printf-type functions.
# We prefer "gnu_printf", as that most closely matches the features supported
# We prefer "gnu_printf", as that most closely matches the features supported
# by src/port/snprintf.c (particularly the %m conversion spec).
# by src/port/snprintf.c (particularly the %m conversion spec). However,
# on some NetBSD versions, that doesn't work while "__syslog__" does.
# If all else fails, use "printf".
AC_DEFUN([PGAC_PRINTF_ARCHETYPE],
AC_DEFUN([PGAC_PRINTF_ARCHETYPE],
[AC_CACHE_CHECK([for printf format archetype], pgac_cv_printf_archetype,
[AC_CACHE_CHECK([for printf format archetype], pgac_cv_printf_archetype,
[pgac_cv_printf_archetype=gnu_printf
PGAC_TEST_PRINTF_ARCHETYPE
if [[ "$ac_archetype_ok" = no ]]; then
pgac_cv_printf_archetype=__syslog__
PGAC_TEST_PRINTF_ARCHETYPE
if [[ "$ac_archetype_ok" = no ]]; then
pgac_cv_printf_archetype=printf
fi
fi])
AC_DEFINE_UNQUOTED([PG_PRINTF_ATTRIBUTE], [$pgac_cv_printf_archetype],
[Define to best printf format archetype, usually gnu_printf if available.])
])# PGAC_PRINTF_ARCHETYPE
# Subroutine: test $pgac_cv_printf_archetype, set $ac_archetype_ok to yes or no
AC_DEFUN([PGAC_TEST_PRINTF_ARCHETYPE],
[ac_save_c_werror_flag=$ac_c_werror_flag
[ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_c_werror_flag=yes
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[extern int
[extern void pgac_write(int ignore, const char *fmt,...)
pgac_write(int ignore, const char *fmt,...)
__attribute__((format($pgac_cv_printf_archetype, 2, 3)));],
__attribute__((format(gnu_printf, 2, 3)));], [])],
[pgac_write(0, "error %s: %m", "foo");])],
[pgac_cv_printf_archetype=gnu_printf],
[ac_archetype_ok=yes],
[pgac_cv_printf_archetype=printf])
[ac_archetype_ok=no])
ac_c_werror_flag=$ac_save_c_werror_flag])
ac_c_werror_flag=$ac_save_c_werror_flag
AC_DEFINE_UNQUOTED([PG_PRINTF_ATTRIBUTE], [$pgac_cv_printf_archetype],
])# PGAC_TEST_PRINTF_ARCHETYPE
[Define to gnu_printf if compiler supports it, else printf.])
])# PGAC_PRINTF_ARCHETYPE
# PGAC_TYPE_64BIT_INT(TYPE)
# PGAC_TYPE_64BIT_INT(TYPE)