2017-04-11 09:17:55 +08:00
|
|
|
#include "jemalloc/internal/jemalloc_preamble.h"
|
|
|
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
2010-01-24 18:53:40 +08:00
|
|
|
|
2017-04-12 05:43:12 +08:00
|
|
|
#include "jemalloc/internal/assert.h"
|
2017-05-24 05:42:32 +08:00
|
|
|
#include "jemalloc/internal/extent_mmap.h"
|
2017-04-12 05:43:12 +08:00
|
|
|
|
2017-04-25 08:28:55 +08:00
|
|
|
/******************************************************************************/
|
|
|
|
/* Data. */
|
|
|
|
|
2017-04-27 07:26:12 +08:00
|
|
|
bool opt_retain =
|
|
|
|
#ifdef JEMALLOC_RETAIN
|
2017-04-25 08:28:55 +08:00
|
|
|
true
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2010-01-24 18:53:40 +08:00
|
|
|
/******************************************************************************/
|
2012-04-19 00:29:43 +08:00
|
|
|
|
2012-04-12 09:13:45 +08:00
|
|
|
void *
|
2016-06-02 03:59:02 +08:00
|
|
|
extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero,
|
2017-01-16 08:56:30 +08:00
|
|
|
bool *commit) {
|
2019-03-29 11:42:40 +08:00
|
|
|
assert(alignment == ALIGNMENT_CEILING(alignment, PAGE));
|
|
|
|
void *ret = pages_map(new_addr, size, alignment, commit);
|
2017-04-17 07:23:32 +08:00
|
|
|
if (ret == NULL) {
|
|
|
|
return NULL;
|
2012-04-22 10:17:21 +08:00
|
|
|
}
|
2012-04-22 04:33:48 +08:00
|
|
|
assert(ret != NULL);
|
2017-04-20 07:14:54 +08:00
|
|
|
if (*commit) {
|
|
|
|
*zero = true;
|
|
|
|
}
|
2017-01-20 10:15:45 +08:00
|
|
|
return ret;
|
2010-01-24 18:53:40 +08:00
|
|
|
}
|
|
|
|
|
2012-04-13 11:20:58 +08:00
|
|
|
bool
|
2017-01-16 08:56:30 +08:00
|
|
|
extent_dalloc_mmap(void *addr, size_t size) {
|
2017-04-27 07:26:12 +08:00
|
|
|
if (!opt_retain) {
|
2016-06-02 03:59:02 +08:00
|
|
|
pages_unmap(addr, size);
|
2017-01-16 08:56:30 +08:00
|
|
|
}
|
2017-04-27 07:26:12 +08:00
|
|
|
return opt_retain;
|
2010-01-24 18:53:40 +08:00
|
|
|
}
|