This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug in logarithm()



Hi Jeff, hi Patrick,


On Wed, 17 Oct 2007, Jeff Johnston wrote:
Patrick Mansfield wrote:
On Wed, Oct 17, 2007 at 12:28:47PM +0200, Martin Koeppe wrote:

I'm using newlib on a i386 architecture, and now I wonder if it's possible to configure libm in such a way that the fast asm versions of e.g. log() are used. In my current newlib-libm.a there are the entry points for _f_log() etc., but apparently log() doesn't make use of _f_log().

(How) Is it possible to configure newlib's libm to make use of _f_log within log()?

Thank you very much


They aren't compatible per comments in the code. You could call them directly. AFAIUI there should be prototypes and proper names (without underscore prefix, like #define f_log _f_log) for them in newlib, but I don't see any.

-- Patrick Mansfield

Actually, they are meant to be called when the user specifies -ffast-math on the compilation.

The definitions used to be part of libc/include/machine/fastmath.h with an i386 check. This got inadvertently left out when we initially made the transition of newlib from internal to external repositories.

Anyway, I have added libc/machine/i386/machine/fastmath.h based on the older sources plus a few changes. If you compile your code with the -ffast-math option, <math.h> will bring in <machine/fastmath.h> and you will get access to the few fast math routines available for x86, including log().

I use newlib's libm, and only the libm, not the whole libc+libm, on Interix, as replacement for the buggy standard libm there. So I don't want to use any different header files if at all possible.


I can see from the code that e.g. log() and _f_log() don't provide the same functionality, e.g. errno is set by the former, but not by the latter. My question/wishlist item was more that I would like to compile newlib with some option like -ffast-math, or better a configure option, just like --enable-newlib-hw-fp, so that log() checks the argument and sets errno, but then calls _f_log() to calculate the logarithm instead of using the Newton algorithm.

User programs then still could be further optimized by skipping errno processing and call _f_log() directly with -ffast-math if necessary, but even without that it would be reasonably fast.


BTW: Are there any snapshots available for easy building?


Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]