This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: gen-num-limits runs forever on GNU/Linux/sparc (Red Hat Linux 6.2)
On Feb 2, 2001, Gabriel Dos Reis <gdr@codesourcery.com> wrote:
> Alexandre Oliva <aoliva@redhat.com> writes:
> | On Feb 1, 2001, Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> wrote:
> | > Hmm, I think at some point, gen-num-limits.cc (which needs a clean up)
> | > would require more collaboration from the compiler, so #including a
> | > <config.h> isn't a big deal.
> |
> | And the other problem is that mknumeric_limits runs before config.h is
> | built :-)
I lied. It's built after config.h is already available. I found it
out the hard way :-(
> In the case of mknumeric_limits we _just_ need to test for
> `sigsetjump', we should not have to wait until the completion of
> totality of the features we test for.
> | Or we could delay the execution of mknumeric_limits to a Makefile
> | rule. Thoughts?
> I would like we keep running mknumeric_limits at confiigure-time.
Ok, here's a new patch, tested on sparc-linux-gnu and a number of
other platforms. Ok to install?
Index: libstdc++-v3/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* src/gen-num-limits.cc: Use sigsetjmp and siglongjmp if available.
* mknumeric_limits: Compile it with -DHAVE_CONFIG_H.
* configure.in: Test for sigsetjmp.
* configure, config.h.in: Rebuilt.
Index: libstdc++-v3/src/gen-num-limits.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/src/gen-num-limits.cc,v
retrieving revision 1.6
diff -u -p -r1.6 gen-num-limits.cc
--- libstdc++-v3/src/gen-num-limits.cc 2001/01/17 07:13:39 1.6
+++ libstdc++-v3/src/gen-num-limits.cc 2001/02/09 18:31:30
@@ -35,6 +35,10 @@
#include <bits/c++config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
//
// Force Linux <limits.h> to define the *LONG_LONG*
//
@@ -57,6 +61,18 @@
#include <wchar.h>
#endif
+// mknumeric_limits will first try to compile this file with
+// HAVE_SIGSETJMP. If it fails, then it will try without it. Some
+// systems, such as GNU/Linux/sparc, would remain with the signal
+// blocked if the signal handler uses longjmp instead of siglongjmp.
+// We assume here setjmp/longjmp will preserve the sigblock mask if
+// sigsetjmp is not present.
+
+#if ! HAVE_SIGSETJMP
+# define sigjmp_buf jmp_buf
+# define sigsetjmp(buf, save) setjmp (buf)
+# define siglongjmp(env, ret) longjmp (env, ret)
+#endif
const char tab[] = " ";
const char tab2[] = " ";
@@ -90,7 +106,7 @@ const int integer_base_rep = 2;
// occur for int, unsigned, long, unsigned long. Furthermore
// overflow cannot happen for unsigned integer types.
-jmp_buf env;
+sigjmp_buf env;
/* The prototype of signal() may vary. Accomodate variations such as
void(*)(int) and void(*)(...). */
@@ -112,13 +128,13 @@ void signal_handler(int sig)
sigemptyset (&x);
sigprocmask(SIG_SETMASK, &x, NULL);
#endif /* __CYGWIN__ */
- longjmp(env, sig);
+ siglongjmp(env, sig);
}
template<typename Operation>
bool trapping(const Operation& op)
{
- if (setjmp(env) == 0) op();
+ if (sigsetjmp(env, 1) == 0) op();
else return true;
return false;
}
Index: libstdc++-v3/mknumeric_limits
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/mknumeric_limits,v
retrieving revision 1.7
diff -u -p -r1.7 mknumeric_limits
--- libstdc++-v3/mknumeric_limits 2000/12/22 08:15:27 1.7
+++ libstdc++-v3/mknumeric_limits 2001/02/09 18:31:30
@@ -178,18 +178,17 @@ namespace std {
EOF
-echo "$CXX $CPPFLAGS -I$BUILD_DIR/include \
+echo "$CXX -I. $CPPFLAGS -I$BUILD_DIR/include -DHAVE_CONFIG_H \
-o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
$LDFLAGS"
-$CXX $CPPFLAGS -I$BUILD_DIR/include \
+{ $CXX -I. $CPPFLAGS -I$BUILD_DIR/include -DHAVE_CONFIG_H \
-o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
$LDFLAGS
-
-if [ ! -f "$BUILD_DIR/src/gen-num-limits" ]; then
+} || {
echo "gen-num-limits failed to build, exiting."
exit 1
-fi
+}
"$BUILD_DIR/src/gen-num-limits" >> $OUT_H-t
Index: libstdc++-v3/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/configure.in,v
retrieving revision 1.53
diff -u -p -r1.53 configure.in
--- libstdc++-v3/configure.in 2001/02/07 01:54:19 1.53
+++ libstdc++-v3/configure.in 2001/02/09 18:31:30
@@ -217,6 +217,11 @@ else
GLIBCPP_CHECK_WCHAR_T_SUPPORT
GLIBCPP_CHECK_STDLIB_SUPPORT
+ AC_TRY_COMPILE([
+#include <setjmp.h>
+], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
+[AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])])
+
AC_FUNC_MMAP
fi
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me