projects
/
cacao.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merged trunk and subtype.
[cacao.git]
/
src
/
mm
/
memory.c
diff --git
a/src/mm/memory.c
b/src/mm/memory.c
index fd4b0f388e3671a16277897ad8d8f5348573b583..ccaa8ec4d1b196c579f1c888b3a5893c52d2abae 100644
(file)
--- a/
src/mm/memory.c
+++ b/
src/mm/memory.c
@@
-26,11
+26,7
@@
#include "config.h"
#include <assert.h>
#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
#if defined(__DARWIN__)
/* If we compile with -ansi on darwin, <sys/types.h> is not
@@
-47,23
+43,21
@@
#include "native/native.h"
#include "threads/lock-common.h"
#include "native/native.h"
#include "threads/lock-common.h"
-#include "threads/thread
s-common.h
"
+#include "threads/thread
.hpp
"
#include "toolbox/logging.h"
#include "toolbox/logging.h"
-#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/global.h"
-#include "vm/string
local.h
"
-#include "vm/vm.h"
+#include "vm/string
.hpp
"
+#include "vm/vm.h
pp
"
-#include "vmcore/options.h"
+#include "vm/options.h"
+#include "vm/os.hpp"
#if defined(ENABLE_STATISTICS)
#if defined(ENABLE_STATISTICS)
-# include "vm
core
/statistics.h"
+# include "vm/statistics.h"
#endif
#endif
-#include "vmcore/system.h"
-
/* memory_mprotect *************************************************************
/* memory_mprotect *************************************************************
@@
-74,9
+68,8
@@
void memory_mprotect(void *addr, size_t len, int prot)
{
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");
}
}
@@
-93,7
+86,7
@@
void *memory_checked_alloc(size_t size)
{
/* always allocate memory zeroed out */
{
/* 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");
if (p == NULL)
vm_abort("memory_checked_alloc: calloc failed: out of memory");
@@
-102,7
+95,7
@@
void *memory_checked_alloc(size_t size)
}
}
-void *mem_alloc(
s4
size)
+void *mem_alloc(
int32_t
size)
{
void *m;
{
void *m;
@@
-130,7
+123,7
@@
void *mem_alloc(s4 size)
}
}
-void *mem_realloc(void *src,
s4 len1, s4
len2)
+void *mem_realloc(void *src,
int32_t len1, int32_t
len2)
{
void *dst;
{
void *dst;
@@
-149,7
+142,7
@@
void *mem_realloc(void *src, s4 len1, s4 len2)
#if defined(ENABLE_MEMCHECK)
if (len2 < len1)
#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);
#endif
dst = realloc(src, len2);
@@
-159,14
+152,14
@@
void *mem_realloc(void *src, s4 len1, s4 len2)
#if defined(ENABLE_MEMCHECK)
if (len2 > len1)
#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;
}
#endif
return dst;
}
-void mem_free(void *m,
s4
size)
+void mem_free(void *m,
int32_t
size)
{
if (!m) {
if (size == 0)
{
if (!m) {
if (size == 0)
@@
-183,10
+176,10
@@
void mem_free(void *m, s4 size)
#if defined(ENABLE_MEMCHECK)
/* destroy the contents */
#if defined(ENABLE_MEMCHECK)
/* destroy the contents */
- memset(m, MEMORY_CLEAR_BYTE, size);
+
os_
memset(m, MEMORY_CLEAR_BYTE, size);
#endif
#endif
- free(m);
+
os_
free(m);
}
}