[llvm-commits] CVS: llvm/runtime/GCCLibraries/libc/string.c

Reid Spencer reid at x10sys.com
Sat Oct 16 17:18:32 PDT 2004



Changes in directory llvm/runtime/GCCLibraries/libc:

string.c updated: 1.8 -> 1.9
---
Log message:

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.


---
Diffs of the changes:  (+24 -0)

Index: llvm/runtime/GCCLibraries/libc/string.c
diff -u llvm/runtime/GCCLibraries/libc/string.c:1.8 llvm/runtime/GCCLibraries/libc/string.c:1.9
--- llvm/runtime/GCCLibraries/libc/string.c:1.8	Fri Feb 20 14:15:47 2004
+++ llvm/runtime/GCCLibraries/libc/string.c	Sat Oct 16 19:17:54 2004
@@ -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 @@
   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 @@
   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 @@
 }
 #endif
 
+#ifdef memcpy
+#undef memcpy
+#endif
 void *memcpy(void *dstpp, const void *srcpp, size_t len) {
   char *dstp = (char*)dstpp;
   char *srcp = (char*) srcpp;






More information about the llvm-commits mailing list