#include "asterisk/autoconfig.h"
#include "asterisk/compat.h"
Go to the source code of this file.
Defines | |
#define | AST_DIR_MODE 0777 |
#define | AST_FILE_MODE 0666 |
#define | ASTERISK_FILE_VERSION(file, version) |
Register/unregister a source code file with the core. | |
#define | bcopy 0x__dont_use_bcopy__use_memmove_instead() |
#define | bzero 0x__dont_use_bzero__use_memset_instead"" |
#define | DEFAULT_LANGUAGE "en" |
#define | DEFAULT_SAMPLE_RATE 8000 |
#define | DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000) |
#define | sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__ |
#define | setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__ |
Functions | |
int | ast_add_profile (const char *, uint64_t scale) |
support for event profiling | |
char * | ast_complete_source_filename (const char *partial, int n) |
int | ast_fd_init (void) |
const char * | ast_file_version_find (const char *file) |
Find version for given module name. | |
int64_t | ast_mark (int, int start1_stop0) |
int | ast_pbx_init (void) |
int64_t | ast_profile (int, int64_t) |
int | ast_register_atexit (void(*func)(void)) |
Register a function to be executed before Asterisk exits. | |
void | ast_register_file_version (const char *file, const char *version) |
Register the version of a source code file with the core. | |
int | ast_set_priority (int) |
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing. | |
void | ast_unregister_atexit (void(*func)(void)) |
Unregister a function registered with ast_register_atexit(). | |
void | ast_unregister_file_version (const char *file) |
Unregister a source code file from the core. |
Definition in file asterisk.h.
#define AST_DIR_MODE 0777 |
Definition at line 33 of file asterisk.h.
#define AST_FILE_MODE 0666 |
Definition at line 36 of file asterisk.h.
Referenced by __ast_play_and_record(), action_createconfig(), ast_lock_path_lockfile(), ast_monitor_start(), chanspy_exec(), copy(), dbinit(), dictate_exec(), extenspy_exec(), festival_exec(), handle_cli_file_convert(), handle_pri_set_debug_file(), handle_recordfile(), load_module(), recordthread(), sms_log(), and try_firmware().
#define ASTERISK_FILE_VERSION | ( | file, | |||
version | ) |
Register/unregister a source code file with the core.
file | the source file name | |
version | the version string (typically a SVN revision keyword string) |
Example:
ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
Definition at line 164 of file asterisk.h.
#define bcopy 0x__dont_use_bcopy__use_memmove_instead() |
Definition at line 224 of file asterisk.h.
#define bzero 0x__dont_use_bzero__use_memset_instead"" |
Definition at line 223 of file asterisk.h.
#define DEFAULT_LANGUAGE "en" |
#define DEFAULT_SAMPLE_RATE 8000 |
Definition at line 41 of file asterisk.h.
Referenced by check_header(), ogg_vorbis_rewrite(), setformat(), and write_header().
#define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000) |
Definition at line 42 of file asterisk.h.
Referenced by ast_stream_fastforward(), ast_stream_rewind(), and isAnsweringMachine().
#define sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__ |
#define setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__ |
int ast_add_profile | ( | const char * | name, | |
uint64_t | scale | |||
) |
support for event profiling
Definition at line 691 of file asterisk.c.
References ast_calloc, ast_realloc, ast_strdup, profile_data::e, profile_data::entries, profile_entry::events, profile_entry::mark, profile_data::max_size, profile_entry::name, prof_data, profile_entry::scale, and profile_entry::value.
Referenced by extension_match_core().
00692 { 00693 int l = sizeof(struct profile_data); 00694 int n = 10; /* default entries */ 00695 00696 if (prof_data == NULL) { 00697 prof_data = ast_calloc(1, l + n*sizeof(struct profile_entry)); 00698 if (prof_data == NULL) 00699 return -1; 00700 prof_data->entries = 0; 00701 prof_data->max_size = n; 00702 } 00703 if (prof_data->entries >= prof_data->max_size) { 00704 void *p; 00705 n = prof_data->max_size + 20; 00706 p = ast_realloc(prof_data, l + n*sizeof(struct profile_entry)); 00707 if (p == NULL) 00708 return -1; 00709 prof_data = p; 00710 prof_data->max_size = n; 00711 } 00712 n = prof_data->entries++; 00713 prof_data->e[n].name = ast_strdup(name); 00714 prof_data->e[n].value = 0; 00715 prof_data->e[n].events = 0; 00716 prof_data->e[n].mark = 0; 00717 prof_data->e[n].scale = scale; 00718 return n; 00719 }
char* ast_complete_source_filename | ( | const char * | partial, | |
int | n | |||
) |
Definition at line 341 of file asterisk.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdup, file_version::file, len(), and ast_atexit::list.
Referenced by handle_verbose().
00342 { 00343 struct file_version *find; 00344 size_t len = strlen(partial); 00345 int count = 0; 00346 char *res = NULL; 00347 00348 AST_RWLIST_RDLOCK(&file_versions); 00349 AST_RWLIST_TRAVERSE(&file_versions, find, list) { 00350 if (!strncasecmp(find->file, partial, len) && ++count > n) { 00351 res = ast_strdup(find->file); 00352 break; 00353 } 00354 } 00355 AST_RWLIST_UNLOCK(&file_versions); 00356 return res; 00357 }
int ast_fd_init | ( | void | ) |
const char* ast_file_version_find | ( | const char * | file | ) |
Find version for given module name.
file | Module name (i.e. chan_sip.so) |
Definition at line 360 of file asterisk.c.
References AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, file_version::file, ast_atexit::list, and file_version::version.
Referenced by manager_modulecheck().
00361 { 00362 struct file_version *iterator; 00363 00364 AST_RWLIST_WRLOCK(&file_versions); 00365 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&file_versions, iterator, list) { 00366 if (!strcasecmp(iterator->file, file)) 00367 break; 00368 } 00369 AST_RWLIST_TRAVERSE_SAFE_END; 00370 AST_RWLIST_UNLOCK(&file_versions); 00371 if (iterator) 00372 return iterator->version; 00373 return NULL; 00374 }
int64_t ast_mark | ( | int | , | |
int | start1_stop0 | |||
) |
Definition at line 756 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, profile_entry::mark, prof_data, rdtsc(), profile_entry::scale, and profile_entry::value.
Referenced by __ast_pthread_mutex_lock(), and extension_match_core().
00757 { 00758 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00759 return 0; 00760 if (startstop == 1) 00761 prof_data->e[i].mark = rdtsc(); 00762 else { 00763 prof_data->e[i].mark = (rdtsc() - prof_data->e[i].mark); 00764 if (prof_data->e[i].scale > 1) 00765 prof_data->e[i].mark /= prof_data->e[i].scale; 00766 prof_data->e[i].value += prof_data->e[i].mark; 00767 prof_data->e[i].events++; 00768 } 00769 return prof_data->e[i].mark; 00770 }
int ast_pbx_init | ( | void | ) |
Provided by pbx.c
Definition at line 10243 of file pbx.c.
References ao2_container_alloc, hint_cmp(), hint_hash(), and hints.
Referenced by main().
10244 { 10245 hints = ao2_container_alloc(HASH_EXTENHINT_SIZE, hint_hash, hint_cmp); 10246 10247 return hints ? 0 : -1; 10248 }
int64_t ast_profile | ( | int | , | |
int64_t | ||||
) |
Definition at line 721 of file asterisk.c.
References profile_data::e, profile_data::entries, profile_entry::events, prof_data, profile_entry::scale, and profile_entry::value.
00722 { 00723 if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */ 00724 return 0; 00725 if (prof_data->e[i].scale > 1) 00726 delta /= prof_data->e[i].scale; 00727 prof_data->e[i].value += delta; 00728 prof_data->e[i].events++; 00729 return prof_data->e[i].value; 00730 }
int ast_register_atexit | ( | void(*)(void) | func | ) |
Register a function to be executed before Asterisk exits.
func | The callback function to use. |
0 | on success. | |
-1 | on error. |
Definition at line 932 of file asterisk.c.
References ast_calloc, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_unregister_atexit(), and ast_atexit::list.
Referenced by ast_cel_engine_init(), do_reload(), load_module(), and main().
00933 { 00934 struct ast_atexit *ae; 00935 00936 if (!(ae = ast_calloc(1, sizeof(*ae)))) 00937 return -1; 00938 00939 ae->func = func; 00940 00941 ast_unregister_atexit(func); 00942 00943 AST_RWLIST_WRLOCK(&atexits); 00944 AST_RWLIST_INSERT_HEAD(&atexits, ae, list); 00945 AST_RWLIST_UNLOCK(&atexits); 00946 00947 return 0; 00948 }
void ast_register_file_version | ( | const char * | file, | |
const char * | version | |||
) |
Register the version of a source code file with the core.
file | the source file name | |
version | the version string (typically a SVN revision keyword string) |
Definition at line 302 of file asterisk.c.
References ast_calloc, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdupa, ast_strip(), ast_strip_quoted(), and ast_atexit::list.
00303 { 00304 struct file_version *new; 00305 char *work; 00306 size_t version_length; 00307 00308 work = ast_strdupa(version); 00309 work = ast_strip(ast_strip_quoted(work, "$", "$")); 00310 version_length = strlen(work) + 1; 00311 00312 if (!(new = ast_calloc(1, sizeof(*new) + version_length))) 00313 return; 00314 00315 new->file = file; 00316 new->version = (char *) new + sizeof(*new); 00317 memcpy(new->version, work, version_length); 00318 AST_RWLIST_WRLOCK(&file_versions); 00319 AST_RWLIST_INSERT_HEAD(&file_versions, new, list); 00320 AST_RWLIST_UNLOCK(&file_versions); 00321 }
int ast_set_priority | ( | int | ) |
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing.
Provided by asterisk.c
Definition at line 1551 of file asterisk.c.
References ast_log(), ast_verbose, LOG_WARNING, sched_setscheduler, and setpriority.
Referenced by ast_safe_system(), canary_thread(), icesencode(), launch_script(), main(), mp3play(), NBScatplay(), send_waveform_to_fd(), spawn_mp3(), and spawn_ras().
01552 { 01553 struct sched_param sched; 01554 memset(&sched, 0, sizeof(sched)); 01555 #ifdef __linux__ 01556 if (pri) { 01557 sched.sched_priority = 10; 01558 if (sched_setscheduler(0, SCHED_RR, &sched)) { 01559 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01560 return -1; 01561 } else 01562 if (option_verbose) 01563 ast_verbose("Set to realtime thread\n"); 01564 } else { 01565 sched.sched_priority = 0; 01566 /* According to the manpage, these parameters can never fail. */ 01567 sched_setscheduler(0, SCHED_OTHER, &sched); 01568 } 01569 #else 01570 if (pri) { 01571 if (setpriority(PRIO_PROCESS, 0, -10) == -1) { 01572 ast_log(LOG_WARNING, "Unable to set high priority\n"); 01573 return -1; 01574 } else 01575 if (option_verbose) 01576 ast_verbose("Set to high priority\n"); 01577 } else { 01578 /* According to the manpage, these parameters can never fail. */ 01579 setpriority(PRIO_PROCESS, 0, 0); 01580 } 01581 #endif 01582 return 0; 01583 }
void ast_unregister_atexit | ( | void(*)(void) | func | ) |
Unregister a function registered with ast_register_atexit().
func | The callback function to unregister. |
Definition at line 950 of file asterisk.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, free, ast_atexit::func, and ast_atexit::list.
Referenced by ast_register_atexit(), do_reload(), and unload_module().
00951 { 00952 struct ast_atexit *ae = NULL; 00953 00954 AST_RWLIST_WRLOCK(&atexits); 00955 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) { 00956 if (ae->func == func) { 00957 AST_RWLIST_REMOVE_CURRENT(list); 00958 break; 00959 } 00960 } 00961 AST_RWLIST_TRAVERSE_SAFE_END; 00962 AST_RWLIST_UNLOCK(&atexits); 00963 00964 free(ae); 00965 }
void ast_unregister_file_version | ( | const char * | file | ) |
Unregister a source code file from the core.
file | the source file name |
Definition at line 323 of file asterisk.c.
References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, file_version::file, and ast_atexit::list.
00324 { 00325 struct file_version *find; 00326 00327 AST_RWLIST_WRLOCK(&file_versions); 00328 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) { 00329 if (!strcasecmp(find->file, file)) { 00330 AST_RWLIST_REMOVE_CURRENT(list); 00331 break; 00332 } 00333 } 00334 AST_RWLIST_TRAVERSE_SAFE_END; 00335 AST_RWLIST_UNLOCK(&file_versions); 00336 00337 if (find) 00338 ast_free(find); 00339 }