mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
updated.
1998-12-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * Makefile.am (EXTRA_DIST): updated. * testgthread.c, gthread-*.c: Changed private to private_key to avoid problems when compiling with under C++.
This commit is contained in:
parent
961205a025
commit
2c30e8620f
@ -1,5 +1,10 @@
|
||||
1998-12-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): updated.
|
||||
|
||||
* testgthread.c, gthread-*.c: Changed private to private_key to
|
||||
avoid problems when compiling with under C++.
|
||||
|
||||
* gthread-none.c:
|
||||
s/g_mutex_functions_for_glib_use/g_thread_functions_for_glib_use/
|
||||
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gthread -DG_LOG_DOMAIN=g_log_domain_gthread
|
||||
|
||||
EXTRA_DIST = \
|
||||
gthread-posix.c
|
||||
EXTRA_DIST = \
|
||||
gthread-posix.c \
|
||||
gthread-solaris.c \
|
||||
gthread-nspr.c \
|
||||
gthread-none.c
|
||||
|
||||
libglib = $(top_builddir)/libglib.la # -lglib
|
||||
|
||||
|
@ -122,7 +122,7 @@ struct _GPrivateNSPRData
|
||||
typedef struct _GPrivateNSPR GPrivateNSPR;
|
||||
struct _GPrivateNSPR
|
||||
{
|
||||
PRUintn private;
|
||||
PRUintn private_key;
|
||||
GDestroyNotify destructor;
|
||||
};
|
||||
|
||||
@ -131,28 +131,28 @@ g_private_nspr_data_constructor (GDestroyNotify destructor, gpointer data)
|
||||
{
|
||||
/* we can not use g_new and friends, as they might use private data by
|
||||
themself */
|
||||
GPrivateNSPRData *private = malloc (sizeof (GPrivateNSPRData));
|
||||
g_assert (private);
|
||||
private->data = data;
|
||||
private->destructor = destructor;
|
||||
GPrivateNSPRData *private_key = malloc (sizeof (GPrivateNSPRData));
|
||||
g_assert (private_key);
|
||||
private_key->data = data;
|
||||
private_key->destructor = destructor;
|
||||
|
||||
return private;
|
||||
return private_key;
|
||||
}
|
||||
|
||||
static void
|
||||
g_private_nspr_data_destructor (gpointer data)
|
||||
{
|
||||
GPrivateNSPRData *private = data;
|
||||
if (private->destructor && private->data)
|
||||
(*private->destructor) (private->data);
|
||||
free (private);
|
||||
GPrivateNSPRData *private_key = data;
|
||||
if (private_key->destructor && private_key->data)
|
||||
(*private_key->destructor) (private_key->data);
|
||||
free (private_key);
|
||||
}
|
||||
|
||||
static GPrivate *
|
||||
g_private_new_nspr_impl (GDestroyNotify destructor)
|
||||
{
|
||||
GPrivateNSPR *result = g_new (GPrivateNSPR, 1);
|
||||
PRStatus status = PR_NewThreadPrivateIndex (&result->private,
|
||||
PRStatus status = PR_NewThreadPrivateIndex (&result->private_key,
|
||||
g_private_nspr_data_destructor);
|
||||
g_assert (status == PR_SUCCESS);
|
||||
|
||||
@ -164,17 +164,17 @@ g_private_new_nspr_impl (GDestroyNotify destructor)
|
||||
functions from gmem.c and gmessages.c */
|
||||
|
||||
static GPrivateNSPRData *
|
||||
g_private_nspr_data_get (GPrivateNSPR * private)
|
||||
g_private_nspr_data_get (GPrivateNSPR * private_key)
|
||||
{
|
||||
GPrivateNSPRData *data;
|
||||
|
||||
STDERR_ASSERT (private);
|
||||
STDERR_ASSERT (private_key);
|
||||
|
||||
data = PR_GetThreadPrivate (private->private);
|
||||
data = PR_GetThreadPrivate (private_key->private_key);
|
||||
if (!data)
|
||||
{
|
||||
data = g_private_nspr_data_constructor (private->destructor, NULL);
|
||||
STDERR_ASSERT (PR_SetThreadPrivate (private->private, data)
|
||||
data = g_private_nspr_data_constructor (private_key->destructor, NULL);
|
||||
STDERR_ASSERT (PR_SetThreadPrivate (private_key->private_key, data)
|
||||
== PR_SUCCESS);
|
||||
}
|
||||
|
||||
@ -182,21 +182,21 @@ g_private_nspr_data_get (GPrivateNSPR * private)
|
||||
}
|
||||
|
||||
static void
|
||||
g_private_set_nspr_impl (GPrivate * private, gpointer value)
|
||||
g_private_set_nspr_impl (GPrivate * private_key, gpointer value)
|
||||
{
|
||||
if (!private)
|
||||
if (!private_key)
|
||||
return;
|
||||
|
||||
g_private_nspr_data_get ((GPrivateNSPR *) private)->data = value;
|
||||
g_private_nspr_data_get ((GPrivateNSPR *) private_key)->data = value;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
g_private_get_nspr_impl (GPrivate * private)
|
||||
g_private_get_nspr_impl (GPrivate * private_key)
|
||||
{
|
||||
if (!private)
|
||||
if (!private_key)
|
||||
return NULL;
|
||||
|
||||
return g_private_nspr_data_get ((GPrivateNSPR *) private)->data;
|
||||
return g_private_nspr_data_get ((GPrivateNSPR *) private_key)->data;
|
||||
}
|
||||
|
||||
static GThreadFunctions g_thread_functions_for_glib_use_default =
|
||||
|
@ -140,21 +140,21 @@ g_private_new_posix_impl (GDestroyNotify destructor)
|
||||
functions from gmem.c and gmessages.c */
|
||||
|
||||
static void
|
||||
g_private_set_posix_impl (GPrivate * private, gpointer value)
|
||||
g_private_set_posix_impl (GPrivate * private_key, gpointer value)
|
||||
{
|
||||
if (!private)
|
||||
if (!private_key)
|
||||
return;
|
||||
|
||||
pthread_setspecific (*(pthread_key_t *) private, value);
|
||||
pthread_setspecific (*(pthread_key_t *) private_key, value);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
g_private_get_posix_impl (GPrivate * private)
|
||||
g_private_get_posix_impl (GPrivate * private_key)
|
||||
{
|
||||
if (!private)
|
||||
if (!private_key)
|
||||
return NULL;
|
||||
|
||||
return pthread_getspecific (*(pthread_key_t *) private);
|
||||
return pthread_getspecific (*(pthread_key_t *) private_key);
|
||||
}
|
||||
|
||||
static GThreadFunctions g_thread_functions_for_glib_use_default =
|
||||
|
@ -137,23 +137,23 @@ g_private_new_solaris_impl (GDestroyNotify destructor)
|
||||
functions from gmem.c and gmessages.c */
|
||||
|
||||
static void
|
||||
g_private_set_solaris_impl (GPrivate * private, gpointer value)
|
||||
g_private_set_solaris_impl (GPrivate * private_key, gpointer value)
|
||||
{
|
||||
if (!private)
|
||||
if (!private_key)
|
||||
return;
|
||||
|
||||
thr_setspecific (*(thread_key_t *) private, value);
|
||||
thr_setspecific (*(thread_key_t *) private_key, value);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
g_private_get_solaris_impl (GPrivate * private)
|
||||
g_private_get_solaris_impl (GPrivate * private_key)
|
||||
{
|
||||
gpointer result;
|
||||
|
||||
if (!private)
|
||||
if (!private_key)
|
||||
return NULL;
|
||||
|
||||
thr_getspecific (*(thread_key_t *) private, &result);
|
||||
thr_getspecific (*(thread_key_t *) private_key, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ private_destructor (gpointer data)
|
||||
g_free (real);
|
||||
}
|
||||
|
||||
GStaticPrivate private;
|
||||
GStaticPrivate private_key;
|
||||
|
||||
void
|
||||
test_private_func (void *data)
|
||||
@ -153,15 +153,15 @@ test_private_func (void *data)
|
||||
while (i < TEST_PRIVATE_ROUNDS)
|
||||
{
|
||||
guint random_value = rand () % 10000;
|
||||
guint *data = g_static_private_get (&private);
|
||||
guint *data = g_static_private_get (&private_key);
|
||||
if (!data)
|
||||
{
|
||||
data = private_constructor ();
|
||||
g_static_private_set (&private, data, private_destructor);
|
||||
g_static_private_set (&private_key, data, private_destructor);
|
||||
}
|
||||
*data = random_value;
|
||||
wait_thread (.2);
|
||||
g_assert (*(guint *) g_static_private_get (&private) == random_value);
|
||||
g_assert (*(guint *) g_static_private_get (&private_key) == random_value);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user