aboutsummaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-10-17 00:17:54 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-10-17 00:17:54 +0000
commit2bf0292432d9a99667eef82f0df2de19022da97d (patch)
treebc91211aac495ea622b145e31529787365230152 /runtime
parent71d3778c0b75a637c66704689bf624e9bd317521 (diff)
downloadexternal_llvm-2bf0292432d9a99667eef82f0df2de19022da97d.zip
external_llvm-2bf0292432d9a99667eef82f0df2de19022da97d.tar.gz
external_llvm-2bf0292432d9a99667eef82f0df2de19022da97d.tar.bz2
Make sure that for systems where the string functions are actually macros
that we undefine the macro before using its name in the definition. This can happen on Linux if _GNU_SOURCE is defined. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/GCCLibraries/libc/string.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/runtime/GCCLibraries/libc/string.c b/runtime/GCCLibraries/libc/string.c
index 9cff5ec..bd43b34 100644
--- a/runtime/GCCLibraries/libc/string.c
+++ b/runtime/GCCLibraries/libc/string.c
@@ -7,12 +7,18 @@
#include <stdlib.h>
#include <string.h>
+#ifdef strlen
+#undef strlen
+#endif
size_t strlen(const char *Str) {
size_t Count = 0;
while (*Str) { ++Count; ++Str; }
return Count;
}
+#ifdef strdup
+#undef strdup
+#endif
char *strdup(const char *str) {
size_t Len = strlen(str);
char *Result = (char*)malloc((Len+1)*sizeof(char));
@@ -20,6 +26,9 @@ char *strdup(const char *str) {
return Result;
}
+#ifdef strndup
+#undef strndup
+#endif
char *strndup(const char *str, size_t n) {
size_t Len = strlen(str);
if (Len > n) Len = n;
@@ -29,24 +38,36 @@ char *strndup(const char *str, size_t n) {
return Result;
}
+#ifdef strcpy
+#undef strcpy
+#endif
char *strcpy(char *s1, const char *s2) {
char *dest = s1;
while ((*s1++ = *s2++));
return dest;
}
+#ifdef strncpy
+#undef strncpy
+#endif
char *strncpy(char *s1, const char *s2, size_t n) {
char *dest = s1;
while (n-- && (*s1++ = *s2++));
return dest;
}
+#ifdef strcat
+#undef strcat
+#endif
char *strcat(char *s1, const char *s2) {
strcpy(s1+strlen(s1), s2);
return s1;
}
+#ifdef strcmp
+#undef strcmp
+#endif
/* Compare S1 and S2, returning less than, equal to or
greater than zero if S1 is lexicographically less than,
equal to or greater than S2. */
@@ -136,6 +157,9 @@ void *memset (void *dstpp, int c, size_t len) {
}
#endif
+#ifdef memcpy
+#undef memcpy
+#endif
void *memcpy(void *dstpp, const void *srcpp, size_t len) {
char *dstp = (char*)dstpp;
char *srcp = (char*) srcpp;