Skip to content

Commit

Permalink
Merge pull request #42 from knocte/gtk-sharp-2-12-branch
Browse files Browse the repository at this point in the history
glib: do not call g_thread_ functions in GLib >= 2.31 (2-12 branch)
  • Loading branch information
mkestner committed May 10, 2012
2 parents d6ad5db + be18f43 commit a14b818
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
14 changes: 12 additions & 2 deletions configure.in.in
Expand Up @@ -86,8 +86,6 @@ if test "x$platform_win32" = "xyes"; then
fi

CSDEFINES='@VERSIONCSDEFINES@'
CSFLAGS="$DEBUG_FLAGS $CSDEFINES $WIN64DEFINES"
AC_SUBST(CSFLAGS)

GTK_SHARP_VERSION_CFLAGS='@VERSIONCFLAGS@'
AC_SUBST(GTK_SHARP_VERSION_CFLAGS)
Expand Down Expand Up @@ -223,6 +221,18 @@ AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_monodoc" = "xyes")
AM_CONDITIONAL(ENABLE_MSI, test "x$enable_msi" = "xyes")
AM_CONDITIONAL(ENABLE_MONOGETOPTIONS, test "x$has_mono" = "xtrue")

CSFLAGS="$DEBUG_FLAGS $CSDEFINES $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)

if test "x$HAVE_GLIB_2_31_OR_HIGHER" = "xyes" ; then
CFLAGS="$CFLAGS -DDISABLE_GTHREAD_CHECK"
CSFLAGS="$CSFLAGS -define:DISABLE_GTHREAD_CHECK"
fi

AC_SUBST(CSFLAGS)
AC_SUBST(CFLAGS)

AC_OUTPUT([
Expand Down
15 changes: 14 additions & 1 deletion glib/Thread.cs
Expand Up @@ -27,7 +27,18 @@ namespace GLib
public class Thread
{
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")]
static extern void g_thread_init (IntPtr i);

Expand All @@ -45,5 +56,7 @@ public static bool Supported
return glibsharp_g_thread_supported ();
}
}
#endif

}
}
4 changes: 4 additions & 0 deletions glib/glue/thread.c
Expand Up @@ -27,6 +27,10 @@ gboolean glibsharp_g_thread_supported (void);
gboolean
glibsharp_g_thread_supported ()
{
#ifdef DISABLE_GTHREAD_CHECK
return true;
#else
return g_thread_supported ();
#endif
}

0 comments on commit a14b818

Please sign in to comment.