AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
+# Dump loading
+AC_CHECK_FUNCS([posix_madvise])
+
dnl Cannot use AC_CHECK_FUNCS
AC_CACHE_CHECK([for __builtin_frame_address],
[emacs_cv_func___builtin_frame_address],
void *private;
};
+/* Mark the pages as unneeded, potentially zeroing them, without
+ releasing the address space reservation. */
+static void
+dump_discard_mem (void *mem, size_t size)
+{
+ if (VM_SUPPORTED == VM_MS_WINDOWS)
+ {
+#if VM_SUPPORTED == VM_MS_WINDOWS
+ /* Discard COWed pages. */
+ (void) VirtualFree (mem, size, MEM_DECOMMIT);
+ /* Release the commit charge for the mapping. */
+ (void) VirtualProtect (mem, size, PAGE_NOACCESS, NULL);
+#endif
+ }
+ else if (VM_SUPPORTED == VM_POSIX)
+ {
+#ifdef HAVE_POSIX_MADVISE
+ /* Discard COWed pages. */
+ (void) posix_madvise (mem, size, POSIX_MADV_DONTNEED);
+#endif
+ /* Release the commit charge for the mapping. */
+ (void) mprotect (mem, size, PROT_NONE);
+ }
+ else
+ /* Do nothing */;
+}
+
+static void
+dump_mmap_discard_contents (struct dump_memory_map *map)
+{
+ if (map->mapping)
+ dump_discard_mem (map->mapping, map->spec.size);
+}
+
static void
dump_mmap_reset (struct dump_memory_map *map)
{
dump_do_all_dump_relocations (header, dump_base);
dump_do_all_emacs_relocations (header, dump_base);
- dump_mmap_release (§ions[DS_DISCARDABLE]);
+ dump_mmap_discard_contents (§ions[DS_DISCARDABLE]);
for (int i = 0; i < ARRAYELTS (sections); ++i)
dump_mmap_reset (§ions[i]);