Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
updated.
Browse files Browse the repository at this point in the history
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++.
  • Loading branch information
Sebastian Wilhelmi authored and Sebastian Wilhelmi committed Dec 15, 1998
1 parent 961205a commit 2c30e86
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 40 deletions.
5 changes: 5 additions & 0 deletions gthread/ChangeLog
Original file line number Diff line number Diff line change
@@ -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/

Expand Down
7 changes: 5 additions & 2 deletions gthread/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
44 changes: 22 additions & 22 deletions gthread/gthread-nspr.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct _GPrivateNSPRData
typedef struct _GPrivateNSPR GPrivateNSPR;
struct _GPrivateNSPR
{
PRUintn private;
PRUintn private_key;
GDestroyNotify destructor;
};

Expand All @@ -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);

Expand All @@ -164,39 +164,39 @@ 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);
}

return data;
}

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 =
Expand Down
12 changes: 6 additions & 6 deletions gthread/gthread-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
12 changes: 6 additions & 6 deletions gthread/gthread-solaris.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions gthread/testgthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private_destructor (gpointer data)
g_free (real);
}

GStaticPrivate private;
GStaticPrivate private_key;

void
test_private_func (void *data)
Expand All @@ -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++;
}
}
Expand Down

0 comments on commit 2c30e86

Please sign in to comment.