Geant4  10.00.p01
mymalloc.cc File Reference
#include <sys/types.h>
#include <iostream>
#include "tls.hh"
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/param.h>
+ Include dependency graph for mymalloc.cc:

Go to the source code of this file.

Classes

struct  mallinfo
 
struct  malloc_chunk
 
struct  malloc_tree_chunk
 
struct  malloc_segment
 
struct  malloc_state
 
struct  malloc_params
 

Macros

#define MSPACES   1
 
#define DLMALLOC_VERSION   20804
 
#define SPIN_LOCKS_AVAILABLE   0
 
#define MAX_SIZE_T   (~(size_t)0)
 
#define ONLY_MSPACES   0 /* define to a value */
 
#define MALLOC_ALIGNMENT   ((size_t)8U)
 
#define FOOTERS   0
 
#define ABORT   abort()
 
#define ABORT_ON_ASSERT_FAILURE   1
 
#define PROCEED_ON_ERROR   0
 
#define USE_LOCKS   0
 
#define USE_SPIN_LOCKS   0
 
#define INSECURE   0
 
#define HAVE_MMAP   1
 
#define MMAP_CLEARS   1
 
#define HAVE_MREMAP   0
 
#define MALLOC_FAILURE_ACTION   errno = ENOMEM;
 
#define HAVE_MORECORE   1
 
#define MORECORE_DEFAULT   sbrk
 
#define MORECORE_CONTIGUOUS   1
 
#define DEFAULT_GRANULARITY   (0) /* 0 means to compute in init_mparams */
 
#define DEFAULT_TRIM_THRESHOLD   ((size_t)2U * (size_t)1024U * (size_t)1024U)
 
#define DEFAULT_MMAP_THRESHOLD   ((size_t)256U * (size_t)1024U)
 
#define MAX_RELEASE_CHECK_RATE   4095
 
#define USE_BUILTIN_FFS   0
 
#define USE_DEV_RANDOM   0
 
#define NO_MALLINFO   0
 
#define MALLINFO_FIELD_TYPE   size_t
 
#define NO_SEGMENT_TRAVERSAL   0
 
#define M_TRIM_THRESHOLD   (-1)
 
#define M_GRANULARITY   (-2)
 
#define M_MMAP_THRESHOLD   (-3)
 
#define STRUCT_MALLINFO_DECLARED   1
 
#define NOINLINE
 
#define FORCEINLINE
 
#define dlcalloc   mycalloc
 
#define dlfree   myfree
 
#define dlmalloc   mymalloc
 
#define dlmemalign   mymemalign
 
#define dlrealloc   myrealloc
 
#define dlvalloc   myvalloc
 
#define dlpvalloc   mypvalloc
 
#define dlmallinfo   mymallinfo
 
#define dlmallopt   mymallopt
 
#define dlmalloc_trim   mymalloc_trim
 
#define dlmalloc_stats   mymalloc_stats
 
#define dlmalloc_usable_size   mymalloc_usable_size
 
#define dlmalloc_footprint   mymalloc_footprint
 
#define dlmalloc_max_footprint   mymalloc_max_footprint
 
#define dlindependent_calloc   myindependent_calloc
 
#define dlindependent_comalloc   myindependent_comalloc
 
#define assert(x)
 
#define DEBUG   0
 
#define malloc_getpagesize   ((size_t)4096U)
 
#define SIZE_T_SIZE   (sizeof(size_t))
 
#define SIZE_T_BITSIZE   (sizeof(size_t) << 3)
 
#define SIZE_T_ZERO   ((size_t)0)
 
#define SIZE_T_ONE   ((size_t)1)
 
#define SIZE_T_TWO   ((size_t)2)
 
#define SIZE_T_FOUR   ((size_t)4)
 
#define TWO_SIZE_T_SIZES   (SIZE_T_SIZE<<1)
 
#define FOUR_SIZE_T_SIZES   (SIZE_T_SIZE<<2)
 
#define SIX_SIZE_T_SIZES   (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)
 
#define HALF_MAX_SIZE_T   (MAX_SIZE_T / 2U)
 
#define CHUNK_ALIGN_MASK   (MALLOC_ALIGNMENT - SIZE_T_ONE)
 
#define is_aligned(A)   (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)
 
#define align_offset(A)
 
#define MFAIL   ((void*)(MAX_SIZE_T))
 
#define CMFAIL   ((char*)(MFAIL)) /* defined for convenience */
 
#define MUNMAP_DEFAULT(a, s)   munmap((a), (s))
 
#define MMAP_PROT   (PROT_READ|PROT_WRITE)
 
#define MMAP_FLAGS   (MAP_PRIVATE)
 
#define MMAP_DEFAULT(s)
 
#define DIRECT_MMAP_DEFAULT(s)   MMAP_DEFAULT(s)
 
#define CALL_MORECORE(S)   MORECORE_DEFAULT(S)
 Define CALL_MORECORE. More...
 
#define USE_MMAP_BIT   (SIZE_T_ONE)
 Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP. More...
 
#define CALL_MMAP(s)   MMAP_DEFAULT(s)
 
#define CALL_MUNMAP(a, s)   MUNMAP_DEFAULT((a), (s))
 
#define CALL_DIRECT_MMAP(s)   DIRECT_MMAP_DEFAULT(s)
 
#define CALL_MREMAP(addr, osz, nsz, mv)   MFAIL
 Define CALL_MREMAP. More...
 
#define USE_NONCONTIGUOUS_BIT   (4U)
 
#define EXTERN_BIT   (8U)
 
#define USE_LOCK_BIT   (0U)
 
#define INITIAL_LOCK(l)
 
#define ACQUIRE_MALLOC_GLOBAL_LOCK()
 
#define RELEASE_MALLOC_GLOBAL_LOCK()
 
#define MCHUNK_SIZE   (sizeof(mchunk))
 
#define CHUNK_OVERHEAD   (SIZE_T_SIZE)
 
#define MMAP_CHUNK_OVERHEAD   (TWO_SIZE_T_SIZES)
 
#define MMAP_FOOT_PAD   (FOUR_SIZE_T_SIZES)
 
#define MIN_CHUNK_SIZE   ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
 
#define chunk2mem(p)   ((void*)((char*)(p) + TWO_SIZE_T_SIZES))
 
#define mem2chunk(mem)   ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))
 
#define align_as_chunk(A)   (mchunkptr)((A) + align_offset(chunk2mem(A)))
 
#define MAX_REQUEST   ((-MIN_CHUNK_SIZE) << 2)
 
#define MIN_REQUEST   (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
 
#define pad_request(req)   (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
 
#define request2size(req)   (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
 
#define PINUSE_BIT   (SIZE_T_ONE)
 
#define CINUSE_BIT   (SIZE_T_TWO)
 
#define FLAG4_BIT   (SIZE_T_FOUR)
 
#define INUSE_BITS   (PINUSE_BIT|CINUSE_BIT)
 
#define FLAG_BITS   (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT)
 
#define FENCEPOST_HEAD   (INUSE_BITS|SIZE_T_SIZE)
 
#define cinuse(p)   ((p)->head & CINUSE_BIT)
 
#define pinuse(p)   ((p)->head & PINUSE_BIT)
 
#define is_inuse(p)   (((p)->head & INUSE_BITS) != PINUSE_BIT)
 
#define is_mmapped(p)   (((p)->head & INUSE_BITS) == 0)
 
#define chunksize(p)   ((p)->head & ~(FLAG_BITS))
 
#define clear_pinuse(p)   ((p)->head &= ~PINUSE_BIT)
 
#define chunk_plus_offset(p, s)   ((mchunkptr)(((char*)(p)) + (s)))
 
#define chunk_minus_offset(p, s)   ((mchunkptr)(((char*)(p)) - (s)))
 
#define next_chunk(p)   ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS)))
 
#define prev_chunk(p)   ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))
 
#define next_pinuse(p)   ((next_chunk(p)->head) & PINUSE_BIT)
 
#define get_foot(p, s)   (((mchunkptr)((char*)(p) + (s)))->prev_foot)
 
#define set_foot(p, s)   (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))
 
#define set_size_and_pinuse_of_free_chunk(p, s)   ((p)->head = (s|PINUSE_BIT), set_foot(p, s))
 
#define set_free_with_pinuse(p, s, n)   (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))
 
#define overhead_for(p)   (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)
 
#define calloc_must_clear(p)   (!is_mmapped(p))
 
#define leftmost_child(t)   ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
 
#define is_mmapped_segment(S)   ((S)->sflags & USE_MMAP_BIT)
 
#define is_extern_segment(S)   ((S)->sflags & EXTERN_BIT)
 
#define NSMALLBINS   (32U)
 
#define NTREEBINS   (32U)
 
#define SMALLBIN_SHIFT   (3U)
 
#define SMALLBIN_WIDTH   (SIZE_T_ONE << SMALLBIN_SHIFT)
 
#define TREEBIN_SHIFT   (8U)
 
#define MIN_LARGE_SIZE   (SIZE_T_ONE << TREEBIN_SHIFT)
 
#define MAX_SMALL_SIZE   (MIN_LARGE_SIZE - SIZE_T_ONE)
 
#define MAX_SMALL_REQUEST   (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)
 
#define ensure_initialization()   (void)(mparams.magic != 0 || init_mparams())
 
#define gm   (&_gm_)
 
#define is_global(M)   ((M) == &_gm_)
 
#define is_initialized(M)   ((M)->top != 0)
 
#define use_lock(M)   ((M)->mflags & USE_LOCK_BIT)
 
#define enable_lock(M)   ((M)->mflags |= USE_LOCK_BIT)
 
#define disable_lock(M)   ((M)->mflags &= ~USE_LOCK_BIT)
 
#define use_mmap(M)   ((M)->mflags & USE_MMAP_BIT)
 
