This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
971225: MT fixes for Solaris 2.6.
- To: egcs at cygnus dot com
- Subject: 971225: MT fixes for Solaris 2.6.
- From: Teemu Torma <tot at trema dot com>
- Date: Tue, 06 Jan 1998 14:59:54 +0100
- Organization: Trema Laboratories SARL
It seems that Solaris 2.6 has dummy pthread routines in libc.
pthread_once returns success but does nothing. Here are some patches
to make sure that __gthread_once really called the initialization
routine. I also fixed some inconsistencies in return value handling
and checking.
Teemu
1998-01-06 Teemu Torma <tot@trema.com>
* gthr.h: Changed the comment about return values.
* gthr-solaris.h (__gthread_once): Do not use errno; return the
error number instead of -1.
(__gthread_key_create): Any non-zero return value is an error.
* libgcc2.c (eh_context_initialize): Check for non-zero return
value from __gthread_once.
Check that the value of get_eh_context was really changed.
Index: gthr-solaris.h
===================================================================
RCS file: /trema/cvs/gnu/egcs/gcc/gthr-solaris.h,v
retrieving revision 1.2
diff -c -c -3 -p -r1.2 gthr-solaris.h
*** gthr-solaris.h 1997/12/18 12:38:09 1.2
--- gthr-solaris.h 1998/01/06 13:00:03
*************** __gthread_once (__gthread_once_t *once,
*** 88,102 ****
return -1;
if (once == 0 || func == 0)
! {
! errno = EINVAL;
! return -1;
! }
if (once->once == 0)
{
! if (mutex_lock (&once->mutex) != 0)
! return -1;
if (once->once == 0)
{
(*func) ();
--- 88,100 ----
return -1;
if (once == 0 || func == 0)
! return EINVAL;
if (once->once == 0)
{
! int status = mutex_lock (&once->mutex);
! if (status != 0)
! return status;
if (once->once == 0)
{
(*func) ();
*************** __gthread_key_create (__gthread_key_t *k
*** 113,119 ****
/* Solaris 2.5 contains thr_* routines no-op in libc, so test if we actually
got a reasonable key value, and if not, fail. */
*key = -1;
! if (thr_keycreate (key, dtor) == -1 || *key == -1)
return -1;
else
return 0;
--- 111,117 ----
/* Solaris 2.5 contains thr_* routines no-op in libc, so test if we actually
got a reasonable key value, and if not, fail. */
*key = -1;
! if (thr_keycreate (key, dtor) != 0 || *key == -1)
return -1;
else
return 0;
Index: gthr.h
===================================================================
RCS file: /trema/cvs/gnu/egcs/gcc/gthr.h,v
retrieving revision 1.3
diff -c -c -3 -p -r1.3 gthr.h
*** gthr.h 1997/12/18 12:38:09 1.3
--- gthr.h 1998/01/06 13:05:33
*************** Boston, MA 02111-1307, USA. */
*** 65,71 ****
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
! All functions returning int should return 0 on success, -1 on error.
Currently supported threads packages are
POSIX threads with -D_PTHREADS
--- 65,72 ----
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
! All functions returning int should return zero on success or the error
! number. If the operation is not supported, -1 is returned.
Currently supported threads packages are
POSIX threads with -D_PTHREADS
Index: libgcc2.c
===================================================================
RCS file: /trema/cvs/gnu/egcs/gcc/libgcc2.c,v
retrieving revision 1.19
diff -c -c -3 -p -r1.19 libgcc2.c
*** libgcc2.c 1998/01/05 12:12:35 1.19
--- libgcc2.c 1998/01/06 13:11:50
*************** eh_context_initialize ()
*** 3095,3101 ****
#if __GTHREADS
static __gthread_once_t once = __GTHREAD_ONCE_INIT;
! if (__gthread_once (&once, eh_threads_initialize) == -1)
{
/* Use static version of EH context. */
get_eh_context = &eh_context_static;
--- 3095,3105 ----
#if __GTHREADS
static __gthread_once_t once = __GTHREAD_ONCE_INIT;
! /* Make sure that get_eh_context does not point to us anymore.
! Some systems have dummy thread routines in their libc that
! return a success (Solaris 2.6 for example). */
! if (__gthread_once (&once, eh_threads_initialize) != 0
! || get_eh_context == &eh_context_initialize)
{
/* Use static version of EH context. */
get_eh_context = &eh_context_static;