summaryrefslogtreecommitdiffstats
path: root/llvm/runtime/GCCLibraries/libc/memory.c
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-12-16 22:57:30 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-12-16 22:57:30 +0000
commit91ed92fe5f730a588e0c054cc382c14d0ab4a639 (patch)
tree928db44b78c3f4e41e1c4c81db5183c7922ccd29 /llvm/runtime/GCCLibraries/libc/memory.c
parente7670a0bbb05f5b38caa13d48bde2fd5adcae499 (diff)
downloadbcm5719-llvm-91ed92fe5f730a588e0c054cc382c14d0ab4a639.tar.gz
bcm5719-llvm-91ed92fe5f730a588e0c054cc382c14d0ab4a639.zip
Disable __attribute__((weak)) on Mac OS X and other lame platforms.
llvm-svn: 10489
Diffstat (limited to 'llvm/runtime/GCCLibraries/libc/memory.c')
-rw-r--r--llvm/runtime/GCCLibraries/libc/memory.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/runtime/GCCLibraries/libc/memory.c b/llvm/runtime/GCCLibraries/libc/memory.c
index a839832d1ce..64aef89094a 100644
--- a/llvm/runtime/GCCLibraries/libc/memory.c
+++ b/llvm/runtime/GCCLibraries/libc/memory.c
@@ -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)
+#endif
+
+// 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))
+#else
+#define __ATTRIBUTE_WEAK__
+#endif
+
+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);
OpenPOWER on IntegriCloud