33#if !defined(DEBUG_THREADLOCALS) 
   61#undef pthread_mutex_lock 
   62#undef pthread_mutex_unlock 
   63#undef pthread_mutex_init 
   64#undef pthread_mutex_destroy 
   76void __ast_threadstorage_object_add(
void *key, 
size_t len, 
const char *file, 
const char *function, 
unsigned int line)
 
   78    struct tls_object *to;
 
   86    to->function = function;
 
   88    to->thread = pthread_self();
 
   95void __ast_threadstorage_object_remove(
void *key)
 
   97    struct tls_object *to;
 
  101        if (to->key == key) {
 
  112void __ast_threadstorage_object_replace(
void *key_old, 
void *key_new, 
size_t len)
 
  114    struct tls_object *to;
 
  118        if (to->key == key_old) {
 
  130    const char *fn = 
NULL;
 
  132    unsigned int count = 0;
 
  133    struct tls_object *to;
 
  137        e->
command = 
"threadstorage show allocations";
 
  139            "Usage: threadstorage show allocations [<file>]\n" 
  140            "       Dumps a list of all thread-specific memory allocations,\n" 
  141            "       optionally limited to those from a specific file\n";
 
  156        if (fn && strcasecmp(to->file, fn))
 
  159        ast_cli(
a->fd, 
"%10d bytes allocated in %20s at line %5d of %25s (thread %p)\n",
 
  160            (
int) to->size, to->function, to->line, to->file, (
void *) to->thread);
 
  167    ast_cli(
a->fd, 
"%10d bytes allocated in %d allocation%s\n", (
int) 
len, count, count > 1 ? 
"s" : 
"");
 
  174    const char *fn = 
NULL;
 
  176    unsigned int count = 0;
 
  177    struct tls_object *to;
 
  188        e->
command = 
"threadstorage show summary";
 
  190            "Usage: threadstorage show summary [<file>]\n" 
  191            "       Summarizes thread-specific memory allocations by file, or optionally\n" 
  192            "       by function, if a file is specified\n";
 
  207        if (fn && strcasecmp(to->file, fn))
 
  211            if ((!fn && (
file->name == to->file)) || (fn && (
file->name == to->function)))
 
  217            memset(file, 0, 
sizeof(*file));
 
  218            file->name = fn ? to->function : to->file;
 
  222        file->len += to->size;
 
  230        count += 
file->count;
 
  232            ast_cli(
a->fd, 
"%10d bytes in %d allocation%ss in function %s\n",
 
  235            ast_cli(
a->fd, 
"%10d bytes in %d allocation%s in file %s\n",
 
  240    ast_cli(
a->fd, 
"%10d bytes allocated in %d allocation%s\n", (
int) 
len, count, count > 1 ? 
"s" : 
"");
 
  246    AST_CLI_DEFINE(handle_cli_threadstorage_show_allocations, 
"Display outstanding thread local storage allocations"),
 
  247    AST_CLI_DEFINE(handle_cli_threadstorage_show_summary,     
"Summarize outstanding memory allocations")
 
  250static void threadstorage_shutdown(
void)
 
Prototypes for public functions only of internal interest,.
void ast_cli_unregister_multiple(void)
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_calloc(num, len)
A wrapper for calloc()
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct ast_cli_entry cli[]
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
A set of macros to manage forward-linked lists.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_HEAD_NOLOCK_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define pthread_mutex_lock
#define pthread_mutex_unlock
#define pthread_mutex_init
String manipulation functions.
descriptor for a cli entry.
void threadstorage_init(void)
Definitions to aid in the use of thread local storage.