#define enable_mmap(M)   ((M)->mflags |= USE_MMAP_BIT)
 
#define disable_mmap(M)   ((M)->mflags &= ~USE_MMAP_BIT)
 
#define use_noncontiguous(M)   ((M)->mflags & USE_NONCONTIGUOUS_BIT)
 
#define disable_contiguous(M)   ((M)->mflags |= USE_NONCONTIGUOUS_BIT)
 
#define set_lock(M, L)
 
#define page_align(S)   (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE))
 
#define granularity_align(S)
 
#define mmap_align(S)   page_align(S)
 
#define SYS_ALLOC_PADDING   (TOP_FOOT_SIZE + MALLOC_ALIGNMENT)
 
#define is_page_aligned(S)   (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)
 
#define is_granularity_aligned(S)   (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)
 
#define segment_holds(S, A)   ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
 
#define should_trim(M, s)   ((s) > (M)->trim_check)
 
#define TOP_FOOT_SIZE   (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
 
#define PREACTION(M)   (0)
 
#define POSTACTION(M)
 
#define CORRUPTION_ERROR_ACTION(m)   ABORT
 
#define USAGE_ERROR_ACTION(m, p)   ABORT
 
#define check_free_chunk(M, P)
 
#define check_inuse_chunk(M, P)
 
#define check_malloced_chunk(M, P, N)
 
#define check_mmapped_chunk(M, P)
 
#define check_malloc_state(M)
 
#define check_top_chunk(M, P)
 
#define is_small(s)   (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)
 
#define small_index(s)   ((s) >> SMALLBIN_SHIFT)
 
#define small_index2size(i)   ((i) << SMALLBIN_SHIFT)
 
#define MIN_SMALL_INDEX   (small_index(MIN_CHUNK_SIZE))
 
#define smallbin_at(M, i)   ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))
 
#define treebin_at(M, i)   (&((M)->treebins[i]))
 
#define compute_tree_index(S, I)
 
#define bit_for_tree_index(i)   (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)
 
#define leftshift_for_tree_index(i)
 
#define minsize_for_tree_index(i)
 
#define idx2bit(i)   ((binmap_t)(1) << (i))
 
#define mark_smallmap(M, i)   ((M)->smallmap |= idx2bit(i))
 
#define clear_smallmap(M, i)   ((M)->smallmap &= ~idx2bit(i))
 
#define smallmap_is_marked(M, i)   ((M)->smallmap & idx2bit(i))
 
#define mark_treemap(M, i)   ((M)->treemap |= idx2bit(i))
 
#define clear_treemap(M, i)   ((M)->treemap &= ~idx2bit(i))
 
#define treemap_is_marked(M, i)   ((M)->treemap & idx2bit(i))
 
#define least_bit(x)   ((x) & -(x))
 
#define left_bits(x)   ((x<<1) | -(x<<1))
 
#define same_or_left_bits(x)   ((x) | -(x))
 
#define compute_bit2idx(X, I)
 
#define ok_address(M, a)   ((char*)(a) >= (M)->least_addr)
 
#define ok_next(p, n)   ((char*)(p) < (char*)(n))
 
#define ok_inuse(p)   is_inuse(p)
 
#define ok_pinuse(p)   pinuse(p)
 
#define ok_magic(M)   (1)
 
#define RTCHECK(e)   (e)
 
#define mark_inuse_foot(M, p, s)
 
#define set_inuse(M, p, s)
 
#define set_inuse_and_pinuse(M, p, s)
 
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)   ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))
 
#define insert_small_chunk(M, P, S)
 
#define unlink_small_chunk(M, P, S)
 
#define unlink_first_small_chunk(M, B, P, I)
 
#define replace_dv(M, P, S)
 
#define insert_large_chunk(M, X, S)
 
#define unlink_large_chunk(M, X)
 
#define insert_chunk(M, P, S)
 
#define unlink_chunk(M, P, S)
 
#define internal_malloc(m, b)   (m == gm)? dlmalloc(b) : mspace_malloc(m, b)
 
#define internal_free(m, mem)   if (m == gm) dlfree(mem); else mspace_free(m,mem);
 
#define fm   gm
 

Typedefs

typedef void * mspace
 
typedef struct malloc_chunk mchunk
 
typedef struct malloc_chunkmchunkptr
 
typedef struct malloc_chunksbinptr
 
typedef unsigned int bindex_t
 
typedef unsigned int binmap_t
 
typedef unsigned int flag_t
 
typedef struct malloc_tree_chunk tchunk
 
typedef struct malloc_tree_chunktchunkptr
 
typedef struct malloc_tree_chunktbinptr
 
typedef struct malloc_segment msegment
 
typedef struct malloc_segmentmsegmentptr
 
typedef struct malloc_statemstate
 

Functions

void * dlmalloc (size_t)
 
void dlfree (void *)
 
void * dlcalloc (size_t, size_t)
 
void * dlrealloc (void *, size_t)
 
void * dlmemalign (size_t, size_t)
 
void * dlvalloc (size_t)
 
int dlmallopt (int, int)
 
size_t dlmalloc_footprint (void)
 
size_t dlmalloc_max_footprint (void)
 
struct mallinfo dlmallinfo (void)
 
void ** dlindependent_calloc (size_t, size_t, void **)
 
void ** dlindependent_comalloc (size_t, size_t *, void **)
 
void * dlpvalloc (size_t)
 
int dlmalloc_trim (size_t)
 
void dlmalloc_stats (void)
 
size_t dlmalloc_usable_size (void *)
 
mspace create_mspace (size_t capacity, int locked)
 
size_t destroy_mspace (mspace msp)
 
mspace create_mspace_with_base (void *base, size_t capacity, int locked)
 
int mspace_track_large_chunks (mspace msp, int enable)
 
void * mspace_malloc (mspace msp, size_t bytes)
 
void mspace_free (mspace msp, void *mem)
 
void * mspace_realloc (mspace msp, void *mem, size_t newsize)
 
void * mspace_calloc (mspace msp, size_t n_elements, size_t elem_size)
 
void * mspace_memalign (mspace msp, size_t alignment, size_t bytes)
 
void ** mspace_independent_calloc (mspace msp, size_t n_elements, size_t elem_size, void *chunks[])
 
void ** mspace_independent_comalloc (mspace msp, size_t n_elements, size_t sizes[], void *chunks[])
 
size_t mspace_footprint (mspace msp)
 
size_t mspace_max_footprint (mspace msp)
 
struct mallinfo mspace_mallinfo (mspace msp)
 
size_t mspace_usable_size (void *mem)
 
void mspace_malloc_stats (mspace msp)
 
int mspace_trim (mspace msp, size_t pad)
 
int mspace_mallopt (int, int)
 
static msegmentptr segment_holding (mstate m, char *addr)
 
static int has_segment_link (mstate m, msegmentptr ss)
 
static int init_mparams (void)
 
static int change_mparam (int param_number, int value)
 
static struct mallinfo internal_mallinfo (mstate m)
 
static void internal_malloc_stats (mstate m)
 
static void * mmap_alloc (mstate m, size_t nb)
 
static mchunkptr mmap_resize (mstate m, mchunkptr oldp, size_t nb)
 
static void init_top (mstate m, mchunkptr p, size_t psize)
 
static void init_bins (mstate m)
 
static void * prepend_alloc (mstate m, char *newbase, char *oldbase, size_t nb)
 
static void add_segment (mstate m, char *tbase, size_t tsize, flag_t mmapped)
 
static void * sys_alloc (mstate m, size_t nb)
 
static size_t release_unused_segments (mstate m)
 
static int sys_trim (mstate m, size_t pad)
 
static void * tmalloc_large (mstate m, size_t nb)
 
static void * tmalloc_small (mstate m, size_t nb)
 
static void * internal_realloc (mstate m, void *oldmem, size_t bytes)
 
static void * internal_memalign (mstate m, size_t alignment, size_t bytes)
 
static void ** ialloc (mstate m, size_t n_elements, size_t *sizes, int opts, void *chunks[])
 
void ** dlindependent_calloc (size_t n_elements, size_t elem_size, void *chunks[])
 
void ** dlindependent_comalloc (size_t n_elements, size_t sizes[], void *chunks[])
 
static mstate init_user_mstate (char *tbase, size_t tsize)
 

Variables

static G4ThreadLocal int dev_zero_fd = -1
 
static G4ThreadLocal struct
malloc_params 
mparams
 
static G4ThreadLocal struct
malloc_state 
_gm_
 

Macro Definition Documentation

#define ABORT   abort()

Definition at line 566 of file mymalloc.cc.

Referenced by init_mparams().

#define ABORT_ON_ASSERT_FAILURE   1

Definition at line 569 of file mymalloc.cc.

#define ACQUIRE_MALLOC_GLOBAL_LOCK ( )

Definition at line 1915 of file mymalloc.cc.

Referenced by init_mparams(), sys_alloc(), and sys_trim().

#define align_as_chunk (   A)    (mchunkptr)((A) + align_offset(chunk2mem(A)))
#define align_offset (   A)
Value:
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
#define CHUNK_ALIGN_MASK
Definition: mymalloc.cc:1456
static const G4double A[nN]
#define MALLOC_ALIGNMENT
Definition: mymalloc.cc:560

Definition at line 1462 of file mymalloc.cc.

Referenced by add_segment(), init_top(), and mmap_alloc().

#define assert (   x)

Definition at line 1309 of file mymalloc.cc.

