When running testing parrot-HEAD, I get a test failure in t/op/trans.t on
OpenBSD. Running the same tests on Linux seem to work just fine...
> perl -Ilib t/op/trans.t
1..19
ok 1 - sin
ok 2 - cos
ok 3 - tan
ok 4 - sec
ok 5 - atan
ok 6 - asin
ok 7 - acos
ok 8 - asec
ok 9 - cosh
ok 10 - sinh
ok 11 - tanh
ok 12 - sech
not ok 13 - atan2
# Failed test (t/op/trans.t at line 307)
# got: 'ok 1
# ok 2
# ok 3
# ok 4
# ok 5
# ok 6
# ok 7
# ok 8
# ok 9
# ok 10
# ok 11
# ok 12
# ok 13
# ok 14
# ok 15
# ok 16
# not 0.000000ok 17
# '
# expected: 'ok 1
# ok 2
# ok 3
# ok 4
# ok 5
# ok 6
# ok 7
# ok 8
# ok 9
# ok 10
# ok 11
# ok 12
# ok 13
# ok 14
# ok 15
# ok 16
# ok 17
# '
ok 14 - log2
ok 15 - log10
ok 16 - ln
ok 17 - exp
ok 18 - pow
ok 19 - sqrt
# Looks like you failed 1 tests of 19.
> When running testing parrot-HEAD, I get a test failure in t/op/trans.t on
> OpenBSD. Running the same tests on Linux seem to work just fine...
>> perl -Ilib t/op/trans.t
> not ok 13 - atan2
> # Failed test (t/op/trans.t at line 307)
> # got: 'ok 1
> # not 0.000000ok 17
atan N4, -0.0, -0.0
Obviously another broken C system. What says your perl:
$ perl -le'print atan2(-0.0,-0.0)'
-3.14159265358979324
leo
Tasty :-/
On OpenBSD, I get
> perl -le'print atan2(-0.0,-0.0)'
0
Steve
> Tasty :-/
> On OpenBSD, I get
Time to start some more OS-specific docs that summarize such "features"?
> Steve
leo
> >Number: 4154
> >Category: library
> >Synopsis: atan2(-0.0, -0.0) returning incorrect result
Our libm is compiled in multi mode and defaults to posix mode, which
sets errno and returns 0 if both args are (+-)0.0. IEEE mode does what you
want.
Check lib/libm/Makfile and lib/lib/src/{e,w}w_atan2.c for some background
info.
If you force libm to IEEE mode, you'll get the expected results:
(on macppc, same results on i386):
[otto@fonzo:9]$ cat x.c
#include <errno.h>
#include <stdio.h>
#include <math.h>
int main() {
double res;
_LIB_VERSION = _IEEE_;
errno = 0;
res = atan2(0.0, 0.0);
perror("atan2");
printf("atan2(0.0, 0.0) = %f\n", res);
errno = 0;
res = atan2(-0.0, 0.0);
perror("atan2");
printf("atan2(-0.0, 0.0) = %f\n", res);
errno = 0;
res = atan2(0.0, -0.0);
perror("atan2");
printf("atan2(0.0, -0.0) = %f\n", res);
errno = 0;
res = atan2(-0.0, -0.0);
perror("atan2");
printf("atan2(-0.0, -0.0) = %f\n", res);
}
[otto@fonzo:10]$ a.out
atan2: Undefined error: 0
atan2(0.0, 0.0) = 0.000000
atan2: Undefined error: 0
atan2(-0.0, 0.0) = 0.000000
atan2: Undefined error: 0
atan2(0.0, -0.0) = 3.141593
atan2: Undefined error: 0
atan2(-0.0, -0.0) = -3.141593
[otto@fonzo:11]$
----- End forwarded message -----
[ ... ]
> _LIB_VERSION = _IEEE_;
Fine. Thanks for the research. It should probably suffice to set the
_LIB_VERSION once. As this is platform-specific this belongs into
config/gen/platform/*bsd/init.c
where the new file init.c should contain a function
void Parrot_platform_init(Interp *i)
{
_LIB_VERSION = _IEEE_;
}
or some such. The fallback generic/init.c should do nothing. I think the
configure system will pick up these files automatically, we just have to
call the init function during interpreter startup.
Header definition should go into platform/platform_interface.h.
Comments, takers?
Do we need a test, if "_LIB_VERSION" is compiled into libm?
leo
Since I'm fixing this in Perl, I take a whack at it in Parrot as well.
Steve
Included below is a patch that fixes the above test failures on
OpenBSD. I've also included code to fix the problem on Cygwin (see
ticket #36835) although I could not get Cygwin to compile with or
without my patch. A similar solution will likely work on a gcc-
compiled Solaris, but I discuss that in the more recent ticket there.
I'm also guessing that NetBSD will require a similar patch, but I need
to get on a NetBSD machine a test my patch. Expect that patch later
today.
--- MANIFEST.old Thu Dec 29 00:03:32 2005
+++ MANIFEST Thu Dec 29 08:31:01 2005
@@ -189,6 +189,7 @@
config/gen/platform/ansi/dl.c []
config/gen/platform/ansi/exec.c []
config/gen/platform/ansi/io.h []
+config/gen/platform/cygwin/init.c []
config/gen/platform/ansi/time.c []
config/gen/platform/darwin/begin.c []
config/gen/platform/darwin/dl.c []
@@ -197,6 +198,7 @@
config/gen/platform/generic/dl.h []
config/gen/platform/generic/env.c []
config/gen/platform/generic/exec.c []
+config/gen/platform/generic/init.c []
config/gen/platform/generic/io.h []
config/gen/platform/generic/itimer.c []
config/gen/platform/generic/math.c []
@@ -210,6 +212,7 @@
config/gen/platform/generic/threads.h []
config/gen/platform/generic/time.c []
config/gen/platform/ia64/asm.s []
+config/gen/platform/openbsd/init.c []
config/gen/platform/openbsd/memexec.c []
config/gen/platform/openbsd/misc.h []
config/gen/platform/platform_interface.h []
--- /dev/null Thu Dec 29 05:43:20 2005
+++ config/gen/platform/generic/init.c Wed Dec 28 23:11:38 2005
@@ -0,0 +1,3 @@
+/* Placeholder for platform specific initializations (header includes,
+ * global variable initialization, etc.
+ */
--- /dev/null Thu Dec 29 05:43:38 2005
+++ config/gen/platform/openbsd/init.c Wed Dec 28 23:23:45 2005
@@ -0,0 +1,3 @@
+#include <math.h>
+
+_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
--- /dev/null Thu Dec 29 05:43:38 2005
+++ config/gen/platform/cygwin/init.c Wed Dec 28 23:23:45 2005
@@ -0,0 +1,3 @@
+#include <math.h>
+
+const _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
-J
--
This doesn't appear to have done anything for gcc/solaris... can someone
test openbsd and cygwin?
-J
--
: I've commited a possible fix for openbsd, cygwin, & solaris as changesets
After upping to r10844, trans.t still fails:
t/op/trans....1..19
ok 1 - sin
ok 2 - cos
ok 3 - tan
ok 4 - sec
ok 5 - atan
ok 6 - asin
ok 7 - acos
ok 8 - asec
ok 9 - cosh
ok 10 - sinh
ok 11 - tanh
ok 12 - sech
# Failed test (t/op/trans.t at line 313)
# got: 'ok 1
# ok 2
# ok 3
# ok 4
# ok 5
# ok 6
# ok 7
# ok 8
# ok 9
# ok 10
# ok 11
# ok 12
# ok 13
# ok 14
# ok 15
# ok 16
not ok 13 - atan2
# Looks like you failed 1 test of 19.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 13
Failed 1/19 tests, 94.74% okay
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/op/trans.t 1 256 19 1 5.26% 13
Failed 1/1 test scripts, 0.00% okay. 1/19 subtests failed, 94.74% okay.
What operating system are you using?
Steve Peters
st...@fisharerojo.org
: On Mon, Jan 02, 2006 at 09:01:55AM -0600, Greg Bacon wrote:
:
: > After upping to r10844, trans.t still fails:
:
: What operating system are you using?
Sorry. That report was for Cygwin.
Greg
These changes fixed OpenBSD and were used with NetBSD to allow it to
pass all of its tests. That leaves the issue open for Solaris and Cygwin.
perl t/harness t/op/trans.t
but fails miserably when run like
perl t/harness -v t/op/trans.t
Steve Peters
st...@fisharerojo.org
*Solaris
*OpenBSD
*NetBSD
*Cygwin
If it passes all these platforms, I think the ticket is resolved. If
not, maybe we need to break this into more-specific sub-tickets for each
failing platform.
--Andrew Whitworth
It still fails in the identical way on Solaris 8/SPARC with gcc.
--
Andy Dougherty doug...@lafayette.edu
Steve
On Thu, Jul 17, 2008 at 7:29 PM, Thorsten Glaser via RT
<parrotbug...@parrotcode.org> wrote:
> On Wed Jul 16 10:33:06 2008, Whiteknight wrote:
>> Is this still not resolved?
>
> On MirBSD (perl $^O 'mirbsd'), whose libm is about 85% NetBSD,
> 15% OpenBSD, the Perl test succeeds.
>
> The following lines in perl/pp.c already trigger:
> 38 /*
> 39 * Some BSDs and Cygwin default to POSIX math instead of IEEE.
> 40 * This switches them over to IEEE.
> 41 */
> 42 #if defined(LIBM_LIB_VERSION)
> 43 _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
> 44 #endif
>
> I _suspect_ this would work on OpenBSD and NetBSD as well,
> but it's better to check with actual users of the system.
> I got this via IRC from a NetBSD developer:
> 00:16│«replaced» $ perl -le'print atan2(-0.0,-0.0)'
> 00:16│«replaced» -3.14159265358979
>
> This matches mine:
> tg@odem:~ $ perl -le'print atan2(-0.0,-0.0)'
> -3.14159265358979
>
> I think the bit less of precision is due to us trying to
> avoid the i387 issue of intermediate high precision (the
> FPCW is initialised to low precision by the kernel, which
> may be a good thing).
>
> bye,
> //mirabilos
> --
> "Using Lynx is like wearing a really good pair of shades: cuts out
> the glare and harmful UV (ultra-vanity), and you feel so-o-o COOL."
> -- Henry Nelson, March 1999
>
>