summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-08-31 18:00:03 -0400
committerRyan Lortie <desrt@desrt.ca>2011-09-09 12:47:40 -0400
commitcfa1d0540e4aaf83641f3876a2589a1e8f2b1242 (patch)
tree4ee4a1511122b0a8dbf56cd673c15f6e73101585
parent96e489680423f87428c74b1f6ec8a6b8a9c99645 (diff)
downloadglib-cfa1d0540e4aaf83641f3876a2589a1e8f2b1242.tar.gz
Move the GThread implementations to glib/
We can now get threads initialised from inside of libglib by calling g_thread_init_glib().
-rw-r--r--glib/Makefile.am10
-rw-r--r--glib/gthread-posix.c (renamed from gthread/gthread-posix.c)8
-rw-r--r--glib/gthread-win32.c (renamed from gthread/gthread-win32.c)11
-rw-r--r--glib/gthread.c4
-rw-r--r--glib/gthreadprivate.h1
-rw-r--r--gthread/Makefile.am8
-rw-r--r--gthread/gthread-impl.c6
7 files changed, 23 insertions, 25 deletions
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 1703277f5..d92f0e695 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -207,7 +207,13 @@ libglib_2_0_la_SOURCES = \
if OS_UNIX
libglib_2_0_la_SOURCES += glib-unix.c
-endif
+endif
+
+if OS_WIN32
+libglib_2_0_la_SOURCES += gthread-win32.c
+else
+libglib_2_0_la_SOURCES += gthread-posix.c
+endif
EXTRA_libglib_2_0_la_SOURCES = \
giounix.c \
@@ -347,7 +353,7 @@ pcre_lib =
pcre_inc =
endif
-libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(GLIB_RT_LIBS)
+libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(GLIB_RT_LIBS) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD)
libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def)
libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
diff --git a/gthread/gthread-posix.c b/glib/gthread-posix.c
index da580a766..96abcf80e 100644
--- a/gthread/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -132,8 +132,8 @@ static gulong g_thread_min_stack_size = 0;
#define G_MUTEX_SIZE (sizeof (pthread_mutex_t))
-static void
-g_thread_impl_init(void)
+void
+_g_thread_impl_init(void)
{
#ifdef _SC_THREAD_STACK_MIN
g_thread_min_stack_size = MAX (sysconf (_SC_THREAD_STACK_MIN), 0);
@@ -381,7 +381,7 @@ g_thread_equal_posix_impl (gpointer thread1, gpointer thread2)
return (pthread_equal (*(pthread_t*)thread1, *(pthread_t*)thread2) != 0);
}
-static GThreadFunctions g_thread_functions_for_glib_use_default =
+GThreadFunctions g_thread_functions_for_glib_use =
{
g_mutex_new_posix_impl,
(void (*)(GMutex *)) pthread_mutex_lock,
@@ -405,5 +405,3 @@ static GThreadFunctions g_thread_functions_for_glib_use_default =
g_thread_self_posix_impl,
g_thread_equal_posix_impl
};
-
-#include "gthread-impl.c"
diff --git a/gthread/gthread-win32.c b/glib/gthread-win32.c
index bfd1ef77f..d50aee184 100644
--- a/gthread/gthread-win32.c
+++ b/glib/gthread-win32.c
@@ -70,9 +70,6 @@ static GDestroyNotify g_private_destructors[G_PRIVATE_MAX];
static guint g_private_next = 0;
-/* A "forward" declaration of this structure */
-static GThreadFunctions g_thread_functions_for_glib_use_default;
-
typedef struct _GThreadData GThreadData;
struct _GThreadData
{
@@ -516,7 +513,7 @@ g_thread_join_win32_impl (gpointer thread)
g_free (target);
}
-static GThreadFunctions g_thread_functions_for_glib_use_default =
+GThreadFunctions g_thread_functions_for_glib_use =
{
g_mutex_new_win32_impl, /* mutex */
g_mutex_lock_win32_impl,
@@ -541,8 +538,8 @@ static GThreadFunctions g_thread_functions_for_glib_use_default =
NULL /* no equal function necessary */
};
-static void
-g_thread_impl_init ()
+void
+_g_thread_impl_init (void)
{
static gboolean beenhere = FALSE;
@@ -559,5 +556,3 @@ g_thread_impl_init ()
(g_cond_event_tls = TlsAlloc ()));
InitializeCriticalSection (&g_thread_global_spinlock);
}
-
-#include "gthread-impl.c"
diff --git a/glib/gthread.c b/glib/gthread.c
index 310a49333..9fc525419 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -356,7 +356,7 @@ gboolean g_threads_got_initialized = FALSE;
*
* For that reason, all of those macros are documented here.
*/
-GThreadFunctions g_thread_functions_for_glib_use = {
+static GThreadFunctions g_thread_functions_for_glib_use_old = {
/* GMutex Virtual Functions {{{2 ------------------------------------------ */
/**
@@ -925,6 +925,8 @@ G_LOCK_DEFINE_STATIC (g_thread);
void
g_thread_init_glib (void)
{
+ _g_thread_impl_init ();
+
/* We let the main thread (the one that calls g_thread_init) inherit
* the static_private data set before calling g_thread_init
*/
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index 30357d7cc..fdd803a5d 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -59,6 +59,7 @@ G_GNUC_INTERNAL void _g_main_thread_init (void);
G_GNUC_INTERNAL void _g_atomic_thread_init (void);
G_GNUC_INTERNAL void _g_utils_thread_init (void);
G_GNUC_INTERNAL void _g_futex_thread_init (void);
+G_GNUC_INTERNAL void _g_thread_impl_init (void);
#ifdef G_OS_WIN32
G_GNUC_INTERNAL void _g_win32_thread_init (void);
diff --git a/gthread/Makefile.am b/gthread/Makefile.am
index 700f39c45..70b630512 100644
--- a/gthread/Makefile.am
+++ b/gthread/Makefile.am
@@ -13,8 +13,6 @@ AM_CPPFLAGS = \
EXTRA_DIST += \
makefile.msc.in \
- gthread-posix.c \
- gthread-win32.c \
gthread.def \
gthread.rc.in
@@ -66,11 +64,7 @@ gthread_win32_res = gthread-win32-res.o
gthread_win32_res_ldflag = -Wl,$(gthread_win32_res)
endif
-if OS_WIN32
-libgthread_2_0_la_SOURCES = gthread-win32.c
-else
-libgthread_2_0_la_SOURCES = gthread-posix.c
-endif
+libgthread_2_0_la_SOURCES = gthread-impl.c
libgthread_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gthread_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
diff --git a/gthread/gthread-impl.c b/gthread/gthread-impl.c
index bd7ba79a3..123faa00f 100644
--- a/gthread/gthread-impl.c
+++ b/gthread/gthread-impl.c
@@ -31,6 +31,10 @@
* MT safe
*/
+#include "glib.h"
+
+#include "gthreadprivate.h"
+
void
g_thread_init (GThreadFunctions *init)
{
@@ -44,8 +48,6 @@ g_thread_init (GThreadFunctions *init)
already_done = TRUE;
- g_thread_impl_init ();
- g_thread_functions_for_glib_use = g_thread_functions_for_glib_use_default;
g_thread_init_glib ();
}