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