nedmalloc.c File Reference

#include "nedmalloc.h"
#include "malloc.c.h"

Include dependency graph for nedmalloc.c:

Go to the source code of this file.

Classes

struct  threadcacheblk_t
struct  threadcache_t
struct  nedpool_t

Defines

#define MSPACES   1
#define ONLY_MSPACES   1
#define USE_LOCKS   1
#define FOOTERS   1
#define DEBUG   0
#define DEFAULT_GRANULARITY   (1*1024*1024)
#define MAXTHREADSINPOOL   16
#define THREADCACHEMAXCACHES   256
#define THREADCACHEMAX   8192
#define THREADCACHEMAXBINS   (13-4)
#define THREADCACHEMAXFREESPACE   (512*1024)
#define TLSVAR   pthread_key_t
#define TLSALLOC(k)   pthread_key_create(k, 0)
#define TLSFREE(k)   pthread_key_delete(k)
#define TLSGET(k)   pthread_getspecific(k)
#define TLSSET(k, a)   pthread_setspecific(k, a)
#define GETMSPACE(m, p, tc, ms, s, action)

Typedefs

typedef struct threadcacheblk_t threadcacheblk
typedef struct threadcache_t threadcache

Functions

size_t nedblksize (void *mem) THROWSPEC
void nedsetvalue (void *v) THROWSPEC
void * nedmalloc (size_t size) THROWSPEC
void * nedcalloc (size_t no, size_t size) THROWSPEC
void * nedrealloc (void *mem, size_t size) THROWSPEC
void nedfree (void *mem) THROWSPEC
void * nedmemalign (size_t alignment, size_t bytes) THROWSPEC
struct mallinfo nedmallinfo (void)
int nedmallopt (int parno, int value) THROWSPEC
int nedmalloc_trim (size_t pad) THROWSPEC
void nedmalloc_stats ()
size_t nedmalloc_footprint ()
void ** nedindependent_calloc (size_t elemsno, size_t elemsize, void **chunks) THROWSPEC
void ** nedindependent_comalloc (size_t elems, size_t *sizes, void **chunks) THROWSPEC
static FORCEINLINE unsigned int size2binidx (size_t _size) THROWSPEC
static NOINLINE void RemoveCacheEntries (nedpool *p, threadcache *tc, unsigned int age) THROWSPEC
static void DestroyCaches (nedpool *p) THROWSPEC
static NOINLINE threadcacheAllocCache (nedpool *p) THROWSPEC
static void * threadcache_malloc (nedpool *p, threadcache *tc, size_t *size) THROWSPEC
static NOINLINE void ReleaseFreeInCache (nedpool *p, threadcache *tc, int mymspace) THROWSPEC
static void threadcache_free (nedpool *p, threadcache *tc, int mymspace, void *mem, size_t size) THROWSPEC
static NOINLINE int InitPool (nedpool *p, size_t capacity, int threads) THROWSPEC
static NOINLINE mstate FindMSpace (nedpool *p, threadcache *tc, int *lastUsed, size_t size) THROWSPEC
nedpoolnedcreatepool (size_t capacity, int threads) THROWSPEC
void neddestroypool (nedpool *p) THROWSPEC
void nedpsetvalue (nedpool *p, void *v) THROWSPEC
void * nedgetvalue (nedpool **p, void *mem) THROWSPEC
void neddisablethreadcache (nedpool *p) THROWSPEC
static FORCEINLINE mstate GetMSpace (nedpool *p, threadcache *tc, int mymspace, size_t size) THROWSPEC
static FORCEINLINE void GetThreadCache (nedpool **p, threadcache **tc, int *mymspace, size_t *size) THROWSPEC
void * nedpmalloc (nedpool *p, size_t size) THROWSPEC
void * nedpcalloc (nedpool *p, size_t no, size_t size) THROWSPEC
void * nedprealloc (nedpool *p, void *mem, size_t size) THROWSPEC
void nedpfree (nedpool *p, void *mem) THROWSPEC
void * nedpmemalign (nedpool *p, size_t alignment, size_t bytes) THROWSPEC
struct mallinfo nedpmallinfo (nedpool *p) THROWSPEC
int nedpmallopt (nedpool *p, int parno, int value) THROWSPEC
int nedpmalloc_trim (nedpool *p, size_t pad) THROWSPEC
void nedpmalloc_stats (nedpool *p) THROWSPEC
size_t nedpmalloc_footprint (nedpool *p) THROWSPEC
void ** nedpindependent_calloc (nedpool *p, size_t elemsno, size_t elemsize, void **chunks) THROWSPEC
void ** nedpindependent_comalloc (nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC

Variables

static nedpool syspool


Define Documentation

#define DEBUG   0

Definition at line 50 of file nedmalloc.c.

#define DEFAULT_GRANULARITY   (1*1024*1024)

Definition at line 57 of file nedmalloc.c.

Referenced by init_mparams().

#define FOOTERS   1

Definition at line 45 of file nedmalloc.c.

#define GETMSPACE ( m,
p,
tc,
ms,
s,
action   ) 

