Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Apr 1998 19:51:14 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        jb@cimlogic.com.au (John Birrell)
Cc:        tlambert@primenet.com, jkh@time.cdrom.com, paul@mu.org, freebsd-hackers@FreeBSD.ORG
Subject:   Re: mozilla source
Message-ID:  <199804011951.MAA18072@usr05.primenet.com>
In-Reply-To: <199804010918.TAA06221@cimlogic.com.au> from "John Birrell" at Apr 1, 98 07:18:24 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > The problem is that egcs requires that you decide whether or not you
> > are going to use pthreads when you build your compiler, and then
> > assumes that forever afterward, you will use -lc_r with all programs
> > you ever compile with it (and in the FreeBSD case, _THREAD_SAFE, a
> > bogosity from the bowels of the incompatibility fairy).
> 
> Are you calling me a fairy?
> Oh well, I guess it is April 1.

The Incompatibility Fairy is the creature who sprinkles the
Incompatability Dust on our heads as we code up changes to
software.  You are her victim (boy, what an ego, thinking that
*you* could possibly be the Incompatability Fairy!  Sheesh!  8-)).


> Would you like me to explain _why_ _THREAD_SAFE extracted from the
> bowels... ?

It shouldn't be #ifdef'ed at all.  The default headers should be
the same for both threads and not threads.  Yes, I know this means
wrapping errno and a couple of other changes to the default libc.  I
don't care.  It's The Right Thing To Do.  "Magic" light switches
should be left in Incompatability Land, where they belong.


=(1)=================================================================
=                                                                   =
=  One problem here is that Cygnus Royally F***ed Up exception and  =
=  mutex code in egcs.  You have to decide at compile time whether  =
=  or not you are going have threads support in the compiler.       =
=                                                                   =
======================================================================

IMO, egcs is *evil* because of the soloution they chose.

=(2)=================================================================
=                                                                   =
=  If you decide to have threads support in the compiler, then you  =
=  *MUST*, in all cases, compile all code with -D_THREAD_SAFE and   =
=  link all code with -lc_r in place of the standard library.       =
=  A failure to do this will result in "wierd" code behaviour.      =
=                                                                   =
======================================================================

In contrast, you can, with this patch (which was already submitted
for inclusion in the FreeBSD gcc/g++ 2.8.x port, but is apparently
not there: Jordan had problems) *dynamically* decide, *at the time
you compile your code, NOT at the time you compile your compiler*
whther or not you are required to use _THREAD_SAFE and/or link with
-lc_r.

Note: Cygnus rejected this patch because they had already decided
on their bogus implementation, where you need two compilers to be
able to compile with or without threads.  The patch was not submitted
to FSF (but should be) for fear of a schism.

Oh, yeah: it's under the same license as the code it patches.

-- BEGIN: Jeremy Allison's patch ---------------------------------------
*** libgcc2.c.orig	Fri Feb  6 12:17:16 1998
--- libgcc2.c	Fri Feb  6 14:57:17 1998
***************
*** 3201,3206 ****
--- 3201,3229 ----
  static void *top_elt[2];
  void **__dynamic_handler_chain = top_elt;
  
+ #if 1 /* MAKE_THREAD_SAFE */
+ 
+ typedef void *** (*dynamic_handler_allocator)();
+ static dynamic_handler_allocator dah = 0;
+ 
+ void __set_dynamic_handler_allocator( dynamic_handler_allocator
new_dah)
+ {
+   dah = new_dah;
+ }
+ 
+ /* Routine to get the head of the current thread's dynamic handler
chain
+    use for exception handling. */
+ 
+ void ***
+ __get_dynamic_handler_chain ()
+ {
+   if(dah == 0)
+     return &__dynamic_handler_chain;
+   return (*dah)();
+ }
+ 
+ #else
+ 
  /* Routine to get the head of the current thread's dynamic handler
chain
     use for exception handling.
  
***************
*** 3211,3216 ****
--- 3234,3241 ----
  {
    return &__dynamic_handler_chain;
  }
+ 
+ #endif
  
  /* This is used to throw an exception when the setjmp/longjmp codegen
     method is used for exception handling.


-- END: Jeremy Allison's patch -----------------------------------------

					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804011951.MAA18072>