Referenced by add_segment(), G4VoxelLimits::AddLimit(), addThread(), G4VUserDetectorConstruction::CloneF(), G4VUserDetectorConstruction::CloneSD(), Run::ComputeStatistics(), G4OpenInventorXtExaminerViewer::constructor(), G4WorkerRunManager::ConstructScoringWorlds(), G4VisManager::CurrentTrajDrawModel(), G4MagneticFieldModel::DescribeYourselfTo(), G4VisManager::DispatchToModel(), G4OpenInventorXtExaminerViewer::distanceToTrajectory(), dlmalloc(), G4TrajectoryDrawByOriginVolume::Draw(), G4TrajectoryDrawByAttribute::Draw(), ElectronRunAction::EndOfRunAction(), G4TrajectoryOriginVolumeFilter::Evaluate(), tbbTask::execute(), FinishDetection(), finishtracer(), G4AtomicShells::GetBindingEnergy(), G4VTrajectoryModel::GetContext(), G4HepRepSceneHandler::getGeometryOrEventInstance(), G4SandiaTable::GetIonizationPot(), G4SandiaTable::GetNbOfIntervals(), G4AttFilterUtils::GetNewFilter(), G4AtomicShells::GetNumberOfElectrons(), G4AtomicShells::GetNumberOfShells(), G4SandiaTable::GetSandiaCofForMaterial(), G4SandiaTable::GetSandiaCofForMaterialPAI(), G4SandiaTable::GetSandiaCofPerAtom(), G4SandiaTable::GetSandiaMatTable(), G4SandiaTable::GetSandiaMatTablePAI(), G4SandiaTable::GetSandiaPerAtom(), G4OpenInventorXtExaminerViewer::getSuperimpositionNode(), G4AtomicShells::GetTotalBindingEnergy(), G4SandiaTable::GetZtoA(), handler0(), handler1(), ialloc(), insertAddress(), internal_memalign(), mmap_alloc(), mspace_malloc(), prepend_alloc(), ElectronRun::RecordEvent(), G4VisListManager< T >::Register(), G4ITModelHandler::RegisterModel(), release_unused_segments(), G4VoxelSafety::SafetyForVoxelHeader(), G4ITModelManager::SetModel(), G4ITModelHandler::SetModel(), G4VisCommandListManagerList< Manager >::SetNewValue(), G4VisCommandModelCreate< Factory >::SetNewValue(), G4VisCommandListManagerSelect< Manager >::SetNewValue(), G4VisCommandManagerMode< Manager >::SetNewValue(), G3Division::SetRangeAndAxis(), G4WorkerRunManager::SetupDefaultRNGEngine(), StartDetection(), tmalloc_large(), tmalloc_small(), G4OpenInventorXtExaminerViewer::updateSpeedIndicator(), and XML_GetParsingStatus().

#define bit_for_tree_index (   i)    (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)

Definition at line 2757 of file mymalloc.cc.

#define CALL_DIRECT_MMAP (   s)    DIRECT_MMAP_DEFAULT(s)

Definition at line 1583 of file mymalloc.cc.

Referenced by mmap_alloc().

#define CALL_MMAP (   s)    MMAP_DEFAULT(s)

Definition at line 1573 of file mymalloc.cc.

Referenced by create_mspace(), and sys_alloc().

#define CALL_MORECORE (   S)    MORECORE_DEFAULT(S)

Define CALL_MORECORE.

Definition at line 1558 of file mymalloc.cc.

Referenced by sys_alloc(), and sys_trim().

#define CALL_MREMAP (   addr,
  osz,
  nsz,
  mv 
)    MFAIL

Define CALL_MREMAP.

Definition at line 1606 of file mymalloc.cc.

Referenced by mmap_resize(), and sys_trim().

#define CALL_MUNMAP (   a,
  s 
)    MUNMAP_DEFAULT((a), (s))

Definition at line 1578 of file mymalloc.cc.

Referenced by destroy_mspace(), dlfree(), mspace_free(), release_unused_segments(), and sys_trim().

#define calloc_must_clear (   p)    (!is_mmapped(p))

Definition at line 2167 of file mymalloc.cc.

Referenced by dlcalloc(), and mspace_calloc().

#define check_free_chunk (   M,
 
)

Definition at line 2651 of file mymalloc.cc.

Referenced by dlfree(), mspace_free(), and prepend_alloc().

#define check_inuse_chunk (   M,
 
)

Definition at line 2652 of file mymalloc.cc.

Referenced by dlfree(), ialloc(), internal_memalign(), internal_realloc(), and mspace_free().

#define check_malloc_state (   M)

Definition at line 2655 of file mymalloc.cc.

Referenced by internal_mallinfo(), and internal_malloc_stats().

#define check_malloced_chunk (   M,
  P,
 
)

Definition at line 2653 of file mymalloc.cc.

Referenced by dlmalloc(), mspace_malloc(), prepend_alloc(), and sys_alloc().

#define check_mmapped_chunk (   M,
 
)

Definition at line 2654 of file mymalloc.cc.

Referenced by mmap_alloc(), and mmap_resize().

#define check_top_chunk (   M,
 
)
#define CHUNK_ALIGN_MASK   (MALLOC_ALIGNMENT - SIZE_T_ONE)

Definition at line 1456 of file mymalloc.cc.

Referenced by add_segment(), mmap_alloc(), and mmap_resize().

#define chunk_minus_offset (   p,
  s 
)    ((mchunkptr)(((char*)(p)) - (s)))

Definition at line 2140 of file mymalloc.cc.

Referenced by dlfree(), and mspace_free().

#define CHUNK_OVERHEAD   (SIZE_T_SIZE)

Definition at line 2078 of file mymalloc.cc.

Referenced by ialloc(), and internal_memalign().

#define chunk_plus_offset (   p,
  s 
)    ((mchunkptr)(((char*)(p)) + (s)))
#define cinuse (   p)    ((p)->head & CINUSE_BIT)

Definition at line 2129 of file mymalloc.cc.

Referenced by dlfree(), and mspace_free().

#define CINUSE_BIT   (SIZE_T_TWO)

Definition at line 2120 of file mymalloc.cc.

#define clear_pinuse (   p)    ((p)->head &= ~PINUSE_BIT)

Definition at line 2136 of file mymalloc.cc.

#define clear_smallmap (   M,
 
)    ((M)->smallmap &= ~idx2bit(i))

Definition at line 2778 of file mymalloc.cc.

#define clear_treemap (   M,
 
)    ((M)->treemap &= ~idx2bit(i))

Definition at line 2782 of file mymalloc.cc.

#define CMFAIL   ((char*)(MFAIL)) /* defined for convenience */

Definition at line 1477 of file mymalloc.cc.

Referenced by create_mspace(), mmap_alloc(), mmap_resize(), sys_alloc(), and sys_trim().

#define compute_bit2idx (   X,
 
)
Value:
{\
unsigned int Y = X - 1;\
unsigned int K = Y >> (16-4) & 16;\
unsigned int N = K; Y >>= K;\
N += K = Y >> (8-3) & 8; Y >>= K;\
N += K = Y >> (4-2) & 4; Y >>= K;\
N += K = Y >> (2-1) & 2; Y >>= K;\
N += K = Y >> (1-0) & 1; Y >>= K;\
I = (bindex_t)(N + Y);\
}
unsigned int bindex_t
Definition: mymalloc.cc:2067

Definition at line 2824 of file mymalloc.cc.

Referenced by dlmalloc(), mspace_malloc(), tmalloc_large(), and tmalloc_small().

#define compute_tree_index (   S,
 
)
Value:
{\
size_t X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
else {\
unsigned int Y = (unsigned int)X;\
unsigned int N = ((Y - 0x100) >> 16) & 8;\
unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\
N += K;\
N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\
K = 14 - N + ((Y <<= K) >> 15);\
I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\
}\
}
#define TREEBIN_SHIFT
Definition: mymalloc.cc:2441
#define NTREEBINS
Definition: mymalloc.cc:2438

Definition at line 2737 of file mymalloc.cc.

Referenced by tmalloc_large().

#define CORRUPTION_ERROR_ACTION (   m)    ABORT

Definition at line 2638 of file mymalloc.cc.

Referenced by tmalloc_large(), and tmalloc_small().

#define DEFAULT_GRANULARITY   (0) /* 0 means to compute in init_mparams */

Definition at line 620 of file mymalloc.cc.

Referenced by init_mparams().

#define DEFAULT_MMAP_THRESHOLD   ((size_t)256U * (size_t)1024U)

Definition at line 634 of file mymalloc.cc.

Referenced by init_mparams().

#define DEFAULT_TRIM_THRESHOLD   ((size_t)2U * (size_t)1024U * (size_t)1024U)

Definition at line 627 of file mymalloc.cc.

Referenced by init_mparams().

#define DIRECT_MMAP_DEFAULT (   s)    MMAP_DEFAULT(s)

Definition at line 1503 of file mymalloc.cc.

#define disable_contiguous (   M)    ((M)->mflags |= USE_NONCONTIGUOUS_BIT)

Definition at line 2519 of file mymalloc.cc.

Referenced by init_user_mstate(), and sys_alloc().

#define disable_lock (   M)    ((M)->mflags &= ~USE_LOCK_BIT)

Definition at line 2512 of file mymalloc.cc.

#define disable_mmap (   M)    ((M)->mflags &= ~USE_MMAP_BIT)

Definition at line 2516 of file mymalloc.cc.

Referenced by ialloc(), and mspace_track_large_chunks().

#define dlcalloc   mycalloc

Definition at line 760 of file mymalloc.cc.

#define dlfree   myfree

Definition at line 761 of file mymalloc.cc.

Referenced by dlrealloc().

#define dlindependent_calloc   myindependent_calloc

Definition at line 774 of file mymalloc.cc.

#define dlindependent_comalloc   myindependent_comalloc

Definition at line 775 of file mymalloc.cc.

#define dlmallinfo   mymallinfo

Definition at line 767 of file mymalloc.cc.

#define dlmalloc   mymalloc

Definition at line 762 of file mymalloc.cc.

