Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2011-06-10 22:30:38 +0400
committerJeff Johnston <jjohnstn@redhat.com>2011-06-10 22:30:38 +0400
commit38e356f0e4277cd9804fcbcef1c3300154e19f90 (patch)
tree386056d18ac22dc3865cad38dfa8606a61528a13 /newlib/libc/include/string.h
parent1516a0b4d7e213e8db5ee025b9c1691864d35403 (diff)
2011-06-09 Yaakov Selkowitz <yselkowitz@...>
* libc/include/string.h (strdupa): New macro function. (strndupa): New macro function.
Diffstat (limited to 'newlib/libc/include/string.h')
-rw-r--r--newlib/libc/include/string.h14
1 files changed, 14 insertions, 0 deletions
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