[polyml] 05/07: Don't pretend to support floating point rounding on armel
James Clarke
jrtc27-guest at moszumanska.debian.org
Thu Jan 28 10:16:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
jrtc27-guest pushed a commit to branch master
in repository polyml.
commit c7e1ec4d74900c3e79cd90d7666c5c878d21521d
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Mon Jan 25 22:58:08 2016 +0000
Don't pretend to support floating point rounding on armel
---
debian/changelog | 3 +
debian/patches/series | 1 +
debian/patches/soft-float-rounding.diff | 115 ++++++++++++++++++++++++++++++++
3 files changed, 119 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index b16117e..9e90f70 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,9 @@ polyml (5.6-1) UNRELEASED; urgency=medium
* New upstream version
* Removed patches applied upstream
* Rename libpolyml6 to libpolyml7
+ * New patches:
+ - soft-float-rounding.diff: Don't support rounding modes for soft-float
+ systems. Skips Tests/Succeed/Test121.ML on armel.
-- James Clarke <jrtc27 at jrtc27.com> Mon, 25 Jan 2016 18:45:49 +0000
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..ee4beb8
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+soft-float-rounding.diff
diff --git a/debian/patches/soft-float-rounding.diff b/debian/patches/soft-float-rounding.diff
new file mode 100644
index 0000000..64759a2
--- /dev/null
+++ b/debian/patches/soft-float-rounding.diff
@@ -0,0 +1,115 @@
+Description: Don't support rounding modes for soft-float systems
+ On armel, floating point operations are implemented in software.
+ However, the implementation always rounds to nearest. If the system has
+ a hardware FPU, it will support setting the rounding mode to any valid
+ value, and subsequent gets will return this value, but it will have no
+ effect on the actual rounding performed. If the system doesn't have a
+ hardware FPU, it will only allow the rounding mode to be set to
+ FE_NEAREST, and getting the rounding mode will always return this.
+ .
+ Since rounding may not be supported, the floating point rounding mode
+ test needs to be skipped on unsupported systems. This is implemented by
+ raising Fail "Skip Test", which is caught in runTests.
+Author: James Clarke <jrtc27 at jrtc27.com>
+Forwarded: https://github.com/polyml/polyml/16
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/libpolyml/reals.cpp
++++ b/libpolyml/reals.cpp
+@@ -370,9 +370,28 @@
+ #define POLY_ROUND_UPWARD 2
+ #define POLY_ROUND_TOZERO 3
+
++#if defined(__SOFTFP__)
++// soft-float lacks proper rounding mode support
++// While some systems will support fegetround/fesetround, it will have no
++// effect on the actual rounding performed, as the software implementation only
++// ever rounds to nearest.
++static int getrounding(TaskData *)
++{
++ return POLY_ROUND_TONEAREST;
++}
++
++static void setrounding(TaskData *taskData, Handle args)
++{
++ switch (get_C_long(taskData, DEREFWORDHANDLE(args)))
++ {
++ case POLY_ROUND_TONEAREST: return; // The only mode supported
++ }
++ raise_exception_string(taskData, EXC_Fail, "Setting the floating point rounding control to a value other than TO_NEAREST is not supported for software-based floating point implementations");
++}
++
+ // It would be nice to be able to use autoconf to test for these as functions
+ // but they are frequently inlined
+-#if defined(HAVE_FENV_H)
++#elif defined(HAVE_FENV_H)
+ // C99 version. This is becoming the most common.
+ static int getrounding(TaskData *)
+ {
+--- a/Tests/Succeed/Test121.ML
++++ b/Tests/Succeed/Test121.ML
+@@ -2,7 +2,7 @@
+ and compiled code. *)
+ fun check x = if x then () else raise Fail "Wrong";
+ open IEEEReal;
+-setRoundingMode(TO_POSINF);
++setRoundingMode(TO_POSINF) handle Fail _ => raise Fail "Skip Test";
+ check(getRoundingMode() = TO_POSINF);
+ val pos = 1.0/3.0;
+ check(pos * 3.0 > 1.0);
+--- a/Tests/RunTests.sml
++++ b/Tests/RunTests.sml
+@@ -6,6 +6,8 @@
+
+ fun runTests (dirName, expectSuccess) =
+ let
++ datatype test_result = TEST_PASS | TEST_FAIL | TEST_SKIP;
++
+ (* Run a file. Returns true if it succeeds, false if it fails. *)
+ fun runTest fileName =
+ let
+@@ -79,6 +81,7 @@
+ (* The tests in the Fail directory should all raise exceptions
+ in the compiler as a result of detecting errors. *)
+ exception CompilerException
++ exception SkipTestException
+ in
+ (
+ while not (TextIO.StreamIO.endOfStream(!stream)) do
+@@ -90,14 +93,18 @@
+ PolyML.compiler(getChar, [CPOutStream discardOut, CPNameSpace localNameSpace])
+ handle Fail "Static Errors" => raise CompilerException
+ in
+- code()
++ code() handle Fail "Skip Test" => raise SkipTestException
+ end;
+ (* Normal termination: close the stream. *)
+ TextIO.StreamIO.closeIn (! stream);
+- expectSuccess (* OK if we expected success. *)
++ if expectSuccess then TEST_PASS else TEST_FAIL (* OK if we expected success. *)
+ ) handle
+- CompilerException => (TextIO.StreamIO.closeIn(!stream); not expectSuccess)
+- | exn => (TextIO.StreamIO.closeIn(!stream); false)
++ CompilerException => (
++ TextIO.StreamIO.closeIn(!stream);
++ if expectSuccess then TEST_FAIL else TEST_PASS
++ )
++ | SkipTestException => (TextIO.StreamIO.closeIn(!stream); TEST_SKIP)
++ | exn => (TextIO.StreamIO.closeIn(!stream); TEST_FAIL)
+
+ end;
+
+@@ -112,9 +119,10 @@
+ then
+ (
+ print f; print " => ";
+- if runTest(joinDirFile{dir=testPath, file=f})
+- then (print "Passed\n"; runDir fails)
+- else (print "Failed!!\n"; runDir(fails @ [joinDirFile{dir=dirName, file=f}]))
++ case runTest(joinDirFile{dir=testPath, file=f}) of
++ TEST_PASS => (print "Passed\n"; runDir fails)
++ | TEST_FAIL => (print "Failed!!\n"; runDir(fails @ [joinDirFile{dir=dirName, file=f}]))
++ | TEST_SKIP => (print "Skipped\n"; runDir fails)
+ )
+ else runDir fails
+ val failedTests = runDir []
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/polyml.git
More information about the debian-science-commits
mailing list