Referenced by dlcalloc(), and dlrealloc().

#define dlmalloc_footprint   mymalloc_footprint

Definition at line 772 of file mymalloc.cc.

#define dlmalloc_max_footprint   mymalloc_max_footprint

Definition at line 773 of file mymalloc.cc.

void dlmalloc_stats   mymalloc_stats

Definition at line 770 of file mymalloc.cc.

#define dlmalloc_trim   mymalloc_trim

Definition at line 769 of file mymalloc.cc.

#define dlmalloc_usable_size   mymalloc_usable_size

Definition at line 771 of file mymalloc.cc.

#define DLMALLOC_VERSION   20804

Definition at line 488 of file mymalloc.cc.

#define dlmallopt   mymallopt

Definition at line 768 of file mymalloc.cc.

#define dlmemalign   mymemalign

Definition at line 763 of file mymalloc.cc.

Referenced by dlpvalloc(), and dlvalloc().

#define dlpvalloc   mypvalloc

Definition at line 766 of file mymalloc.cc.

#define dlrealloc   myrealloc

Definition at line 764 of file mymalloc.cc.

#define dlvalloc   myvalloc

Definition at line 765 of file mymalloc.cc.

#define enable_lock (   M)    ((M)->mflags |= USE_LOCK_BIT)

Definition at line 2511 of file mymalloc.cc.

#define enable_mmap (   M)    ((M)->mflags |= USE_MMAP_BIT)

Definition at line 2515 of file mymalloc.cc.

Referenced by ialloc(), and mspace_track_large_chunks().

#define ensure_initialization ( )    (void)(mparams.magic != 0 || init_mparams())
#define EXTERN_BIT   (8U)

Definition at line 1613 of file mymalloc.cc.

Referenced by create_mspace_with_base(), and destroy_mspace().

#define FENCEPOST_HEAD   (INUSE_BITS|SIZE_T_SIZE)
#define FLAG4_BIT   (SIZE_T_FOUR)

Definition at line 2121 of file mymalloc.cc.

#define FLAG_BITS   (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT)

Definition at line 2123 of file mymalloc.cc.

#define FOOTERS   0

Definition at line 563 of file mymalloc.cc.

#define FORCEINLINE

Definition at line 752 of file mymalloc.cc.

#define FOUR_SIZE_T_SIZES   (SIZE_T_SIZE<<2)

Definition at line 1451 of file mymalloc.cc.

Referenced by add_segment().

#define get_foot (   p,
  s 
)    (((mchunkptr)((char*)(p) + (s)))->prev_foot)

Definition at line 2150 of file mymalloc.cc.

#define granularity_align (   S)
Value:
#define SIZE_T_ONE
Definition: mymalloc.cc:1447
static G4ThreadLocal struct malloc_params mparams
Definition: mymalloc.cc:2490
size_t granularity
Definition: mymalloc.cc:2484

Definition at line 2531 of file mymalloc.cc.

Referenced by create_mspace(), and sys_alloc().

#define HALF_MAX_SIZE_T   (MAX_SIZE_T / 2U)

Definition at line 1453 of file mymalloc.cc.

Referenced by sys_alloc(), and sys_trim().

#define HAVE_MMAP   1

Definition at line 588 of file mymalloc.cc.

Referenced by create_mspace(), sys_alloc(), and sys_trim().

#define HAVE_MORECORE   1

Definition at line 607 of file mymalloc.cc.

Referenced by create_mspace(), sys_alloc(), and sys_trim().

#define HAVE_MREMAP   0

Definition at line 597 of file mymalloc.cc.

#define idx2bit (   i)    ((binmap_t)(1) << (i))

Definition at line 2774 of file mymalloc.cc.

Referenced by dlmalloc(), mspace_malloc(), and tmalloc_large().

#define INITIAL_LOCK (   l)

Definition at line 1904 of file mymalloc.cc.

Referenced by init_mparams(), and init_user_mstate().

#define INSECURE   0

Definition at line 585 of file mymalloc.cc.

#define insert_chunk (   M,
  P,
 
)
Value:
if (is_small(S)) insert_small_chunk(M, P, S)\
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }
struct malloc_tree_chunk * tchunkptr
Definition: mymalloc.cc:2276
#define insert_small_chunk(M, P, S)
Definition: mymalloc.cc:3415
#define is_small(s)
Definition: mymalloc.cc:2682
#define insert_large_chunk(M, X, S)
Definition: mymalloc.cc:3488

Definition at line 3629 of file mymalloc.cc.

Referenced by add_segment(), prepend_alloc(), and tmalloc_large().

#define insert_large_chunk (   M,
  X,
 
)

Definition at line 3488 of file mymalloc.cc.

Referenced by dlfree(), mspace_free(), and release_unused_segments().

#define insert_small_chunk (   M,
  P,
 
)
Value:
{\
if (!smallmap_is_marked(M, I))\
else if (RTCHECK(ok_address(M, B->fd)))\
F = B->fd;\
else {\
}\
B->fd = P;\
F->bk = P;\
P->fd = F;\
P->bk = B;\
}
#define CORRUPTION_ERROR_ACTION(m)
Definition: mymalloc.cc:2638
struct malloc_chunk * mchunkptr
Definition: mymalloc.cc:2065
#define assert(x)
Definition: mymalloc.cc:1309
#define mark_smallmap(M, i)
Definition: mymalloc.cc:2777
#define smallbin_at(M, i)
Definition: mymalloc.cc:2688
unsigned int bindex_t
Definition: mymalloc.cc:2067
#define smallmap_is_marked(M, i)
Definition: mymalloc.cc:2779
#define small_index(s)
Definition: mymalloc.cc:2683
#define ok_address(M, a)
Definition: mymalloc.cc:2868
#define MIN_CHUNK_SIZE
Definition: mymalloc.cc:2087
#define RTCHECK(e)
Definition: mymalloc.cc:2896

Definition at line 3415 of file mymalloc.cc.

Referenced by dlfree(), and mspace_free().

#define internal_free (   m,
  mem 
)    if (m == gm) dlfree(mem); else mspace_free(m,mem);

Definition at line 3647 of file mymalloc.cc.

Referenced by internal_memalign(), and internal_realloc().

#define internal_malloc (   m,
 
)    (m == gm)? dlmalloc(b) : mspace_malloc(m, b)

Definition at line 3645 of file mymalloc.cc.

Referenced by ialloc(), internal_memalign(), internal_realloc(), and mspace_calloc().

#define INUSE_BITS   (PINUSE_BIT|CINUSE_BIT)

Definition at line 2122 of file mymalloc.cc.

Referenced by dlfree(), init_user_mstate(), and mspace_free().

#define is_aligned (   A)    (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)

Definition at line 1459 of file mymalloc.cc.

Referenced by add_segment(), and mmap_alloc().

#define is_extern_segment (   S)    ((S)->sflags & EXTERN_BIT)

Definition at line 2347 of file mymalloc.cc.

Referenced by release_unused_segments(), sys_alloc(), and sys_trim().

#define is_global (   M)    ((M) == &_gm_)

Definition at line 2500 of file mymalloc.cc.

Referenced by sys_alloc().

#define is_granularity_aligned (   S)    (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)

Definition at line 2548 of file mymalloc.cc.

#define is_initialized (   M)    ((M)->top != 0)

Definition at line 2504 of file mymalloc.cc.

Referenced by internal_mallinfo(), internal_malloc_stats(), sys_alloc(), and sys_trim().

#define is_inuse (   p)    (((p)->head & INUSE_BITS) != PINUSE_BIT)
#define is_mmapped (   p)    (((p)->head & INUSE_BITS) == 0)

Definition at line 2132 of file mymalloc.cc.

Referenced by dlfree(), ialloc(), internal_memalign(), internal_realloc(), and mspace_free().

#define is_mmapped_segment (   S)    ((S)->sflags & USE_MMAP_BIT)

Definition at line 2346 of file mymalloc.cc.

Referenced by release_unused_segments(), and sys_trim().

#define is_page_aligned (   S)    (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)

Definition at line 2546 of file mymalloc.cc.

Referenced by sys_alloc().

#define is_small (   s)    (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)

Definition at line 2682 of file mymalloc.cc.

Referenced by dlfree(), mmap_resize(), and mspace_free().

#define least_bit (   x)    ((x) & -(x))

Definition at line 2786 of file mymalloc.cc.

Referenced by dlmalloc(), mspace_malloc(), tmalloc_large(), and tmalloc_small().

#define left_bits (   x)    ((x<<1) | -(x<<1))

Definition at line 2789 of file mymalloc.cc.

Referenced by dlmalloc(), mspace_malloc(), and tmalloc_large().

#define leftmost_child (   t)    ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])

Definition at line 2280 of file mymalloc.cc.

Referenced by tmalloc_large(), and tmalloc_small().

#define leftshift_for_tree_index (   i)
Value:
((i == NTREEBINS-1)? 0 : \
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))
#define SIZE_T_ONE
Definition: mymalloc.cc:1447
#define TREEBIN_SHIFT
Definition: mymalloc.cc:2441
#define NTREEBINS
Definition: mymalloc.cc:2438
#define SIZE_T_BITSIZE
Definition: mymalloc.cc:1442

Definition at line 2761 of file mymalloc.cc.

Referenced by tmalloc_large().

#define M_GRANULARITY   (-2)

Definition at line 670 of file mymalloc.cc.

Referenced by change_mparam().

#define M_MMAP_THRESHOLD   (-3)

Definition at line 671 of file mymalloc.cc.

Referenced by change_mparam().

#define M_TRIM_THRESHOLD   (-1)

Definition at line 669 of file mymalloc.cc.

Referenced by change_mparam().

#define MALLINFO_FIELD_TYPE   size_t

Definition at line 656 of file mymalloc.cc.

