#if !defined(_EMBEDDED_H) && defined(APPLE_KERNEL_EXTENSION)
#define _EMBEDDED_H
#ifdef __cplusplus
extern "C" {
#endif
#define MON_ERROR_RUN_INTERNAL 1
#define MON_ERROR_PURE_VIRTUAL 2
#define MON_ERROR_NO_MEM 3
#ifdef MACOSX
#define MONITOR_ERROR(code) panic(code)
#undef MON_ERROR_RUN_INTERNAL
#define MON_ERROR_RUN_INTERNAL "Internal C++ runtime error"
#undef MON_ERROR_PURE_VIRTUAL
#define MON_ERROR_PURE_VIRTUAL "C++ pure virtual function called"
#undef MON_ERROR_NO_MEM
#define MON_ERROR_NO_MEM "C/C++ runtime memory allocation failed"
#define ABORT MONITOR_ERROR (MON_ERROR_RUN_INTERNAL)
#define TERMINATE MONITOR_ERROR (MON_ERROR_PURE_VIRTUAL)
extern void *kalloc (unsigned int size) ;
extern void kfree (void * data, unsigned int size) ;
extern void panic (const char *, ...) ;
static inline void *malloc (long unsigned int size)
{
void *ptr = (void *) kalloc (size+4);
if (ptr)
{
*(unsigned int *) ptr = size + 4 ;
ptr = (void *) ((unsigned char *) ptr + 4) ;
}
return ptr;
}
static inline void free (void *ptr)
{
if (ptr)
{
ptr = (void *) ((unsigned char *) ptr - 4);
kfree (ptr, *(unsigned int *) ptr);
}
}
#endif
#ifndef PRIVATE_EXTERN
#define PRIVATE_EXTERN
#endif
#ifdef __cplusplus
}
#endif
#endif