info: Support new printf extensions in glibc 2.10
authorJan Schmidt <thaytan@noraisin.net>
Fri, 24 Apr 2009 21:06:19 +0000 (22:06 +0100)
committerJan Schmidt <thaytan@noraisin.net>
Mon, 11 May 2009 20:30:14 +0000 (21:30 +0100)
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
gst/gstinfo.c

index 9059ddf..384f16f 100644 (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)
index 97d5171..35d583f 100644 (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,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 */