URL:
<http://savannah.nongnu.org/bugs/?23677>
Summary: Request for cbrt() and strdup to be added to libc
Project: AVR C Runtime Library
Submitted by: hutchinsonandy
Submitted on: Sunday 06/22/2008 at 21:51
Category: Feature Request
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: libc code
Status: None
Percent Complete: 0%
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Release: Any
Fixed Release: None
_______________________________________________________
Details:
It seems gcc testsuite assumes presence of widely available strdup() and
cbrt() functions.
strdup is a derivative of malloc
cbrt is cubic root x^(1/3)
Here are some generic version that can be used as starter.
I'm sure someone can trim them up a bit - or even convert to asm.
Best version depends on how we built existing maths functions.
double cbrt(const double x)
{
return pow(x,1.0/3.0);
}
OR
double cbrt(const double xx)
{
double x= xx;
if (x==0.0) /* log will fail, but answer is easy */
return 0.0;
else if (x>0.0)
return(exp(log(x)/3.0));
else
x= -x;
return(exp(log(x)/3.0));
}