restored new and delete for PPC mac to avoid 10.3 linking problem

svn: r3086
This commit is contained in:
Matthew Flatt 2006-05-27 14:22:14 +00:00
parent 6e2be1403c
commit 058f6c3530

View File

@ -31,10 +31,17 @@ Authors: John R. Ellis and Jesse Hull
/* With x86 Mac OS X, MrEd's `new' gets used by libraries /* With x86 Mac OS X, MrEd's `new' gets used by libraries
that shouldn't use it. So we can't define `new' on that that shouldn't use it. So we can't define `new' on that
platform. For PPC, we define `new' to help ensure that platform. For PPC, we define `new' and `delete' to use
we're not accidentally using it in the OS X port. */ malloc() and free(); for some reason, linking fails in
Mac OS X 10.3 if we just omit `new' and `delete'. */
#if defined(OS_X) && !defined(XONX) #if defined(OS_X) && !defined(XONX)
# ifdef __POWERPC__
# define MALLOC_FOR_BUILTIN_NEW
# include <stdio.h>
# include <stdlib.h>
# else
# define DONT_DEFINE_BUILTIN_NEW # define DONT_DEFINE_BUILTIN_NEW
# endif
#endif #endif
#ifdef COMPACT_BACKTRACE_GC #ifdef COMPACT_BACKTRACE_GC
@ -64,8 +71,7 @@ typedef void (*GC_finalization_proc)(void *, void *);
void *operator new(size_t size) void *operator new(size_t size)
{ {
#ifdef SHOULDNT_USE_BUILTIN_NEW #ifdef MALLOC_FOR_BUILTIN_NEW
printf("MrEd used global new operator!\n");
return malloc(size); return malloc(size);
#else #else
# ifdef USE_SENORA_GC # ifdef USE_SENORA_GC
@ -79,10 +85,10 @@ void *operator new(size_t size)
#endif #endif
} }
void operator delete(void * /*obj*/) void operator delete(void *obj)
{ {
#ifdef SHOULDNT_USE_BUILTIN_NEW #ifdef MALLOC_FOR_BUILTIN_NEW
printf("MrEd used global delete operator!\n"); free(obj);
#endif #endif
} }
@ -184,8 +190,7 @@ void GC_cleanup(void *obj, void *)
void* operator new[](size_t size) void* operator new[](size_t size)
{ {
#ifdef SHOULDNT_USE_BUILTIN_NEW #ifdef MALLOC_FOR_BUILTIN_NEW
printf("MrEd used global new[] operator!\n");
return malloc(size); return malloc(size);
#else #else
# ifdef USE_SENORA_GC # ifdef USE_SENORA_GC
@ -199,10 +204,10 @@ void* operator new[](size_t size)
#endif #endif
} }
void operator delete[](void * /*obj*/) void operator delete[](void *obj)
{ {
#ifdef SHOULDNT_USE_BUILTIN_NEW #ifdef MALLOC_FOR_BUILTIN_NEW
printf("MrEd used global delete[] operator!\n"); free(obj);
#endif #endif
} }