#define MALLOC_ALIGNMENT   ((size_t)8U)

Definition at line 560 of file mymalloc.cc.

Referenced by init_mparams(), and internal_memalign().

#define MALLOC_FAILURE_ACTION   errno = ENOMEM;

Definition at line 601 of file mymalloc.cc.

Referenced by internal_memalign(), internal_realloc(), and sys_alloc().

#define malloc_getpagesize   ((size_t)4096U)

Definition at line 1425 of file mymalloc.cc.

Referenced by init_mparams().

#define mark_inuse_foot (   M,
  p,
  s 
)

Definition at line 2906 of file mymalloc.cc.

Referenced by mmap_alloc(), and mmap_resize().

#define mark_smallmap (   M,
 
)    ((M)->smallmap |= idx2bit(i))

Definition at line 2777 of file mymalloc.cc.

#define mark_treemap (   M,
 
)    ((M)->treemap |= idx2bit(i))

Definition at line 2781 of file mymalloc.cc.

#define MAX_RELEASE_CHECK_RATE   4095

Definition at line 641 of file mymalloc.cc.

Referenced by init_user_mstate(), release_unused_segments(), and sys_alloc().

#define MAX_REQUEST   ((-MIN_CHUNK_SIZE) << 2)

Definition at line 2097 of file mymalloc.cc.

Referenced by dlmalloc(), internal_memalign(), internal_realloc(), mspace_malloc(), and sys_trim().

#define MAX_SIZE_T   (~(size_t)0)
#define MAX_SMALL_REQUEST   (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)

Definition at line 2444 of file mymalloc.cc.

Referenced by dlmalloc(), and mspace_malloc().

#define MAX_SMALL_SIZE   (MIN_LARGE_SIZE - SIZE_T_ONE)

Definition at line 2443 of file mymalloc.cc.

#define MCHUNK_SIZE   (sizeof(mchunk))

Definition at line 2073 of file mymalloc.cc.

Referenced by init_mparams().

#define MFAIL   ((void*)(MAX_SIZE_T))

Definition at line 1476 of file mymalloc.cc.

Referenced by sys_trim().

#define MIN_LARGE_SIZE   (SIZE_T_ONE << TREEBIN_SHIFT)

Definition at line 2442 of file mymalloc.cc.

#define MIN_REQUEST   (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)

Definition at line 2098 of file mymalloc.cc.

Referenced by dlmalloc(), and mspace_malloc().

#define MIN_SMALL_INDEX   (small_index(MIN_CHUNK_SIZE))

Definition at line 2685 of file mymalloc.cc.

#define minsize_for_tree_index (   i)
Value:
((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \
(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))
#define SIZE_T_ONE
Definition: mymalloc.cc:1447
#define TREEBIN_SHIFT
Definition: mymalloc.cc:2441

Definition at line 2766 of file mymalloc.cc.

#define mmap_align (   S)    page_align(S)

Definition at line 2540 of file mymalloc.cc.

Referenced by mmap_alloc(), and mmap_resize().

#define MMAP_CHUNK_OVERHEAD   (TWO_SIZE_T_SIZES)

Definition at line 2082 of file mymalloc.cc.

#define MMAP_CLEARS   1

Definition at line 591 of file mymalloc.cc.

#define MMAP_DEFAULT (   s)
Value:
((dev_zero_fd < 0) ? \
(dev_zero_fd = open("/dev/zero", O_RDWR), \
mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \
mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0))
static G4ThreadLocal int dev_zero_fd
Definition: mymalloc.cc:1496
#define MMAP_FLAGS
Definition: mymalloc.cc:1495
static const double s
Definition: G4SIunits.hh:150
#define MMAP_PROT
Definition: mymalloc.cc:1483

Definition at line 1497 of file mymalloc.cc.

#define MMAP_FLAGS   (MAP_PRIVATE)

Definition at line 1495 of file mymalloc.cc.

#define MMAP_FOOT_PAD   (FOUR_SIZE_T_SIZES)

Definition at line 2084 of file mymalloc.cc.

Referenced by dlfree(), mmap_alloc(), mmap_resize(), and mspace_free().

#define MMAP_PROT   (PROT_READ|PROT_WRITE)

Definition at line 1483 of file mymalloc.cc.

#define MORECORE_CONTIGUOUS   1

Definition at line 615 of file mymalloc.cc.

Referenced by sys_alloc().

#define MORECORE_DEFAULT   sbrk

Definition at line 613 of file mymalloc.cc.

#define MSPACES   1

Definition at line 485 of file mymalloc.cc.

Referenced by create_mspace().

#define MUNMAP_DEFAULT (   a,
  s 
)    munmap((a), (s))

Definition at line 1482 of file mymalloc.cc.

#define next_chunk (   p)    ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS)))
#define next_pinuse (   p)    ((next_chunk(p)->head) & PINUSE_BIT)

Definition at line 2147 of file mymalloc.cc.

#define NO_MALLINFO   0

Definition at line 653 of file mymalloc.cc.

#define NO_SEGMENT_TRAVERSAL   0

Definition at line 659 of file mymalloc.cc.

Referenced by release_unused_segments(), and sys_alloc().

#define NOINLINE

Definition at line 741 of file mymalloc.cc.

#define NSMALLBINS   (32U)

Definition at line 2437 of file mymalloc.cc.

Referenced by init_bins().

#define NTREEBINS   (32U)

Definition at line 2438 of file mymalloc.cc.

#define ok_address (   M,
  a 
)    ((char*)(a) >= (M)->least_addr)

Definition at line 2868 of file mymalloc.cc.

Referenced by dlfree(), internal_realloc(), mspace_free(), tmalloc_large(), and tmalloc_small().

#define ok_inuse (   p)    is_inuse(p)

Definition at line 2872 of file mymalloc.cc.

Referenced by dlfree(), internal_realloc(), and mspace_free().

#define ok_next (   p,
  n 
)    ((char*)(p) < (char*)(n))

Definition at line 2870 of file mymalloc.cc.

Referenced by dlfree(), internal_realloc(), mspace_free(), tmalloc_large(), and tmalloc_small().

#define ok_pinuse (   p)    pinuse(p)

Definition at line 2874 of file mymalloc.cc.

Referenced by dlfree(), internal_realloc(), and mspace_free().

#define ONLY_MSPACES   0 /* define to a value */

Definition at line 548 of file mymalloc.cc.

Referenced by create_mspace().

#define overhead_for (   p)    (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)

Definition at line 2162 of file mymalloc.cc.

Referenced by dlmalloc_usable_size(), internal_realloc(), and mspace_usable_size().

#define pad_request (   req)    (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
#define page_align (   S)    (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE))

Definition at line 2527 of file mymalloc.cc.

Referenced by sys_alloc().

#define pinuse (   p)    ((p)->head & PINUSE_BIT)

Definition at line 2130 of file mymalloc.cc.

Referenced by dlfree(), mspace_free(), and prepend_alloc().

#define PINUSE_BIT   (SIZE_T_ONE)
#define prev_chunk (   p)    ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))

Definition at line 2144 of file mymalloc.cc.

#define PROCEED_ON_ERROR   0

Definition at line 572 of file mymalloc.cc.

#define RELEASE_MALLOC_GLOBAL_LOCK ( )

Definition at line 1916 of file mymalloc.cc.

Referenced by init_mparams(), sys_alloc(), and sys_trim().

#define replace_dv (   M,
  P,
 
)
Value:
{\
size_t DVS = M->dvsize;\
if (DVS != 0) {\
mchunkptr DV = M->dv;\
insert_small_chunk(M, DV, DVS);\
}\
M->dvsize = S;\
M->dv = P;\
}
struct malloc_chunk * mchunkptr
Definition: mymalloc.cc:2065
#define insert_small_chunk(M, P, S)
Definition: mymalloc.cc:3415
#define is_small(s)
Definition: mymalloc.cc:2682
#define assert(x)
Definition: mymalloc.cc:1309

Definition at line 3474 of file mymalloc.cc.

Referenced by dlmalloc(), mspace_malloc(), and tmalloc_small().

#define request2size (   req)    (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))

Definition at line 2105 of file mymalloc.cc.

Referenced by ialloc(), internal_memalign(), and internal_realloc().

#define RTCHECK (   e)    (e)

Definition at line 2896 of file mymalloc.cc.

Referenced by dlfree(), internal_realloc(), mspace_free(), tmalloc_large(), and tmalloc_small().

#define same_or_left_bits (   x)    ((x) | -(x))

Definition at line 2792 of file mymalloc.cc.

#define segment_holds (   S,
  A 
)    ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
#define set_foot (   p,
  s 
)    (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))

Definition at line 2151 of file mymalloc.cc.

#define set_free_with_pinuse (   p,
  s,
  n 
)    (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))

Definition at line 2158 of file mymalloc.cc.

Referenced by add_segment(), dlfree(), mspace_free(), and prepend_alloc().

#define set_inuse (   M,
  p,
  s 
)
Value:
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
#define CINUSE_BIT
Definition: mymalloc.cc:2120
#define PINUSE_BIT
Definition: mymalloc.cc:2119
static const double s
Definition: G4SIunits.hh:150

Definition at line 2911 of file mymalloc.cc.

Referenced by internal_memalign(), and internal_realloc().

#define set_inuse_and_pinuse (   M,
  p,
  s 
)
Value:
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
#define CINUSE_BIT
Definition: mymalloc.cc:2120
struct malloc_chunk * mchunkptr
Definition: mymalloc.cc:2065
#define PINUSE_BIT
Definition: mymalloc.cc:2119
static const double s
Definition: G4SIunits.hh:150

Definition at line 2916 of file mymalloc.cc.

Referenced by dlmalloc(), internal_realloc(), mspace_malloc(), tmalloc_large(), and tmalloc_small().

