38 #ifdef HAVE_TIMERFD_CREATE
39 #include <sys/timerfd.h>
43 #define DISABLE_1MS_COND
47 #define UINT32_MAX 0xffffffff
50 #define MAX_TICK UINT32_MAX - 1024
52 #define MAX_ELEMENTS 3600
53 #define IDLE_SPEED 100
60 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
72 #if defined(HAVE_TIMERFD_CREATE)
74 #if defined(HAVE_CLOCK_NANOSLEEP)
91 static CRITICAL_SECTION timer_section;
93 static DWORD win32_last_get_time_tick = 0;
95 static uint8_t win32_use_qpc = 0;
96 static uint64_t win32_qpc_freq = 0;
110 #undef SWITCH_MOD_DECLARE_DATA
111 #define SWITCH_MOD_DECLARE_DATA __declspec(dllexport)
152 #if defined(HAVE_CLOCK_NANOSLEEP) || defined(DARWIN)
163 if (t > 100000 || !
NANO) {
169 #if defined(HAVE_CLOCK_NANOSLEEP)
171 ts.tv_sec = t / 1000000;
172 ts.tv_nsec = ((t % 1000000) * 1000);
173 clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
175 #elif defined(DARWIN)
177 ts.tv_sec = t / APR_USEC_PER_SEC;
178 ts.tv_nsec = (t % APR_USEC_PER_SEC) * 850;
179 nanosleep(&ts, NULL);
195 for (x = 0; x < reps; x++) {
199 sum += (stop - start);
206 #define calc_step() if (step > 11) step -= 10; else if (step > 1) step--
211 int over = 0, under = 0, good = 0, step = 50, diff = 0, retry = 0, lastgood = 0, one_k = 0;
213 #ifdef HAVE_CLOCK_GETRES
216 clock_getres(CLOCK_MONOTONIC, &ts);
217 res = ts.tv_nsec / 1000;
220 if (res > 900 && res < 1100) {
226 "Timer resolution of %ld microseconds detected!\n"
227 "Do you have your kernel timer frequency set to lower than 1,000Hz? "
238 over = under = good = 0;
241 for (x = 0; x < 100; x++) {
245 diff = abs((
int) (want - avg));
248 "Abnormally large timer gap %d detected!\n"
249 "Do you have your kernel timer frequency set to lower than 1,000Hz? You may experience audio problems.\n", diff);
256 lastgood = (int) val;
261 lastgood = (int) val;
265 }
else if (avg > want) {
270 if ((val - step) < 0) {
277 }
else if (avg < want) {
282 if ((val - step) < 0) {
293 OFFSET = (int) (want - val);
295 }
else if (lastgood) {
296 OFFSET = (int) (want - lastgood);
332 #if (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) || defined(WIN32)
333 MONO = enable ? 1 : 0;
349 #if defined(HAVE_TIMERFD_CREATE)
367 #if defined(HAVE_CLOCK_NANOSLEEP)
368 NANO = enable ? 1 : 0;
374 COND = enable ? 1 : 0;
384 int64_t elapsed = (now - timer->
start);
395 #ifdef HAVE_TIMERFD_CREATE
397 #define MAX_INTERVAL 2000
399 struct interval_timer {
402 typedef struct interval_timer interval_timer_t;
404 static switch_status_t timerfd_start_interval(interval_timer_t *it,
int interval)
406 struct itimerspec val;
410 fd = timerfd_create(CLOCK_MONOTONIC, 0);
416 val.it_interval.tv_sec = interval / 1000;
417 val.it_interval.tv_nsec = (interval % 1000) * 1000000;
418 val.it_value.tv_sec = 0;
419 val.it_value.tv_nsec = 100000;
421 if (timerfd_settime(fd, 0, &val, NULL) < 0) {
426 if ((r = read(fd, &exp,
sizeof(exp)) < 0)) {
445 interval_timer_t *it;
474 if (read(it->fd, &u64,
sizeof(u64)) < 0) {
487 struct itimerspec val;
490 timerfd_gettime(it->fd, &val);
491 diff = val.it_interval.tv_nsec / 1000;
501 _timerfd_step(timer);
512 rc = timerfd_stop_interval(it);
524 #if (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) || defined(WIN32)
528 clock_gettime(offset ? CLOCK_MONOTONIC : CLOCK_REALTIME, &ts);
529 if (offset < 0) offset = 0;
530 now = ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec / 1000) + offset;
534 }
else if (offset < 0) offset = 0;
540 QueryPerformanceCounter((LARGE_INTEGER*)&count);
541 now = ((count * 1000000) / win32_qpc_freq) + offset;
547 tick_now = timeGetTime();
548 if (win32_tick_time_since_start != -1) {
549 EnterCriticalSection(&timer_section);
551 tick_diff = tick_now - win32_last_get_time_tick;
552 win32_tick_time_since_start += tick_diff;
554 win32_last_get_time_tick = tick_now;
555 now = (win32_tick_time_since_start * 1000) + offset;
556 LeaveCriticalSection(&timer_section);
561 now = (tick_now * 1000) + offset;
569 #if (defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)) || defined(WIN32)
623 if (
globals.RUNNING != 1 || t < 1000 || t >= 10000) {
627 #ifndef DISABLE_1MS_COND
628 if (
globals.use_cond_yield == 1) {
644 #ifdef DISABLE_1MS_COND
694 #ifdef HAVE_TIMERFD_CREATE
696 return _timerfd_init(timer);
702 if (++sanity == 300) {
721 private_info->
start -= 2;
723 private_info->
ready = 1;
749 #define check_roll() if (private_info->roll < TIMER_MATRIX[timer->interval].roll) { \
750 private_info->roll++; \
751 private_info->reference = private_info->start = (switch_size_t)TIMER_MATRIX[timer->interval].tick; \
752 private_info->start--; \
765 #ifdef HAVE_TIMERFD_CREATE
767 return _timerfd_step(timer);
799 #ifdef HAVE_TIMERFD_CREATE
825 #ifdef DISABLE_1MS_COND
836 #ifdef HAVE_TIMERFD_CREATE
838 return _timerfd_next(timer);
868 if (
globals.use_cond_yield == 1) {
893 #ifdef HAVE_TIMERFD_CREATE
895 return _timerfd_check(timer, step);
938 #ifdef HAVE_TIMERFD_CREATE
940 return _timerfd_destroy(timer);
955 private_info->
ready = 0;
973 OSVERSIONINFOEX version_info;
975 EnterCriticalSection(&timer_section);
977 ZeroMemory(&version_info,
sizeof(OSVERSIONINFOEX));
978 version_info.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
982 if (GetVersionEx((OSVERSIONINFO*) &version_info)) {
983 if (version_info.dwPlatformId == VER_PLATFORM_WIN32_NT && version_info.dwMajorVersion >= 6) {
984 if (QueryPerformanceFrequency((LARGE_INTEGER*)&win32_qpc_freq) && win32_qpc_freq > 0) {
1000 if (win32_use_qpc) {
1003 if (!QueryPerformanceCounter((LARGE_INTEGER*)&count) || count == 0) {
1009 if (!win32_use_qpc) {
1011 win32_last_get_time_tick = timeGetTime();
1012 win32_tick_time_since_start = win32_last_get_time_tick;
1015 LeaveCriticalSection(&timer_section);
1022 uint32_t current_ms = 0;
1023 uint32_t x, tick = 0, sps_interval_ticks = 0;
1025 int fwd_errs = 0, rev_errs = 0;
1026 int profile_tick = 0;
1030 #ifdef HAVE_TIMERFD_CREATE
1033 struct itimerspec spec = { { 0 } };
1036 tfd = timerfd_create(CLOCK_MONOTONIC, 0);
1039 spec.it_interval.tv_sec = 0;
1041 spec.it_value.tv_sec = 0;
1042 spec.it_value.tv_nsec = 100000;
1044 if (timerfd_settime(tfd, 0, &spec, NULL)) {
1050 if (tfd > -1)
MATRIX = 0;
1073 for (loops = 0; loops < 3; loops++) {
1091 fwd_errs = rev_errs = 0;
1093 #ifndef DISABLE_1MS_COND
1107 while (
globals.RUNNING == 1) {
1109 #ifdef HAVE_TIMERFD_CREATE
1112 timerfd_settime(tfd, 0, &spec, NULL);
1132 int64_t diff = (int64_t) (ts - last);
1142 #if defined(HAVE_CLOCK_NANOSLEEP)
1144 "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. I AM *FREE* afterall.\n");
1147 "If you see this message many times consider a nicer machine to run me on. I AM *FREE* afterall.\n");
1157 if (tfd > -1 &&
globals.RUNNING == 1) {
1160 r = read(tfd, &exp,
sizeof(exp));
1205 if (fwd_errs > 9 || rev_errs > 9) {
1209 fwd_errs = rev_errs = 0;
1221 if (++profile_tick == 1) {
1232 if (sps_interval_ticks >= 300) {
1234 sps_interval_ticks = 0;
1240 sps_interval_ticks++;
1253 #ifndef DISABLE_1MS_COND
1254 TIMER_MATRIX[1].
tick++;
1259 if (TIMER_MATRIX[1].tick ==
MAX_TICK) {
1260 TIMER_MATRIX[1].
tick = 0;
1261 TIMER_MATRIX[1].
roll++;
1268 if ((current_ms % x) == 0) {
1269 if (TIMER_MATRIX[x].count) {
1270 TIMER_MATRIX[x].
tick++;
1271 #ifdef DISABLE_1MS_COND
1278 if (TIMER_MATRIX[x].tick ==
MAX_TICK) {
1279 TIMER_MATRIX[x].
tick = 0;
1280 TIMER_MATRIX[x].
roll++;
1330 memset(xt, 0,
sizeof(*xt));
1342 #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
1365 if (
zstr(tz_name) || !TIMEZONES_LIST.
hash) {
1378 switch_xml_t xml = NULL, x_lists = NULL, x_list = NULL, cfg = NULL;
1381 if (TIMEZONES_LIST.
hash) {
1385 if (TIMEZONES_LIST.
pool) {
1389 memset(&TIMEZONES_LIST, 0,
sizeof(TIMEZONES_LIST));
1425 static void tztime(
const time_t *
const timep,
const char *tzstring,
struct tm *
const tmp);
1429 struct tm xtm = { 0 };
1430 const char *tz_name = tz;
1438 timep = (thetime) / (int64_t) (1000000);
1440 if (!
zstr(tz_name)) {
1449 tztime(&timep, tzdef, &xtm);
1462 const char *tz_name = tz;
1467 struct tm tm = { 0 };
1474 timep = (thetime) / (int64_t) (1000000);
1476 if (!
zstr(tz_name)) {
1485 tztime(&timep, tzdef, &tm);
1503 InitializeCriticalSection(&timer_section);
1543 if (win32_use_qpc) {
1576 while (
globals.RUNNING == -1) {
1582 win32_tick_time_since_start = -1;
1583 DeleteCriticalSection(&timer_section);
1586 if (TIMEZONES_LIST.
hash) {
1590 if (TIMEZONES_LIST.
pool) {
1621 #include <sys/time.h>
1635 #ifndef TZ_MAX_TIMES
1642 #define TZ_MAX_TIMES 370
1645 #ifndef TZ_MAX_TYPES
1648 #define TZ_MAX_TYPES 256
1656 #define TZ_MAX_TYPES 20
1661 #ifndef TZ_MAX_CHARS
1662 #define TZ_MAX_CHARS 50
1666 #ifndef TZ_MAX_LEAPS
1667 #define TZ_MAX_LEAPS 50
1671 #define MY_TZNAME_MAX TZNAME_MAX
1675 #define MY_TZNAME_MAX 255
1679 #define SECSPERMIN 60
1680 #define MINSPERHOUR 60
1681 #define HOURSPERDAY 24
1682 #define DAYSPERWEEK 7
1683 #define DAYSPERNYEAR 365
1684 #define DAYSPERLYEAR 366
1685 #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
1686 #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
1687 #define MONSPERYEAR 12
1689 #define JULIAN_DAY 0
1690 #define DAY_OF_YEAR 1
1691 #define MONTH_NTH_DAY_OF_WEEK 2
1693 #define EPOCH_YEAR 1970
1694 #define EPOCH_WDAY TM_THURSDAY
1697 #ifndef TZ_MAX_TIMES
1704 #define TZ_MAX_TIMES 370
1708 #define TZDEFRULES "posixrules"
1718 #ifndef TZDEFRULESTRING
1719 #define TZDEFRULESTRING ",M4.1.0,M10.5.0"
1723 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
1725 #define BIGGEST(a, b) (((a) > (b)) ? (a) : (b))
1727 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
1735 #ifndef GNUC_or_lint
1737 #define GNUC_or_lint
1741 #define GNUC_or_lint
1746 #define GNUC_or_lint
1751 #define INITIALIZE(x) ((x) = 0)
1753 #ifndef GNUC_or_lint
1754 #define INITIALIZE(x)
1761 #define TM_TUESDAY 2
1762 #define TM_WEDNESDAY 3
1763 #define TM_THURSDAY 4
1765 #define TM_SATURDAY 6
1767 #define TM_JANUARY 0
1768 #define TM_FEBRUARY 1
1775 #define TM_SEPTEMBER 8
1776 #define TM_OCTOBER 9
1777 #define TM_NOVEMBER 10
1778 #define TM_DECEMBER 11
1780 #define TM_YEAR_BASE 1900
1782 #define EPOCH_YEAR 1970
1783 #define EPOCH_WDAY TM_THURSDAY
1790 static const char gmt[] =
"GMT";
1792 #define CHARS_DEF BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))
1830 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
1831 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
1854 while ((c = *strp) !=
'\0' && !
is_digit(c) && c !=
',' && c !=
'-' && c !=
'+')
1867 static const char *
getnum(
register const char *strp,
int *
const nump,
const int min,
const int max)
1872 if (strp == NULL || !
is_digit(c = *strp))
1876 num = num * 10 + (c -
'0');
1895 static const char *
getsecs(
register const char *strp,
long *
const secsp)
1918 strp =
getnum(strp, &num, 0, SECSPERMIN);
1934 static const char *
getoffset(
register const char *strp,
long *
const offsetp)
1936 register int neg = 0;
1941 }
else if (*strp ==
'+')
1943 strp =
getsecs(strp, offsetp);
1947 *offsetp = -*offsetp;
1958 static const char *
getrule(
const char *strp,
register struct rule *
const rulep)
1967 }
else if (*strp ==
'M') {
2012 static time_t
transtime(
const time_t janfirst,
const int year,
register const struct rule *
const rulep,
const long offset)
2014 register int leapyear;
2015 register time_t value;
2017 int d, m1, yy0, yy1, yy2, dow;
2032 if (leapyear && rulep->
r_day >= 60)
2050 for (i = 0; i < rulep->
r_mon - 1; ++i)
2051 value += mon_lengths[leapyear][i] *
SECSPERDAY;
2057 m1 = (rulep->
r_mon + 9) % 12 + 1;
2058 yy0 = (rulep->
r_mon <= 2) ? (year - 1) : year;
2061 dow = ((26 * m1 - 2) / 10 + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
2070 d = rulep->
r_day - dow;
2073 for (i = 1; i < rulep->
r_week; ++i) {
2092 return value + rulep->
r_time + offset;
2102 static int tzparse(
const char *name,
register struct state *
const sp,
const int lastditch)
2104 const char *stdname;
2105 const char *dstname;
2110 register time_t *atp;
2111 register unsigned char *typep;
2119 stdlen = strlen(name);
2121 if (stdlen >=
sizeof sp->
chars)
2122 stdlen = (
sizeof sp->
chars) - 1;
2126 stdlen = name - stdname;
2138 if (*name !=
'\0') {
2141 dstlen = name - dstname;
2144 if (*name !=
'\0' && *name !=
',' && *name !=
';') {
2152 if (*name ==
',' || *name ==
';') {
2156 register time_t janfirst;
2161 if ((name =
getrule(name, &start)) == NULL)
2165 if ((name =
getrule(name, &end)) == NULL)
2191 for (year =
EPOCH_YEAR; year <= 2037; ++year) {
2192 starttime =
transtime(janfirst, year, &start, stdoffset);
2193 endtime =
transtime(janfirst, year, &end, dstoffset);
2194 if (starttime > endtime) {
2210 register long theirstdoffset;
2211 register long theirdstoffset;
2212 register long theiroffset;
2223 for (i = 0; i < sp->
timecnt; ++i) {
2231 for (i = 0; i < sp->
timecnt; ++i) {
2242 theiroffset = theirstdoffset;
2247 for (i = 0; i < sp->
timecnt; ++i) {
2268 sp->
ats[i] += dstoffset - theirdstoffset;
2270 sp->
ats[i] += stdoffset - theirstdoffset;
2275 theirdstoffset = theiroffset;
2277 theirstdoffset = theiroffset;
2300 sp->
charcnt = (int) (stdlen + 1);
2302 sp->
charcnt += (int) (dstlen + 1);
2306 (void) strncpy(cp, stdname, stdlen);
2310 (void) strncpy(cp, dstname, dstlen);
2311 *(cp + dstlen) =
'\0';
2319 #if (_MSC_VER >= 1400) // VC8+
2320 #define switch_assert(expr) assert(expr);__analysis_assume( expr )
2322 #define switch_assert(expr) assert(expr)
2325 static void timesub(
const time_t *
const timep,
const long offset,
register const struct state *
const sp,
register struct tm *
const tmp)
2327 register const struct lsinfo *lp;
2329 register time_t rem;
2332 register const int *ip;
2343 i = (sp == NULL) ? 0 : sp->
leapcnt;
2366 if (*timep == 0x80000000) {
2375 rem += (offset - corr);
2392 tmp->tm_sec = (int) (rem %
SECSPERMIN) + hit;
2395 if (tmp->tm_wday < 0)
2400 #define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
2402 while (days < 0 || days >= (
long) year_lengths[yleap =
isleap(y)]) {
2413 tmp->tm_yday = (int) days;
2415 ip = mon_lengths[yleap];
2417 for (tmp->tm_mon = 0; days >= (
long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
2418 days = days - (long) ip[tmp->tm_mon];
2420 tmp->tm_mday = (
int) (days + 1);
2422 #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
2423 tmp->tm_gmtoff = offset;
2431 static void tztime(
const time_t *
const timep,
const char *tzstring,
struct tm *
const tmp)
2433 struct state *tzptr, *sp;
2434 const time_t t = *timep;
2436 register const struct ttinfo *ttisp;
2438 if (tzstring == NULL)
2441 tzptr = (
struct state *) malloc(
sizeof(
struct state));
2444 if (tzptr != NULL) {
2458 for (i = 1; i < sp->
timecnt; ++i)
2461 i = sp->
types[i - 1];
2463 ttisp = &sp->
ttis[i];
2474 #if defined(HAVE_STRUCT_TM_TM_ZONE)
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.
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.
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)
struct apr_thread_cond_t switch_thread_cond_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)
switch_status_t(* timer_next)(switch_timer_t *)
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_status_t(* timer_init)(switch_timer_t *)
switch_memory_pool_t * pool
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
switch_status_t(* timer_sync)(switch_timer_t *)
struct apr_thread_rwlock_t switch_thread_rwlock_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
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]
#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)
struct apr_thread_mutex_t switch_mutex_t
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
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)
switch_status_t(* timer_check)(switch_timer_t *, switch_bool_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.
switch_status_t(* timer_destroy)(switch_timer_t *)
struct apr_pool_t switch_memory_pool_t
#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.
switch_status_t(* timer_step)(switch_timer_t *)
static switch_time_t last_time
while(unpack->bits_cur<=SWITCH_BITS_PER_BYTE)
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)
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.