Value:

do                                            \
  {                                             \
    mstate m = GetMSpace((p),(tc),(ms),(s));    \
    action;                                     \
    RELEASE_LOCK(&m->mutex);                    \
  } while (0)

Definition at line 711 of file nedmalloc.c.

Referenced by nedpcalloc(), nedpindependent_calloc(), nedpindependent_comalloc(), nedpmalloc(), and nedpmemalign().

#define MAXTHREADSINPOOL   16

Definition at line 70 of file nedmalloc.c.

Referenced by InitPool().

#define MSPACES   1

Definition at line 40 of file nedmalloc.c.

#define ONLY_MSPACES   1

Definition at line 41 of file nedmalloc.c.

#define THREADCACHEMAX   8192

#define THREADCACHEMAXBINS   (13-4)

Definition at line 85 of file nedmalloc.c.

Referenced by RemoveCacheEntries(), threadcache_free(), and threadcache_malloc().

#define THREADCACHEMAXCACHES   256

Definition at line 74 of file nedmalloc.c.

Referenced by AllocCache(), and DestroyCaches().

#define THREADCACHEMAXFREESPACE   (512*1024)

Definition at line 89 of file nedmalloc.c.

Referenced by ReleaseFreeInCache(), and threadcache_free().

#define TLSALLOC (  )     pthread_key_create(k, 0)

Definition at line 111 of file nedmalloc.c.

Referenced by InitPool().

#define TLSFREE (  )     pthread_key_delete(k)

Definition at line 112 of file nedmalloc.c.

Referenced by InitPool(), and neddestroypool().

#define TLSGET (  )     pthread_getspecific(k)

Definition at line 113 of file nedmalloc.c.

Referenced by GetThreadCache(), and neddisablethreadcache().

#define TLSSET ( k,
 )     pthread_setspecific(k, a)

Definition at line 114 of file nedmalloc.c.

Referenced by AllocCache(), FindMSpace(), GetThreadCache(), and neddisablethreadcache().

#define TLSVAR   pthread_key_t

Definition at line 110 of file nedmalloc.c.

#define USE_LOCKS   1

Definition at line 43 of file nedmalloc.c.


Typedef Documentation

typedef struct threadcache_t threadcache

Definition at line 168 of file nedmalloc.c.


Function Documentation

static NOINLINE threadcache* AllocCache ( nedpool p  )  [static]

Definition at line 346 of file nedmalloc.c.

References threadcache_t::mymspace, THREADCACHEMAXCACHES, threadcache_t::threadid, and TLSSET.

Referenced by GetThreadCache().

static void DestroyCaches ( nedpool p  )  [static]

static NOINLINE mstate FindMSpace ( nedpool p,
threadcache tc,
int *  lastUsed,
size_t  size 
) [static]

Definition at line 575 of file nedmalloc.c.

References TLSSET.

Referenced by GetMSpace().

static FORCEINLINE mstate GetMSpace ( nedpool p,
threadcache tc,
int  mymspace,
size_t  size 
) [static]

Definition at line 719 of file nedmalloc.c.

References assert, and FindMSpace().

static FORCEINLINE void GetThreadCache ( nedpool **  p,
threadcache **  tc,
int *  mymspace,
size_t *  size 
) [static]

static NOINLINE int InitPool ( nedpool p,
size_t  capacity,
int  threads 
) [static]

size_t nedblksize ( void *  mem  ) 

void* nedcalloc ( size_t  no,
size_t  size 
)

Definition at line 153 of file nedmalloc.c.

References nedpcalloc().

nedpool* nedcreatepool ( size_t  capacity,
int  threads 
)

Definition at line 628 of file nedmalloc.c.

References InitPool(), nedpcalloc(), and nedpfree().

void neddestroypool ( nedpool p  ) 

Definition at line 639 of file nedmalloc.c.

References DestroyCaches(), nedpfree(), and TLSFREE.

void neddisablethreadcache ( nedpool p  ) 

void nedfree ( void *  mem  ) 

Definition at line 155 of file nedmalloc.c.

References nedpfree().

void* nedgetvalue ( nedpool **  p,
void *  mem 
)

void** nedindependent_calloc ( size_t  elemsno,
size_t  elemsize,
void **  chunks 
)

Definition at line 164 of file nedmalloc.c.

References nedpindependent_calloc().

void** nedindependent_comalloc ( size_t  elems,
size_t *  sizes,
void **  chunks 
)

Definition at line 165 of file nedmalloc.c.

References nedpindependent_comalloc().