#define set_lock (   M,
  L 
)
Value:
((M)->mflags = (L)?\
((M)->mflags | USE_LOCK_BIT) :\
((M)->mflags & ~USE_LOCK_BIT))
#define USE_LOCK_BIT
Definition: mymalloc.cc:1903
static const G4int L[nN]

Definition at line 2521 of file mymalloc.cc.

Referenced by create_mspace(), and create_mspace_with_base().

#define set_size_and_pinuse_of_free_chunk (   p,
  s 
)    ((p)->head = (s|PINUSE_BIT), set_foot(p, s))
#define set_size_and_pinuse_of_inuse_chunk (   M,
  p,
  s 
)    ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))
#define should_trim (   M,
  s 
)    ((s) > (M)->trim_check)

Definition at line 2578 of file mymalloc.cc.

Referenced by dlfree(), and mspace_free().

#define SIX_SIZE_T_SIZES   (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)

Definition at line 1452 of file mymalloc.cc.

Referenced by mmap_alloc(), and mmap_resize().

#define SIZE_T_BITSIZE   (sizeof(size_t) << 3)

Definition at line 1442 of file mymalloc.cc.

Referenced by tmalloc_large().

#define SIZE_T_FOUR   ((size_t)4)

Definition at line 1449 of file mymalloc.cc.

#define SIZE_T_ONE   ((size_t)1)
#define SIZE_T_SIZE   (sizeof(size_t))

Definition at line 1441 of file mymalloc.cc.

Referenced by add_segment(), dlmalloc(), ialloc(), mmap_alloc(), mmap_resize(), and mspace_malloc().

#define SIZE_T_TWO   ((size_t)2)

Definition at line 1448 of file mymalloc.cc.

#define SIZE_T_ZERO   ((size_t)0)

Definition at line 1446 of file mymalloc.cc.

#define small_index (   s)    ((s) >> SMALLBIN_SHIFT)

Definition at line 2683 of file mymalloc.cc.

Referenced by dlmalloc(), and mspace_malloc().

#define small_index2size (   i)    ((i) << SMALLBIN_SHIFT)

Definition at line 2684 of file mymalloc.cc.

Referenced by dlmalloc(), and mspace_malloc().

#define smallbin_at (   M,
 
)    ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))

Definition at line 2688 of file mymalloc.cc.

Referenced by dlmalloc(), init_bins(), and mspace_malloc().

#define SMALLBIN_SHIFT   (3U)

Definition at line 2439 of file mymalloc.cc.

#define SMALLBIN_WIDTH   (SIZE_T_ONE << SMALLBIN_SHIFT)

Definition at line 2440 of file mymalloc.cc.

#define smallmap_is_marked (   M,
 
)    ((M)->smallmap & idx2bit(i))

Definition at line 2779 of file mymalloc.cc.

#define SPIN_LOCKS_AVAILABLE   0

Definition at line 541 of file mymalloc.cc.

#define STRUCT_MALLINFO_DECLARED   1

Definition at line 706 of file mymalloc.cc.

#define SYS_ALLOC_PADDING   (TOP_FOOT_SIZE + MALLOC_ALIGNMENT)

Definition at line 2544 of file mymalloc.cc.

Referenced by sys_alloc().

#define treebin_at (   M,
 
)    (&((M)->treebins[i]))

Definition at line 2689 of file mymalloc.cc.

Referenced by tmalloc_large(), and tmalloc_small().

#define TREEBIN_SHIFT   (8U)

Definition at line 2441 of file mymalloc.cc.

#define treemap_is_marked (   M,
 
)    ((M)->treemap & idx2bit(i))

Definition at line 2783 of file mymalloc.cc.

#define TWO_SIZE_T_SIZES   (SIZE_T_SIZE<<1)

Definition at line 1450 of file mymalloc.cc.

#define unlink_chunk (   M,
  P,
 
)
Value:
if (is_small(S)) unlink_small_chunk(M, P, S)\
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }
struct malloc_tree_chunk * tchunkptr
Definition: mymalloc.cc:2276
#define is_small(s)
Definition: mymalloc.cc:2682
#define unlink_large_chunk(M, X)
Definition: mymalloc.cc:3556
#define unlink_small_chunk(M, P, S)
Definition: mymalloc.cc:3434

Definition at line 3633 of file mymalloc.cc.

Referenced by dlfree(), mspace_free(), and prepend_alloc().

#define unlink_first_small_chunk (   M,
  B,
  P,
 
)
Value:
{\
mchunkptr F = P->fd;\
assert(P != B);\
assert(P != F);\
if (B == F)\
else if (RTCHECK(ok_address(M, F))) {\
B->fd = F;\
F->bk = B;\
}\
else {\
}\
}
#define CORRUPTION_ERROR_ACTION(m)
Definition: mymalloc.cc:2638
struct malloc_chunk * mchunkptr
Definition: mymalloc.cc:2065
#define small_index2size(i)
Definition: mymalloc.cc:2684
#define assert(x)
Definition: mymalloc.cc:1309
#define chunksize(p)
Definition: mymalloc.cc:2134
#define clear_smallmap(M, i)
Definition: mymalloc.cc:2778
struct malloc_chunk * fd
Definition: mymalloc.cc:2060
#define ok_address(M, a)
Definition: mymalloc.cc:2868
#define RTCHECK(e)
Definition: mymalloc.cc:2896

Definition at line 3454 of file mymalloc.cc.

Referenced by dlmalloc(), and mspace_malloc().

#define unlink_large_chunk (   M,
 
)

Definition at line 3556 of file mymalloc.cc.

Referenced by release_unused_segments(), tmalloc_large(), and tmalloc_small().

#define unlink_small_chunk (   M,
  P,
 
)
Value:
{\
mchunkptr F = P->fd;\
mchunkptr B = P->bk;\
assert(P != B);\
assert(P != F);\
if (F == B)\
else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\
(B == smallbin_at(M,I) || ok_address(M, B)))) {\
F->bk = B;\
B->fd = F;\
}\
else {\
}\
}
#define CORRUPTION_ERROR_ACTION(m)
Definition: mymalloc.cc:2638
struct malloc_chunk * mchunkptr
Definition: mymalloc.cc:2065
struct malloc_chunk * bk
Definition: mymalloc.cc:2061
#define small_index2size(i)
Definition: mymalloc.cc:2684
#define assert(x)
Definition: mymalloc.cc:1309
#define smallbin_at(M, i)
Definition: mymalloc.cc:2688
unsigned int bindex_t
Definition: mymalloc.cc:2067
#define chunksize(p)
Definition: mymalloc.cc:2134
#define clear_smallmap(M, i)
Definition: mymalloc.cc:2778
struct malloc_chunk * fd
Definition: mymalloc.cc:2060
#define small_index(s)
Definition: mymalloc.cc:2683
#define ok_address(M, a)
Definition: mymalloc.cc:2868
#define RTCHECK(e)
Definition: mymalloc.cc:2896

Definition at line 3434 of file mymalloc.cc.

#define USE_BUILTIN_FFS   0

Definition at line 647 of file mymalloc.cc.

#define USE_DEV_RANDOM   0

Definition at line 650 of file mymalloc.cc.

#define use_lock (   M)    ((M)->mflags & USE_LOCK_BIT)

Definition at line 2510 of file mymalloc.cc.

#define USE_LOCK_BIT   (0U)

Definition at line 1903 of file mymalloc.cc.

Referenced by init_mparams().

#define USE_LOCKS   0

Definition at line 575 of file mymalloc.cc.

Referenced by create_mspace().

#define use_mmap (   M)    ((M)->mflags & USE_MMAP_BIT)

Definition at line 2514 of file mymalloc.cc.

Referenced by ialloc(), mspace_track_large_chunks(), and sys_alloc().

#define USE_MMAP_BIT   (SIZE_T_ONE)

Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP.

Definition at line 1568 of file mymalloc.cc.

Referenced by create_mspace(), destroy_mspace(), init_mparams(), and sys_alloc().

#define use_noncontiguous (   M)    ((M)->mflags & USE_NONCONTIGUOUS_BIT)

Definition at line 2518 of file mymalloc.cc.

Referenced by sys_alloc().

#define USE_NONCONTIGUOUS_BIT   (4U)

Definition at line 1610 of file mymalloc.cc.

Referenced by init_mparams().

#define USE_SPIN_LOCKS   0

Definition at line 581 of file mymalloc.cc.

Typedef Documentation

typedef unsigned int bindex_t

Definition at line 2067 of file mymalloc.cc.

typedef unsigned int binmap_t

Definition at line 2068 of file mymalloc.cc.

typedef unsigned int flag_t

Definition at line 2069 of file mymalloc.cc.

typedef struct malloc_chunk mchunk

Definition at line 2064 of file mymalloc.cc.

typedef struct malloc_chunk* mchunkptr

Definition at line 2065 of file mymalloc.cc.

typedef struct malloc_segment msegment

Definition at line 2349 of file mymalloc.cc.

typedef struct malloc_segment* msegmentptr

Definition at line 2350 of file mymalloc.cc.

typedef void* mspace

Definition at line 1123 of file mymalloc.cc.

typedef struct malloc_state* mstate

Definition at line 2470 of file mymalloc.cc.

typedef struct malloc_chunk* sbinptr

Definition at line 2066 of file mymalloc.cc.

typedef struct malloc_tree_chunk* tbinptr

Definition at line 2277 of file mymalloc.cc.

typedef struct malloc_tree_chunk tchunk

Definition at line 2275 of file mymalloc.cc.

typedef struct malloc_tree_chunk* tchunkptr

Definition at line 2276 of file mymalloc.cc.

Function Documentation

static void add_segment ( mstate  m,
char *  tbase,
size_t  tsize,
flag_t  mmapped 
)
static

