[RFC] libm replacement for Busybox
Loïc Grenié
loic.grenie at gmail.com
Fri Oct 10 14:21:51 UTC 2008
I've noticed that busybox uses few functions from libm.
I've written some replacements for those functions. Right
now this is just the test program and I've not made the
effort of including them in Busybox. However I'd like to
have your opinion: would it be a good idea to include
them ?
They are neither very fast nor very precise (the
trigonometric functions are awful, up to 16 bits are
false) but libm is rather large and usually a user of
Busybox on an initrd or embedded platform does not
need neither speed nor excellent precision. Otherwise
it would always be possible to disable them anyway.
Quick and dirty way to have a look:
cc -Wall -O2 -o libmtest libmtest.c -lm && ./libmtest
for f in err*
do
tail -1 $f | sed "s/^/$f: /"|cut -f1-2
done
The program does 10000 random tests for each of the 7
functions included in the program (log,exp, pow, sin, cos,
tan, atan2) and saves them in a (sorted) file. The first
column is the log2() of the worst relative error of libmtest
function against the same function of libm (i.e. the number
of the first error bit in the mantissa) and the second field is
the value of the arg. that provided the error (the error files are
more complete -- for pow and atan2 there is a second
argument but the for loop above does not print it even though
it is present in the error file).
Thanks,
Loïc Grenié
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libmtest.c
Type: text/x-csrc
Size: 11894 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20081010/ea8c9ce8/attachment-0002.c
More information about the busybox
mailing list