info: Support new printf extensions in glibc 2.10

The printf extension mechanism changed in glibc 2.10, and the older
register_printf_function is deprecated. Detect and use the new
mechanism where available.
This commit is contained in:
Jan Schmidt 2009-04-24 22:06:19 +01:00
parent a3297ad3ed
commit bd07633cc2
2 changed files with 35 additions and 12 deletions

View file

@ -451,20 +451,21 @@ AM_CONDITIONAL(GST_HAVE_MONOTONIC_CLOCK, test "$gst_cv_monotonic_clock" = "yes")
dnl Check for a way to display the function name in debug output
AG_GST_CHECK_FUNCTION
dnl test for register_printf_function
AC_CHECK_FUNC(register_printf_function,
[
GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\""
GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"Q\""
GST_USING_PRINTF_EXTENSION_DEFINE="#define GST_USING_PRINTF_EXTENSION"
AC_DEFINE(HAVE_PRINTF_EXTENSION, 1,
[Defined if we have register_printf_function ()])
], [
dnl test for register_printf_specifier or register_printf_function
AC_CHECK_FUNCS([register_printf_specifier register_printf_function],
[HAVE_PRINTF_EXTENSION=yes])
if test "$HAVE_PRINTF_EXTENSION" = yes; then
GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\""
GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"Q\""
GST_USING_PRINTF_EXTENSION_DEFINE="#define GST_USING_PRINTF_EXTENSION"
AC_DEFINE(HAVE_PRINTF_EXTENSION, 1,
[Defined if we have printf specifier extensions available])
else
GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"p\""
GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"p\""
GST_USING_PRINTF_EXTENSION_DEFINE="#undef GST_USING_PRINTF_EXTENSION"
]
)
fi
AC_SUBST(GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE)
AC_SUBST(GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE)
AC_SUBST(GST_USING_PRINTF_EXTENSION_DEFINE)

View file

@ -164,9 +164,14 @@ static int _gst_info_printf_extension_ptr (FILE * stream,
const struct printf_info *info, const void *const *args);
static int _gst_info_printf_extension_segment (FILE * stream,
const struct printf_info *info, const void *const *args);
#if HAVE_REGISTER_PRINTF_SPECIFIER
static int _gst_info_printf_extension_arginfo (const struct printf_info *info,
size_t n, int *argtypes, int *size);
#else
static int _gst_info_printf_extension_arginfo (const struct printf_info *info,
size_t n, int *argtypes);
#endif
#endif
struct _GstDebugMessage
{
@ -289,10 +294,17 @@ _gst_debug_init (void)
_priv_gst_info_start_time = gst_util_get_timestamp ();
#ifdef HAVE_PRINTF_EXTENSION
#if HAVE_REGISTER_PRINTF_SPECIFIER
register_printf_specifier (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
_gst_info_printf_extension_arginfo);
register_printf_specifier (GST_SEGMENT_FORMAT[0],
_gst_info_printf_extension_segment, _gst_info_printf_extension_arginfo);
#else
register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
_gst_info_printf_extension_arginfo);
register_printf_function (GST_SEGMENT_FORMAT[0],
_gst_info_printf_extension_segment, _gst_info_printf_extension_arginfo);
#endif
#endif
/* do NOT use a single debug function before this line has been run */
@ -1483,12 +1495,22 @@ _gst_info_printf_extension_segment (FILE * stream,
return len;
}
#if HAVE_REGISTER_PRINTF_SPECIFIER
static int
_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
int *argtypes, int *size)
#else
static int
_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
int *argtypes)
#endif
{
if (n > 0)
if (n > 0) {
argtypes[0] = PA_POINTER;
#if HAVE_REGISTER_PRINTF_SPECIFIER
*size = sizeof (gpointer);
#endif
}
return 1;
}
#endif /* HAVE_PRINTF_EXTENSION */