Definition at line 3815 of file mymalloc.cc.

References align_offset, assert, malloc_segment::base, check_top_chunk, chunk2mem, CHUNK_ALIGN_MASK, chunk_plus_offset, FENCEPOST_HEAD, FOUR_SIZE_T_SIZES, malloc_chunk::head, init_top(), insert_chunk, is_aligned, MIN_CHUNK_SIZE, malloc_segment::next, pad_request, malloc_state::seg, segment_holding(), set_free_with_pinuse, set_size_and_pinuse_of_inuse_chunk, malloc_segment::sflags, malloc_segment::size, SIZE_T_SIZE, malloc_state::top, and TOP_FOOT_SIZE.

Referenced by sys_alloc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int change_mparam ( int  param_number,
int  value 
)
static

Definition at line 3038 of file mymalloc.cc.

References ensure_initialization, malloc_params::granularity, M_GRANULARITY, M_MMAP_THRESHOLD, M_TRIM_THRESHOLD, MAX_SIZE_T, malloc_params::mmap_threshold, mparams, malloc_params::page_size, and malloc_params::trim_threshold.

Referenced by dlmallopt(), and mspace_mallopt().

+ Here is the caller graph for this function:

mspace create_mspace ( size_t  capacity,
int  locked 
)

Definition at line 4974 of file mymalloc.cc.

References CALL_MMAP, CMFAIL, ensure_initialization, malloc_params::granularity, granularity_align, HAVE_MMAP, HAVE_MORECORE, init_user_mstate(), m, mparams, MSPACES, ONLY_MSPACES, pad_request, malloc_params::page_size, malloc_state::seg, set_lock, malloc_segment::sflags, TOP_FOOT_SIZE, USE_LOCKS, and USE_MMAP_BIT.

Referenced by calloc(), malloc(), realloc(), and valloc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

mspace create_mspace_with_base ( void *  base,
size_t  capacity,
int  locked 
)

Definition at line 5005 of file mymalloc.cc.

References ensure_initialization, EXTERN_BIT, init_user_mstate(), m, mparams, pad_request, malloc_params::page_size, malloc_state::seg, set_lock, malloc_segment::sflags, and TOP_FOOT_SIZE.

+ Here is the call graph for this function:

void * dlcalloc ( size_t  n_elements,
size_t  elem_size 
)

Definition at line 4837 of file mymalloc.cc.

References calloc_must_clear, dlmalloc, MAX_SIZE_T, and mem2chunk.

void** dlindependent_calloc ( size_t  ,
size_t  ,
void **   
)
void** dlindependent_calloc ( size_t  n_elements,
size_t  elem_size,
void *  chunks[] 
)

Definition at line 4879 of file mymalloc.cc.

References gm, and ialloc().

+ Here is the call graph for this function:

void** dlindependent_comalloc ( size_t  ,
size_t *  ,
void **   
)
void** dlindependent_comalloc ( size_t  n_elements,
size_t  sizes[],
void *  chunks[] 
)

Definition at line 4885 of file mymalloc.cc.

References gm, and ialloc().

+ Here is the call graph for this function:

struct mallinfo dlmallinfo ( void  )

Definition at line 4923 of file mymalloc.cc.

References gm, and internal_mallinfo().

+ Here is the call graph for this function:

size_t dlmalloc_footprint ( void  )

Definition at line 4914 of file mymalloc.cc.

References gm.

size_t dlmalloc_max_footprint ( void  )

Definition at line 4918 of file mymalloc.cc.

References gm.

void dlmalloc_stats ( void  )

Definition at line 4928 of file mymalloc.cc.

References gm, and internal_malloc_stats().

+ Here is the call graph for this function:

int dlmalloc_trim ( size_t  pad)

Definition at line 4904 of file mymalloc.cc.

References ensure_initialization, gm, POSTACTION, PREACTION, and sys_trim().

+ Here is the call graph for this function:

size_t dlmalloc_usable_size ( void *  mem)

Definition at line 4938 of file mymalloc.cc.

References chunksize, is_inuse, mem2chunk, and overhead_for.

int dlmallopt ( int  param_number,
int  value 
)

Definition at line 4932 of file mymalloc.cc.

References change_mparam().

+ Here is the call graph for this function:

void * dlmemalign ( size_t  alignment,
size_t  bytes 
)

Definition at line 4875 of file mymalloc.cc.

References gm, and internal_memalign().

+ Here is the call graph for this function:

void * dlpvalloc ( size_t  bytes)
void * dlrealloc ( void *  oldmem,
size_t  bytes 
)

Definition at line 4852 of file mymalloc.cc.

References dlfree, dlmalloc, gm, internal_realloc(), mem2chunk, ok_magic, and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

void * dlvalloc ( size_t  bytes)

Definition at line 4890 of file mymalloc.cc.

References dlmemalign, ensure_initialization, mparams, and malloc_params::page_size.

static int has_segment_link ( mstate  m,
msegmentptr  ss 
)
static

Definition at line 2567 of file mymalloc.cc.

References malloc_segment::base, malloc_segment::next, malloc_state::seg, malloc_segment::size, and G4InuclParticleNames::sp.

Referenced by sys_trim().

+ Here is the caller graph for this function:

static void** ialloc ( mstate  m,
size_t  n_elements,
size_t *  sizes,
int  opts,
void *  chunks[] 
)
static

Definition at line 4460 of file mymalloc.cc.

References assert, check_inuse_chunk, chunk2mem, CHUNK_OVERHEAD, chunk_plus_offset, chunksize, disable_mmap, enable_mmap, ensure_initialization, internal_malloc, is_mmapped, mem2chunk, POSTACTION, PREACTION, request2size, set_size_and_pinuse_of_inuse_chunk, SIZE_T_SIZE, and use_mmap.

Referenced by dlindependent_calloc(), dlindependent_comalloc(), mspace_independent_calloc(), and mspace_independent_comalloc().

+ Here is the caller graph for this function:

static void init_bins ( mstate  m)
static

Definition at line 3744 of file mymalloc.cc.

References malloc_chunk::bk, malloc_chunk::fd, NSMALLBINS, and smallbin_at.

Referenced by init_user_mstate(), and sys_alloc().

+ Here is the caller graph for this function:

static void init_top ( mstate  m,
mchunkptr  p,
size_t  psize 
)
static

Definition at line 3729 of file mymalloc.cc.

References align_offset, chunk2mem, chunk_plus_offset, malloc_chunk::head, mparams, PINUSE_BIT, malloc_state::top, TOP_FOOT_SIZE, malloc_state::topsize, malloc_state::trim_check, and malloc_params::trim_threshold.

Referenced by add_segment(), init_user_mstate(), sys_alloc(), and sys_trim().

+ Here is the caller graph for this function:

static mstate init_user_mstate ( char *  tbase,
size_t  tsize 
)
static

Definition at line 4951 of file mymalloc.cc.

References align_as_chunk, malloc_segment::base, check_top_chunk, chunk2mem, malloc_params::default_mflags, disable_contiguous, malloc_state::extp, malloc_state::exts, malloc_state::footprint, malloc_chunk::head, init_bins(), init_top(), INITIAL_LOCK, INUSE_BITS, malloc_state::least_addr, m, malloc_state::magic, malloc_params::magic, malloc_state::max_footprint, MAX_RELEASE_CHECK_RATE, mem2chunk, malloc_state::mflags, mparams, next_chunk, pad_request, malloc_state::release_checks, malloc_state::seg, malloc_segment::size, malloc_state::top, and TOP_FOOT_SIZE.

Referenced by create_mspace(), and create_mspace_with_base().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void internal_malloc_stats ( mstate  m)
static

Definition at line 3372 of file mymalloc.cc.

References align_as_chunk, malloc_segment::base, check_malloc_state, chunksize, ensure_initialization, FENCEPOST_HEAD, malloc_state::footprint, malloc_chunk::head, is_initialized, is_inuse, malloc_state::max_footprint, malloc_segment::next, next_chunk, POSTACTION, PREACTION, malloc_state::seg, segment_holds, malloc_state::top, TOP_FOOT_SIZE, and malloc_state::topsize.

Referenced by dlmalloc_stats(), and mspace_malloc_stats().

+ Here is the caller graph for this function:

static void* internal_memalign ( mstate  m,
size_t  alignment,
size_t  bytes 
)
static

Definition at line 4373 of file mymalloc.cc.

References a, assert, check_inuse_chunk, chunk2mem, CHUNK_OVERHEAD, chunk_plus_offset, chunksize, malloc_chunk::head, internal_free, internal_malloc, is_mmapped, MALLOC_ALIGNMENT, MALLOC_FAILURE_ACTION, MAX_REQUEST, mem2chunk, MIN_CHUNK_SIZE, pos, POSTACTION, PREACTION, malloc_chunk::prev_foot, request2size, set_inuse, and SIZE_T_ONE.

Referenced by dlmemalign(), and mspace_memalign().

+ Here is the caller graph for this function:

static void* internal_realloc ( mstate  m,
void *  oldmem,
size_t  bytes 
)
static

Definition at line 4298 of file mymalloc.cc.

References check_inuse_chunk, chunk2mem, chunk_plus_offset, chunksize, malloc_chunk::head, internal_free, internal_malloc, is_mmapped, MALLOC_FAILURE_ACTION, MAX_REQUEST, mem2chunk, MIN_CHUNK_SIZE, mmap_resize(), ok_address, ok_inuse, ok_next, ok_pinuse, overhead_for, PINUSE_BIT, POSTACTION, PREACTION, request2size, RTCHECK, set_inuse, set_inuse_and_pinuse, malloc_state::top, malloc_state::topsize, and USAGE_ERROR_ACTION.

Referenced by dlrealloc(), and mspace_realloc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* mmap_alloc ( mstate  m,
size_t  nb 
)
static

