develooper Front page | perl.perl5.porters | Postings from August 2014

C99 math

Thread Next
From:
Jarkko Hietaniemi
Date:
August 31, 2014 23:56
Subject:
C99 math
Message ID:
5403B624.1060107@iki.fi
In 2acc0aed..fa86ae13 I broke everything^W^Wupgraded the POSIX :math_h 
bravely to the future^Wfifteen years ago, that is, C99 (from C89) [1] [2].

Lots of new interfaces, in ext/POSIX/POSIX.xs search for "C99 math" 
comment.  Not just functions, also constants, like M_PI, M_E, and 
ta-dah, INFINITY and NAN.

I also threw in the Bessel functions ([jy][012n), being common <math.h> 
extensions (and present for a long time, BSD/SVID/XPG4, don't know why 
they didn't make it to C99).

Problem #1: not all places are C99 [3].  And even those who claim to be, 
are not necessarily there, that is, having the full set of promised 
interfaces.

Problem #2: I am very resistant to having a Configure scan / own symbol 
for each of the new 40+ interfaces.  So I played a lot of tricks.  Some 
dirtier than others.  For example, acosh got the privilege of being the 
canary for all the C99 interfaces: if there's no acosh, we give up 
trying to believe the system has any others.  (Though the emulations
will still kick in, see below.)  There are other similar canaries: j0 
stands in for all the Bessel functions, for example Win32 has many 
interfaces "hidden" as _underbar versions.

Some of the missing interfaces are rather trivial, or easy to get 98% 
emulation, so I added some.  There are useful sources out there [4]

Tested as much as I could, but probably broke a lot of things, and most 
importantly missed things in platforms I couldn't directly/well test.

Due to my other recent activities, I couldn't resist throwing in Inf and 
NaN: "use POSIX;" now imports Inf and NaN, which work as might be 
guessed (though not completely transparently... -Inf is uglynoisy).

[1] http://port70.net/~nsz/c/c99/n1256.html

[2] http://port70.net/~nsz/c/c89/c89-draft.html

[3] I'm looking at you, Redmond, and at you, Palo Alto, and you, 
Mountain View (no, not Google), and so forth...

[4] http://www.johndcook.com/math_h.html

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About