[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #23677] Request for cbrt() and strdup to be added to
From: |
Andy Hutchinson |
Subject: |
[avr-libc-dev] [bug #23677] Request for cbrt() and strdup to be added to libc |
Date: |
Sun, 22 Jun 2008 21:51:39 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 |
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));
}
char * strdup( const char *str)
{
unsigned int len;
char *copy;
len = strlen(str) + 1;
copy = malloc(len);
if (!copy)
return (copy);
memcpy(copy, str, len);
return (copy);
}
Andy
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?23677>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [avr-libc-dev] [bug #23677] Request for cbrt() and strdup to be added to libc,
Andy Hutchinson <=