Definition at line 3666 of file mymalloc.cc.

References align_offset, assert, CALL_DIRECT_MMAP, check_mmapped_chunk, chunk2mem, CHUNK_ALIGN_MASK, chunk_plus_offset, CMFAIL, FENCEPOST_HEAD, malloc_state::footprint, malloc_chunk::head, is_aligned, malloc_state::least_addr, mark_inuse_foot, malloc_state::max_footprint, mm, mmap_align, MMAP_FOOT_PAD, malloc_chunk::prev_foot, SIX_SIZE_T_SIZES, and SIZE_T_SIZE.

Referenced by sys_alloc().

+ Here is the caller graph for this function:

static mchunkptr mmap_resize ( mstate  m,
mchunkptr  oldp,
size_t  nb 
)
static

Definition at line 3693 of file mymalloc.cc.

References CALL_MREMAP, check_mmapped_chunk, CHUNK_ALIGN_MASK, chunk_plus_offset, chunksize, CMFAIL, cp, FENCEPOST_HEAD, malloc_state::footprint, malloc_params::granularity, malloc_chunk::head, is_small, malloc_state::least_addr, mark_inuse_foot, malloc_state::max_footprint, mmap_align, MMAP_FOOT_PAD, mparams, malloc_chunk::prev_foot, SIX_SIZE_T_SIZES, and SIZE_T_SIZE.

Referenced by internal_realloc().

+ Here is the caller graph for this function:

void * mspace_calloc ( mspace  msp,
size_t  n_elements,
size_t  elem_size 
)

Definition at line 5276 of file mymalloc.cc.

References calloc_must_clear, internal_malloc, MAX_SIZE_T, mem2chunk, ms, ok_magic, and USAGE_ERROR_ACTION.

Referenced by calloc().

+ Here is the caller graph for this function:

size_t mspace_footprint ( mspace  msp)

Definition at line 5375 of file mymalloc.cc.

References malloc_state::footprint, ms, ok_magic, and USAGE_ERROR_ACTION.

void mspace_free ( mspace  msp,
void *  mem 
)

Definition at line 5175 of file mymalloc.cc.

References CALL_MUNMAP, check_free_chunk, check_inuse_chunk, chunk_minus_offset, chunk_plus_offset, chunksize, cinuse, malloc_state::dv, malloc_state::dvsize, fm, malloc_state::footprint, malloc_chunk::head, insert_large_chunk, insert_small_chunk, INUSE_BITS, is_mmapped, is_small, mem2chunk, MMAP_FOOT_PAD, ok_address, ok_inuse, ok_magic, ok_next, ok_pinuse, pinuse, PINUSE_BIT, POSTACTION, PREACTION, malloc_chunk::prev_foot, malloc_state::release_checks, release_unused_segments(), RTCHECK, set_free_with_pinuse, set_size_and_pinuse_of_free_chunk, should_trim, sys_trim(), malloc_state::top, malloc_state::topsize, G4InuclParticleNames::tp, unlink_chunk, and USAGE_ERROR_ACTION.

Referenced by cfree(), free(), and mspace_realloc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ** mspace_independent_calloc ( mspace  msp,
size_t  n_elements,
size_t  elem_size,
void *  chunks[] 
)

Definition at line 5329 of file mymalloc.cc.

References ialloc(), ms, ok_magic, and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

void ** mspace_independent_comalloc ( mspace  msp,
size_t  n_elements,
size_t  sizes[],
void *  chunks[] 
)

Definition at line 5340 of file mymalloc.cc.

References ialloc(), ms, ok_magic, and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

struct mallinfo mspace_mallinfo ( mspace  msp)

Definition at line 5402 of file mymalloc.cc.

References internal_mallinfo(), ms, ok_magic, and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

void * mspace_malloc ( mspace  msp,
size_t  bytes 
)

Definition at line 5061 of file mymalloc.cc.

References assert, check_malloced_chunk, check_top_chunk, chunk2mem, chunk_plus_offset, chunksize, compute_bit2idx, malloc_state::dv, malloc_state::dvsize, malloc_chunk::fd, malloc_chunk::head, idx2bit, least_bit, left_bits, MAX_REQUEST, MAX_SIZE_T, MAX_SMALL_REQUEST, MIN_CHUNK_SIZE, MIN_REQUEST, ms, ok_magic, pad_request, PINUSE_BIT, POSTACTION, PREACTION, replace_dv, set_inuse_and_pinuse, set_size_and_pinuse_of_free_chunk, set_size_and_pinuse_of_inuse_chunk, SIZE_T_SIZE, small_index, small_index2size, smallbin_at, malloc_state::smallmap, sys_alloc(), tmalloc_large(), tmalloc_small(), malloc_state::top, malloc_state::topsize, malloc_state::treemap, unlink_first_small_chunk, and USAGE_ERROR_ACTION.

Referenced by malloc(), mspace_realloc(), and valloc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mspace_malloc_stats ( mspace  msp)

Definition at line 5365 of file mymalloc.cc.

References internal_malloc_stats(), ms, ok_magic, and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

int mspace_mallopt ( int  param_number,
int  value 
)

Definition at line 5420 of file mymalloc.cc.

References change_mparam().

+ Here is the call graph for this function:

size_t mspace_max_footprint ( mspace  msp)

Definition at line 5388 of file mymalloc.cc.

References malloc_state::max_footprint, ms, ok_magic, and USAGE_ERROR_ACTION.

void * mspace_memalign ( mspace  msp,
size_t  alignment,
size_t  bytes 
)

Definition at line 5320 of file mymalloc.cc.

References internal_memalign(), ms, ok_magic, and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

void * mspace_realloc ( mspace  msp,
void *  mem,
size_t  newsize 
)

Definition at line 5296 of file mymalloc.cc.

References internal_realloc(), mem2chunk, ms, mspace_free(), mspace_malloc(), ok_magic, and USAGE_ERROR_ACTION.

Referenced by realloc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mspace_track_large_chunks ( mspace  msp,
int  enable 
)

Definition at line 5019 of file mymalloc.cc.

References disable_mmap, enable_mmap, ms, POSTACTION, PREACTION, and use_mmap.

int mspace_trim ( mspace  msp,
size_t  pad 
)

Definition at line 5350 of file mymalloc.cc.

References ms, ok_magic, POSTACTION, PREACTION, sys_trim(), and USAGE_ERROR_ACTION.

+ Here is the call graph for this function:

size_t mspace_usable_size ( void *  mem)

Definition at line 5411 of file mymalloc.cc.

References chunksize, is_inuse, mem2chunk, and overhead_for.

static void* prepend_alloc ( mstate  m,
char *  newbase,
char *  oldbase,
size_t  nb 
)
static

Definition at line 3773 of file mymalloc.cc.

References align_as_chunk, assert, check_free_chunk, check_malloced_chunk, check_top_chunk, chunk2mem, chunk_plus_offset, chunksize, malloc_state::dv, malloc_state::dvsize, malloc_chunk::head, insert_chunk, is_inuse, MIN_CHUNK_SIZE, pinuse, PINUSE_BIT, set_free_with_pinuse, set_size_and_pinuse_of_free_chunk, set_size_and_pinuse_of_inuse_chunk, malloc_state::top, malloc_state::topsize, and unlink_chunk.

Referenced by sys_alloc().

+ Here is the caller graph for this function:

static size_t release_unused_segments ( mstate  m)
static
static msegmentptr segment_holding ( mstate  m,
char *  addr 
)
static

Definition at line 2556 of file mymalloc.cc.

References malloc_segment::base, malloc_segment::next, malloc_state::seg, malloc_segment::size, and G4InuclParticleNames::sp.

Referenced by add_segment(), sys_alloc(), and sys_trim().

+ Here is the caller graph for this function:

static int sys_trim ( mstate  m,
size_t  pad 
)
static

Definition at line 4120 of file mymalloc.cc.

References ACQUIRE_MALLOC_GLOBAL_LOCK, malloc_segment::base, CALL_MORECORE, CALL_MREMAP, CALL_MUNMAP, check_top_chunk, CMFAIL, ensure_initialization, malloc_state::footprint, malloc_params::granularity, HALF_MAX_SIZE_T, has_segment_link(), HAVE_MMAP, HAVE_MORECORE, init_top(), is_extern_segment, is_initialized, is_mmapped_segment, MAX_REQUEST, MAX_SIZE_T, MFAIL, mparams, RELEASE_MALLOC_GLOBAL_LOCK, release_unused_segments(), segment_holding(), malloc_segment::size, SIZE_T_ONE, malloc_state::top, TOP_FOOT_SIZE, malloc_state::topsize, and malloc_state::trim_check.

Referenced by dlfree(), dlmalloc_trim(), mspace_free(), and mspace_trim().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* tmalloc_large ( mstate  m,
size_t  nb 
)
static
static void* tmalloc_small ( mstate  m,
size_t  nb 
)
static

Definition at line 4259 of file mymalloc.cc.

References assert, chunk2mem, chunk_plus_offset, chunksize, compute_bit2idx, CORRUPTION_ERROR_ACTION, least_bit, leftmost_child, MIN_CHUNK_SIZE, ok_address, ok_next, replace_dv, RTCHECK, set_inuse_and_pinuse, set_size_and_pinuse_of_free_chunk, set_size_and_pinuse_of_inuse_chunk, treebin_at, malloc_state::treemap, and unlink_large_chunk.

Referenced by dlmalloc(), and mspace_malloc().

+ Here is the caller graph for this function:

Variable Documentation

G4ThreadLocal struct malloc_state _gm_
static

Definition at line 2498 of file mymalloc.cc.

G4ThreadLocal int dev_zero_fd = -1
static

Definition at line 1496 of file mymalloc.cc.