Asterisk - The Open Source Telephony Project GIT-master-7921072
Macros | Enumerations | Functions | Variables
time.h File Reference

Time-related functions and macros. More...

#include "asterisk/autoconfig.h"
#include <sys/time.h>
#include <unistd.h>
#include <math.h>
#include "asterisk/inline_api.h"
Include dependency graph for time.h:

Go to the source code of this file.

Macros

#define AST_TIME_T_LEN   21
 

Enumerations

enum  TIME_UNIT {
  TIME_UNIT_ERROR = -1 , TIME_UNIT_NANOSECOND , TIME_UNIT_MICROSECOND , TIME_UNIT_MILLISECOND ,
  TIME_UNIT_SECOND , TIME_UNIT_MINUTE , TIME_UNIT_HOUR , TIME_UNIT_DAY ,
  TIME_UNIT_WEEK , TIME_UNIT_MONTH , TIME_UNIT_YEAR
}
 Time units enumeration. More...
 

Functions

struct timeval ast_double2tv (double _td)
 Returns a timeval structure corresponding to the number of seconds in the double _td. More...
 
void ast_format_duration_hh_mm_ss (int duration, char *buf, size_t length)
 Formats a duration into HH:MM:SS. More...
 
int ast_remaining_ms (struct timeval start, int max_ms)
 Calculate remaining milliseconds given a starting timestamp and upper bound. More...
 
double ast_samp2sec (unsigned int _nsamp, unsigned int _rate)
 Returns the duration in seconds of _nsamp samples at rate _rate. More...
 
struct timeval ast_samp2tv (unsigned int _nsamp, unsigned int _rate)
 Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to timevals, or even milliseconds to timevals in the form ast_samp2tv(milliseconds, 1000) More...
 
unsigned int ast_sec2samp (double _seconds, int _rate)
 Returns the number of samples at _rate in the duration in _seconds. More...
 
time_t ast_string_to_time_t (const char *str)
 Returns a time_t from a string containing seconds since the epoch. More...
 
struct timeval ast_time_create (ast_time_t sec, ast_suseconds_t usec)
 Create a timeval object initialized to given values. More...
 
struct timeval ast_time_create_by_unit (unsigned long val, enum TIME_UNIT unit)
 Convert the given unit value, and create a timeval object from it. More...
 
struct timeval ast_time_create_by_unit_str (unsigned long val, const char *unit)
 Convert the given unit value, and create a timeval object from it. More...
 
enum TIME_UNIT ast_time_str_to_unit (const char *unit)
 Convert a string to a time unit enumeration value. More...
 
int ast_time_t_to_string (time_t time, char *buf, size_t length)
 Converts to a string representation of a time_t as decimal seconds since the epoch. Returns -1 on failure, zero otherwise. More...
 
ast_suseconds_t ast_time_tv_to_usec (const struct timeval *tv)
 Convert a timeval structure to microseconds. More...
 
struct timespec ast_tsnow (void)
 Returns current timespec. Meant to avoid calling ast_tvnow() just to create a timespec from the timeval it returns. More...
 
struct timeval ast_tv (ast_time_t sec, ast_suseconds_t usec)
 Returns a timeval from sec, usec. More...
 
double ast_tv2double (const struct timeval *tv)
 Returns a double corresponding to the number of seconds in the timeval tv. More...
 
time_t ast_tv2samp (const struct timeval *_tv, int _rate)
 Returns the number of samples at rate _rate in the duration specified by _tv. More...
 
struct timeval ast_tvadd (struct timeval a, struct timeval b)
 Returns the sum of two timevals a + b. More...
 
int ast_tvcmp (struct timeval _a, struct timeval _b)
 Compress two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second. More...
 
int64_t ast_tvdiff_ms (struct timeval end, struct timeval start)
 Computes the difference (in milliseconds) between two struct timeval instances. More...
 
int64_t ast_tvdiff_sec (struct timeval end, struct timeval start)
 Computes the difference (in seconds) between two struct timeval instances. More...
 
int64_t ast_tvdiff_us (struct timeval end, struct timeval start)
 Computes the difference (in microseconds) between two struct timeval instances. More...
 
int ast_tveq (struct timeval _a, struct timeval _b)
 Returns true if the two struct timeval arguments are equal. More...
 
struct timeval ast_tvnow (void)
 Returns current timeval. Meant to replace calls to gettimeofday(). More...
 
struct timeval ast_tvsub (struct timeval a, struct timeval b)
 Returns the difference of two timevals a - b. More...
 
int ast_tvzero (const struct timeval t)
 Returns true if the argument is 0,0. More...
 
typedef typeof (dummy_tv_var_for_types.tv_sec) ast_time_t
 

