diff --git a/gthread/ChangeLog b/gthread/ChangeLog index f4c6c9617..d6805efdf 100644 --- a/gthread/ChangeLog +++ b/gthread/ChangeLog @@ -1,5 +1,10 @@ 1998-12-15 Sebastian Wilhelmi + * 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/ diff --git a/gthread/Makefile.am b/gthread/Makefile.am index 3b7bc9748..c81bbecf9 100644 --- a/gthread/Makefile.am +++ b/gthread/Makefile.am @@ -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 diff --git a/gthread/gthread-nspr.c b/gthread/gthread-nspr.c index 77672e5f0..180e7da5b 100644 --- a/gthread/gthread-nspr.c +++ b/gthread/gthread-nspr.c @@ -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 = diff --git a/gthread/gthread-posix.c b/gthread/gthread-posix.c index 5b59672fe..4af75916c 100644 --- a/gthread/gthread-posix.c +++ b/gthread/gthread-posix.c @@ -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 = diff --git a/gthread/gthread-solaris.c b/gthread/gthread-solaris.c index 52d4c5552..df4c99f6b 100644 --- a/gthread/gthread-solaris.c +++ b/gthread/gthread-solaris.c @@ -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; } diff --git a/gthread/testgthread.c b/gthread/testgthread.c index b82a25267..5312e341d 100644 --- a/gthread/testgthread.c +++ b/gthread/testgthread.c @@ -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++; } }