struct mallinfo nedmallinfo ( void   )  [read]

Definition at line 158 of file nedmalloc.c.

References nedpmallinfo().

void* nedmalloc ( size_t  size  ) 

Definition at line 152 of file nedmalloc.c.

References nedpmalloc().

size_t nedmalloc_footprint ( void   ) 

Definition at line 163 of file nedmalloc.c.

References nedpmalloc_footprint().

void nedmalloc_stats ( void   ) 

Definition at line 162 of file nedmalloc.c.

References nedpmalloc_stats().

int nedmalloc_trim ( size_t  pad  ) 

Definition at line 161 of file nedmalloc.c.

References nedpmalloc_trim().

int nedmallopt ( int  parno,
int  value 
)

Definition at line 160 of file nedmalloc.c.

References nedpmallopt().

void* nedmemalign ( size_t  alignment,
size_t  bytes 
)

Definition at line 156 of file nedmalloc.c.

References nedpmemalign().

void* nedpcalloc ( nedpool p,
size_t  no,
size_t  size 
)

Definition at line 790 of file nedmalloc.c.

References GETMSPACE, GetThreadCache(), threadcache_malloc(), and THREADCACHEMAX.

Referenced by nedcalloc(), and nedcreatepool().

void nedpfree ( nedpool p,
void *  mem 
)

void** nedpindependent_calloc ( nedpool p,
size_t  elemsno,
size_t  elemsize,
void **  chunks 
)

Definition at line 923 of file nedmalloc.c.

References GETMSPACE, and GetThreadCache().

Referenced by nedindependent_calloc().

void** nedpindependent_comalloc ( nedpool p,
size_t  elems,
size_t *  sizes,
void **  chunks 
)

Definition at line 933 of file nedmalloc.c.

References GETMSPACE, and GetThreadCache().

Referenced by nedindependent_comalloc().

struct mallinfo nedpmallinfo ( nedpool p  )  [read]

void* nedpmalloc ( nedpool p,
size_t  size 
)

Definition at line 771 of file nedmalloc.c.

References GETMSPACE, GetThreadCache(), threadcache_malloc(), and THREADCACHEMAX.

Referenced by nedmalloc(), and nedprealloc().

size_t nedpmalloc_footprint ( nedpool p  ) 

Definition at line 912 of file nedmalloc.c.

References InitPool(), and nedpool_t::threads.

Referenced by nedmalloc_footprint().

void nedpmalloc_stats ( nedpool p  ) 

Definition at line 903 of file nedmalloc.c.

References InitPool(), and nedpool_t::threads.

Referenced by nedmalloc_stats().

int nedpmalloc_trim ( nedpool p,
size_t  pad 
)

Definition at line 893 of file nedmalloc.c.

References InitPool(), and nedpool_t::threads.

Referenced by nedmalloc_trim().

int nedpmallopt ( nedpool p,
int  parno,
int  value 
)

Definition at line 889 of file nedmalloc.c.

Referenced by nedmallopt().

void* nedpmemalign ( nedpool p,
size_t  alignment,
size_t  bytes 
)

Definition at line 857 of file nedmalloc.c.

References GETMSPACE, and GetThreadCache().

Referenced by nedmemalign().

void* nedprealloc ( nedpool p,
void *  mem,
size_t  size 
)

void nedpsetvalue ( nedpool p,
void *  v 
)

Definition at line 654 of file nedmalloc.c.

References InitPool(), and nedpool_t::threads.

Referenced by nedsetvalue().

void* nedrealloc ( void *  mem,
size_t  size 
)

Definition at line 154 of file nedmalloc.c.

References nedprealloc().

void nedsetvalue ( void *  v  ) 

Definition at line 151 of file nedmalloc.c.

References nedpsetvalue().

static NOINLINE void ReleaseFreeInCache ( nedpool p,
threadcache tc,
int  mymspace 
) [static]

Definition at line 461 of file nedmalloc.c.

References RemoveCacheEntries(), and THREADCACHEMAXFREESPACE.

Referenced by threadcache_free().

static NOINLINE void RemoveCacheEntries ( nedpool p,
threadcache tc,
unsigned int  age 
) [static]

static FORCEINLINE unsigned int size2binidx ( size_t  _size  )  [static]

Definition at line 202 of file nedmalloc.c.

Referenced by threadcache_free(), and threadcache_malloc().

static void threadcache_free ( nedpool p,
threadcache tc,
int  mymspace,
void *  mem,
size_t  size 
) [static]

static void* threadcache_malloc ( nedpool p,
threadcache tc,
size_t *  size 
) [static]


Variable Documentation

nedpool syspool [static]

Definition at line 200 of file nedmalloc.c.


Generated on Wed May 23 06:00:17 2012 for cpp by  doxygen 1.5.6