[gst-cvs] gstreamer: info: Support new printf extensions in glibc 2.10
Jan Schmidt
thaytan at kemper.freedesktop.org
Mon May 11 13:31:45 PDT 2009
Module: gstreamer
Branch: master
Commit: bd07633cc207d3425bd4f04f5c2ec294e0e352ea
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=bd07633cc207d3425bd4f04f5c2ec294e0e352ea
Author: Jan Schmidt <thaytan at noraisin.net>
Date: Fri Apr 24 22:06:19 2009 +0100
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.
---
configure.ac | 23 ++++++++++++-----------
gst/gstinfo.c | 24 +++++++++++++++++++++++-
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9059ddf..384f16f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 97d5171..35d583f 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -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,11 +294,18 @@ _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 */
GST_CAT_DEFAULT = _gst_debug_category_new ("default",
@@ -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 */
More information about the Gstreamer-commits
mailing list