#include <stdlib.h>                   // for malloc and free

#include "SFBAssert.h"   /* for BUG_CODE */

void *operator new(size_t size) throw() { return malloc(size); }

void operator delete(void *p) throw() { free(p); }

int raise(int) { return 0; }

extern "C" int __aeabi_atexit(void *,
                              void (*)(void *),
                              void *)
{
  return 0;
}


extern "C" void __cxa_pure_virtual()
{
  BUG_CODE("pure virtual called",E_API_PURE_VIRTUAL);
}

extern "C"
int __cxa_guard_acquire() 
{
  BUG_CODE("cxa_guard_acquire called",E_API_CXA_GUARD);
}
 
extern "C"
void __cxa_guard_release()
{
  BUG_CODE("cxa_guard_release called",E_API_CXA_GUARD);
}

extern "C"
void __cxa_guard_abort()
{
  BUG_CODE("cxa_guard_abort called",E_API_CXA_GUARD);
}

extern "C" void * memcpy (void * dstpp, const void * srcpp, size_t len)
{
  // Use incredibly slow and stupid byte copy until we understand
  // why this is being called!
  char * dst = (char *) dstpp;
  const char * src = (char *) srcpp;
  while (len--) 
    *dst++ = *src++;
  return dstpp;
}
