This commit merges the glib-threads branch into the main

branch. See the ChangeLog for details of the changes.

In brief overview:

 - The set of threading functions can be set
 - A default implementation is provided in -lgthread
 - All static data structures are locked using these
   functions if g_thread_init() is called.
This commit is contained in:
Owen Taylor
1998-12-15 05:28:02 +00:00
parent c8ba100dab
commit 931ea95265
79 changed files with 3635 additions and 245 deletions

View File

@@ -17,6 +17,10 @@
* Boston, MA 02111-1307, USA.
*/
/*
* MT safe for the unix part, FIXME: make the win32 part MT safe as well.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -367,11 +371,14 @@ g_getenv (const gchar *variable)
#endif
}
static G_LOCK_DEFINE(g_utils_global);
static gchar *g_tmp_dir = NULL;
static gchar *g_user_name = NULL;
static gchar *g_real_name = NULL;
static gchar *g_home_dir = NULL;
/* HOLDS: g_utils_global_lock */
static void
g_get_any_init (void)
{
@@ -442,14 +449,16 @@ g_get_any_init (void)
g_home_dir = NULL;
# endif /* !NATIVE_WIN32 */
#endif /* !HAVE_PWD_H */
}
}
}
gchar*
g_get_user_name (void)
{
g_lock (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
g_unlock (g_utils_global);
return g_user_name;
}
@@ -457,9 +466,11 @@ g_get_user_name (void)
gchar*
g_get_real_name (void)
{
g_lock (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
g_unlock (g_utils_global);
return g_real_name;
}
@@ -472,8 +483,10 @@ g_get_real_name (void)
gchar*
g_get_home_dir (void)
{
g_lock (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
g_unlock (g_utils_global);
return g_home_dir;
}
@@ -488,8 +501,10 @@ g_get_home_dir (void)
gchar*
g_get_tmp_dir (void)
{
g_lock (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
g_unlock (g_utils_global);
return g_tmp_dir;
}
@@ -499,16 +514,25 @@ static gchar *g_prgname = NULL;
gchar*
g_get_prgname (void)
{
return g_prgname;
gchar* retval;
g_lock (g_utils_global);
retval = g_prgname;
g_unlock (g_utils_global);
return retval;
}
void
g_set_prgname (const gchar *prgname)
{
gchar *c = g_prgname;
gchar *c;
g_lock (g_utils_global);
c = g_prgname;
g_prgname = g_strdup (prgname);
g_free (c);
g_unlock (g_utils_global);
}
guint