39 #ifdef HAVE_TIMERFD_CREATE 40 #include <sys/timerfd.h> 44 #define DISABLE_1MS_COND 48 #define UINT32_MAX 0xffffffff 51 #define MAX_TICK UINT32_MAX - 1024 53 #define MAX_ELEMENTS 3600 54 #define IDLE_SPEED 100 61 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) 73 #if defined(HAVE_TIMERFD_CREATE) 75 #if defined(HAVE_CLOCK_NANOSLEEP) 92 static CRITICAL_SECTION timer_section;
94 static DWORD win32_last_get_time_tick = 0;
96 static uint8_t win32_use_qpc = 0;
97 static uint64_t win32_qpc_freq = 0;
111 #undef SWITCH_MOD_DECLARE_DATA 112 #define SWITCH_MOD_DECLARE_DATA __declspec(dllexport) 153 #if defined(HAVE_CLOCK_NANOSLEEP) || defined(DARWIN) 164 if (t > 100000 || !
NANO) {
170 #if defined(HAVE_CLOCK_NANOSLEEP) 172 ts.tv_sec = t / 1000000;
173 ts.tv_nsec = ((t % 1000000) * 1000);
174 clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
176 #elif defined(DARWIN) 178 ts.tv_sec = t / APR_USEC_PER_SEC;
179 ts.tv_nsec = (t % APR_USEC_PER_SEC) * 850;
180 nanosleep(&ts, NULL);
196 for (x = 0; x < reps; x++) {
200 sum += (stop -
start);
207 #define calc_step() if (step > 11) step -= 10; else if (step > 1) step-- 212 int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0, lastgood = 0, one_k = 0;
214 #ifdef HAVE_CLOCK_GETRES 217 clock_getres(CLOCK_MONOTONIC, &ts);
218 res = ts.tv_nsec / 1000;
221 if (res > 900 && res < 1100) {
227 "Timer resolution of %ld microseconds detected!\n" 228 "Do you have your kernel timer frequency set to lower than 1,000Hz? " 239 over = under = good = 0;
242 for (x = 0; x < 100; x++) {
246 diff = abs((
int) (want - avg));
249 "Abnormally large timer gap %d detected!\n" 250 "Do you have your kernel timer frequency set to lower than 1,000Hz? You may experience audio problems.\n", diff);
257 lastgood = (int) val;
262 lastgood = (int) val;
266 }
else if (avg > want) {
271 if ((val - step) < 0) {
278 }
else if (avg < want) {
283 if ((val - step) < 0) {
294 OFFSET = (int) (want - val);
296 }
else if (lastgood) {
297 OFFSET = (int) (want - lastgood);
333 #if (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) || defined(WIN32) 334 MONO = enable ? 1 : 0;
350 #if defined(HAVE_TIMERFD_CREATE) 368 #if defined(HAVE_CLOCK_NANOSLEEP) 369 NANO = enable ? 1 : 0;
375 COND = enable ? 1 : 0;
385 int64_t elapsed = (now - timer->
start);
404 #ifdef HAVE_TIMERFD_CREATE 406 #define MAX_INTERVAL 2000 408 struct interval_timer {
411 typedef struct interval_timer interval_timer_t;
413 static switch_status_t timerfd_start_interval(interval_timer_t *it,
int interval)
415 struct itimerspec val;
419 fd = timerfd_create(CLOCK_MONOTONIC, 0);
425 val.it_interval.tv_sec = interval / 1000;
426 val.it_interval.tv_nsec = (interval % 1000) * 1000000;
427 val.it_value.tv_sec = 0;
428 val.it_value.tv_nsec = 100000;
430 if (timerfd_settime(fd, 0, &val, NULL) < 0) {
435 if (read(fd, &exp,
sizeof(exp)) < 0) {
454 interval_timer_t *it;
487 if (read(it->fd, &u64,
sizeof(u64)) < 0) {
500 struct itimerspec val;
507 timerfd_gettime(it->fd, &val);
508 diff = val.it_interval.tv_nsec / 1000;
518 _timerfd_step(timer);
530 rc = timerfd_stop_interval(it);
544 #if (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) || defined(WIN32) 548 clock_gettime(offset ? CLOCK_MONOTONIC : CLOCK_REALTIME, &ts);
549 if (offset < 0) offset = 0;
550 now = ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000) + offset;
554 }
else if (offset < 0) offset = 0;
560 QueryPerformanceCounter((LARGE_INTEGER*)&count);
561 now = ((count * 1000000) / win32_qpc_freq) + offset;
567 tick_now = timeGetTime();
568 if (win32_tick_time_since_start != -1) {
569 EnterCriticalSection(&timer_section);
571 tick_diff = tick_now - win32_last_get_time_tick;
572 win32_tick_time_since_start += tick_diff;
574 win32_last_get_time_tick = tick_now;
575 now = (win32_tick_time_since_start * 1000) + offset;
576 LeaveCriticalSection(&timer_section);
581 now = (tick_now * 1000) + offset;
589 #if (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) || defined(WIN32) 643 if (
globals.RUNNING != 1 || t < 1000 || t >= 10000) {
647 #ifndef DISABLE_1MS_COND 648 if (
globals.use_cond_yield == 1) {
664 #ifdef DISABLE_1MS_COND 713 #ifdef HAVE_TIMERFD_CREATE 715 return _timerfd_init(timer);
721 if (++sanity == 300) {
740 private_info->
start -= 2;
742 private_info->
ready = 1;
768 #define check_roll() if (private_info->roll < TIMER_MATRIX[timer->interval].roll) { \ 769 private_info->roll++; \ 770 private_info->reference = private_info->start = (switch_size_t)TIMER_MATRIX[timer->interval].tick; \ 771 private_info->start--; \ 784 #ifdef HAVE_TIMERFD_CREATE 786 return _timerfd_step(timer);
818 #ifdef HAVE_TIMERFD_CREATE 844 #ifdef DISABLE_1MS_COND 855 #ifdef HAVE_TIMERFD_CREATE 857 return _timerfd_next(timer);
887 if (
globals.use_cond_yield == 1) {
912 #ifdef HAVE_TIMERFD_CREATE 914 return _timerfd_check(timer, step);
957 #ifdef HAVE_TIMERFD_CREATE 959 return _timerfd_destroy(timer);
974 private_info->
ready = 0;
992 OSVERSIONINFOEX version_info;
994 EnterCriticalSection(&timer_section);
996 ZeroMemory(&version_info,
sizeof(OSVERSIONINFOEX));
997 version_info.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
1001 if (GetVersionEx((OSVERSIONINFO*) &version_info)) {
1002 if (version_info.dwPlatformId == VER_PLATFORM_WIN32_NT && version_info.dwMajorVersion >= 6) {
1003 if (QueryPerformanceFrequency((LARGE_INTEGER*)&win32_qpc_freq) && win32_qpc_freq > 0) {
1019 if (win32_use_qpc) {
1022 if (!QueryPerformanceCounter((LARGE_INTEGER*)&count) || count == 0) {
1028 if (!win32_use_qpc) {
1030 win32_last_get_time_tick = timeGetTime();
1031 win32_tick_time_since_start = win32_last_get_time_tick;
1034 LeaveCriticalSection(&timer_section);
1041 uint32_t current_ms = 0;
1042 uint32_t x, tick = 0, sps_interval_ticks = 0;
1044 int fwd_errs = 0, rev_errs = 0;
1045 int profile_tick = 0;
1049 #ifdef HAVE_TIMERFD_CREATE 1052 struct itimerspec spec = { { 0 } };
1055 tfd = timerfd_create(CLOCK_MONOTONIC, 0);
1058 spec.it_interval.tv_sec = 0;
1060 spec.it_value.tv_sec = 0;
1061 spec.it_value.tv_nsec = 100000;
1063 if (timerfd_settime(tfd, 0, &spec, NULL)) {
1069 if (tfd > -1)
MATRIX = 0;
1091 for (loops = 0; loops < 3; loops++) {
1108 fwd_errs = rev_errs = 0;
1110 #ifndef DISABLE_1MS_COND 1124 while (
globals.RUNNING == 1) {
1126 #ifdef HAVE_TIMERFD_CREATE 1129 timerfd_settime(tfd, 0, &spec, NULL);
1149 int64_t diff = (int64_t) (ts - last);
1159 #if defined(HAVE_CLOCK_NANOSLEEP) 1161 "If you see this message many times try setting the param enable-clock-nanosleep to true in switch.conf.xml or consider a nicer machine to run me on.\n");
1164 "If you see this message many times consider a nicer machine to run me on.\n");
1174 if (tfd > -1 &&
globals.RUNNING == 1) {
1176 read(tfd, &exp,
sizeof(exp));
1221 if (fwd_errs > 9 || rev_errs > 9) {
1225 fwd_errs = rev_errs = 0;
1237 if (++profile_tick == 1) {
1251 if (sps_interval_ticks >= 300) {
1253 sps_interval_ticks = 0;
1258 sps_interval_ticks++;
1272 #ifndef DISABLE_1MS_COND 1273 TIMER_MATRIX[1].
tick++;
1278 if (TIMER_MATRIX[1].tick ==
MAX_TICK) {
1279 TIMER_MATRIX[1].
tick = 0;
1280 TIMER_MATRIX[1].
roll++;
1287 if ((current_ms % x) == 0) {
1288 if (TIMER_MATRIX[x].
count) {
1289 TIMER_MATRIX[x].
tick++;
1290 #ifdef DISABLE_1MS_COND 1297 if (TIMER_MATRIX[x].tick ==
MAX_TICK) {
1298 TIMER_MATRIX[x].
tick = 0;
1299 TIMER_MATRIX[x].
roll++;
1348 memset(xt, 0,
sizeof(*xt));
1360 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) 1383 if (
zstr(tz_name) || !TIMEZONES_LIST.
hash) {
1396 switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL;
1399 if (TIMEZONES_LIST.
hash) {
1403 if (TIMEZONES_LIST.
pool) {
1407 memset(&TIMEZONES_LIST, 0,
sizeof(TIMEZONES_LIST));
1443 static void tztime(
const time_t *
const timep,
const char *tzstring,
struct tm *
const tmp);
1447 struct tm xtm = { 0 };
1448 const char *tz_name = tz;
1456 timep = (thetime) / (int64_t) (1000000);
1458 if (!
zstr(tz_name)) {
1466 tztime(&timep, tzdef, &xtm);
1479 const char *tz_name = tz;
1484 struct tm tm = { 0 };
1491 timep = (thetime) / (int64_t) (1000000);
1493 if (!
zstr(tz_name)) {
1501 tztime(&timep, tzdef, &tm);
1519 InitializeCriticalSection(&timer_section);
1559 if (win32_use_qpc) {
1592 while (
globals.RUNNING == -1) {
1598 win32_tick_time_since_start = -1;
1599 DeleteCriticalSection(&timer_section);
1602 if (TIMEZONES_LIST.
hash) {
1606 if (TIMEZONES_LIST.
pool) {
1637 #include <sys/time.h> 1651 #ifndef TZ_MAX_TIMES 1658 #define TZ_MAX_TIMES 370 1661 #ifndef TZ_MAX_TYPES 1664 #define TZ_MAX_TYPES 256 1672 #define TZ_MAX_TYPES 20 1677 #ifndef TZ_MAX_CHARS 1678 #define TZ_MAX_CHARS 50 1682 #ifndef TZ_MAX_LEAPS 1683 #define TZ_MAX_LEAPS 50 1687 #define MY_TZNAME_MAX TZNAME_MAX 1691 #define MY_TZNAME_MAX 255 1695 #define SECSPERMIN 60 1696 #define MINSPERHOUR 60 1697 #define HOURSPERDAY 24 1698 #define DAYSPERWEEK 7 1699 #define DAYSPERNYEAR 365 1700 #define DAYSPERLYEAR 366 1701 #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) 1702 #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) 1703 #define MONSPERYEAR 12 1705 #define JULIAN_DAY 0 1706 #define DAY_OF_YEAR 1 1707 #define MONTH_NTH_DAY_OF_WEEK 2 1709 #define EPOCH_YEAR 1970 1710 #define EPOCH_WDAY TM_THURSDAY 1713 #ifndef TZ_MAX_TIMES 1720 #define TZ_MAX_TIMES 370 1724 #define TZDEFRULES "posixrules" 1734 #ifndef TZDEFRULESTRING 1735 #define TZDEFRULESTRING ",M4.1.0,M10.5.0" 1739 #define is_digit(c) ((unsigned)(c) - '0' <= 9) 1741 #define BIGGEST(a, b) (((a) > (b)) ? (a) : (b)) 1743 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) 1751 #ifndef GNUC_or_lint 1753 #define GNUC_or_lint 1757 #define GNUC_or_lint 1762 #define GNUC_or_lint 1767 #define INITIALIZE(x) ((x) = 0) 1769 #ifndef GNUC_or_lint 1770 #define INITIALIZE(x) 1777 #define TM_TUESDAY 2 1778 #define TM_WEDNESDAY 3 1779 #define TM_THURSDAY 4 1781 #define TM_SATURDAY 6 1783 #define TM_JANUARY 0 1784 #define TM_FEBRUARY 1 1791 #define TM_SEPTEMBER 8 1792 #define TM_OCTOBER 9 1793 #define TM_NOVEMBER 10 1794 #define TM_DECEMBER 11 1796 #define TM_YEAR_BASE 1900 1798 #define EPOCH_YEAR 1970 1799 #define EPOCH_WDAY TM_THURSDAY 1806 static const char gmt[] =
"GMT";
1808 #define CHARS_DEF BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), (2 * (MY_TZNAME_MAX + 1))) 1846 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
1847 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
1870 while ((c = *strp) !=
'\0' && !
is_digit(c) && c !=
',' && c !=
'-' && c !=
'+')
1883 static const char *
getnum(
register const char *strp,
int *
const nump,
const int min,
const int max)
1888 if (strp == NULL || !
is_digit(c = *strp))
1892 num = num * 10 + (c -
'0');
1911 static const char *
getsecs(
register const char *strp,
long *
const secsp)
1934 strp =
getnum(strp, &num, 0, SECSPERMIN);
1950 static const char *
getoffset(
register const char *strp,
long *
const offsetp)
1952 register int neg = 0;
1957 }
else if (*strp ==
'+')
1959 strp =
getsecs(strp, offsetp);
1963 *offsetp = -*offsetp;
1974 static const char *
getrule(
const char *strp,
register struct rule *
const rulep)
1983 }
else if (*strp ==
'M') {
2028 static time_t
transtime(
const time_t janfirst,
const int year,
register const struct rule *
const rulep,
const long offset)
2030 register int leapyear;
2031 register time_t
value;
2033 int d, m1, yy0, yy1, yy2, dow;
2048 if (leapyear && rulep->
r_day >= 60)
2066 for (i = 0; i < rulep->
r_mon - 1; ++i)
2073 m1 = (rulep->
r_mon + 9) % 12 + 1;
2074 yy0 = (rulep->
r_mon <= 2) ? (year - 1) : year;
2077 dow = ((26 * m1 - 2) / 10 + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
2086 d = rulep->
r_day - dow;
2089 for (i = 1; i < rulep->
r_week; ++i) {
2108 return value + rulep->
r_time + offset;
2120 const char *stdname;
2121 const char *dstname;
2126 register time_t *atp;
2127 register unsigned char *typep;
2135 stdlen = strlen(name);
2137 if (stdlen >=
sizeof sp->
chars)
2138 stdlen = (
sizeof sp->
chars) - 1;
2142 stdlen = name - stdname;
2154 if (*name !=
'\0') {
2157 dstlen = name - dstname;
2160 if (*name !=
'\0' && *name !=
',' && *name !=
';') {
2168 if (*name ==
',' || *name ==
';') {
2172 register time_t janfirst;
2177 if ((name =
getrule(name, &start)) == NULL)
2181 if ((name =
getrule(name, &end)) == NULL)
2207 for (year =
EPOCH_YEAR; year <= 2037; ++year) {
2208 starttime =
transtime(janfirst, year, &start, stdoffset);
2209 endtime =
transtime(janfirst, year, &end, dstoffset);
2210 if (starttime > endtime) {
2226 register long theirstdoffset;
2227 register long theirdstoffset;
2228 register long theiroffset;
2239 for (i = 0; i < sp->
timecnt; ++i) {
2247 for (i = 0; i < sp->
timecnt; ++i) {
2262 for (i = 0; i < sp->
timecnt; ++i) {
2283 sp->
ats[i] += dstoffset - theirdstoffset;
2285 sp->
ats[i] += stdoffset - theirstdoffset;
2290 theirdstoffset = theiroffset;
2292 theirstdoffset = theiroffset;
2315 sp->
charcnt = (int) (stdlen + 1);
2317 sp->
charcnt += (int) (dstlen + 1);
2321 (void) strncpy(cp, stdname, stdlen);
2325 (void) strncpy(cp, dstname, dstlen);
2326 *(cp + dstlen) =
'\0';
2334 #if (_MSC_VER >= 1400) // VC8+ 2335 #define switch_assert(expr) assert(expr);__analysis_assume( expr ) 2337 #define switch_assert(expr) assert(expr) 2340 static void timesub(
const time_t *
const timep,
const long offset,
register const struct state *
const sp,
register struct tm *
const tmp)
2342 register const struct lsinfo *lp;
2344 register time_t rem;
2347 register const int *
ip;
2358 i = (sp == NULL) ? 0 : sp->
leapcnt;
2381 if (*timep == 0x80000000) {
2390 rem += (offset - corr);
2407 tmp->tm_sec = (int) (rem %
SECSPERMIN) + hit;
2410 if (tmp->tm_wday < 0)
2415 #define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) 2428 tmp->tm_yday = (int) days;
2432 for (tmp->tm_mon = 0; days >= (
long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
2433 days = days - (long) ip[tmp->tm_mon];
2435 tmp->tm_mday = (
int) (days + 1);
2437 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) 2438 tmp->tm_gmtoff = offset;
2446 static void tztime(
const time_t *
const timep,
const char *tzstring,
struct tm *
const tmp)
2448 struct state *tzptr, *sp;
2449 const time_t t = *timep;
2451 register const struct ttinfo *ttisp;
2453 if (tzstring == NULL)
2456 tzptr = (
struct state *) malloc(
sizeof(
struct state));
2459 if (tzptr != NULL) {
2473 for (i = 1; i < sp->
timecnt; ++i)
2476 i = sp->
types[i - 1];
2478 ttisp = &sp->
ttis[i];
2489 #if defined(HAVE_STRUCT_TM_TM_ZONE)
switch_status_t(* timer_sync)(switch_timer_t *)
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
void switch_time_sync(void)
static switch_status_t timer_sync(switch_timer_t *timer)
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
static switch_status_t timer_init(switch_timer_t *timer)
static switch_status_t timer_step(switch_timer_t *timer)
switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
SWITCH_MODULE_DEFINITION(CORE_SOFTTIMER_MODULE, softtimer_load, softtimer_shutdown, softtimer_runtime)
switch_status_t switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data, switch_event_node_t **node)
Bind an event callback to a specific event.
#define SWITCH_CHANNEL_LOG
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
static switch_time_t time_now(int64_t offset)
const char * switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr)
returns the value of the requested tag attribute, or NULL if not found
static void tm2switchtime(struct tm *tm, switch_time_exp_t *xt)
#define switch_core_hash_init(_hash)
void switch_os_yield(void)
static timer_matrix_t TIMER_MATRIX[MAX_ELEMENTS+1]
void switch_time_set_nanosleep(switch_bool_t enable)
static const char * getoffset(register const char *strp, long *const offsetp)
void switch_sleep(switch_interval_time_t t)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
Representation of an event.
const char *const const char *const const cJSON *const value
void switch_cond_yield(switch_interval_time_t t)
SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown)
static switch_timezones_list_t TIMEZONES_LIST
SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
A representation of an XML tree.
static switch_memory_pool_t * module_pool
switch_mutex_t * throttle_mutex
switch_status_t switch_thread_cond_wait(switch_thread_cond_t *cond, switch_mutex_t *mutex)
A table of functions that a timer module implements.
char const int const cJSON_bool format
A node to store binded events.
switch_status_t switch_strftime_nocheck(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
void switch_time_set_timerfd(int enable)
static const int year_lengths[2]
Abstract handler to a timer module.
struct switch_runtime runtime
uint32_t microseconds_per_tick
static switch_interval_time_t average_time(switch_interval_time_t t, int reps)
switch_status_t(* timer_init)(switch_timer_t *)
static switch_status_t timer_destroy(switch_timer_t *timer)
switch_status_t switch_core_thread_set_cpu_affinity(int cpu)
static switch_status_t timer_next(switch_timer_t *timer)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
SWITCH_MODULE_LOAD_FUNCTION(softtimer_load)
struct lsinfo lsis[TZ_MAX_LEAPS]
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
void switch_micro_sleep(switch_interval_time_t t)
#define SWITCH_MUTEX_NESTED
int32_t sessions_peak_fivemin
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
static void timesub(const time_t *const timep, const long offset, register const struct state *const sp, register struct tm *const tmp)
void switch_time_set_matrix(switch_bool_t enable)
static time_t transtime(const time_t janfirst, const int year, register const struct rule *const rulep, const long offset)
switch_bool_t switch_get_system_idle_time(switch_profile_timer_t *p, double *idle_percentage)
provides the percentage of idle system time
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
switch_memory_pool_t * memory_pool
switch_memory_pool_t * pool
switch_status_t(* timer_check)(switch_timer_t *, switch_bool_t)
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
switch_status_t(* timer_destroy)(switch_timer_t *)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
static int tzparse(const char *name, register struct state *const sp, const int lastditch)
switch_status_t switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime)
static const int mon_lengths[2][MONSPERYEAR]
switch_mutex_t * session_hash_mutex
void switch_cond_next(void)
int64_t switch_interval_time_t
uint32_t last_samplecount
static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp)
void switch_delete_profile_timer(switch_profile_timer_t **p)
Deletes profile timer.
static switch_status_t timer_check(switch_timer_t *timer, switch_bool_t step)
struct ttinfo ttis[TZ_MAX_TYPES]
unsigned char types[TZ_MAX_TIMES]
struct fspr_thread_mutex_t switch_mutex_t
#define switch_assert(expr)
switch_profile_timer_t * switch_new_profile_timer(void)
create a new profile timer
static switch_event_node_t * NODE
const char * switch_lookup_timezone(const char *tz_name)
void switch_load_timezones(switch_bool_t reload)
void switch_time_set_monotonic(switch_bool_t enable)
switch_status_t
Common return values.
switch_xml_t switch_xml_open_cfg(_In_z_ const char *file_path, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params)
open a config in the core registry
switch_status_t(* timer_step)(switch_timer_t *)
static const char * getzname(register const char *strp)
switch_loadable_module_interface_t * switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name)
switch_thread_cond_t * cond
#define switch_core_hash_insert(_h, _k, _d)
static switch_status_t timer_generic_sync(switch_timer_t *timer)
void switch_time_calibrate_clock(void)
static const char * getsecs(register const char *strp, long *const secsp)
struct switch_session_manager session_manager
#define LEAPS_THRU_END_OF(y)
struct fspr_thread_cond_t switch_thread_cond_t
#define MONTH_NTH_DAY_OF_WEEK
switch_time_t switch_mono_micro_time_now(void)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
static const char * getnum(register const char *strp, int *const nump, const int min, const int max)
void switch_time_set_use_system_time(switch_bool_t enable)
void switch_time_set_cond_yield(switch_bool_t enable)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
static switch_time_t last_time
while(unpack->bits_cur<=SWITCH_BITS_PER_BYTE)
struct fspr_pool_t switch_memory_pool_t
static void do_sleep(switch_interval_time_t t)
switch_status_t switch_thread_cond_broadcast(switch_thread_cond_t *cond)
static void event_handler(switch_event_t *event)
switch_status_t switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime)
switch_thread_rwlock_t * rwlock
static void win32_init_timers(void)
switch_time_t switch_time_now(void)
struct fspr_thread_rwlock_t switch_thread_rwlock_t
switch_status_t(* timer_next)(switch_timer_t *)
switch_profile_timer_t * profile_timer
const char * interface_name
void * switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname)
switch_time_t switch_time_ref(void)
static const char * getrule(const char *strp, register struct rule *const rulep)
switch_status_t switch_event_unbind(switch_event_node_t **node)
Unbind a bound event consumer.