This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tru64: introduce PERL_SYS_FPU_INIT, use it.
authorJarkko Hietaniemi <jhi@iki.fi>
Wed, 24 Sep 2014 20:23:11 +0000 (16:23 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 26 Sep 2014 21:04:52 +0000 (17:04 -0400)
In Tru64 the cc -ieee enables the IEEE math but disables traps.
We need to reenable the "invalid" trap because otherwise generation
of NaN values leaves the IEEE fp flags in bad state, leaving any further
fp ops behaving strangely (Inf + 1 resulting in zero, for example).

ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm
miniperlmain.c
perl.h

index 99276fc..5cf6252 100644 (file)
@@ -8,7 +8,7 @@ use vars qw($VERSION @ISA @EXPORT);
 
 @ISA = qw(Exporter);
 @EXPORT = qw(writemain);
-$VERSION = '1.02';
+$VERSION = '1.03';
 
 # blead will run this with miniperl, hence we can't use autodie or File::Temp
 my $temp;
@@ -136,6 +136,8 @@ main(int argc, char **argv, char **env)
                    Perl_atfork_unlock);
 #endif
 
+    PERL_SYS_FPU_INIT;
+
     if (!PL_do_undump) {
        my_perl = perl_alloc();
        if (!my_perl)
index e748523..fa7951f 100644 (file)
@@ -107,6 +107,8 @@ main(int argc, char **argv, char **env)
                    Perl_atfork_unlock);
 #endif
 
+    PERL_SYS_FPU_INIT;
+
     if (!PL_do_undump) {
        my_perl = perl_alloc();
        if (!my_perl)
diff --git a/perl.h b/perl.h
index 5b72bd6..436c7d1 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -2898,6 +2898,23 @@ typedef SV PADNAME;
 #  define PERL_FPU_POST_EXEC  }
 #endif
 
+/* In Tru64 the cc -ieee enables the IEEE math but disables traps.
+ * We need to reenable the "invalid" trap because otherwise generation
+ * of NaN values leaves the IEEE fp flags in bad state, leaving any further
+ * fp ops behaving strangely (Inf + 1 resulting in zero, for example). */
+#ifdef __osf__
+#  include <machine/fpu.h>
+#  define PERL_SYS_FPU_INIT \
+     STMT_START { \
+         ieee_set_fp_control(IEEE_TRAP_ENABLE_INV); \
+         signal(SIGFPE, SIG_IGN); \
+     } STMT_END
+#endif
+
+#ifndef PERL_SYS_FPU_INIT
+#  define PERL_SYS_FPU_INIT NOOP
+#endif
+
 #ifndef PERL_SYS_INIT3_BODY
 #  define PERL_SYS_INIT3_BODY(argvp,argcp,envp) PERL_SYS_INIT_BODY(argvp,argcp)
 #endif