Commit 8e91cf9e authored by Sebastian Wilhelmi's avatar Sebastian Wilhelmi Committed by Sebastian Wilhelmi

Fixes for #101264 and #99372:


2003-02-14  Sebastian Wilhelmi  <seppi@seppi.de>

	Fixes for #101264 and #99372:

	* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
	glib/grand.c: Include gthreadinit.h and rename the thread
	initialization functions a bit and let them start with _, so that
	later we can stop exporting them.

	* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
	new functions. They have to be called after setting
	g_threads_got_initialized to TRUE (see #101264).

	* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
	g_thread_init_glib(). Call the thread initialization functions
	(which are not allowed to call g_private_new), then set
	g_threads_got_initialized to TRUE, then call the other thread
	initialization functions (which must not call anything but
	g_private_new()).

	* glib/gthreadinit.h: New private header to cleanly declare all
	thread initialization functions.

	* gthread/gthread-impl.c: Include gthreadinit.h. In
	g_thread_init() just call g_thread_init_glib(), which in turn calls the
	other functions (see #99372).

	* glib/Makefile.am: Added gthreadinit.h.
parent f0e22eaa
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2003-02-12 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in: Make GLib recognize Tru64Unix thread system. (#103020)
......
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2003-02-12 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in: Make GLib recognize Tru64Unix thread system. (#103020)
......
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2003-02-12 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in: Make GLib recognize Tru64Unix thread system. (#103020)
......
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2003-02-12 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in: Make GLib recognize Tru64Unix thread system. (#103020)
......
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2003-02-12 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in: Make GLib recognize Tru64Unix thread system. (#103020)
......
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2003-02-12 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in: Make GLib recognize Tru64Unix thread system. (#103020)
......
......@@ -77,6 +77,7 @@ libglib_2_0_la_SOURCES = \
gstrfuncs.c \
gstring.c \
gthread.c \
gthreadinit.h \
gthreadpool.c \
gtimer.c \
gtree.c \
......
......@@ -30,6 +30,7 @@
#include "glib.h"
#include "gprintfint.h"
#include "gthreadinit.h"
#ifdef G_PLATFORM_WIN32
#define STRICT
......@@ -1222,7 +1223,7 @@ have_broken_filenames (void)
* initialize some static data in a threadsafe way.
*/
void
g_convert_init (void)
_g_convert_thread_init (void)
{
#ifndef G_PLATFORM_WIN32
(void)have_broken_filenames ();
......
......@@ -37,6 +37,7 @@
/* #define G_MAIN_POLL_DEBUG */
#include "glib.h"
#include "gthreadinit.h"
#include <sys/types.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
......@@ -623,7 +624,7 @@ g_main_context_init_pipe (GMainContext *context)
}
void
g_main_thread_init ()
_g_main_thread_init ()
{
GSList *curr = main_contexts_without_pipe;
while (curr)
......
......@@ -35,7 +35,7 @@
#include <signal.h>
#include "glib.h"
#include "gthreadinit.h"
/* notes on macros:
* having DISABLE_MEM_POOLS defined, disables mem_chunks alltogether, their
......@@ -1253,13 +1253,22 @@ g_allocator_free (GAllocator *allocator)
}
void
g_mem_init (void)
_g_mem_thread_init (void)
{
#ifndef DISABLE_MEM_POOLS
mem_chunks_lock = g_mutex_new ();
#endif
#ifndef G_DISABLE_CHECKS
mem_chunk_recursion = g_private_new (NULL);
g_profile_mutex = g_mutex_new ();
#endif
}
void
_g_mem_thread_private_init (void)
{
#ifndef G_DISABLE_CHECKS
g_assert (mem_chunk_recursion == NULL);
mem_chunk_recursion = g_private_new (NULL);
#endif
}
......@@ -44,6 +44,7 @@
#include "glib.h"
#include "gdebug.h"
#include "gprintfint.h"
#include "gthreadinit.h"
#ifdef G_OS_WIN32
#include <io.h>
......@@ -929,14 +930,20 @@ g_printf_string_upper_bound (const gchar *format,
}
void
g_messages_init (void)
_g_messages_thread_init (void)
{
g_messages_lock = g_mutex_new ();
g_log_depth = g_private_new (NULL);
g_messages_prefixed_init ();
_g_debug_init ();
}
void
_g_messages_thread_private_init (void)
{
g_assert (g_log_depth == NULL);
g_log_depth = g_private_new (NULL);
}
gboolean _g_debug_initialized = FALSE;
guint _g_debug_flags = 0;
......
......@@ -43,7 +43,7 @@
#include <string.h>
#include "glib.h"
#include "gthreadinit.h"
G_LOCK_DEFINE_STATIC (global_random);
static GRand* global_random = NULL;
......@@ -93,7 +93,7 @@ get_random_version (void)
* initialize some static data in a threadsafe way.
*/
void
g_rand_init (void)
_g_rand_thread_init (void)
{
(void)get_random_version ();
}
......
......@@ -48,7 +48,7 @@
#include <string.h>
#include "glib.h"
#include "gthreadinit.h"
#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
# define g_system_thread_equal_simple(thread1, thread2) \
......@@ -158,22 +158,22 @@ G_LOCK_DEFINE_STATIC (g_thread);
/* This must be called only once, before any threads are created.
* It will only be called from g_thread_init() in -lgthread.
*/
void
g_mutex_init (void)
void
g_thread_init_glib (void)
{
GRealThread* main_thread;
/* We let the main thread (the one that calls g_thread_init) inherit
* the data, that it set before calling g_thread_init
* the static_private data set before calling g_thread_init
*/
main_thread = (GRealThread*) g_thread_self ();
g_thread_specific_private = g_private_new (g_thread_cleanup);
G_THREAD_UF (private_set, (g_thread_specific_private, main_thread));
G_THREAD_UF (thread_self, (&main_thread->system_thread));
GRealThread* main_thread = (GRealThread*) g_thread_self ();
g_mutex_protect_static_mutex_allocation = g_mutex_new ();
_g_convert_thread_init ();
_g_rand_thread_init ();
_g_main_thread_init ();
_g_mem_thread_init ();
_g_messages_thread_init ();
#ifdef G_THREAD_USE_PID_SURROGATE
priority_map[G_THREAD_PRIORITY_NORMAL] =
getpriority (PRIO_PROCESS, (getpid ()));
......@@ -184,6 +184,16 @@ g_mutex_init (void)
priority_map[G_THREAD_PRIORITY_URGENT] =
MAX (-20, priority_map[G_THREAD_PRIORITY_NORMAL] - 15);
#endif /* G_THREAD_USE_PID_SURROGATE */
g_threads_got_initialized = TRUE;
g_thread_specific_private = g_private_new (g_thread_cleanup);
g_private_set (g_thread_specific_private, main_thread);
G_THREAD_UF (thread_self, (&main_thread->system_thread));
_g_mem_thread_private_init ();
_g_messages_thread_private_init ();
}
void
......
/* gthreadinit.h - GLib internal thread initialization functions
*
* Copyright (C) 2003 Sebastian Wilhelmi
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __G_THREADINIT_H__
#define __G_THREADINIT_H__
G_BEGIN_DECLS
/* Is called from gthread/gthread-impl.c */
void g_thread_init_glib (void);
/* Are called from glib/gthread.c. May not contain g_private_new calls */
void _g_mem_thread_init (void);
void _g_messages_thread_init (void);
void _g_convert_thread_init (void);
void _g_rand_thread_init (void);
void _g_main_thread_init (void);
/* Are called from glib/gthread.c. Must only contain g_private_new calls */
void _g_mem_thread_private_init (void);
void _g_messages_thread_private_init (void);
G_END_DECLS
#endif /* __G_THREADINIT_H__ */
......@@ -36,6 +36,7 @@
#endif
#include <glib.h>
#include <gthreadinit.h>
#ifdef G_THREADS_ENABLED
......@@ -336,9 +337,6 @@ g_thread_init (GThreadFunctions* init)
g_thread_functions_for_glib_use = *init;
/* It is important, that g_threads_got_initialized is not set before the
* thread initialization functions of the different modules are called
*/
supported = (init->mutex_new &&
init->mutex_lock &&
init->mutex_trylock &&
......@@ -376,24 +374,7 @@ g_thread_init (GThreadFunctions* init)
g_thread_priority_map [G_THREAD_PRIORITY_HIGH] = PRIORITY_HIGH_VALUE;
g_thread_priority_map [G_THREAD_PRIORITY_URGENT] = PRIORITY_URGENT_VALUE;
/* now call the thread initialization functions of the different
* glib modules. order does matter, g_mutex_init MUST come first.
*/
g_mutex_init ();
g_mem_init ();
g_messages_init ();
g_convert_init ();
g_rand_init ();
/* now we can set g_threads_got_initialized and thus enable
* all the thread functions
*/
g_threads_got_initialized = TRUE;
/* This has to come after g_threads_got_initialized is set
* since it uses a private variable created by g_mem_init()
*/
g_main_thread_init ();
g_thread_init_glib ();
}
#else /* !G_THREADS_ENABLED */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment