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.
This commit is contained in:
Tim-Philipp Müller 2006-10-05 12:31:07 +00:00
parent c4be4aa916
commit 376f6c34da
6 changed files with 102 additions and 56 deletions

View file

@ -1,3 +1,18 @@
2006-10-05 Tim-Philipp Müller <tim at centricular dot net>
* 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 <tim at centricular dot net> 2006-10-03 Tim-Philipp Müller <tim at centricular dot net>
* gst/gstbus.c: (gst_bus_class_init), (gst_bus_post): * gst/gstbus.c: (gst_bus_class_init), (gst_bus_post):

View file

@ -323,14 +323,18 @@ AC_CHECK_FUNC(register_printf_function,
[ [
GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\"" GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\""
GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"Q\"" 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, AC_DEFINE(HAVE_PRINTF_EXTENSION, 1,
[Defined if we have register_printf_function ()]) [Defined if we have register_printf_function ()])
], ], [
GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_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_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_POINTER_FORMAT_DEFINE)
AC_SUBST(GST_PRINTF_EXTENSION_SEGMENT_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 dnl test if we have dladdr(); we use it for debugging; see gst/gstinfo.c
save_cflags="$CFLAGS" save_cflags="$CFLAGS"

View file

@ -394,6 +394,7 @@ GST_PLUGIN_EXPORT
GST_PADDING GST_PADDING
GST_PADDING_LARGE GST_PADDING_LARGE
GST_PADDING_INIT GST_PADDING_INIT
GST_USING_PRINTF_EXTENSION
</SECTION> </SECTION>
<SECTION> <SECTION>

View file

@ -155,6 +155,11 @@
*/ */
@GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE@ @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 */ /* whether or not the CPU supports unaligned access */
@GST_HAVE_UNALIGNED_ACCESS_DEFINE@ @GST_HAVE_UNALIGNED_ACCESS_DEFINE@

View file

@ -570,7 +570,11 @@ gboolean gst_element_query (GstElement *element, GstQuery *query);
gboolean gst_element_post_message (GstElement * element, GstMessage * message); gboolean gst_element_post_message (GstElement * element, GstMessage * message);
/* error handling */ /* error handling */
#ifdef GST_USING_PRINTF_EXTENSION
gchar * _gst_element_error_printf (const gchar *format, ...); 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, void gst_element_message_full (GstElement * element, GstMessageType type,
GQuark domain, gint code, gchar * text, GQuark domain, gint code, gchar * text,
gchar * debug, const gchar * file, gchar * debug, const gchar * file,

View file

@ -227,68 +227,84 @@ typedef struct _GstDebugMessage GstDebugMessage;
* gst_debug_add_log_function(). * gst_debug_add_log_function().
* Use G_GNUC_NO_INSTRUMENT on that function. * Use G_GNUC_NO_INSTRUMENT on that function.
*/ */
typedef void (*GstLogFunction) (GstDebugCategory * category, typedef void (*GstLogFunction) (GstDebugCategory * category,
GstDebugLevel level, GstDebugLevel level,
const gchar * file, const gchar * file,
const gchar * function, const gchar * function,
gint line, gint line,
GObject * object, GObject * object,
GstDebugMessage * message, GstDebugMessage * message,
gpointer data); gpointer data);
#ifndef GST_DISABLE_GST_DEBUG #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, /* not using G_GNUC_PRINTF, since gcc will choke on GST_PTR_FORMAT being %P */
GstDebugLevel level, void gst_debug_log (GstDebugCategory * category,
const gchar * file, GstDebugLevel level,
const gchar * function, const gchar * file,
gint line, const gchar * function,
GObject * object, gint line,
GstDebugMessage * message, GObject * object,
gpointer unused) G_GNUC_NO_INSTRUMENT; 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 * 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, void gst_debug_add_log_function (GstLogFunction func,
gpointer data); gpointer data);
guint gst_debug_remove_log_function (GstLogFunction func); guint gst_debug_remove_log_function (GstLogFunction func);
guint gst_debug_remove_log_function_by_data (gpointer data); guint gst_debug_remove_log_function_by_data (gpointer data);
void gst_debug_set_active (gboolean active); void gst_debug_set_active (gboolean active);
gboolean gst_debug_is_active (void); gboolean gst_debug_is_active (void);
void gst_debug_set_colored (gboolean colored); void gst_debug_set_colored (gboolean colored);
gboolean gst_debug_is_colored (void); gboolean gst_debug_is_colored (void);
void gst_debug_set_default_threshold (GstDebugLevel level); void gst_debug_set_default_threshold (GstDebugLevel level);
GstDebugLevel gst_debug_get_default_threshold (void); GstDebugLevel gst_debug_get_default_threshold (void);
void gst_debug_set_threshold_for_name (const gchar * name, void gst_debug_set_threshold_for_name (const gchar * name,
GstDebugLevel level); GstDebugLevel level);
void gst_debug_unset_threshold_for_name (const gchar * name); void gst_debug_unset_threshold_for_name (const gchar * name);
/** /**
* GST_DEBUG_CATEGORY: * GST_DEBUG_CATEGORY:
@ -911,10 +927,11 @@ G_CONST_RETURN gchar *
#define gst_debug_set_default_threshold(level) /* NOP */ #define gst_debug_set_default_threshold(level) /* NOP */
#define gst_debug_get_default_threshold() (GST_LEVEL_NONE) #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 */ #define gst_debug_add_log_function(func,data) /* NOP */
guint gst_debug_remove_log_function (GstLogFunction func); #define gst_debug_remove_log_function(func) (0)
guint gst_debug_remove_log_function_by_data (gpointer data); #define gst_debug_remove_log_function_by_data(data) (0)
#define gst_debug_set_active(active) /* NOP */ #define gst_debug_set_active(active) /* NOP */
#define gst_debug_is_active() (FALSE) #define gst_debug_is_active() (FALSE)
#define gst_debug_set_colored(colored) /* NOP */ #define gst_debug_set_colored(colored) /* NOP */