From a2a974bfaee012cc6020382e86810bfea0df731d Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 28 Apr 2004 23:26:06 +0000 Subject: [PATCH] A bunch of portability fixes, derived from Steve Lhomme's MSVC Original commit message from CVS: A bunch of portability fixes, derived from Steve Lhomme's MSVC patch (bug #141317): * gst/gst-i18n-lib.h: Allow disabling gettext. * gst/gstatomic_impl.h: disable warning when it's dumb. * gst/gstclock.c: fix include * gst/gstcompat.h: fix variadic macro * gst/gstinfo.c: fix include * gst/gstmacros.h: add defines for inlines on MSVC * gst/gstplugin.c: fix includes * gst/gstregistry.c: fix includes * gst/gstregistry.h: use S_IREAD, etc., if S_IRUSR isn't defined * gst/gstsystemclock.c: fix include * gst/gsttrace.c: (gst_trace_new), (gst_trace_text_flush): use S_IREAD if S_IRUSR isn't defined. fix use of non-portable functions * gst/registries/gstxmlregistry.c: (gst_xml_registry_parse_element_factory): fix use of non-portable functions * libs/gst/control/dparam.h: Remove trailing comma in enum definition * libs/gst/control/dparammanager.h: same --- ChangeLog | 22 ++++++++++++++++++++++ gst/gst-i18n-lib.h | 18 ++++++++++++++---- gst/gstatomic_impl.h | 4 ++++ gst/gstclock.c | 2 +- gst/gstcompat.h | 4 +++- gst/gstinfo.c | 2 ++ gst/gstmacros.h | 3 +++ gst/gstplugin.c | 8 +++++++- gst/gstregistry.c | 5 +++++ gst/gstregistry.h | 8 ++++++++ gst/gstsystemclock.c | 2 +- gst/gsttrace.c | 14 ++++++++++++-- gst/registries/gstxmlregistry.c | 6 ++++-- libs/gst/control/dparam.h | 2 +- libs/gst/control/dparammanager.h | 2 +- 15 files changed, 88 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c489561f6..86dff6b02e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2004-04-28 David Schleef + + A bunch of portability fixes, derived from Steve Lhomme's MSVC + patch (bug #141317): + * gst/gst-i18n-lib.h: Allow disabling gettext. + * gst/gstatomic_impl.h: disable warning when it's dumb. + * gst/gstclock.c: fix include + * gst/gstcompat.h: fix variadic macro + * gst/gstinfo.c: fix include + * gst/gstmacros.h: add defines for inlines on MSVC + * gst/gstplugin.c: fix includes + * gst/gstregistry.c: fix includes + * gst/gstregistry.h: use S_IREAD, etc., if S_IRUSR isn't defined + * gst/gstsystemclock.c: fix include + * gst/gsttrace.c: (gst_trace_new), (gst_trace_text_flush): use + S_IREAD if S_IRUSR isn't defined. fix use of non-portable functions + * gst/registries/gstxmlregistry.c: + (gst_xml_registry_parse_element_factory): fix use of non-portable + functions + * libs/gst/control/dparam.h: Remove trailing comma in enum definition + * libs/gst/control/dparammanager.h: same + 2004-04-28 David Schleef Move a bunch of unused files to old/ with names that are diff --git a/gst/gst-i18n-lib.h b/gst/gst-i18n-lib.h index f5db797d12..a68d505043 100644 --- a/gst/gst-i18n-lib.h +++ b/gst/gst-i18n-lib.h @@ -23,15 +23,25 @@ #ifndef __GST_I18N_LIB_H__ #define __GST_I18N_LIB_H__ -#include "gettext.h" /* included with gettext distribution and copied */ - -#ifndef GETTEXT_PACKAGE -#error You must define GETTEXT_PACKAGE before including this header. +#ifndef GST_VERSION +#error You must include config.h before including this header. #endif +#ifdef ENABLE_NLS + +#include "gettext.h" /* included with gettext distribution and copied */ + /* we want to use shorthand _() for translating and N_() for marking */ #define _(String) dgettext (GETTEXT_PACKAGE, String) #define N_(String) gettext_noop (String) /* FIXME: if we need it, we can add Q_ as well, like in glib */ +#else + +#define GETTEXT_PACKAGE NULL +#define _(String) String +#define N_(String) String + +#endif + #endif /* __GST_I18N_LIB_H__ */ diff --git a/gst/gstatomic_impl.h b/gst/gstatomic_impl.h index 8228d7bd26..2fd577d381 100644 --- a/gst/gstatomic_impl.h +++ b/gst/gstatomic_impl.h @@ -423,7 +423,11 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) } #else + +/* no need warning about this if we can't do inline assembly */ +#ifdef __GNUC__ #warning consider putting your architecture specific atomic implementations here +#endif /* * generic implementation diff --git a/gst/gstclock.c b/gst/gstclock.c index 2c604f4717..1552d6617d 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include +#include #include "gst_private.h" diff --git a/gst/gstcompat.h b/gst/gstcompat.h index 5ec3458468..ff6b0b8243 100644 --- a/gst/gstcompat.h +++ b/gst/gstcompat.h @@ -36,9 +36,11 @@ G_BEGIN_DECLS gst_element_link_pads(a,b,c,d) #ifdef G_HAVE_ISO_VARARGS #define gst_element_connect_many(a,...) gst_element_link_many(a,__VA_ARGS__) -#else +#elif defined(G_HAVE_GNUC_VARARGS) #define gst_element_connect_many(a,args...) \ gst_element_link_many(a, ## args) +#else +/* FIXME: need an inline function */ #endif #define gst_element_connect_filtered(a,b,c) \ gst_element_link_filtered(a,b,c) diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 3dc2a1c196..f27e8b297c 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -34,7 +34,9 @@ #include #endif #include /* fprintf */ +#ifdef HAVE_UNISTD_H #include +#endif #include /* G_VA_COPY */ #include "gstinfo.h" #include "gstlog.h" diff --git a/gst/gstmacros.h b/gst/gstmacros.h index 537d90ffc4..6f20ac8273 100644 --- a/gst/gstmacros.h +++ b/gst/gstmacros.h @@ -32,6 +32,9 @@ G_BEGIN_DECLS #if defined (__GNUC__) && !defined (GST_IMPLEMENT_INLINES) # define GST_INLINE_FUNC extern __inline__ # define GST_CAN_INLINE 1 +#elif defined(_MSC_VER) +# define GST_INLINE_FUNC extern __inline +# define GST_CAN_INLINE 1 #else # define GST_INLINE_FUNC extern # undef GST_CAN_INLINE diff --git a/gst/gstplugin.c b/gst/gstplugin.c index d89a762fdb..67af719edd 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -20,10 +20,17 @@ * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include +#ifdef HAVE_DIRENT_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif #include #include "gst_private.h" @@ -32,7 +39,6 @@ #include "gstversion.h" #include "gstregistrypool.h" #include "gstinfo.h" -#include "config.h" #include "gstfilter.h" diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 06de568d4a..dddedcfbcc 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -20,10 +20,15 @@ * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include #include diff --git a/gst/gstregistry.h b/gst/gstregistry.h index ed10727216..e1ac8ee4c6 100644 --- a/gst/gstregistry.h +++ b/gst/gstregistry.h @@ -34,6 +34,8 @@ #define LOCAL_REGISTRY_FILE LOCAL_REGISTRY_DIR"/registry.xml" #define LOCAL_REGISTRY_FILE_TMP LOCAL_REGISTRY_DIR"/.registry.xml.tmp" +/* compatibility for pre-POSIX defines */ +#ifdef S_IRUSR #define REGISTRY_DIR_PERMS (S_ISGID | \ S_IRUSR | S_IWUSR | S_IXUSR | \ S_IRGRP | S_IXGRP | \ @@ -42,6 +44,12 @@ #define REGISTRY_FILE_PERMS (S_IRUSR | S_IWUSR | \ S_IRGRP | S_IWGRP | \ S_IROTH | S_IWOTH) +#else +#define REGISTRY_DIR_PERMS (S_ISGID | \ + S_IREAD | S_IWRITE | S_IEXEC) +#define REGISTRY_TMPFILE_PERMS (S_IREAD | S_IWRITE) +#define REGISTRY_FILE_PERMS (S_IREAD | S_IWRITE) +#endif G_BEGIN_DECLS diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index 9966a58ac8..e5dba1a881 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include +#include #include "gst_private.h" #include "gstinfo.h" diff --git a/gst/gsttrace.c b/gst/gsttrace.c index 68633a62fb..b45dc92e0a 100644 --- a/gst/gsttrace.c +++ b/gst/gsttrace.c @@ -21,9 +21,13 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include +#ifdef HAVE_UNISTD_H #include -#include +#endif #include #include #include @@ -67,6 +71,12 @@ gst_trace_new (gchar * filename, gint size) g_return_val_if_fail (trace != NULL, NULL); trace->filename = g_strdup (filename); g_print ("opening '%s'\n", trace->filename); +#ifndef S_IWUSR +#define S_IWUSR S_IWRITE +#endif +#ifndef S_IRUSR +#define S_IDUSR S_IREAD +#endif trace->fd = open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); perror ("opening trace file"); @@ -120,7 +130,7 @@ gst_trace_text_flush (GstTrace * trace) } for (i = 0; i < trace->bufoffset; i++) { - snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n", + g_snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n", trace->buf[i].timestamp, trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message); write (trace->fd, str, strlen (str)); diff --git a/gst/registries/gstxmlregistry.c b/gst/registries/gstxmlregistry.c index d08bc4ef45..fe3c32f587 100644 --- a/gst/registries/gstxmlregistry.c +++ b/gst/registries/gstxmlregistry.c @@ -29,7 +29,9 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include @@ -757,9 +759,9 @@ gst_xml_registry_parse_element_factory (GMarkupParseContext * context, gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); } } else if (!strcmp (tag, "uri_type")) { - if (strncasecmp (text, "sink", 4) == 0) { + if (g_ascii_strncasecmp (text, "sink", 4) == 0) { factory->uri_type = GST_URI_SINK; - } else if (strncasecmp (text, "source", 5) == 0) { + } else if (g_ascii_strncasecmp (text, "source", 5) == 0) { factory->uri_type = GST_URI_SRC; } } else if (!strcmp (tag, "uri_protocol")) { diff --git a/libs/gst/control/dparam.h b/libs/gst/control/dparam.h index cf0a2c1411..0ece3bf8cf 100644 --- a/libs/gst/control/dparam.h +++ b/libs/gst/control/dparam.h @@ -58,7 +58,7 @@ typedef struct _GstDParamClass GstDParamClass; typedef enum { GST_DPARAM_UPDATE_FIRST, - GST_DPARAM_UPDATE_NORMAL, + GST_DPARAM_UPDATE_NORMAL } GstDParamUpdateInfo; typedef void (*GstDParamDoUpdateFunction) (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info); diff --git a/libs/gst/control/dparammanager.h b/libs/gst/control/dparammanager.h index 72dedbc099..9f4783acf1 100644 --- a/libs/gst/control/dparammanager.h +++ b/libs/gst/control/dparammanager.h @@ -49,7 +49,7 @@ G_BEGIN_DECLS typedef enum { GST_DPMAN_CALLBACK, GST_DPMAN_DIRECT, - GST_DPMAN_ARRAY, + GST_DPMAN_ARRAY } GstDPMUpdateMethod; typedef struct _GstDParamManagerClass GstDParamManagerClass;