From 376f6c34da9dae1c9d100539d9970723409a6f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 5 Oct 2006 12:31:07 +0000 Subject: [PATCH] Add GST_USING_PRINTF_EXTENSION to gstconfig.h so that we know whether we can use G_GNUC_PRINTF in other header files ... Original commit message from CVS: * configure.ac: * docs/gst/gstreamer-sections.txt: * gst/gstconfig.h.in: * gst/gstelement.h: * gst/gstinfo.h: Add GST_USING_PRINTF_EXTENSION to gstconfig.h so that we know whether we can use G_GNUC_PRINTF in other header files and at least check the printf format/arguments of debug messages and GST_ELEMENT_ERROR messages when the printf extension is not being used. Replace more tabs with spaces in gstinfo.h and remove two spurious function declarations in GST_DISABLE_DEBUG part with macros. --- ChangeLog | 15 ++++ configure.ac | 10 ++- docs/gst/gstreamer-sections.txt | 1 + gst/gstconfig.h.in | 5 ++ gst/gstelement.h | 4 ++ gst/gstinfo.h | 123 ++++++++++++++++++-------------- 6 files changed, 102 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71ebe5352a..adaf2895e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2006-10-05 Tim-Philipp Müller + + * configure.ac: + * docs/gst/gstreamer-sections.txt: + * gst/gstconfig.h.in: + * gst/gstelement.h: + * gst/gstinfo.h: + Add GST_USING_PRINTF_EXTENSION to gstconfig.h so that we know + whether we can use G_GNUC_PRINTF in other header files and at + least check the printf format/arguments of debug messages and + GST_ELEMENT_ERROR messages when the printf extension is not + being used. + Replace more tabs with spaces in gstinfo.h and remove two spurious + function declarations in GST_DISABLE_DEBUG part with macros. + 2006-10-03 Tim-Philipp Müller * gst/gstbus.c: (gst_bus_class_init), (gst_bus_post): diff --git a/configure.ac b/configure.ac index 9c34f14d53..39aa7fa582 100644 --- a/configure.ac +++ b/configure.ac @@ -323,14 +323,18 @@ 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 ()]) - ], - GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"p\"" - GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"p\"" + ], [ + 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" + ] ) AC_SUBST(GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE) AC_SUBST(GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE) +AC_SUBST(GST_USING_PRINTF_EXTENSION_DEFINE) dnl test if we have dladdr(); we use it for debugging; see gst/gstinfo.c save_cflags="$CFLAGS" diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 072e6892e3..3cb7a461f8 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -394,6 +394,7 @@ GST_PLUGIN_EXPORT GST_PADDING GST_PADDING_LARGE GST_PADDING_INIT +GST_USING_PRINTF_EXTENSION
diff --git a/gst/gstconfig.h.in b/gst/gstconfig.h.in index daa606596e..e4aa10f258 100644 --- a/gst/gstconfig.h.in +++ b/gst/gstconfig.h.in @@ -155,6 +155,11 @@ */ @GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE@ +/* whether or not GST_PTR_FORMAT or GST_SEGMENT_FORMAT are using + * the printf extension mechanism. This is for internal use in our + * header files so we know whether we can use G_GNUC_PRINTF or not */ +@GST_USING_PRINTF_EXTENSION_DEFINE@ + /* whether or not the CPU supports unaligned access */ @GST_HAVE_UNALIGNED_ACCESS_DEFINE@ diff --git a/gst/gstelement.h b/gst/gstelement.h index 20798e5738..ca87fbc12d 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -570,7 +570,11 @@ gboolean gst_element_query (GstElement *element, GstQuery *query); gboolean gst_element_post_message (GstElement * element, GstMessage * message); /* error handling */ +#ifdef GST_USING_PRINTF_EXTENSION gchar * _gst_element_error_printf (const gchar *format, ...); +#else +gchar * _gst_element_error_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2); +#endif void gst_element_message_full (GstElement * element, GstMessageType type, GQuark domain, gint code, gchar * text, gchar * debug, const gchar * file, diff --git a/gst/gstinfo.h b/gst/gstinfo.h index dd915d26c6..b40c57885d 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -227,68 +227,84 @@ typedef struct _GstDebugMessage GstDebugMessage; * gst_debug_add_log_function(). * Use G_GNUC_NO_INSTRUMENT on that function. */ -typedef void (*GstLogFunction) (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - GstDebugMessage * message, - gpointer data); +typedef void (*GstLogFunction) (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, + GstDebugMessage * message, + gpointer data); #ifndef GST_DISABLE_GST_DEBUG -void _gst_debug_init (void); +void _gst_debug_init (void); -/* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which - * we use for GST_PTR_FORMAT. */ -void gst_debug_log (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - const gchar * format, - ...) G_GNUC_NO_INSTRUMENT; -void gst_debug_log_valist (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - const gchar * format, - va_list args) G_GNUC_NO_INSTRUMENT; -const gchar * gst_debug_message_get (GstDebugMessage * message); +#ifdef GST_USING_PRINTF_EXTENSION -void gst_debug_log_default (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - GstDebugMessage * message, - gpointer unused) G_GNUC_NO_INSTRUMENT; +/* not using G_GNUC_PRINTF, since gcc will choke on GST_PTR_FORMAT being %P */ +void gst_debug_log (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, + const gchar * format, + ...) G_GNUC_NO_INSTRUMENT; + +#else /* GST_USING_PRINTF_EXTENSION */ + +void gst_debug_log (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, + const gchar * format, + ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT; + +#endif /* GST_USING_PRINTF_EXTENSION */ + +void gst_debug_log_valist (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, + const gchar * format, + va_list args) G_GNUC_NO_INSTRUMENT; + +const gchar * gst_debug_message_get (GstDebugMessage * message); + +void gst_debug_log_default (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, + GstDebugMessage * message, + gpointer unused) G_GNUC_NO_INSTRUMENT; G_CONST_RETURN gchar * - gst_debug_level_get_name (GstDebugLevel level); + gst_debug_level_get_name (GstDebugLevel level); -void gst_debug_add_log_function (GstLogFunction func, - gpointer data); -guint gst_debug_remove_log_function (GstLogFunction func); -guint gst_debug_remove_log_function_by_data (gpointer data); +void gst_debug_add_log_function (GstLogFunction func, + gpointer data); +guint gst_debug_remove_log_function (GstLogFunction func); +guint gst_debug_remove_log_function_by_data (gpointer data); -void gst_debug_set_active (gboolean active); -gboolean gst_debug_is_active (void); +void gst_debug_set_active (gboolean active); +gboolean gst_debug_is_active (void); -void gst_debug_set_colored (gboolean colored); -gboolean gst_debug_is_colored (void); +void gst_debug_set_colored (gboolean colored); +gboolean gst_debug_is_colored (void); -void gst_debug_set_default_threshold (GstDebugLevel level); -GstDebugLevel gst_debug_get_default_threshold (void); -void gst_debug_set_threshold_for_name (const gchar * name, - GstDebugLevel level); -void gst_debug_unset_threshold_for_name (const gchar * name); +void gst_debug_set_default_threshold (GstDebugLevel level); +GstDebugLevel gst_debug_get_default_threshold (void); +void gst_debug_set_threshold_for_name (const gchar * name, + GstDebugLevel level); +void gst_debug_unset_threshold_for_name (const gchar * name); /** * GST_DEBUG_CATEGORY: @@ -911,10 +927,11 @@ G_CONST_RETURN gchar * #define gst_debug_set_default_threshold(level) /* NOP */ #define gst_debug_get_default_threshold() (GST_LEVEL_NONE) -#define gst_debug_level_get_name(level) ("NONE") +#define gst_debug_level_get_name(level) ("NONE") +#define gst_debug_message_get(message) ("NONE") #define gst_debug_add_log_function(func,data) /* NOP */ -guint gst_debug_remove_log_function (GstLogFunction func); -guint gst_debug_remove_log_function_by_data (gpointer data); +#define gst_debug_remove_log_function(func) (0) +#define gst_debug_remove_log_function_by_data(data) (0) #define gst_debug_set_active(active) /* NOP */ #define gst_debug_is_active() (FALSE) #define gst_debug_set_colored(colored) /* NOP */