Re: [PATCH] libm/math: Use __math_xflow in obsolete math code

Keith Packard via Newlib <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Szabolcs Nagy <[email protected]> writes:

> note1: i used c99 code when i wrote the
> new math code and currently the old math
> code can be compiled with older compilers,
> this change might prevent that.

Hrm. I just learned about "#pragma STDC FENV_ACCESS on" this morning and
am wondering if we shouldn't just patch the old math library to use that
instead of calling the __math_xflow functions. Would be a simpler patch
and provide precise compatibility with the previous version.

Here's an example of how that works:

        #include <fenv.h>
        #include <stdio.h>

        #pragma STDC FENV_ACCESS on

        int main(void)
        {
                double x;
                int e;
                feclearexcept(FE_ALL_EXCEPT);
                x = 0.0 / 0.0;
                e = fetestexcept(FE_ALL_EXCEPT);
                printf("x %g e %x\n", x, e);
                return 0;
        }

$ cc except.c -lm
$ ./a.out
x -nan e 1
$

As you can see, even using constants still raise the appropriate
exception.

-- 
-keith
signature.asc (application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAl8oUm0ACgkQ2yIaaQAA
ABEhABAAq6n0Jd+o9Rw2IRjFW3neTV+RsdWs1SVmZqQwoFHkHYhUbuPz9DQH1I+V
DTv1lKDLAj1zDGgrA/lk4WHLSy81h2lObwqt7xjxFUsXz74ATkkY7MaSx/J4nvD1
ZXAIXXXA8u8e8CDpnOf85wI7iPUNHA1yD0iRRr50UrY6wl0fW/8JYoolmo7H00uT
0tWwmxaP70McIQvTMWf/IGoI1Wx7D4IvZfW0u/kCqM3YkU14CMFCpWEROtXC3cbd
CsVqRW9pdTQ7U/3pNaleAfFmBpA9FM5lP+P/ZRXBH8VveBbKablcaEIM2mEAW3vK
TUuiyvxMjVBKekVWJ7XbOq7FQwAh57hehgpDl56n9hBfxhA1s2iDPKOMEY/nZy6e
EF4VfEPJk6UyrdWRKnm/6TAE0Al8Tmhjsm0jHH3aGdcfhxjxIPsoQOG1+NHMBq6z
0Th1dqdwleL5Msd+Kf7n0CxdGu3TCj8IW96n5fmG9sqku1cfXQCTHaPSJ6Tt7rpj
fWWEjnXEIIZQGQefoazW7XhpJOeofGpZs2HtSkNcak8eiEkTtHLYkD/0ttf+5XSO
iXX9HPj4DNdLe6g3FGWTDkrJ0nwAY9b2fWEyid/BdKk/tptindvg3onxQM97uj+k
GGnfTH0Qwd3jI8UoqYGrz/LSqZAQmtqbCCFKppYpmZo6Jqjlg00=
=U7vY
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.