1998-12-15 06:28:02 +01:00
|
|
|
/* GLIB - Library of useful routines for C programming
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* gthread.c: thread related functions
|
|
|
|
* Copyright 1998 Sebastian Wilhelmi; University of Karlsruhe
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 13:02:02 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-12-15 06:28:02 +01:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This 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
|
2000-07-26 13:02:02 +02:00
|
|
|
* Lesser General Public License for more details.
|
1998-12-15 06:28:02 +01:00
|
|
|
*
|
2000-07-26 13:02:02 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-12-15 06:28:02 +01:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
1999-02-24 07:14:27 +01:00
|
|
|
/*
|
2000-07-26 13:02:02 +02:00
|
|
|
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:14:27 +01:00
|
|
|
* file for a list of people on the GLib Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
2006-05-11 02:18:46 +02:00
|
|
|
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:14:27 +01:00
|
|
|
*/
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
/*
|
1998-12-15 06:28:02 +01:00
|
|
|
* MT safe
|
|
|
|
*/
|
|
|
|
|
2006-05-10 01:07:27 +02:00
|
|
|
#include "config.h"
|
1998-12-15 06:28:02 +01:00
|
|
|
|
2006-05-10 01:07:27 +02:00
|
|
|
#include "glib.h"
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
#include "gthreadprivate.h"
|
1998-12-15 06:28:02 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
static GSystemThread zero_thread; /* This is initialized to all zero */
|
1998-12-15 06:28:02 +01:00
|
|
|
static gboolean thread_system_already_initialized = FALSE;
|
2001-09-25 09:17:50 +02:00
|
|
|
static gint g_thread_priority_map [G_THREAD_PRIORITY_URGENT + 1];
|
1998-12-15 06:28:02 +01:00
|
|
|
|
|
|
|
#include G_THREAD_SOURCE
|
|
|
|
|
2000-11-21 16:27:44 +01:00
|
|
|
#ifndef PRIORITY_LOW_VALUE
|
|
|
|
# define PRIORITY_LOW_VALUE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PRIORITY_URGENT_VALUE
|
|
|
|
# define PRIORITY_URGENT_VALUE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PRIORITY_NORMAL_VALUE
|
2002-08-06 15:31:26 +02:00
|
|
|
# define PRIORITY_NORMAL_VALUE \
|
|
|
|
((PRIORITY_LOW_VALUE * 6 + PRIORITY_URGENT_VALUE * 4) / 10)
|
2000-11-21 16:27:44 +01:00
|
|
|
#endif /* PRIORITY_NORMAL_VALUE */
|
|
|
|
|
|
|
|
#ifndef PRIORITY_HIGH_VALUE
|
2002-08-06 15:31:26 +02:00
|
|
|
# define PRIORITY_HIGH_VALUE \
|
|
|
|
((PRIORITY_NORMAL_VALUE + PRIORITY_URGENT_VALUE * 2) / 3)
|
2000-11-21 16:27:44 +01:00
|
|
|
#endif /* PRIORITY_HIGH_VALUE */
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
typedef struct _GMutexDebugInfo GMutexDebugInfo;
|
|
|
|
struct _GMutexDebugInfo
|
2000-09-29 15:10:41 +02:00
|
|
|
{
|
|
|
|
gchar *location;
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
GSystemThread owner;
|
2000-09-29 15:10:41 +02:00
|
|
|
};
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
#define G_MUTEX_DEBUG_INFO(mutex) \
|
|
|
|
(((GMutexDebugInfo*)(((char*)mutex)+G_MUTEX_SIZE)))
|
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
static GMutex *
|
|
|
|
g_mutex_new_errorcheck_impl (void)
|
|
|
|
{
|
|
|
|
GMutex *retval = g_thread_functions_for_glib_use_default.mutex_new ();
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info;
|
|
|
|
retval = g_realloc (retval, G_MUTEX_SIZE + sizeof (GMutexDebugInfo));
|
|
|
|
|
|
|
|
info = G_MUTEX_DEBUG_INFO (retval);
|
|
|
|
g_system_thread_assign (info->owner, zero_thread);
|
|
|
|
info->location = "invalid";
|
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-11 02:18:46 +02:00
|
|
|
g_mutex_lock_errorcheck_impl (GMutex *mutex,
|
|
|
|
const gulong magic,
|
|
|
|
gchar * const location)
|
2000-09-29 15:10:41 +02:00
|
|
|
{
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info = G_MUTEX_DEBUG_INFO (mutex);
|
|
|
|
gchar *loc = (magic == G_MUTEX_DEBUG_MAGIC) ? location : "unknown";
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
GSystemThread self;
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_thread_functions_for_glib_use.thread_self (&self);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
if (g_system_thread_equal (info->owner, self))
|
2010-04-21 22:44:26 +02:00
|
|
|
g_error ("Trying to recursively lock a mutex at '%s', "
|
2006-05-11 02:18:46 +02:00
|
|
|
"previously locked at '%s'",
|
|
|
|
loc, info->location);
|
2000-09-29 15:10:41 +02:00
|
|
|
|
|
|
|
g_thread_functions_for_glib_use_default.mutex_lock (mutex);
|
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, self);
|
2006-05-11 02:18:46 +02:00
|
|
|
info->location = loc;
|
2000-09-29 15:10:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2006-05-11 02:18:46 +02:00
|
|
|
g_mutex_trylock_errorcheck_impl (GMutex *mutex,
|
|
|
|
const gulong magic,
|
|
|
|
gchar * const location)
|
2000-09-29 15:10:41 +02:00
|
|
|
{
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info = G_MUTEX_DEBUG_INFO (mutex);
|
|
|
|
gchar *loc = (magic == G_MUTEX_DEBUG_MAGIC) ? location : "unknown";
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
GSystemThread self;
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_thread_functions_for_glib_use.thread_self (&self);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
if (g_system_thread_equal (info->owner, self))
|
2000-11-28 13:56:57 +01:00
|
|
|
g_error ("Trying to recursivly lock a mutex at '%s', "
|
2006-05-11 02:18:46 +02:00
|
|
|
"previously locked at '%s'",
|
|
|
|
loc, info->location);
|
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
if (!g_thread_functions_for_glib_use_default.mutex_trylock (mutex))
|
|
|
|
return FALSE;
|
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, self);
|
2006-05-11 02:18:46 +02:00
|
|
|
info->location = loc;
|
2000-11-28 13:56:57 +01:00
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-11 02:18:46 +02:00
|
|
|
g_mutex_unlock_errorcheck_impl (GMutex *mutex,
|
|
|
|
const gulong magic,
|
|
|
|
gchar * const location)
|
2000-09-29 15:10:41 +02:00
|
|
|
{
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info = G_MUTEX_DEBUG_INFO (mutex);
|
|
|
|
gchar *loc = (magic == G_MUTEX_DEBUG_MAGIC) ? location : "unknown";
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
GSystemThread self;
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_thread_functions_for_glib_use.thread_self (&self);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
if (g_system_thread_equal (info->owner, zero_thread))
|
|
|
|
g_error ("Trying to unlock an unlocked mutex at '%s'", loc);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
if (!g_system_thread_equal (info->owner, self))
|
2000-11-28 13:56:57 +01:00
|
|
|
g_warning ("Trying to unlock a mutex at '%s', "
|
|
|
|
"previously locked by a different thread at '%s'",
|
2006-05-11 02:18:46 +02:00
|
|
|
loc, info->location);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, zero_thread);
|
2000-11-28 13:56:57 +01:00
|
|
|
info->location = NULL;
|
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
g_thread_functions_for_glib_use_default.mutex_unlock (mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-11 02:18:46 +02:00
|
|
|
g_mutex_free_errorcheck_impl (GMutex *mutex,
|
|
|
|
const gulong magic,
|
|
|
|
gchar * const location)
|
2000-09-29 15:10:41 +02:00
|
|
|
{
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info = G_MUTEX_DEBUG_INFO (mutex);
|
|
|
|
gchar *loc = (magic == G_MUTEX_DEBUG_MAGIC) ? location : "unknown";
|
2001-01-30 10:03:22 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
if (info && !g_system_thread_equal (info->owner, zero_thread))
|
2001-01-29 17:32:26 +01:00
|
|
|
g_error ("Trying to free a locked mutex at '%s', "
|
2006-05-11 02:18:46 +02:00
|
|
|
"which was previously locked at '%s'",
|
|
|
|
loc, info->location);
|
2001-01-29 17:32:26 +01:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
g_thread_functions_for_glib_use_default.mutex_free (mutex);
|
2000-09-29 15:10:41 +02:00
|
|
|
}
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
static void
|
2000-11-28 13:56:57 +01:00
|
|
|
g_cond_wait_errorcheck_impl (GCond *cond,
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutex *mutex,
|
|
|
|
const gulong magic,
|
|
|
|
gchar * const location)
|
2000-11-28 13:56:57 +01:00
|
|
|
{
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info = G_MUTEX_DEBUG_INFO (mutex);
|
|
|
|
gchar *loc = (magic == G_MUTEX_DEBUG_MAGIC) ? location : "unknown";
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
GSystemThread self;
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_thread_functions_for_glib_use.thread_self (&self);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
if (g_system_thread_equal (info->owner, zero_thread))
|
|
|
|
g_error ("Trying to use an unlocked mutex in g_cond_wait() at '%s'", loc);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
if (!g_system_thread_equal (info->owner, self))
|
2000-11-28 13:56:57 +01:00
|
|
|
g_error ("Trying to use a mutex locked by another thread in "
|
2006-05-11 02:18:46 +02:00
|
|
|
"g_cond_wait() at '%s'", loc);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, zero_thread);
|
2006-05-11 02:18:46 +02:00
|
|
|
loc = info->location;
|
2000-11-28 13:56:57 +01:00
|
|
|
|
|
|
|
g_thread_functions_for_glib_use_default.cond_wait (cond, mutex);
|
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, self);
|
2006-05-11 02:18:46 +02:00
|
|
|
info->location = loc;
|
2000-11-28 13:56:57 +01:00
|
|
|
}
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
|
|
|
|
static gboolean
|
2000-11-28 13:56:57 +01:00
|
|
|
g_cond_timed_wait_errorcheck_impl (GCond *cond,
|
|
|
|
GMutex *mutex,
|
2006-05-11 02:18:46 +02:00
|
|
|
GTimeVal *end_time,
|
|
|
|
const gulong magic,
|
|
|
|
gchar * const location)
|
2000-11-28 13:56:57 +01:00
|
|
|
{
|
2006-05-11 02:18:46 +02:00
|
|
|
GMutexDebugInfo *info = G_MUTEX_DEBUG_INFO (mutex);
|
|
|
|
gchar *loc = (magic == G_MUTEX_DEBUG_MAGIC) ? location : "unknown";
|
2000-11-28 13:56:57 +01:00
|
|
|
gboolean retval;
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
GSystemThread self;
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_thread_functions_for_glib_use.thread_self (&self);
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
if (g_system_thread_equal (info->owner, zero_thread))
|
2000-11-28 13:56:57 +01:00
|
|
|
g_error ("Trying to use an unlocked mutex in g_cond_timed_wait() at '%s'",
|
2006-05-11 02:18:46 +02:00
|
|
|
loc);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
if (!g_system_thread_equal (info->owner, self))
|
2000-11-28 13:56:57 +01:00
|
|
|
g_error ("Trying to use a mutex locked by another thread in "
|
2006-05-11 02:18:46 +02:00
|
|
|
"g_cond_timed_wait() at '%s'", loc);
|
2000-11-28 13:56:57 +01:00
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, zero_thread);
|
2006-05-11 02:18:46 +02:00
|
|
|
loc = info->location;
|
|
|
|
|
|
|
|
retval = g_thread_functions_for_glib_use_default.cond_timed_wait (cond,
|
|
|
|
mutex,
|
2000-11-28 13:56:57 +01:00
|
|
|
end_time);
|
|
|
|
|
Renamed to glib/gthreadprivate.h and moved system thread identifier
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes #311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-10 02:44:50 +02:00
|
|
|
g_system_thread_assign (info->owner, self);
|
2006-05-11 02:18:46 +02:00
|
|
|
info->location = loc;
|
2000-11-28 13:56:57 +01:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-30 10:03:22 +01:00
|
|
|
/* unshadow function declaration. See gthread.h */
|
2000-09-29 15:10:41 +02:00
|
|
|
#undef g_thread_init
|
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
void
|
2000-09-29 15:10:41 +02:00
|
|
|
g_thread_init_with_errorcheck_mutexes (GThreadFunctions* init)
|
|
|
|
{
|
|
|
|
GThreadFunctions errorcheck_functions;
|
|
|
|
if (init)
|
2006-05-11 02:18:46 +02:00
|
|
|
g_error ("Errorcheck mutexes can only be used for native "
|
2000-09-29 15:10:41 +02:00
|
|
|
"thread implementations. Sorry." );
|
When the sublangid is SUBLANG_DEFAULT, return the locale of the language's
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
gthread:
2001-09-28 Tor Lillqvist <tml@iki.fi>
* gthread-win32.c: Use an extra level of indirection for GMutex.
It is now a pointer either to a pointer to a CRITICAL_SECTION
struct, or to a mutex HANDLE. This is needed in case the user
defines G_ERRORCHECK_MUTEXES. G_MUTEX_SIZE must correctly reflect
the size of *GMutex, but this used to vary depending on whether we
at run-time chose to use CRITICAL_SECTIONs or mutexes.
(g_mutex_free_win32_cs_impl, g_cond_free_win32_impl): Call
DeleteCriticalSection() when done with it.
* gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
g_thread_impl_init() before accessing
g_thread_functions_for_glib_use_default, as the
g_thread_impl_init() function might modify it.
po:
2001-09-28 Tor Lillqvist <tml@iki.fi>
* POTFILES.in: Add iochannel.c and giowin32.c.
* sv.po: Remove a bogus fuzziness indicator.
2001-09-28 00:07:00 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_G_THREAD_IMPL_INIT
|
|
|
|
/* This isn't called in g_thread_init, as it doesn't think to get
|
|
|
|
* the default implementation, so we have to call it on our own.
|
|
|
|
*
|
|
|
|
* We must call this before copying
|
|
|
|
* g_thread_functions_for_glib_use_default as the
|
|
|
|
* implementation-specific init function might modify the contents
|
|
|
|
* of g_thread_functions_for_glib_use_default based on operating
|
|
|
|
* system version, C library version, or whatever. */
|
|
|
|
g_thread_impl_init();
|
2002-02-09 21:08:06 +01:00
|
|
|
#endif /* HAVE_G_THREAD_IMPL_INIT */
|
When the sublangid is SUBLANG_DEFAULT, return the locale of the language's
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
gthread:
2001-09-28 Tor Lillqvist <tml@iki.fi>
* gthread-win32.c: Use an extra level of indirection for GMutex.
It is now a pointer either to a pointer to a CRITICAL_SECTION
struct, or to a mutex HANDLE. This is needed in case the user
defines G_ERRORCHECK_MUTEXES. G_MUTEX_SIZE must correctly reflect
the size of *GMutex, but this used to vary depending on whether we
at run-time chose to use CRITICAL_SECTIONs or mutexes.
(g_mutex_free_win32_cs_impl, g_cond_free_win32_impl): Call
DeleteCriticalSection() when done with it.
* gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
g_thread_impl_init() before accessing
g_thread_functions_for_glib_use_default, as the
g_thread_impl_init() function might modify it.
po:
2001-09-28 Tor Lillqvist <tml@iki.fi>
* POTFILES.in: Add iochannel.c and giowin32.c.
* sv.po: Remove a bogus fuzziness indicator.
2001-09-28 00:07:00 +02:00
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
errorcheck_functions = g_thread_functions_for_glib_use_default;
|
|
|
|
errorcheck_functions.mutex_new = g_mutex_new_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
errorcheck_functions.mutex_lock =
|
2000-09-29 15:10:41 +02:00
|
|
|
(void (*)(GMutex *)) g_mutex_lock_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
errorcheck_functions.mutex_trylock =
|
2000-09-29 15:10:41 +02:00
|
|
|
(gboolean (*)(GMutex *)) g_mutex_trylock_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
errorcheck_functions.mutex_unlock =
|
2000-09-29 15:10:41 +02:00
|
|
|
(void (*)(GMutex *)) g_mutex_unlock_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
errorcheck_functions.mutex_free =
|
2001-01-30 10:03:22 +01:00
|
|
|
(void (*)(GMutex *)) g_mutex_free_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
errorcheck_functions.cond_wait =
|
2001-01-30 10:03:22 +01:00
|
|
|
(void (*)(GCond *, GMutex *)) g_cond_wait_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
errorcheck_functions.cond_timed_wait =
|
|
|
|
(gboolean (*)(GCond *, GMutex *, GTimeVal *))
|
2001-01-30 10:03:22 +01:00
|
|
|
g_cond_timed_wait_errorcheck_impl;
|
2006-05-11 02:18:46 +02:00
|
|
|
|
2000-09-29 15:10:41 +02:00
|
|
|
g_thread_init (&errorcheck_functions);
|
|
|
|
}
|
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
void
|
1998-12-16 06:38:35 +01:00
|
|
|
g_thread_init (GThreadFunctions* init)
|
1998-12-15 06:28:02 +01:00
|
|
|
{
|
|
|
|
gboolean supported;
|
|
|
|
|
|
|
|
if (thread_system_already_initialized)
|
2010-01-12 21:16:59 +01:00
|
|
|
{
|
|
|
|
if (init != NULL)
|
|
|
|
g_warning ("GThread system already initialized, ignoring custom thread implementation.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2006-05-11 02:18:46 +02:00
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
thread_system_already_initialized = TRUE;
|
|
|
|
|
|
|
|
if (init == NULL)
|
2001-05-22 14:28:06 +02:00
|
|
|
{
|
|
|
|
#ifdef HAVE_G_THREAD_IMPL_INIT
|
|
|
|
/* now do any initialization stuff required by the
|
|
|
|
* implementation, but only if called with a NULL argument, of
|
|
|
|
* course. Otherwise it's up to the user to do so. */
|
|
|
|
g_thread_impl_init();
|
|
|
|
#endif /* HAVE_G_THREAD_IMPL_INIT */
|
|
|
|
init = &g_thread_functions_for_glib_use_default;
|
|
|
|
}
|
1998-12-15 06:28:02 +01:00
|
|
|
else
|
|
|
|
g_thread_use_default_impl = FALSE;
|
|
|
|
|
|
|
|
g_thread_functions_for_glib_use = *init;
|
2001-05-22 14:28:06 +02:00
|
|
|
|
2006-05-11 02:18:46 +02:00
|
|
|
supported = (init->mutex_new &&
|
|
|
|
init->mutex_lock &&
|
|
|
|
init->mutex_trylock &&
|
|
|
|
init->mutex_unlock &&
|
|
|
|
init->mutex_free &&
|
|
|
|
init->cond_new &&
|
|
|
|
init->cond_signal &&
|
|
|
|
init->cond_broadcast &&
|
|
|
|
init->cond_wait &&
|
1998-12-16 06:38:35 +01:00
|
|
|
init->cond_timed_wait &&
|
|
|
|
init->cond_free &&
|
|
|
|
init->private_new &&
|
|
|
|
init->private_get &&
|
2002-04-18 13:42:01 +02:00
|
|
|
init->private_set &&
|
2001-05-22 14:28:06 +02:00
|
|
|
init->thread_create &&
|
|
|
|
init->thread_yield &&
|
|
|
|
init->thread_join &&
|
|
|
|
init->thread_exit &&
|
|
|
|
init->thread_set_priority &&
|
2007-01-16 22:25:03 +01:00
|
|
|
init->thread_self);
|
1998-12-15 06:28:02 +01:00
|
|
|
|
|
|
|
/* if somebody is calling g_thread_init (), it means that he wants to
|
1998-12-16 06:38:35 +01:00
|
|
|
* have thread support, so check this
|
|
|
|
*/
|
1998-12-15 06:28:02 +01:00
|
|
|
if (!supported)
|
|
|
|
{
|
|
|
|
if (g_thread_use_default_impl)
|
|
|
|
g_error ("Threads are not supported on this platform.");
|
|
|
|
else
|
|
|
|
g_error ("The supplied thread function vector is invalid.");
|
|
|
|
}
|
|
|
|
|
2000-11-21 16:27:44 +01:00
|
|
|
g_thread_priority_map [G_THREAD_PRIORITY_LOW] = PRIORITY_LOW_VALUE;
|
|
|
|
g_thread_priority_map [G_THREAD_PRIORITY_NORMAL] = PRIORITY_NORMAL_VALUE;
|
|
|
|
g_thread_priority_map [G_THREAD_PRIORITY_HIGH] = PRIORITY_HIGH_VALUE;
|
|
|
|
g_thread_priority_map [G_THREAD_PRIORITY_URGENT] = PRIORITY_URGENT_VALUE;
|
|
|
|
|
2003-02-14 16:08:46 +01:00
|
|
|
g_thread_init_glib ();
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|