GCC vs GLIBC: why this stance, Drepper ?!?
H . J . Lu
hjl@lucon.org
Sun Jul 8 12:23:00 GMT 2001
On Sun, Jul 08, 2001 at 11:56:30AM -0700, H . J . Lu wrote:
> On Sun, Jul 08, 2001 at 11:09:13AM -0700, mike stump wrote:
> > > Date: Sat, 30 Jun 2001 17:23:44 -0700
> > > From: "Zack Weinberg" <zackw@Stanford.EDU>
> > > To: gcc@gcc.gnu.org, libc-alpha@sources.redhat.com.com
> >
> > > If you post a patch for GCC to gcc-patches, I hereby promise that I
> > > will not ignore it. (Be aware that I may have only sporadic net
> > > access for the next month or so, however.)
> >
> > There are some problems patches cannot fix, ever. If an
> > incompatibility is allowed to go in, and is then shipped, but caught
> > after the release, one is screwed. If you accept a patch to fix it,
> > you restore binary compatibility with the older version, but you break
> > compatibility with the newer version. If you don't accept the patch,
> > you maintain binary compatibility with the new version, but break with
> > the old.
> >
> > The game is rigged so one cannot win. The only way to win, is to
> > never, ever, do this. That cannot be done, without extreme caution
> > and control and knowledge and skill and attention. To me, it sounds
> > like this is one of HJ concerns. HJ, if it isn't, apologies.
>
> It is something like that. I think there is a way to do it. See
>
> http://gcc.gnu.org/ml/gcc/2001-07/msg00524.html
>
> My next goal is to provide a patch to gcc 3.0 so that glibc and gcc can
> share the same mixed g++ v2 and v3 frame unwind code. It should be able
> to be conditionally compiled for
>
> 1. Turn on/off of the mixed g++ v2 and v3 support.
> 2. In gcc or glibc.
>
>
Here is a sample patch for unwind-dw2-fde.c. I will also patch
unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h and unwind.h.
H.J.
----
--- unwind-dw2-fde.c.mixed Tue Jun 12 14:39:06 2001
+++ unwind-dw2-fde.c Sun Jul 8 12:18:36 2001
@@ -28,6 +28,15 @@ along with GNU CC; see the file COPYING.
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#ifdef _LIBC
+#include <stdlib.h>
+#include <string.h>
+#include <bits/libc-lock.h>
+#include <dwarf2.h>
+#include <unwind.h>
+#include <unwind-pe.h>
+#include <unwind-dw2-fde.h>
+#else
#include "tconfig.h"
#include "tsystem.h"
#include "dwarf2.h"
@@ -35,6 +44,7 @@ Boston, MA 02111-1307, USA. */
#include "unwind-pe.h"
#include "unwind-dw2-fde.h"
#include "gthr.h"
+#endif
/* The unseen_objects list contains objects that have been registered
but not yet categorized in any way. The seen_objects list has had
@@ -43,6 +53,14 @@ Boston, MA 02111-1307, USA. */
static struct object *unseen_objects;
static struct object *seen_objects;
+#ifdef _LIBC
+__libc_lock_define_initialized_recursive (static, object_lock)
+#define init_object_mutex_once()
+#define object_mutex_lock() __libc_lock_lock (object_lock)
+#define object_mutex_unlock() __libc_lock_unlock (object_lock)
+#else
+#define object_mutex_lock() __gthread_mutex_lock (&object_mutex)
+#define object_mutex_unlock() __gthread_mutex_unlock (&object_mutex)
#ifdef __GTHREAD_MUTEX_INIT
static __gthread_mutex_t object_mutex = __GTHREAD_MUTEX_INIT;
#else
@@ -65,6 +83,7 @@ init_object_mutex_once (void)
#else
#define init_object_mutex_once()
#endif
+#endif /* _LIBC * /
/* Called from crtbegin.o to register the unwind info for an object. */
@@ -80,12 +99,12 @@ __register_frame_info_bases (void *begin
ob->s.b.encoding = DW_EH_PE_omit;
init_object_mutex_once ();
- __gthread_mutex_lock (&object_mutex);
+ object_mutex_lock();
ob->next = unseen_objects;
unseen_objects = ob;
- __gthread_mutex_unlock (&object_mutex);
+ object_mutex_unlock();
}
void
@@ -118,12 +137,12 @@ __register_frame_info_table_bases (void
ob->s.b.encoding = DW_EH_PE_omit;
init_object_mutex_once ();
- __gthread_mutex_lock (&object_mutex);
+ object_mutex_lock();
ob->next = unseen_objects;
unseen_objects = ob;
- __gthread_mutex_unlock (&object_mutex);
+ object_mutex_unlock();
}
void
@@ -158,7 +177,7 @@ __deregister_frame_info_bases (void *beg
struct object *ob = 0;
init_object_mutex_once ();
- __gthread_mutex_lock (&object_mutex);
+ object_mutex_lock();
for (p = &unseen_objects; *p ; p = &(*p)->next)
if ((*p)->u.single == begin)
@@ -189,11 +208,11 @@ __deregister_frame_info_bases (void *beg
}
}
- __gthread_mutex_unlock (&object_mutex);
+ object_mutex_unlock();
abort ();
out:
- __gthread_mutex_unlock (&object_mutex);
+ object_mutex_unlock();
return (void *) ob;
}
@@ -936,7 +955,7 @@ _Unwind_Find_FDE (void *pc, struct dwarf
fde *f = NULL;
init_object_mutex_once ();
- __gthread_mutex_lock (&object_mutex);
+ object_mutex_lock();
/* Linear search through the classified objects, to find the one
containing the pc. Note that pc_begin is sorted decending, and
@@ -970,7 +989,7 @@ _Unwind_Find_FDE (void *pc, struct dwarf
}
fini:
- __gthread_mutex_unlock (&object_mutex);
+ object_mutex_unlock();
if (f)
{
More information about the Libc-alpha
mailing list