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