From 3862bc75ec60aed9589d16d177f0e6684c8cb6d7 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Thu, 3 May 2012 23:45:07 +0100 Subject: [PATCH 1/2] glib: do not call g_thread_ functions in GLib >= 2.31 Based on downstream patch by by Christopher James Halse Rogers Should fix BXC#2329 reported by Sergey Litvinov. --- configure.ac | 5 +++++ glib/Makefile.am | 8 +++++++- glib/Thread.cs | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0335446da..b90e5af31 100644 --- a/configure.ac +++ b/configure.ac @@ -176,6 +176,11 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) +PKG_CHECK_MODULES(GLIB_2_31, + glib-2.0 >= 2.31, + HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no) +AM_CONDITIONAL(DISABLE_GTHREAD_CHECK, test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xyes") + PKG_CHECK_MODULES(PANGO, pango) AC_SUBST(PANGO_CFLAGS) AC_SUBST(PANGO_LIBS) diff --git a/glib/Makefile.am b/glib/Makefile.am index d10c3ba20..c1f82f4b8 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -81,9 +81,15 @@ EXTRA_DIST = \ glib-sharp-3.0.pc.in \ glib-api.xml +if DISABLE_GTHREAD_CHECK +BUILD_DEFINES=-define:DISABLE_GTHREAD_CHECK +else +BUILD_DEFINES= +endif + $(ASSEMBLY): $(build_sources) $(SNK) @rm -f $(ASSEMBLY).mdb - $(CSC) $(CSFLAGS) -keyfile:$(SNK) -unsafe -out:$(ASSEMBLY) -target:library $(references) $(build_sources) + $(CSC) $(CSFLAGS) -keyfile:$(SNK) -unsafe -out:$(ASSEMBLY) -target:library $(references) $(build_sources) $(BUILD_DEFINES) policy.%.config: $(top_builddir)/policy.config sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@ diff --git a/glib/Thread.cs b/glib/Thread.cs index 7ce2ce21a..249dd048e 100644 --- a/glib/Thread.cs +++ b/glib/Thread.cs @@ -28,6 +28,18 @@ namespace GLib { private Thread () {} +#if DISABLE_GTHREAD_CHECK + public static void Init () + { + // GLib automatically inits threads in 2.31 and above + // http://developer.gnome.org/glib/unstable/glib-Deprecated-Thread-APIs.html#g-thread-init + } + + public static bool Supported + { + get { return true; } + } +#else [DllImport ("libgthread-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] static extern void g_thread_init (IntPtr i); @@ -45,5 +57,7 @@ namespace GLib return g_thread_get_initialized (); } } +#endif + } } From b008a626f8337a45b1445b9f287ec47ac685501e Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 4 May 2012 22:20:14 +0100 Subject: [PATCH 2/2] glib: don't modify Makefile.am The new -define flag DISABLE_GTHREAD_CHECK can be added at configure time to already existing $CSFLAGS, as Mike Kestner pointed out. --- configure.ac | 9 +++++---- glib/Makefile.am | 8 +------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index b90e5af31..c7611abaf 100644 --- a/configure.ac +++ b/configure.ac @@ -82,9 +82,6 @@ AC_ARG_ENABLE(debug, [ --enable-debug Build debugger (.mdb) files for ) fi -CSFLAGS="$DEBUG_FLAGS $WIN64DEFINES" -AC_SUBST(CSFLAGS) - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) if test "x$PKG_CONFIG" = "xno"; then AC_MSG_ERROR([You need to install pkg-config]) @@ -176,10 +173,14 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= $GLIB_REQUIRED_VERSION) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) +CSFLAGS="$DEBUG_FLAGS $WIN64DEFINES" PKG_CHECK_MODULES(GLIB_2_31, glib-2.0 >= 2.31, HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no) -AM_CONDITIONAL(DISABLE_GTHREAD_CHECK, test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xyes") +if test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xyes" ; then + CSFLAGS="$CSFLAGS -define:DISABLE_GTHREAD_CHECK" +fi +AC_SUBST(CSFLAGS) PKG_CHECK_MODULES(PANGO, pango) AC_SUBST(PANGO_CFLAGS) diff --git a/glib/Makefile.am b/glib/Makefile.am index c1f82f4b8..d10c3ba20 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -81,15 +81,9 @@ EXTRA_DIST = \ glib-sharp-3.0.pc.in \ glib-api.xml -if DISABLE_GTHREAD_CHECK -BUILD_DEFINES=-define:DISABLE_GTHREAD_CHECK -else -BUILD_DEFINES= -endif - $(ASSEMBLY): $(build_sources) $(SNK) @rm -f $(ASSEMBLY).mdb - $(CSC) $(CSFLAGS) -keyfile:$(SNK) -unsafe -out:$(ASSEMBLY) -target:library $(references) $(build_sources) $(BUILD_DEFINES) + $(CSC) $(CSFLAGS) -keyfile:$(SNK) -unsafe -out:$(ASSEMBLY) -target:library $(references) $(build_sources) policy.%.config: $(top_builddir)/policy.config sed -e "s/@ASSEMBLY_NAME@/$(ASSEMBLY_NAME)/" -e "s/@POLICY@/$*/" $(top_builddir)/policy.config > $@