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 mailing list AVR-libc-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-libc-dev