This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix libjava breakage with glibc 2.2.2pre
- To: Bryce McKinlay <bryce at albatross dot co dot nz>
- Subject: Re: [PATCH] Fix libjava breakage with glibc 2.2.2pre
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 14 Feb 2001 07:09:10 -0500
- Cc: gcc-patches at gcc dot gnu dot org, aph at redhat dot com
- References: <3A8A716D.847170FB@albatross.co.nz>
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
On Thu, Feb 15, 2001 at 12:52:13AM +1300, Bryce McKinlay wrote:
> > __sigaction() is no longer declared in glibc headers (it is internal, so why
> > should it). This patch makes libjava compile with current glibc.
> > Ok to commit (for branch as well)?
> >
> > 2001-02-14 Jakub Jelinek
> >
> > * include/i386-signal.h (INIT_SEGV, INIT_FPE): Use sigaction instead
> > of __sigaction or syscall (SYS_sigaction).
> > * include/ppc-signal.h (INIT_SEGV, INIT_FPE): Likewise.
> >
>
> If __sigaction() is no longer available then we probibly need to use
> syscall (SYS_sigaction), for INIT_FPE at least. The reason is that
> libjava needs to modify the signal context (so it can conditionally
> throw exceptions from the sig handlers), and glibc/linuxthreads fails to
> copy the modified sigcontext back to the kernel. This code is a constant
> source of trouble but quite neccessary, unless anyone has better ideas
> for how to implement the SIGFPE -> ArithmeticException mapping.
>
> btw, did you read this comment in i386-signal.h (right below the code
> you changed)?
I have read it after sending the patch to the list.
The bug in linuxthreads is fixed since 1999-08-19 (and actually now
__sigaction is defined in -lpthread as well, so if it would not be fixed,
the trick with __sigaction would not work either).
So I guess there are two options: either use syscall(SYS_sigaction)
everywhere instead of __sigaction, or a patch below.
This should be safe, because the linuxthreads bug is fixed in glibc-2.1.3
and above and if one compiles libgcj on a box with glibc-2.1.3 and above, it
uses at least some symbols @GLIBC_2.1.3 (like __cxa_finalize), so one cannot
use that libgcj DSO under older (buggy in this regard) glibcs anyway.
2001-02-14 Jakub Jelinek <jakub@redhat.com>
* include/i386-signal.h (init_sigaction): Define.
(INIT_SEGV, INIT_FPE): Use it.
* include/ppc-signal.h: Likewise.
--- libjava/include/i386-signal.h.jj Thu Feb 1 11:15:03 2001
+++ libjava/include/i386-signal.h Wed Feb 14 12:23:38 2001
@@ -120,6 +120,13 @@ do \
} \
while (0)
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 1)
+#define init_sigaction(x, y, z) sigaction (x, y, z)
+#else
+/* Work around a bug in glibc 2.1 and below. */
+#define init_sigaction(x, y, z) __sigaction (x, y, z)
+#endif
+
#define INIT_SEGV \
do \
{ \
@@ -128,7 +135,7 @@ do \
act.sa_handler = catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
- __sigaction (SIGSEGV, &act, NULL); \
+ init_sigaction (SIGSEGV, &act, NULL); \
} \
while (0)
@@ -141,7 +148,7 @@ do \
act.sa_handler = catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
- syscall (SYS_sigaction, SIGFPE, &act, NULL); \
+ init_sigaction (SIGFPE, &act, NULL); \
} \
while (0)
--- libjava/include/ppc-signal.h.jj Tue May 16 16:38:21 2000
+++ libjava/include/ppc-signal.h Wed Feb 14 12:24:21 2001
@@ -1,6 +1,6 @@
// ppc-signal.h - Catch runtime signals and turn them into exceptions.
-/* Copyright (C) 2000 Free Software Foundation
+/* Copyright (C) 2000, 2001 Free Software Foundation
This file is part of libgcj.
@@ -86,6 +86,12 @@ do \
} \
while (0)
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 1)
+#define init_sigaction(x, y, z) sigaction (x, y, z)
+#else
+/* Work around a bug in glibc 2.1 and below. */
+#define init_sigaction(x, y, z) __sigaction (x, y, z)
+#endif
#define INIT_SEGV \
do \
@@ -95,7 +101,7 @@ do \
act.sa_handler = _Jv_catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
- __sigaction (SIGSEGV, &act, NULL); \
+ init_sigaction (SIGSEGV, &act, NULL); \
} \
while (0)
@@ -108,7 +114,7 @@ do \
act.sa_handler = _Jv_catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
- __sigaction (SIGFPE, &act, NULL); \
+ init_sigaction (SIGFPE, &act, NULL); \
} \
while (0)
Jakub