[svn:parrot] r49425 - in trunk: . config/auto config/auto/infnan include/parrot lib/Parrot/Configure/Step src

plobsing at svn.parrot.org plobsing at svn.parrot.org
Sat Oct 2 23:59:42 UTC 2010


Author: plobsing
Date: Sat Oct  2 23:59:42 2010
New Revision: 49425
URL: https://trac.parrot.org/parrot/changeset/49425

Log:
probe for INFINITY and NAN macros provided by system headers
papers over SIGFPE errors on various platforms (netbsd-alpha, minix-i386-ack)
see TT #574

Added:
   trunk/config/auto/infnan/
   trunk/config/auto/infnan.pm   (contents, props changed)
   trunk/config/auto/infnan/test_c.in   (contents, props changed)
Modified:
   trunk/MANIFEST
   trunk/include/parrot/datatypes.h
   trunk/lib/Parrot/Configure/Step/List.pm
   trunk/src/datatypes.c

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Sat Oct  2 23:15:11 2010	(r49424)
+++ trunk/MANIFEST	Sat Oct  2 23:59:42 2010	(r49425)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Fri Oct  1 22:56:56 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sat Oct  2 23:46:07 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -208,6 +208,8 @@
 config/auto/headers.pm                                      []
 config/auto/headers/test_c.in                               []
 config/auto/icu.pm                                          []
+config/auto/infnan.pm                                       []
+config/auto/infnan/test_c.in                                []
 config/auto/inline.pm                                       []
 config/auto/inline/test1_c.in                               []
 config/auto/inline/test2_c.in                               []

Added: trunk/config/auto/infnan.pm
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/config/auto/infnan.pm	Sat Oct  2 23:59:42 2010	(r49425)
@@ -0,0 +1,66 @@
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+config/auto/infnan.pm - detect INFINITY and NAN
+
+=head1 DESCRIPTION
+
+Determining if the system has INFINITY and NAN defined in headers.
+
+=cut
+
+package auto::infnan;
+
+use strict;
+use warnings;
+
+use base qw(Parrot::Configure::Step);
+
+use Parrot::Configure::Utils ':auto';
+
+sub _init {
+    my $self = shift;
+    my %data;
+    $data{description} = q{Are INFINITY and NAN defined};
+    $data{result}      = q{};
+    return \%data;
+}
+
+sub runstep {
+    my ( $self, $conf ) = @_;
+
+    my $infnan = 0;
+
+    $conf->cc_gen('config/auto/infnan/test_c.in');
+    eval { $conf->cc_build(); };
+    if (!$@) {
+        my $output = eval { $conf->cc_run() };
+        if (!$@ && $output =~ /OK/) {
+	    $infnan = 1;
+	}
+    }
+    $conf->cc_clean();
+
+    if ($infnan) {
+        $conf->data->set( HAS_INF_NAN => 1 );
+        $self->set_result('yes');
+    }
+    else {
+	$conf->data->set( HAS_INF_NAN => 0 );
+	$self->set_result('no');
+    }
+
+    return 1;
+}
+
+1;
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+

Added: trunk/config/auto/infnan/test_c.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/config/auto/infnan/test_c.in	Sat Oct  2 23:59:42 2010	(r49425)
@@ -0,0 +1,26 @@
+/*
+Copyright (C) 2010, Parrot Foundation.
+$Id$
+
+seeing if INFINITY and NAN are defined
+
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+int
+main(int argc, char **argv) {
+    double inf = INFINITY;
+    double nan = NAN;
+    printf("OK: %d %d\n", inf, nan);
+    return EXIT_SUCCESS;
+}
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */

Modified: trunk/include/parrot/datatypes.h
==============================================================================
--- trunk/include/parrot/datatypes.h	Sat Oct  2 23:15:11 2010	(r49424)
+++ trunk/include/parrot/datatypes.h	Sat Oct  2 23:59:42 2010	(r49425)
@@ -123,7 +123,7 @@
 };
 #endif /* INSIDE_GLOBAL_SETUP */
 
-#if defined(__NetBSD__) && defined(__alpha__)
+#ifdef PARROT_HAS_INF_NAN
 #  include <math.h>
 #  define PARROT_FLOATVAL_INF_POSITIVE	INFINITY
 #  define PARROT_FLOATVAL_INF_NEGATIVE	-INFINITY

Modified: trunk/lib/Parrot/Configure/Step/List.pm
==============================================================================
--- trunk/lib/Parrot/Configure/Step/List.pm	Sat Oct  2 23:15:11 2010	(r49424)
+++ trunk/lib/Parrot/Configure/Step/List.pm	Sat Oct  2 23:59:42 2010	(r49425)
@@ -49,6 +49,7 @@
     auto::neg_0
     auto::env
     auto::timespec
+    auto::infnan
     auto::thread
     auto::gmp
     auto::readline

Modified: trunk/src/datatypes.c
==============================================================================
--- trunk/src/datatypes.c	Sat Oct  2 23:15:11 2010	(r49424)
+++ trunk/src/datatypes.c	Sat Oct  2 23:59:42 2010	(r49425)
@@ -93,6 +93,8 @@
 
 */
 
+#ifdef PARROT_HAS_INF_NAN
+
 PARROT_EXPORT
 FLOATVAL
 floatval_divide_by_zero(SHIM_INTERP, FLOATVAL num)
@@ -102,6 +104,8 @@
     return num / zero;
 }
 
+#endif
+
 
 /*
 


More information about the parrot-commits mailing list