Defines | Typedefs | Functions | Variables

jemalloc.c File Reference

#include "dsodefs.h"
#include <sys/types.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#include "jemtree.h"
#include <sys/uio.h>
#include <sched.h>
#include <stdbool.h>
#include <stdint.h>
#include <strings.h>
#include <unistd.h>
#include <assert.h>
Include dependency graph for jemalloc.c:

Defines

#define MALLOC_PRODUCTION   1
#define MALLOC_DSS
#define __DECONST(type, var)   ((type)(uintptr_t)(const void *)(var))
#define MADV_FREE   MADV_DONTNEED
#define SIZE_T_MAX   SIZE_MAX
#define __DECONST(type, var)   ((type)(uintptr_t)(const void *)(var))
#define NDEBUG
#define STRERROR_BUF   64
#define QUANTUM_2POW_MIN   4
#define SIZEOF_PTR_2POW   2
#define SIZEOF_PTR   (1U << SIZEOF_PTR_2POW)
#define SIZEOF_INT_2POW   2
#define NO_TLS
#define CHUNK_2POW_DEFAULT   20
#define DIRTY_MAX_DEFAULT   (1U << 9)
#define CACHELINE_2POW   6
#define CACHELINE   ((size_t)(1U << CACHELINE_2POW))
#define TINY_MIN_2POW   1
#define SMALL_MAX_2POW_DEFAULT   9
#define SMALL_MAX_DEFAULT   (1U << SMALL_MAX_2POW_DEFAULT)
#define RUN_BFP   12
#define RUN_MAX_OVRHD   0x0000003dU
#define RUN_MAX_OVRHD_RELAX   0x00001800U
#define RUN_MAX_SMALL_2POW   15
#define RUN_MAX_SMALL   (1U << RUN_MAX_SMALL_2POW)
#define CPU_SPINWAIT
#define SPIN_LIMIT_2POW   11
#define BLOCK_COST_2POW   4
#define CHUNK_MAP_UNTOUCHED   0x80U
#define CHUNK_MAP_DIRTY   0x40U
#define CHUNK_MAP_LARGE   0x20U
#define CHUNK_MAP_POS_MASK   0x1fU
#define UTRACE(a, b, c)
#define malloc_spin_init   malloc_mutex_init
#define malloc_spin_lock   malloc_mutex_lock
#define malloc_spin_unlock   malloc_mutex_unlock
#define CHUNK_ADDR2BASE(a)   ((void *)((uintptr_t)(a) & ~chunksize_mask))
#define CHUNK_ADDR2OFFSET(a)   ((size_t)((uintptr_t)(a) & chunksize_mask))
#define CHUNK_CEILING(s)   (((s) + chunksize_mask) & ~chunksize_mask)
#define CACHELINE_CEILING(s)   (((s) + (CACHELINE - 1)) & ~(CACHELINE - 1))
#define QUANTUM_CEILING(a)   (((a) + quantum_mask) & ~quantum_mask)
#define PAGE_CEILING(s)   (((s) + pagesize_mask) & ~pagesize_mask)
#define _write   write
#define _malloc_message   malloc_message
#define UMAX2S_BUFSIZE   21
#define SIZE_INV_SHIFT   21
#define SIZE_INV(s)   (((1U << SIZE_INV_SHIFT) / (s << QUANTUM_2POW_MIN)) + 1)

Typedefs

typedef malloc_spinlock_t malloc_mutex_t
typedef struct extent_node_s extent_node_t
typedef struct extent_tree_szad_s extent_tree_szad_t
typedef struct extent_tree_ad_s extent_tree_ad_t
typedef struct arena_s arena_t
typedef struct arena_bin_s arena_bin_t
typedef uint8_t arena_chunk_map_t
typedef struct arena_chunk_s arena_chunk_t
typedef struct arena_chunk_tree_s arena_chunk_tree_t
typedef struct arena_run_s arena_run_t
typedef struct arena_run_tree_s arena_run_tree_t

Functions

DSOEXPORT void * memalign (size_t alignment, size_t size)
DSOEXPORT size_t malloc_usable_size (const void *ptr)
DSOEXPORT void * calloc (size_t num, size_t size)
DSOEXPORT void * realloc (void *ptr, size_t size)
DSOEXPORT void * valloc (size_t size)
void _malloc_postfork (void)
void _malloc_prefork (void)
 RB_HEAD (extent_tree_szad_s, extent_node_s)
 RB_HEAD (extent_tree_ad_s, extent_node_s)
 RB_HEAD (arena_chunk_tree_s, arena_chunk_s)
 RB_HEAD (arena_run_tree_s, arena_run_s)
 RB_GENERATE_STATIC (extent_tree_szad_s, extent_node_s, link_szad, extent_szad_comp)
DSOEXPORT void * malloc (size_t size)
DSOEXPORT int posix_memalign (void **memptr, size_t alignment, size_t size)
DSOEXPORT void free (void *ptr)

Variables

const char * _malloc_options
void(* _malloc_message )(const char *p1, const char *p2, const char *p3, const char *p4) = wrtmessage

Define Documentation

