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

Misha Brukman brukman at cs.uiuc.edu
Tue Dec 16 16:58:02 PST 2003

Changes in directory llvm/runtime/GCCLibraries/libc:

memory.c updated: 1.3 -> 1.4

Log message:

Disable __attribute__((weak)) on Mac OS X and other lame platforms.

Diffs of the changes:  (+20 -5)

Index: llvm/runtime/GCCLibraries/libc/memory.c
diff -u llvm/runtime/GCCLibraries/libc/memory.c:1.3 llvm/runtime/GCCLibraries/libc/memory.c:1.4
--- llvm/runtime/GCCLibraries/libc/memory.c:1.3	Mon Dec 15 16:32:50 2003
+++ llvm/runtime/GCCLibraries/libc/memory.c	Tue Dec 16 16:57:30 2003
@@ -2,14 +2,29 @@
 // A lot of this code is ripped gratuitously from glibc and libiberty.
 #include <stdlib.h>
-void *malloc(size_t) __attribute__((weak));
-void free(void *) __attribute__((weak));
-void *memset(void *, int, size_t) __attribute__((weak));
-void *calloc(size_t nelem, size_t elsize) __attribute__((weak));
+// If we're not being compiled with GCC, turn off attributes. Question is how
+// to handle overriding of memory allocation functions in that case.
+#ifndef __GNUC__
+#define __attribute__(X)
+// For now, turn off the weak linkage attribute on Mac OS X.
+#if defined(__GNUC__) && defined(__APPLE_CC__)
+#define __ATTRIBUTE_WEAK__
+#elif defined(__GNUC__)
+#define __ATTRIBUTE_WEAK__ __attribute__((weak))
+#define __ATTRIBUTE_WEAK__
+void *malloc(size_t) __ATTRIBUTE_WEAK__;
+void free(void *) __ATTRIBUTE_WEAK__;
+void *memset(void *, int, size_t) __ATTRIBUTE_WEAK__;
+void *calloc(size_t nelem, size_t elsize) __ATTRIBUTE_WEAK__;
 void *calloc(size_t nelem, size_t elsize) {
   void *Result = malloc(nelem*elsize);

More information about the llvm-commits mailing list