/* src/mm/memory.c - memory management
Copyright (C) 1996-2005, 2006, 2007, 2008
- CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "config.h"
#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <stdint.h>
#if defined(__DARWIN__)
/* If we compile with -ansi on darwin, <sys/types.h> is not
#include "mm/memory.h"
-#include "native/native.h"
+#include "native/native.hpp"
-#include "threads/lock-common.h"
-#include "threads/threads-common.h"
+#include "threads/lock.hpp"
+#include "threads/thread.hpp"
#include "toolbox/logging.h"
-#include "vm/exceptions.h"
#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/string.hpp"
+#include "vm/vm.hpp"
-#include "vmcore/options.h"
+#include "vm/options.h"
+#include "vm/os.hpp"
#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
#endif
-#include "vmcore/system.h"
-
/* memory_mprotect *************************************************************
void memory_mprotect(void *addr, size_t len, int prot)
{
- if (system_mprotect(addr, len, prot) != 0)
- vm_abort("memory_mprotect: system_mprotect failed: %s",
- strerror(errno));
+ if (os_mprotect(addr, len, prot) != 0)
+ vm_abort_errno("memory_mprotect: os_mprotect failed");
}
{
/* always allocate memory zeroed out */
- void *p = calloc(size, 1);
+ void *p = os_calloc(size, 1);
if (p == NULL)
vm_abort("memory_checked_alloc: calloc failed: out of memory");
}
-void *mem_alloc(s4 size)
+void *mem_alloc(int32_t size)
{
void *m;
}
-void *mem_realloc(void *src, s4 len1, s4 len2)
+void *mem_realloc(void *src, int32_t len1, int32_t len2)
{
void *dst;
#if defined(ENABLE_MEMCHECK)
if (len2 < len1)
- memset((u1*)dst + len2, MEMORY_CLEAR_BYTE, len1 - len2);
+ os_memset((u1*)dst + len2, MEMORY_CLEAR_BYTE, len1 - len2);
#endif
dst = realloc(src, len2);
#if defined(ENABLE_MEMCHECK)
if (len2 > len1)
- memset((u1*)dst + len1, MEMORY_CLEAR_BYTE, len2 - len1);
+ os_memset((u1*)dst + len1, MEMORY_CLEAR_BYTE, len2 - len1);
#endif
return dst;
}
-void mem_free(void *m, s4 size)
+void mem_free(void *m, int32_t size)
{
if (!m) {
if (size == 0)
#if defined(ENABLE_MEMCHECK)
/* destroy the contents */
- memset(m, MEMORY_CLEAR_BYTE, size);
+ os_memset(m, MEMORY_CLEAR_BYTE, size);
#endif
- free(m);
+ os_free(m);
}
{
int32_t seconds;
+ /* Prevent compiler warning. */
+
+ seconds = 1;
+
/* If both arguments are specified, use the value of
ProfileMemoryUsage. */