#define __DECONST (   type,
  var 
)    ((type)(uintptr_t)(const void *)(var))
#define __DECONST (   type,
  var 
)    ((type)(uintptr_t)(const void *)(var))
#define _malloc_message   malloc_message
#define _write   write
#define BLOCK_COST_2POW   4
#define CACHELINE   ((size_t)(1U << CACHELINE_2POW))
#define CACHELINE_2POW   6
#define CACHELINE_CEILING (   s  )     (((s) + (CACHELINE - 1)) & ~(CACHELINE - 1))
#define CHUNK_2POW_DEFAULT   20
#define CHUNK_ADDR2BASE (   a  )     ((void *)((uintptr_t)(a) & ~chunksize_mask))
#define CHUNK_ADDR2OFFSET (   a  )     ((size_t)((uintptr_t)(a) & chunksize_mask))
#define CHUNK_CEILING (   s  )     (((s) + chunksize_mask) & ~chunksize_mask)
#define CHUNK_MAP_DIRTY   0x40U
#define CHUNK_MAP_LARGE   0x20U
#define CHUNK_MAP_POS_MASK   0x1fU
#define CHUNK_MAP_UNTOUCHED   0x80U
#define CPU_SPINWAIT
#define DIRTY_MAX_DEFAULT   (1U << 9)
#define MADV_FREE   MADV_DONTNEED
#define MALLOC_DSS
#define MALLOC_PRODUCTION   1
#define malloc_spin_init   malloc_mutex_init
#define malloc_spin_lock   malloc_mutex_lock
#define malloc_spin_unlock   malloc_mutex_unlock
#define NDEBUG
#define NO_TLS
#define PAGE_CEILING (   s  )     (((s) + pagesize_mask) & ~pagesize_mask)
#define QUANTUM_2POW_MIN   4
#define QUANTUM_CEILING (   a  )     (((a) + quantum_mask) & ~quantum_mask)
#define RUN_BFP   12
#define RUN_MAX_OVRHD   0x0000003dU
#define RUN_MAX_OVRHD_RELAX   0x00001800U
#define RUN_MAX_SMALL   (1U << RUN_MAX_SMALL_2POW)
#define RUN_MAX_SMALL_2POW   15
#define SIZE_INV (   s  )     (((1U << SIZE_INV_SHIFT) / (s << QUANTUM_2POW_MIN)) + 1)
#define SIZE_INV_SHIFT   21
#define SIZE_T_MAX   SIZE_MAX

Referenced by calloc().

#define SIZEOF_INT_2POW   2
#define SIZEOF_PTR   (1U << SIZEOF_PTR_2POW)
#define SIZEOF_PTR_2POW   2
#define SMALL_MAX_2POW_DEFAULT   9
#define SMALL_MAX_DEFAULT   (1U << SMALL_MAX_2POW_DEFAULT)
#define SPIN_LIMIT_2POW   11
#define STRERROR_BUF   64
#define TINY_MIN_2POW   1
#define UMAX2S_BUFSIZE   21
#define UTRACE (   a,
  b,
  c 
)

Typedef Documentation

typedef struct arena_bin_s arena_bin_t
typedef uint8_t arena_chunk_map_t
typedef struct arena_chunk_s arena_chunk_t
typedef struct arena_chunk_tree_s arena_chunk_tree_t
typedef struct arena_run_s arena_run_t
typedef struct arena_run_tree_s arena_run_tree_t
typedef struct arena_s arena_t
typedef struct extent_node_s extent_node_t
typedef struct extent_tree_ad_s extent_tree_ad_t
typedef struct extent_tree_szad_s extent_tree_szad_t
typedef malloc_spinlock_t malloc_mutex_t

Function Documentation

void _malloc_postfork ( void   ) 
void _malloc_prefork ( void   ) 
DSOEXPORT void * calloc ( size_t  num,
size_t  size 
)

References _malloc_message, errno, SIZE_T_MAX, and UTRACE.

DSOEXPORT void free ( void *  ptr  ) 
DSOEXPORT void* malloc ( size_t  size  ) 
DSOEXPORT size_t malloc_usable_size ( const void *  ptr  ) 
DSOEXPORT void * memalign ( size_t  alignment,
size_t  size 
)

References posix_memalign().

Referenced by valloc().

DSOEXPORT int posix_memalign ( void **  memptr,
size_t  alignment,
size_t  size 
)

References _malloc_message, and UTRACE.

Referenced by memalign().

RB_GENERATE_STATIC ( extent_tree_szad_s  ,
extent_node_s  ,
link_szad  ,
extent_szad_comp   
)
RB_HEAD ( extent_tree_szad_s  ,
extent_node_s   
)
RB_HEAD ( extent_tree_ad_s  ,
extent_node_s   
)
RB_HEAD ( arena_chunk_tree_s  ,
arena_chunk_s   
)
RB_HEAD ( arena_run_tree_s  ,
arena_run_s   
)
DSOEXPORT void * realloc ( void *  ptr,
size_t  size 
)
DSOEXPORT void * valloc ( size_t  size  ) 

References memalign().


Variable Documentation

void(* _malloc_message)(const char *p1, const char *p2, const char *p3, const char *p4) = wrtmessage
const char* _malloc_options