mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Move the GThread implementations to glib/
We can now get threads initialised from inside of libglib by calling g_thread_init_glib().
This commit is contained in:
parent
96e4896804
commit
cfa1d0540e
@ -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) \
|
||||
|
@ -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"
|
@ -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"
|
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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) \
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user