xref: /freebsd/contrib/jemalloc/src/extent_mmap.c (revision c43cad87172039ccf38172129c79755ea79e6102)
1 #include "jemalloc/internal/jemalloc_preamble.h"
2 #include "jemalloc/internal/jemalloc_internal_includes.h"
3 
4 #include "jemalloc/internal/assert.h"
5 #include "jemalloc/internal/extent_mmap.h"
6 
7 /******************************************************************************/
8 /* Data. */
9 
10 bool	opt_retain =
11 #ifdef JEMALLOC_RETAIN
12     true
13 #else
14     false
15 #endif
16     ;
17 
18 /******************************************************************************/
19 
20 void *
21 extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero,
22     bool *commit) {
23 	assert(alignment == ALIGNMENT_CEILING(alignment, PAGE));
24 	void *ret = pages_map(new_addr, size, alignment, commit);
25 	if (ret == NULL) {
26 		return NULL;
27 	}
28 	assert(ret != NULL);
29 	if (*commit) {
30 		*zero = true;
31 	}
32 	return ret;
33 }
34 
35 bool
36 extent_dalloc_mmap(void *addr, size_t size) {
37 	if (!opt_retain) {
38 		pages_unmap(addr, size);
39 	}
40 	return opt_retain;
41 }
42