diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2011-06-10 18:30:38 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2011-06-10 18:30:38 +0000 |
commit | 38e356f0e4277cd9804fcbcef1c3300154e19f90 (patch) | |
tree | 386056d18ac22dc3865cad38dfa8606a61528a13 /newlib | |
parent | 1516a0b4d7e213e8db5ee025b9c1691864d35403 (diff) | |
download | cygnal-38e356f0e4277cd9804fcbcef1c3300154e19f90.tar.gz cygnal-38e356f0e4277cd9804fcbcef1c3300154e19f90.tar.bz2 cygnal-38e356f0e4277cd9804fcbcef1c3300154e19f90.zip |
2011-06-09 Yaakov Selkowitz <yselkowitz@...>
* libc/include/string.h (strdupa): New macro function.
(strndupa): New macro function.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 5 | ||||
-rw-r--r-- | newlib/libc/include/string.h | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 561c278ab..f2faad486 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2011-06-09 Yaakov Selkowitz <yselkowitz@...> + + * libc/include/string.h (strdupa): New macro function. + (strndupa): New macro function. + 2011-05-27 Nick Clifton <nickc@redhat.com> * libc/sys/sysnecv850/sbrk.c (_sbrk): Tidy code. diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index d565e8e32..cd80ce76b 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -99,6 +99,20 @@ int _EXFUN(strtosigno, (const char *__name)); /* Recursive version of strerror. */ char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); +#if defined _GNU_SOURCE && defined __GNUC__ +#define strdupa(__s) \ + (__extension__ ({const char *__in = (__s); \ + size_t __len = strlen (__in) + 1; \ + char * __out = (char *) __builtin_alloca (__len); \ + (char *) memcpy (__out, __in, __len);})) +#define strndupa(__s, __n) \ + (__extension__ ({const char *__in = (__s); \ + size_t __len = strnlen (__in, (__n)) + 1; \ + char *__out = (char *) __builtin_alloca (__len); \ + __out[__len-1] = '\0'; \ + (char *) memcpy (__out, __in, __len-1);})) +#endif /* _GNU_SOURCE && __GNUC__ */ + /* These function names are used on Windows and perhaps other systems. */ #ifndef strcmpi #define strcmpi strcasecmp |