1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
/* Copyright (C) 2010 Matthew Fluet.
* Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
* Copyright (C) 1997-2000 NEC Research Institute.
*
* MLton is released under a BSD-style license.
* See the file MLton-LICENSE for details.
*/
void *GC_mmapAnon_safe (void *p, size_t length) {
void *result;
result = GC_mmapAnon (p, length);
if ((void*)-1 == result) {
GC_displayMem ();
die ("Out of memory. Unable to allocate %s bytes.\n",
uintmaxToCommaString(length));
}
return result;
}
static inline void GC_memcpy (pointer src, pointer dst, size_t size) {
if (DEBUG_DETAILED)
fprintf (stderr, "GC_memcpy ("FMTPTR", "FMTPTR", %"PRIuMAX")\n",
(uintptr_t)src, (uintptr_t)dst, (uintmax_t)size);
assert (isAligned ((size_t)src, sizeof(unsigned int)));
assert (isAligned ((size_t)dst, sizeof(unsigned int)));
assert (isAligned (size, sizeof(unsigned int)));
assert (! (src <= dst and dst < src + size));
assert (! (dst <= src and src < dst + size));
memcpy (dst, src, size);
}
static inline void GC_memmove (pointer src, pointer dst, size_t size) {
if (DEBUG_DETAILED)
fprintf (stderr, "GC_memmove ("FMTPTR", "FMTPTR", %"PRIuMAX")\n",
(uintptr_t)src, (uintptr_t)dst, (uintmax_t)size);
assert (isAligned ((size_t)src, sizeof(unsigned int)));
assert (isAligned ((size_t)dst, sizeof(unsigned int)));
assert (isAligned (size, sizeof(unsigned int)));
if (src == dst)
return;
memmove (dst, src, size);
}
|