[glib] win32: Allow POSIX threads to be used if --with-threads=posix
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] win32: Allow POSIX threads to be used if --with-threads=posix
- Date: Tue, 9 Apr 2013 12:10:31 +0000 (UTC)
commit 2ca9dda72aa85756010dfc9b73aa0d891e61bf29
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Tue Apr 9 14:09:33 2013 +0200
win32: Allow POSIX threads to be used if --with-threads=posix
All tests pass with this patch AND a good pthreads implementation
(i'm using winpthreads, not pthreads-w32).
https://bugzilla.gnome.org/show_bug.cgi?id=697626
configure.ac | 6 ++++++
glib/Makefile.am | 4 +++-
glib/glib-init.c | 4 ++++
glib/gthread-posix.c | 3 +++
4 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 73c9d60..55d1c55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2177,14 +2177,20 @@ AS_IF([test x$have_threads = xposix], [
])
g_threads_impl="POSIX"
+ AC_DEFINE([THREADS_POSIX], [1], [Use pthreads])
AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES)
CPPFLAGS="$glib_save_CPPFLAGS"
], [test x$have_threads = xwin32], [
+ AC_DEFINE([THREADS_WIN32], [1], [Use w32 threads])
g_threads_impl="WIN32"
], [
+ AC_DEFINE([THREADS_NONE], [1], [Use no threads])
g_threads_impl="NONE"
G_THREAD_LIBS=error
])
+AM_CONDITIONAL(THREADS_POSIX, [test "$g_threads_impl" = "POSIX"])
+AM_CONDITIONAL(THREADS_WIN32, [test "$g_threads_impl" = "WIN32"])
+AM_CONDITIONAL(THREADS_NONE, [test "$g_threads_impl" = "NONE"])
if test "x$G_THREAD_LIBS" = xerror; then
AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 021a26a..98d91af 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -214,11 +214,13 @@ if OS_UNIX
libglib_2_0_la_SOURCES += glib-unix.c
endif
-if OS_WIN32
+if THREADS_WIN32
libglib_2_0_la_SOURCES += gthread-win32.c
else
+if THREADS_POSIX
libglib_2_0_la_SOURCES += gthread-posix.c
endif
+endif
EXTRA_libglib_2_0_la_SOURCES = \
giounix.c \
diff --git a/glib/glib-init.c b/glib/glib-init.c
index 49c7f61..0032ee8 100644
--- a/glib/glib-init.c
+++ b/glib/glib-init.c
@@ -239,12 +239,16 @@ DllMain (HINSTANCE hinstDLL,
case DLL_PROCESS_ATTACH:
glib_dll = hinstDLL;
g_clock_win32_init ();
+#ifdef THREADS_WIN32
g_thread_win32_init ();
+#endif
glib_init ();
break;
case DLL_THREAD_DETACH:
+#ifdef THREADS_WIN32
g_thread_win32_thread_detach ();
+#endif
break;
default:
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index e65e437..23371ae 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -66,6 +66,9 @@
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
static void
g_thread_abort (gint status,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]