From 54cbcd0c180d5f4d384b873272445c86f0bfa2a5 Mon Sep 17 00:00:00 2001 From: Christian Schaller Date: Fri, 29 Nov 2002 11:10:35 +0000 Subject: [PATCH] commit Brian's patch with AC fix from thomas Original commit message from CVS: commit Brian's patch with AC fix from thomas --- configure.ac | 41 +++++++++++- docs/gst/Makefile.am | 6 +- gst/gst.c | 10 +-- gst/gstcaps.h | 26 ++++++++ gst/gstevent.h | 13 ++++ gst/gstformat.h | 13 ++++ gst/gstinfo.c | 5 +- gst/gstinfo.h | 153 ++++++++++++++++++++++++++++++++++++++++--- gst/gstlog.h | 13 ++++ gst/gstpad.h | 38 +++++++++++ gst/gstprops.h | 11 +++- gst/parse/parse.l | 12 ++++ 12 files changed, 320 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index 9e9c91b209..cf2b91edad 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,13 @@ AC_CANONICAL_TARGET([]) dnl when going to/from release please set the nano (fourth number) right ! dnl releases only do Wall, cvs and prerelease does Werror too -AS_VERSION(gstreamer, GST_VERSION, 0, 4, 2, 1, GST_ERROR="-Wall", GST_ERROR="-Wall -Werror") +dnl only use Wall or Werror if compiler is gcc. +if test "x$GCC" = "xyes"; then + AS_VERSION(gstreamer, GST_VERSION, 0, 4, 2, 1, GST_ERROR="-Wall", GST_ERROR="-Wall -Werror") +else + AS_VERSION(gstreamer, GST_VERSION, 0, 4, 2, 1, GST_ERROR="", GST_ERROR="") +fi + dnl AM_MAINTAINER_MODE only provides the option to configure to enable it AM_MAINTAINER_MODE AM_INIT_AUTOMAKE($PACKAGE,$VERSION) @@ -173,6 +179,39 @@ main() { atomic_t t; atomic_set(&t,0); atomic_inc(&t); atomic_add(1,&t);return 0 ]) fi +dnl +dnl Check for functions +dnl +AC_MSG_CHECKING(whether $GCC implements __func__) +AC_CACHE_VAL(have_func, +[AC_TRY_LINK([#include ],[printf("%s", __func__);], +have_func=yes, +have_func=no)]) +AC_MSG_RESULT($have_func) +if test "$have_func" = yes; then + AC_DEFINE(HAVE_FUNC,1,[defined if gcc have HAVE_FUNC)]) +else + AC_MSG_CHECKING(whether $GCC implements __PRETTY_FUNCTION__) + AC_CACHE_VAL(have_pretty_function, + [AC_TRY_LINK([#include ],[printf("%s", __PRETTY_FUNCTION__);], + have_pretty_function=yes, + have_pretty_function=no)]) + AC_MSG_RESULT($have_pretty_function) + if test "$have_pretty_function" = yes; then + AC_DEFINE(HAVE_PRETTY_FUNCTION,1,[defined if gcc have HAVE_PRETTY_FUNCTION)]) + else + AC_MSG_CHECKING(whether $GCC implements __FUNCTION__) + AC_CACHE_VAL(have_function, + [AC_TRY_LINK([#include ],[printf("%s", __FUNCTION__);], + have_function=yes, + have_function=no)]) + AC_MSG_RESULT($have_function) + if test "$have_function" = yes; then + AC_DEFINE(HAVE_FUNCTION,1,[defined if gcc have HAVE_FUNCTION)]) + fi + fi +fi + dnl ###################################################################### dnl # Check command line parameters, and set shell variables accordingly # dnl ###################################################################### diff --git a/docs/gst/Makefile.am b/docs/gst/Makefile.am index 66cab70eb5..89a4f37951 100644 --- a/docs/gst/Makefile.am +++ b/docs/gst/Makefile.am @@ -17,7 +17,7 @@ SCAN_OPTIONS= # FIXME : # there's something wrong with gstreamer-sections.txt not being in the dist # maybe it doesn't resolve; we're adding it below for now -#EXTRA_DIST = gstreamer.types.in gstreamer.hierarchy $(DOC_MODULE)-sections.txt gstreamer-sections.txt $(DOC_MAIN_SGML_FILE) +#EXTRA_DIST = gstreamer.types.in gstreamer.hierarchy $(DOC_MODULE)-sections.txt # gstreamer-sections.txt $(DOC_MAIN_SGML_FILE) # Extra options to supply to gtkdoc-mkdb. MKDB_OPTIONS= @@ -73,8 +73,8 @@ EXTRA_DIST = \ $(extra_files) \ $(HTML_IMAGES) \ $(DOC_MAIN_SGML_FILE) \ - $(DOC_MODULE).types \ - $(DOC_MODULE)-sections.txt + $(DOC_MODULE).types +# $(DOC_MODULE)-sections.txt DOC_STAMPS=scan-build.stamp tmpl-build.stamp sgml-build.stamp html-build.stamp \ $(srcdir)/tmpl.stamp $(srcdir)/sgml.stamp $(srcdir)/html.stamp diff --git a/gst/gst.c b/gst/gst.c index 1573a459c2..c4b752c152 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -95,7 +95,7 @@ enum { /* default scheduler, 'basicomega', can be changed in * gstscheduler.c in function gst_scheduler_factory_class_init */ -static const struct poptOption options[] = { +static const struct poptOption gstreamer_options[] = { {NULL, NUL, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, &init_popt_callback, 0, NULL, NULL}, {"gst-version", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, "Print the GStreamer version", NULL}, {"gst-fatal-warnings", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_FATAL_WARNINGS, "Make all warnings fatal", NULL}, @@ -126,7 +126,7 @@ static const struct poptOption options[] = { const struct poptOption * gst_init_get_popt_table (void) { - return options; + return gstreamer_options; } /** @@ -186,15 +186,15 @@ gst_init_with_popt_table (int *argc, char **argv[], gchar **temp; const struct poptOption *options; /* this is probably hacky, no? */ - const struct poptOption options_with[] = { + struct poptOption options_with[] = { {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gst_init_get_popt_table(), 0, "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, gstreamer_options, 0, "GStreamer options:", NULL}, {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) popt_options, 0, "Application options:", NULL}, POPT_TABLEEND }; const struct poptOption options_without[] = { {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gst_init_get_popt_table(), 0, "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, gstreamer_options, 0, "GStreamer options:", NULL}, POPT_TABLEEND }; diff --git a/gst/gstcaps.h b/gst/gstcaps.h index 6dae7c24c6..1d259cb7dc 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -58,6 +58,26 @@ struct _GstCaps { /* factory macros which make it easier for plugins to instantiate */ +#ifdef G_HAVE_ISO_VARARGS +#define GST_CAPS_NEW(name, type, ...) \ +gst_caps_new ( \ + name, \ + type, \ + gst_props_new ( \ + __VA_ARGS__, \ + NULL)) + +#define GST_CAPS_FACTORY(factoryname, ...) \ +static GstCaps* \ +factoryname (void) \ +{ \ + static GstCaps *caps = NULL; \ + if (!caps) { \ + caps = gst_caps_chain (__VA_ARGS_, NULL); \ + } \ + return caps; \ +} +#elif defined(G_HAVE_GNUC_VARARGS) #define GST_CAPS_NEW(name, type, a...) \ gst_caps_new ( \ name, \ @@ -76,6 +96,7 @@ factoryname (void) \ } \ return caps; \ } +#endif #define GST_CAPS_GET(fact) (fact)() @@ -108,8 +129,13 @@ void gst_caps_set_type_id (GstCaps *caps, guint16 type_id); GstCaps* gst_caps_set_props (GstCaps *caps, GstProps *props); GstProps* gst_caps_get_props (GstCaps *caps); +#ifdef G_HAVE_ISO_VARARGS +#define gst_caps_set(caps, ...) gst_props_set ((caps)->properties, __VA_ARGS__) +#define gst_caps_get(caps, ...) gst_props_get ((caps)->properties, __VA_ARGS__) +#elif defined(G_HAVE_GNUC_VARARGS) #define gst_caps_set(caps, name, args...) gst_props_set ((caps)->properties, name, ##args) #define gst_caps_get(caps, name, args...) gst_props_get ((caps)->properties, name, ##args) +#endif #define gst_caps_get_int(caps,name,res) gst_props_entry_get_int(gst_props_get_entry((caps)->properties,name),res) #define gst_caps_get_float(caps,name,res) gst_props_entry_get_float(gst_props_get_entry((caps)->properties,name),res) diff --git a/gst/gstevent.h b/gst/gstevent.h index 543a76ea4c..71d6886363 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -78,6 +78,18 @@ typedef struct GstEventFlag flags; } GstEventMask; +#ifdef G_HAVE_ISO_VARARGS +#define GST_EVENT_MASK_FUNCTION(functionname, ...) \ +static const GstEventMask* \ +functionname (GstPad *pad) \ +{ \ + static const GstEventMask masks[] = { \ + __VA_ARGS__, \ + { 0, } \ + }; \ + return masks; \ +} +#elif defined(G_HAVE_GNUC_VARARGS) #define GST_EVENT_MASK_FUNCTION(functionname, a...) \ static const GstEventMask* \ functionname (GstPad *pad) \ @@ -88,6 +100,7 @@ functionname (GstPad *pad) \ }; \ return masks; \ } +#endif /* seek events, extends GstEventFlag */ typedef enum { diff --git a/gst/gstformat.h b/gst/gstformat.h index b7c0944c62..ec24900927 100644 --- a/gst/gstformat.h +++ b/gst/gstformat.h @@ -48,6 +48,18 @@ struct _GstFormatDefinition gchar *description; }; +#ifdef G_HAVE_ISO_VARARGS +#define GST_FORMATS_FUNCTION(functionname, ...) \ +static const GstFormat* \ +functionname (GstPad *pad) \ +{ \ + static const GstFormat formats[] = { \ + __VA_ARGS__, \ + 0 \ + }; \ + return formats; \ +} +#elif defined(G_HAVE_GNUC_VARARGS) #define GST_FORMATS_FUNCTION(functionname, a...) \ static const GstFormat* \ functionname (GstPad *pad) \ @@ -58,6 +70,7 @@ functionname (GstPad *pad) \ }; \ return formats; \ } +#endif void _gst_format_initialize (void); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index ed577e8f01..2b24513ea0 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -81,8 +81,9 @@ static gchar *_gst_info_category_strings[] = { "REFCOUNTING", "EVENT", "PARAMS", - - [30] = "CALL_TRACE", + "", + "", + "CALL_TRACE", }; /** diff --git a/gst/gstinfo.h b/gst/gstinfo.h index 89d467de22..83191813d4 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -31,6 +31,15 @@ #include #endif +#ifdef HAVE_FUNC +#define FUNCTION __func__ +#elif HAVE_PRETTY_FUNCTION +#define FUNCTION __PRETTY_FUNCTION__ +#elif HAVE_FUNCTION +#define FUNCTION __FUNCTION__ +#else +#define FUNCTION "" +#endif /***** are we in the core or not? *****/ #ifdef __GST_PRIVATE_H__ @@ -136,17 +145,38 @@ G_GNUC_UNUSED static gchar *_debug_string = NULL; +#ifdef G_HAVE_ISO_VARARGS + +#ifdef GST_DEBUG_ENABLED +#define GST_DEBUG(cat, ...) G_STMT_START{ \ + if ((1< +#ifdef G_HAVE_ISO_VARARGS + +#ifdef DEBUG +# define PRINT(...) printf(__VAR_ARGS__) +#else +#define PRINT(...) +#endif + +#elif defined(G_HAVE_GNUC_VARARGS) + #ifdef DEBUG # define PRINT(a...) printf(##a) #else #define PRINT(a...) #endif +#endif + #define CHAR(x) PRINT ("char: %c\n", *yytext); return *yytext; #define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp)