mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +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>
|
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:
|
* gthread-none.c:
|
||||||
s/g_mutex_functions_for_glib_use/g_thread_functions_for_glib_use/
|
s/g_mutex_functions_for_glib_use/g_thread_functions_for_glib_use/
|
||||||
|
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gthread -DG_LOG_DOMAIN=g_log_domain_gthread
|
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gthread -DG_LOG_DOMAIN=g_log_domain_gthread
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
gthread-posix.c
|
gthread-posix.c \
|
||||||
|
gthread-solaris.c \
|
||||||
|
gthread-nspr.c \
|
||||||
|
gthread-none.c
|
||||||
|
|
||||||
libglib = $(top_builddir)/libglib.la # -lglib
|
libglib = $(top_builddir)/libglib.la # -lglib
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ struct _GPrivateNSPRData
|
|||||||
typedef struct _GPrivateNSPR GPrivateNSPR;
|
typedef struct _GPrivateNSPR GPrivateNSPR;
|
||||||
struct _GPrivateNSPR
|
struct _GPrivateNSPR
|
||||||
{
|
{
|
||||||
PRUintn private;
|
PRUintn private_key;
|
||||||
GDestroyNotify destructor;
|
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
|
/* we can not use g_new and friends, as they might use private data by
|
||||||
themself */
|
themself */
|
||||||
GPrivateNSPRData *private = malloc (sizeof (GPrivateNSPRData));
|
GPrivateNSPRData *private_key = malloc (sizeof (GPrivateNSPRData));
|
||||||
g_assert (private);
|
g_assert (private_key);
|
||||||
private->data = data;
|
private_key->data = data;
|
||||||
private->destructor = destructor;
|
private_key->destructor = destructor;
|
||||||
|
|
||||||
return private;
|
return private_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_private_nspr_data_destructor (gpointer data)
|
g_private_nspr_data_destructor (gpointer data)
|
||||||
{
|
{
|
||||||
GPrivateNSPRData *private = data;
|
GPrivateNSPRData *private_key = data;
|
||||||
if (private->destructor && private->data)
|
if (private_key->destructor && private_key->data)
|
||||||
(*private->destructor) (private->data);
|
(*private_key->destructor) (private_key->data);
|
||||||
free (private);
|
free (private_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPrivate *
|
static GPrivate *
|
||||||
g_private_new_nspr_impl (GDestroyNotify destructor)
|
g_private_new_nspr_impl (GDestroyNotify destructor)
|
||||||
{
|
{
|
||||||
GPrivateNSPR *result = g_new (GPrivateNSPR, 1);
|
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_private_nspr_data_destructor);
|
||||||
g_assert (status == PR_SUCCESS);
|
g_assert (status == PR_SUCCESS);
|
||||||
|
|
||||||
@ -164,17 +164,17 @@ g_private_new_nspr_impl (GDestroyNotify destructor)
|
|||||||
functions from gmem.c and gmessages.c */
|
functions from gmem.c and gmessages.c */
|
||||||
|
|
||||||
static GPrivateNSPRData *
|
static GPrivateNSPRData *
|
||||||
g_private_nspr_data_get (GPrivateNSPR * private)
|
g_private_nspr_data_get (GPrivateNSPR * private_key)
|
||||||
{
|
{
|
||||||
GPrivateNSPRData *data;
|
GPrivateNSPRData *data;
|
||||||
|
|
||||||
STDERR_ASSERT (private);
|
STDERR_ASSERT (private_key);
|
||||||
|
|
||||||
data = PR_GetThreadPrivate (private->private);
|
data = PR_GetThreadPrivate (private_key->private_key);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
data = g_private_nspr_data_constructor (private->destructor, NULL);
|
data = g_private_nspr_data_constructor (private_key->destructor, NULL);
|
||||||
STDERR_ASSERT (PR_SetThreadPrivate (private->private, data)
|
STDERR_ASSERT (PR_SetThreadPrivate (private_key->private_key, data)
|
||||||
== PR_SUCCESS);
|
== PR_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,21 +182,21 @@ g_private_nspr_data_get (GPrivateNSPR * private)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
return;
|
||||||
|
|
||||||
g_private_nspr_data_get ((GPrivateNSPR *) private)->data = value;
|
g_private_nspr_data_get ((GPrivateNSPR *) private_key)->data = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
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 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 =
|
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 */
|
functions from gmem.c and gmessages.c */
|
||||||
|
|
||||||
static void
|
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;
|
return;
|
||||||
|
|
||||||
pthread_setspecific (*(pthread_key_t *) private, value);
|
pthread_setspecific (*(pthread_key_t *) private_key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
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 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 =
|
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 */
|
functions from gmem.c and gmessages.c */
|
||||||
|
|
||||||
static void
|
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;
|
return;
|
||||||
|
|
||||||
thr_setspecific (*(thread_key_t *) private, value);
|
thr_setspecific (*(thread_key_t *) private_key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
g_private_get_solaris_impl (GPrivate * private)
|
g_private_get_solaris_impl (GPrivate * private_key)
|
||||||
{
|
{
|
||||||
gpointer result;
|
gpointer result;
|
||||||
|
|
||||||
if (!private)
|
if (!private_key)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thr_getspecific (*(thread_key_t *) private, &result);
|
thr_getspecific (*(thread_key_t *) private_key, &result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ private_destructor (gpointer data)
|
|||||||
g_free (real);
|
g_free (real);
|
||||||
}
|
}
|
||||||
|
|
||||||
GStaticPrivate private;
|
GStaticPrivate private_key;
|
||||||
|
|
||||||
void
|
void
|
||||||
test_private_func (void *data)
|
test_private_func (void *data)
|
||||||
@ -153,15 +153,15 @@ test_private_func (void *data)
|
|||||||
while (i < TEST_PRIVATE_ROUNDS)
|
while (i < TEST_PRIVATE_ROUNDS)
|
||||||
{
|
{
|
||||||
guint random_value = rand () % 10000;
|
guint random_value = rand () % 10000;
|
||||||
guint *data = g_static_private_get (&private);
|
guint *data = g_static_private_get (&private_key);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
data = private_constructor ();
|
data = private_constructor ();
|
||||||
g_static_private_set (&private, data, private_destructor);
|
g_static_private_set (&private_key, data, private_destructor);
|
||||||
}
|
}
|
||||||
*data = random_value;
|
*data = random_value;
|
||||||
wait_thread (.2);
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user