|
From: | Andy H |
Subject: | [avr-libc-dev] Re: Request for cbrt() and strdup to be added to libc |
Date: | Sun, 22 Jun 2008 14:22:02 -0400 |
User-agent: | Thunderbird 2.0.0.14 (Windows/20080421) |
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); } 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 Weddington, Eric wrote:
I don't see any problem with adding these to avr-libc, other than a lack of an implementation. ;-) In general, we try to do as much hand-coded assembly as possible, except for very large functions (e.g. printf and friends) where it would be difficult to do so.Eric-----Original Message-----From: Andy H [mailto:address@hidden Sent: Sunday, June 22, 2008 10:35 AMTo: Weddington, Eric; Joerg Wunsch; Dmitry K. Subject: Request for cbrt() and strdup to be added to libcIt 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) I dont think it would be any hardship to add these to avr library. Can this be done? best regards
[Prev in Thread] | Current Thread | [Next in Thread] |