Variables

struct timeval dummy_tv_var_for_types
 

Detailed Description

Time-related functions and macros.

Definition in file time.h.

Macro Definition Documentation

◆ AST_TIME_T_LEN

#define AST_TIME_T_LEN   21

Definition at line 45 of file time.h.

Enumeration Type Documentation

◆ TIME_UNIT

enum TIME_UNIT

Time units enumeration.

Enumerator
TIME_UNIT_ERROR 
TIME_UNIT_NANOSECOND 
TIME_UNIT_MICROSECOND 
TIME_UNIT_MILLISECOND 
TIME_UNIT_SECOND 
TIME_UNIT_MINUTE 
TIME_UNIT_HOUR 
TIME_UNIT_DAY 
TIME_UNIT_WEEK 
TIME_UNIT_MONTH 
TIME_UNIT_YEAR 

Definition at line 338 of file time.h.

338 {
339 TIME_UNIT_ERROR = -1,
350};
@ TIME_UNIT_MONTH
Definition: time.h:348
@ TIME_UNIT_MICROSECOND
Definition: time.h:341
@ TIME_UNIT_WEEK
Definition: time.h:347
@ TIME_UNIT_MINUTE
Definition: time.h:344
@ TIME_UNIT_SECOND
Definition: time.h:343
@ TIME_UNIT_ERROR
Definition: time.h:339
@ TIME_UNIT_YEAR
Definition: time.h:349
@ TIME_UNIT_MILLISECOND
Definition: time.h:342
@ TIME_UNIT_HOUR
Definition: time.h:345
@ TIME_UNIT_DAY
Definition: time.h:346
@ TIME_UNIT_NANOSECOND
Definition: time.h:340

Function Documentation

◆ ast_double2tv()

struct timeval ast_double2tv ( double  _td)
inline

Returns a timeval structure corresponding to the number of seconds in the double _td.

Parameters
_tdThe number of seconds.
Returns
A timeval structure containing the number of seconds.

This is the inverse of ast_tv2double().

Definition at line 254 of file time.h.

267{

◆ ast_format_duration_hh_mm_ss()

void ast_format_duration_hh_mm_ss ( int  duration,
char *  buf,
size_t  length 
)

Formats a duration into HH:MM:SS.

Since
12
Parameters
durationThe time (in seconds) to format
bufA buffer to hold the formatted string'
lengthThe size of the buffer

Definition at line 2297 of file utils.c.

2298{
2299 int durh, durm, durs;
2300 durh = duration / 3600;
2301 durm = (duration % 3600) / 60;
2302 durs = duration % 60;
2303 snprintf(buf, length, "%02d:%02d:%02d", durh, durm, durs);
2304}
char buf[BUFSIZE]
Definition: eagi_proxy.c:66

References buf.

Referenced by cli_channel_print_body(), cli_channelstats_print_body(), handle_bridge_show_all(), handle_bridge_show_specific(), and stasis_show_topic().

◆ ast_remaining_ms()

int ast_remaining_ms ( struct timeval  start,
int  max_ms 
)

Calculate remaining milliseconds given a starting timestamp and upper bound.

If the upper bound is negative, then this indicates that there is no upper bound on the amount of time to wait. This will result in a negative return.

Parameters
startWhen timing started being calculated
max_msThe maximum number of milliseconds to wait from start. May be negative.
Returns
The number of milliseconds left to wait for. May be negative.

Definition at line 2281 of file utils.c.

2282{
2283 int ms;
2284
2285 if (max_ms < 0) {
2286 ms = max_ms;
2287 } else {
2288 ms = max_ms - ast_tvdiff_ms(ast_tvnow(), start);
2289 if (ms < 0) {
2290 ms = 0;
2291 }
2292 }
2293
2294 return ms;
2295}
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159

References ast_tvdiff_ms(), and ast_tvnow().

Referenced by __analog_ss_thread(), __ast_answer(), __ast_request_and_dial(), analog_ss_thread(), ast_iostream_write(), ast_recvtext(), ast_stun_request(), ast_waitfordigit_full(), disable_t38(), generic_fax_exec(), iostream_read(), parking_set_duration(), read_mf_digits(), read_sf_digits(), receivefax_t38_init(), record_exec(), safe_sleep_conditional(), scan_exec(), sendfax_t38_init(), SLEEP_SPINNER(), wait_exec(), wait_for_answer(), wait_for_signal_or_hangup(), waitforcond_exec(), and waitforring_exec().

◆ ast_samp2sec()

double ast_samp2sec ( unsigned int  _nsamp,
unsigned int  _rate 
)
inline

Returns the duration in seconds of _nsamp samples at rate _rate.

Parameters
_nsampThe number of samples
_rateThe sample rate in Hz.
Returns
A double containing the number of seconds.

This is the inverse of ast_sec2samp().

Definition at line 316 of file time.h.

330{

Referenced by ast_rtcp_calculate_sr_rr_statistics(), ast_rtcp_interpret(), calc_rxstamp_and_jitter(), and update_jitter_stats().

◆ ast_samp2tv()

struct timeval ast_samp2tv ( unsigned int  _nsamp,
unsigned int  _rate 
)
inline

◆ ast_sec2samp()

unsigned int ast_sec2samp ( double  _seconds,
int  _rate 
)
inline

Returns the number of samples at _rate in the duration in _seconds.

Parameters
_secondsThe time interval in seconds.
_rateThe sample rate in Hz.
Returns
The number of samples.

This is the inverse of ast_samp2sec().

Definition at line 333 of file time.h.

338{

Referenced by calc_rxstamp_and_jitter().

◆ ast_string_to_time_t()

time_t ast_string_to_time_t ( const char *  str)

Returns a time_t from a string containing seconds since the epoch.

Definition at line 163 of file time.c.

164{
165 struct tm tm = { 0, };
166
167 /* handle leading spaces */
168 if (strptime(str, " %s", &tm) == NULL) {
169 return (time_t)-1;
170 }
171 tm.tm_isdst = -1;
172 return mktime(&tm);
173}
const char * str
Definition: app_jack.c:147
#define NULL
Definition: resample.c:96

References NULL, and str.

Referenced by bucket_file_expired(), evaluate_equal(), evaluate_greater_than(), and evaluate_less_than().

◆ ast_time_create()

struct timeval ast_time_create ( ast_time_t  sec,
ast_suseconds_t  usec 
)

Create a timeval object initialized to given values.

Parameters
secThe timeval seconds value
usecThe timeval microseconds value
Returns
A timeval object

Definition at line 95 of file time.c.

96{
97 return ast_tv(sec, usec);
98}
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:235

References ast_tv().

Referenced by AST_TEST_DEFINE(), ast_time_create_by_unit(), and normalize_and_create().

◆ ast_time_create_by_unit()

struct timeval ast_time_create_by_unit ( unsigned long  val,
enum TIME_UNIT  unit 
)

Convert the given unit value, and create a timeval object from it.

Parameters
valThe value to convert to a timeval
unitThe time unit type of val
Returns
A timeval object

Definition at line 113 of file time.c.

114{
115 switch (unit) {
117 return normalize_and_create(val / 1000);
121 return normalize_and_create(val * 1000);
122 case TIME_UNIT_SECOND:
123 return ast_time_create(val, 0);
124 case TIME_UNIT_MINUTE:
125 return ast_time_create(val * 60, 0);
126 case TIME_UNIT_HOUR:
127 return ast_time_create(val * 3600, 0);
128 case TIME_UNIT_DAY:
129 return ast_time_create(val * 86400, 0);
130 case TIME_UNIT_WEEK:
131 return ast_time_create(val * 604800, 0);
132 case TIME_UNIT_MONTH:
133 /* Using Gregorian mean month - 30.436875 * 86400 */
134 return ast_time_create(val * 2629746, 0);
135 case TIME_UNIT_YEAR:
136 /* Using Gregorian year - 365.2425 * 86400 */
137 return ast_time_create(val * 31556952, 0);
138 default:
139 return ast_time_create(0, 0);
140 }
141}
Definition: ast_expr2.c:325
struct timeval ast_time_create(ast_time_t sec, ast_suseconds_t usec)
Create a timeval object initialized to given values.
Definition: time.c:95
static struct timeval normalize_and_create(unsigned long usec)
Create a timeval first converting the given microsecond value into seconds and microseconds.
Definition: time.c:108

References ast_time_create(), normalize_and_create(), TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MICROSECOND, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_MONTH, TIME_UNIT_NANOSECOND, TIME_UNIT_SECOND, TIME_UNIT_WEEK, and TIME_UNIT_YEAR.

Referenced by AST_TEST_DEFINE(), and ast_time_create_by_unit_str().

◆ ast_time_create_by_unit_str()

struct timeval ast_time_create_by_unit_str ( unsigned long  val,
const char *  unit 
)

Convert the given unit value, and create a timeval object from it.

This will first attempt to convert the unit from a string to a TIME_UNIT enumeration. If that conversion fails then a zeroed out timeval object is returned.

Parameters
valThe value to convert to a timeval
unitThe time unit type of val
Returns
A timeval object

Definition at line 143 of file time.c.

144{
146}
enum TIME_UNIT ast_time_str_to_unit(const char *unit)
Convert a string to a time unit enumeration value.
Definition: time.c:66
struct timeval ast_time_create_by_unit(unsigned long val, enum TIME_UNIT unit)
Convert the given unit value, and create a timeval object from it.
Definition: time.c:113

References ast_time_create_by_unit(), and ast_time_str_to_unit().

Referenced by AST_TEST_DEFINE().

◆ ast_time_str_to_unit()

enum TIME_UNIT ast_time_str_to_unit ( const char *  unit)

Convert a string to a time unit enumeration value.

This method attempts to be as flexible, and forgiving as possible when converting. In most cases the algorithm will match on the beginning of up to three strings (short, medium, long form). So that means if the given string at least starts with one of the form values it will match.

For example: us, usec, microsecond will all map to TIME_UNIT_MICROSECOND. So will uss, usecs, microseconds, or even microsecondvals

Matching is also not case sensitive.

Parameters
unitThe string to map to an enumeration
Returns
A time unit enumeration

Definition at line 66 of file time.c.

67{
68 size_t i, j;
69
70 if (!unit) {
71 return TIME_UNIT_ERROR;
72 }
73
74 for (i = 0; i < unit_labels_size; ++i) {
75 for (j = 0; j < MAX_UNIT_LABELS; ++j) {
76 /*
77 * A lazy pluralization check. If the given unit string at least starts
78 * with a label assume a match.
79 */
80 if (*unit_labels[i].values[j] && !strncasecmp(unit, unit_labels[i].values[j],
81 strlen(unit_labels[i].values[j]))) {
82 return unit_labels[i].unit;
83 }
84 }
85 }
86
87 return TIME_UNIT_ERROR;
88}
enum TIME_UNIT unit
Definition: time.c:47
static struct time_unit_labels unit_labels[]
Definition: time.c:51
#define MAX_UNIT_LABELS
Definition: time.c:44
const unsigned int unit_labels_size
Definition: time.c:64

References MAX_UNIT_LABELS, TIME_UNIT_ERROR, time_unit_labels::unit, unit_labels, and unit_labels_size.

Referenced by AST_TEST_DEFINE(), and ast_time_create_by_unit_str().

◆ ast_time_t_to_string()

int ast_time_t_to_string ( time_t  time,
char *  buf,
size_t  length 
)

Converts to a string representation of a time_t as decimal seconds since the epoch. Returns -1 on failure, zero otherwise.

The buffer should be at least 22 bytes long.

Converts to a string representation of a time_t as decimal seconds since the epoch. Returns -1 on failure, zero otherwise.

Definition at line 152 of file time.c.

153{
154 struct tm tm;
155
156 localtime_r(&time, &tm);
157 return (strftime(buf, length, "%s", &tm) == 0) ? -1 : 0;
158}
#define localtime_r
Definition: utils.h:521

References buf, and localtime_r.

Referenced by ast_sip_format_contact_ami(), bucket_file_set_expiration(), caldav_add_event(), check_expiration_thread(), display_single_entry(), expiration_struct2str(), icalendar_add_event(), odbc_obj_connect(), persistence_expires_struct2str(), and sprint_list_entry().

◆ ast_time_tv_to_usec()

ast_suseconds_t ast_time_tv_to_usec ( const struct timeval *  tv)

Convert a timeval structure to microseconds.

Parameters
tvThe timeval to convert
Returns
The time in microseconds

Definition at line 90 of file time.c.

91{
92 return tv->tv_sec * 1000000 + tv->tv_usec;
93}

Referenced by AST_TEST_DEFINE().

◆ ast_tsnow()

struct timespec ast_tsnow ( void  )
inline

Returns current timespec. Meant to avoid calling ast_tvnow() just to create a timespec from the timeval it returns.

Definition at line 186 of file time.h.

229{

Referenced by AST_TEST_DEFINE(), query_set_test(), resolution_thread(), and wait_for_resolution().

◆ ast_tv()

struct timeval ast_tv ( ast_time_t  sec,
ast_suseconds_t  usec 
)
inline

◆ ast_tv2double()

double ast_tv2double ( const struct timeval *  tv)
inline

Returns a double corresponding to the number of seconds in the timeval tv.

Parameters
tvA pointer to a timeval structure.
Returns
A double containing the number of seconds.

This is the inverse of ast_double2tv().

Definition at line 270 of file time.h.

279{

References ast_tv().

Referenced by ast_samp2tv(), and calc_rxstamp_and_jitter().

◆ ast_tv2samp()

time_t ast_tv2samp ( const struct timeval *  _tv,
int  _rate 
)
inline

Returns the number of samples at rate _rate in the duration specified by _tv.

Parameters
_tvA pointer to a timeval structure.
_rateThe sample rate in Hz.
Returns
A time_t containing the number of samples.

This is the inverse of ast_samp2tv().

Definition at line 299 of file time.h.

313{

◆ ast_tvadd()

struct timeval ast_tvadd ( struct timeval  a,
struct timeval  b 
)

Returns the sum of two timevals a + b.

Definition at line 2282 of file extconf.c.

2283{
2284 /* consistency checks to guarantee usec in 0..999999 */
2285 a = tvfix(a);
2286 b = tvfix(b);
2287 a.tv_sec += b.tv_sec;
2288 a.tv_usec += b.tv_usec;
2289 if (a.tv_usec >= ONE_MILLION) {
2290 a.tv_sec++;
2291 a.tv_usec -= ONE_MILLION;
2292 }
2293 return a;
2294}
#define ONE_MILLION
Definition: extconf.c:2261
static struct timeval tvfix(struct timeval a)
Definition: extconf.c:2266
static struct test_val b
static struct test_val a

References a, b, ONE_MILLION, and tvfix().

Referenced by __get_from_jb(), acf_jabberreceive_read(), ast_audiohook_trigger_wait(), ast_bridge_channel_feature_digit(), ast_bridge_interval_hook(), ast_channel_cmpwhentohangup_tv(), ast_channel_setwhentohangup_tv(), ast_poll2(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_end_with_duration(), ast_rtp_sendcng(), ast_sched_runq(), ast_sip_sched_task_get_times2(), ast_sip_schedule_task(), ast_smoother_read(), AST_TEST_DEFINE(), ast_translate(), bridge_builtin_set_limits(), bridge_channel_handle_interval(), bridge_sync_wait(), calc_rxstamp_and_jitter(), calc_timestamp(), cli_show_tasks(), cli_tps_ping(), conf_run(), consumer_should_stay(), dial_exec_full(), do_cdr(), do_timing(), expire_objects_from_cache(), handler_wait_for_message(), hook_event_cb(), iax2_process_thread(), jb_get_and_deliver(), jitterbuffer_frame_get_ntp_timestamp(), make_deadline(), mb_poll_thread(), monmp3thread(), mp3_exec(), mwi_monitor_handler(), rtp_deallocate_transport(), run_task(), sched_run(), sched_settime(), schedule_cache_expiration(), schedule_delivery(), set_timeout(), sla_process_timers(), smdi_message_wait(), sorcery_memory_cache_print_object(), subscription_persistence_update(), timeout_write(), user_event_wait_for_events(), and wait_for_stimulus().

◆ ast_tvcmp()

int ast_tvcmp ( struct timeval  _a,
struct timeval  _b 
)
inline

◆ ast_tvdiff_ms()

int64_t ast_tvdiff_ms ( struct timeval  end,
struct timeval  start 
)
inline

Computes the difference (in milliseconds) between two struct timeval instances.

Parameters
endend of the time period
startbeginning of the time period
Returns
the difference in milliseconds

Definition at line 107 of file time.h.

114{

Referenced by __analog_handle_event(), __ast_read(), __get_from_jb(), acf_jabberreceive_read(), action_coreshowchannels(), ast_audiohook_write_frame(), ast_carefulwrite(), ast_cdr_format_var(), ast_channel_cmpwhentohangup_tv(), ast_channel_end_dtmf(), ast_channel_get_duration_ms(), ast_channel_get_up_time_ms(), ast_check_hangup(), ast_get_enum(), ast_odbc_direct_execute(), ast_odbc_prepare_and_execute(), ast_poll2(), ast_remaining_ms(), ast_rtp_interpret(), ast_rtp_read(), ast_sched_wait(), ast_sip_sched_task_get_times2(), AST_TEST_DEFINE(), ast_waitfor_nandfds(), audiohook_read_frame_both(), background_detect_exec(), bridge_agent_hold_heartbeat(), bridge_channel_feature_timeout(), bridge_channel_handle_feature_timeout(), bridge_channel_handle_interval(), bridge_channel_next_interval(), bridge_channel_settle_owed_events(), calc_rxstamp(), calc_timestamp(), calc_txpeerstamp(), calc_txstamp(), cdr_object_finalize(), cdr_object_get_billsec(), cdr_object_get_duration(), check_date_header(), check_endpoint(), check_timer(), cli_show_channel(), cli_show_channels(), cli_subscription_expiry(), cli_unid_print_body(), conf_run(), contact_expire(), dahdi_handle_event(), dahdi_read(), destroy_trans(), disa_exec(), dundi_do_lookup(), dundi_do_precache(), dundi_lookup_internal(), dundi_precache_internal(), dundi_query_eid_internal(), expire_contact(), expire_objects_from_cache(), expire_requests(), fax_detect_framehook(), fax_gateway_framehook(), fix_peerts(), get_now(), handle_chanlist(), handle_cli_file_convert(), handle_cli_performance_test(), handle_cli_queue_test(), handle_recordfile(), handle_timeout_trip(), hook_callback(), hook_event_cb(), http_callback(), isAnsweringMachine(), limits_interval_playback(), measurenoise(), monmp3thread(), mp3_exec(), process_dtmf_rfc2833(), publish_msg(), purge_old_fn(), purge_old_messages(), receive_ademco_event(), receive_dtmf_digits(), registrar_add_contact(), rtp_codecs_find_non_primary_dynamic_rx(), rtp_learning_rtp_seq_update(), run_task(), schedule_cache_expiration(), scheduler(), set_interval_hook(), should_skip_dtmf(), should_trigger_dtmf_emulating(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), sla_check_station_delay(), smdi_message_wait(), softmix_bridge_write_control(), softmix_mixing_loop(), sorcery_memory_cache_print_object(), sorcery_memory_cache_thrash_retrieve(), sorcery_memory_cache_thrash_update(), speech_background(), sub_persistence_recreate(), subscription_invoke(), subscription_persistence_recreate(), talk_detect_audiohook_cb(), test_write_and_read_interleaved_frames(), testloop(), timeout_read(), timing_test(), update_jbsched(), updates(), wait_for_answer(), wait_for_output(), and waituntil_exec().

◆ ast_tvdiff_sec()

int64_t ast_tvdiff_sec ( struct timeval  end,
struct timeval  start 
)
inline

Computes the difference (in seconds) between two struct timeval instances.

Parameters
endthe end of the time period
startthe beginning of the time period
Returns
the difference in seconds

Definition at line 73 of file time.h.

83{

References end.

Referenced by acf_jabberreceive_read(), delete_old_messages(), generate_status(), get_channel_duration(), get_core_uptime_cb(), get_last_reload_cb(), and purge_events().

◆ ast_tvdiff_us()

int64_t ast_tvdiff_us ( struct timeval  end,
struct timeval  start 
)
inline

Computes the difference (in microseconds) between two struct timeval instances.

Parameters
endthe end of the time period
startthe beginning of the time period
Returns
the difference in microseconds

Definition at line 87 of file time.h.

97{

References end.

Referenced by ast_media_index_update_for_file(), ast_merge_contexts_and_delete(), cdr_read_callback(), execute_cb(), handle_cli_sched_bench(), is_timed_out(), load_modules(), odbc_log(), pgsql_log(), rtp_transport_wide_cc_feedback_produce(), sip_options_contact_status_notify_task(), and tds_log().

◆ ast_tveq()

int ast_tveq ( struct timeval  _a,
struct timeval  _b 
)
inline

Returns true if the two struct timeval arguments are equal.

Definition at line 147 of file time.h.

154{

References NULL.

Referenced by ast_translate().

◆ ast_tvnow()

struct timeval ast_tvnow ( void  )
inline

Returns current timeval. Meant to replace calls to gettimeofday().

Definition at line 159 of file time.h.

168{

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_answer(), __ast_channel_alloc_ap(), __ast_read(), __ast_request_and_dial(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __dahdi_exception(), __get_from_jb(), __manager_event_sessions_va(), acf_jabberreceive_read(), acf_strftime(), action_coreshowchannels(), action_login(), action_ping(), agent_alert(), agent_login_exec(), agent_run(), alarmreceiver_exec(), alloc_security_event_json_object(), analog_call(), analog_ss_thread(), app_send_end_msg(), app_update(), append_event(), ast_ari_asterisk_ping(), ast_audiohook_trigger_wait(), ast_audiohook_write_frame(), ast_bridge_channel_feature_digit(), ast_bridge_interval_hook(), ast_carefulwrite(), ast_cdr_fork(), ast_cdr_format_var(), ast_cdr_reset(), ast_cel_create_event(), ast_channel_cmpwhentohangup_tv(), ast_channel_end_dtmf(), ast_channel_get_duration_ms(), ast_channel_get_up_time_ms(), ast_channel_setwhentohangup_tv(), ast_check_hangup(), ast_check_timing(), ast_get_enum(), ast_http_send(), ast_iostream_write(), ast_localtime_wakeup_monitor(), ast_merge_contexts_and_delete(), ast_module_reload(), ast_odbc_direct_execute(), ast_odbc_prepare_and_execute(), ast_poll2(), ast_queue_log(), ast_recvtext(), ast_remaining_ms(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_end_with_duration(), ast_rtp_read(), ast_rtp_rtcp_handle_nack(), ast_rtp_sendcng(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_is(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_from_now_pt(), ast_sched_dump(), ast_sched_runq(), ast_sched_wait(), ast_sched_when(), ast_senddigit_begin(), ast_serializer_shutdown_group_join(), ast_sip_sched_task_get_times2(), ast_sip_schedule_task(), ast_sorcery_alloc(), ast_stun_request(), AST_TEST_DEFINE(), ast_translate(), ast_waitfor_nandfds(), ast_waitfordigit_full(), ast_websocket_write(), asterisk_daemon(), audiohook_read_frame_both(), authenticate(), background_detect_exec(), bridge_agent_hold_heartbeat(), bridge_base_init(), bridge_builtin_set_limits(), bridge_channel_feature_timeout(), bridge_channel_handle_feature_timeout(), bridge_channel_handle_interval(), bridge_channel_next_interval(), bridge_channel_settle_owed_events(), bridge_channel_write_frame(), bridge_sync_wait(), bucket_file_expired(), bucket_file_set_expiration(), build_device(), calc_rxstamp(), calc_timestamp(), calc_txstamp(), caldav_load_calendar(), calendar_busy_callback(), calendar_devstate_change(), calendar_write_exec(), callerid_genmsg(), canary_thread(), cdr_object_get_billsec(), cdr_object_get_duration(), cdr_read_callback(), check_date_header(), check_endpoint(), check_expiration_thread(), check_timer(), cleanup(), cli_channel_print_body(), cli_channelstats_print_body(), cli_prompt(), cli_show_channel(), cli_show_channels(), cli_show_tasks(), cli_subscription_expiry(), cli_tps_ping(), cli_unid_print_body(), conf_run(), consumer_should_stay(), consumer_wait_for(), consumer_wait_for_completion(), contact_expire(), create_dtmf_frame(), create_transaction(), dahdi_handle_event(), dahdi_read(), debug_check_frame_for_silence(), delete_old_messages(), destroy_trans(), dial_exec_full(), disa_exec(), disable_t38(), do_cdr(), do_refresh(), do_timing(), dundi_do_lookup(), dundi_do_precache(), dundi_lookup_internal(), dundi_precache_internal(), dundi_query_eid_internal(), endpoint_lookup(), evt_gen_auth_method_not_allowed(), evt_gen_chal_resp_failed(), evt_gen_chal_sent(), evt_gen_failed_acl(), evt_gen_inval_acct_id(), evt_gen_inval_password(), evt_gen_inval_transport(), evt_gen_load_avg(), evt_gen_mem_limit(), evt_gen_req_bad_format(), evt_gen_req_no_support(), evt_gen_req_not_allowed(), evt_gen_session_limit(), evt_gen_successful_auth(), evt_gen_unexpected_addr(), ewscal_load_calendar(), exchangecal_load_calendar(), expire_contact(), expire_objects_from_cache(), expire_requests(), fax_detect_framehook(), fax_detect_new(), fax_gateway_detect_t38(), fax_gateway_framehook(), fax_gateway_request_t38(), find_cache(), find_conf_realtime(), find_tpeer(), fix_peerts(), format_log_message_ap(), generate_parked_user(), generate_status(), generic_fax_exec(), geoloc_eprofile_to_intermediate(), get_channel_duration(), get_core_uptime_cb(), get_date(), get_ewscal_ids_for(), get_last_reload_cb(), get_lock(), get_tick_count(), handle_bridge_show_all(), handle_bridge_show_specific(), handle_chanlist(), handle_cli_file_convert(), handle_cli_iax2_show_cache(), handle_cli_performance_test(), handle_cli_queue_test(), handle_cli_sched_bench(), handle_cli_test_locales(), handle_recordfile(), handle_showcalls(), handle_showchan(), handle_showuptime(), handle_timeout_trip(), handler_wait_for_message(), has_complex_started(), hook_callback(), hook_event_cb(), http_callback(), iax2_datetime(), iax2_process_thread(), iax2_trunk_queue(), ical_load_calendar(), iostream_read(), is_cert_cache_entry_expired(), is_timed_out(), isAnsweringMachine(), jb_framedata_init(), leave_voicemail(), limits_interval_playback(), link_topic_proxy(), load_config(), load_modules(), logging_on_tx_msg(), make_deadline(), make_logchannel(), mb_poll_thread(), measurenoise(), meetme_stasis_generate_msg(), memory_cache_stale_check_object(), message_received_handler(), mid_test_sync(), monitor_dial(), monmp3thread(), mp3_exec(), mwi_monitor_handler(), odbc_obj_connect(), parked_call_payload_from_parked_user(), payload_mapping_rx_clear_primary(), pbx_builtin_gotoiftime(), pjsip_history_entry_alloc(), pjsip_logger_write_to_pcap(), play_message_datetime(), process_text_line(), pthread_timer_set_rate(), publish_fully_booted(), publish_msg(), purge_events(), purge_old_messages(), qualify_peer(), queue_ringing_trunk(), read_mf_digits(), read_sf_digits(), realtime_common(), receive_ademco_event(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), registrar_add_contact(), rt_extend_conf(), rtcp_message_handler(), rtp_deallocate_transport(), rtp_instance_parse_transport_wide_cc(), rtp_learning_rtp_seq_update(), rtp_learning_start(), rtp_raw_write(), run_task(), safe_sleep_conditional(), scan_exec(), sched_run(), sched_settime(), schedule_cache_expiration(), schedule_calendar_event(), scheduler(), send_date_time(), send_date_time2(), send_date_time3(), send_device_state(), send_start_msg_snapshots(), sendfax_t38_init(), sendmail(), session_do(), set_channel_answer_time(), set_header(), set_interval_hook(), set_timeout(), should_skip_dtmf(), should_trigger_dtmf_emulating(), shutdown_waitfor_completion(), shutdown_waitfor_start(), sip_options_contact_callback_data_alloc(), sip_options_contact_status_notify_task(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), sla_check_station_delay(), sla_create_failed_station(), sla_create_ringing_station(), sla_process_timers(), SLEEP_SPINNER(), smdi_message_wait(), smdi_read(), sms_handleincoming(), sms_handleincoming_proto2(), sms_readfile(), sms_writefile(), socket_process_meta(), softmix_bridge_write_control(), softmix_mixing_loop(), sorcery_memory_cache_print_object(), sorcery_memory_cache_thrash_retrieve(), sorcery_memory_cache_thrash_update(), sorcery_memory_cached_object_alloc(), speech_background(), stasis_app_exec(), stasis_message_create_full(), stasis_show_topic(), sub_persistence_recreate(), subscription_invoke(), subscription_persistence_recreate(), subscription_persistence_update(), talk_detect_audiohook_cb(), task_1(), task_wait(), test_write_and_read_interleaved_frames(), testloop(), timeout_read(), timeout_write(), timing_read(), timing_test(), update_caldav(), update_exchangecal(), update_jbsched(), user_event_wait_for_events(), verify_mock_cdr_record(), vmu_tm(), wait_exec(), wait_for_answer(), wait_for_channel_callback(), wait_for_completion(), wait_for_complex_completion(), wait_for_complex_start(), wait_for_device_state_updates(), wait_for_empty_notice(), wait_for_hook(), wait_for_output(), wait_for_signal_or_hangup(), wait_for_stimulus(), wait_for_task_pushed(), wait_until_thread_state(), wait_until_thread_state_task_pushed(), waitforcond_exec(), waitforring_exec(), waituntil_exec(), worker_idle(), write_history(), write_metadata(), and xmpp_pak_message().

◆ ast_tvsub()

struct timeval ast_tvsub ( struct timeval  a,
struct timeval  b 
)

Returns the difference of two timevals a - b.

Definition at line 2297 of file extconf.c.

2298{
2299 /* consistency checks to guarantee usec in 0..999999 */
2300 a = tvfix(a);
2301 b = tvfix(b);
2302 a.tv_sec -= b.tv_sec;
2303 a.tv_usec -= b.tv_usec;
2304 if (a.tv_usec < 0) {
2305 a.tv_sec-- ;
2306 a.tv_usec += ONE_MILLION;
2307 }
2308 return a;
2309}

References a, b, ONE_MILLION, and tvfix().

Referenced by action_login(), ast_poll2(), ast_sched_dump(), AST_TEST_DEFINE(), ast_translate(), ast_waitfor_nandfds(), calc_rxstamp(), calc_rxstamp_and_jitter(), calc_timestamp(), cli_tps_ping(), conf_run(), debug_check_frame_for_silence(), handle_showcalls(), handle_showuptime(), jitterbuffer_frame_get_ntp_timestamp(), memory_cache_stale_check_object(), object_stale_callback(), and publish_fully_booted().

◆ ast_tvzero()

int ast_tvzero ( const struct timeval  t)
inline

◆ typeof()

typedef typeof ( dummy_tv_var_for_types.  tv_sec)

Variable Documentation

◆ dummy_tv_var_for_types

struct timeval dummy_tv_var_for_types
extern