#include <sys/time.h>
#include <stdint.h>
Go to the source code of this file.
Defines | |
#define | MB_TIMEVAL_SET(_tv, _sec, _usec) |
#define | MB_TIMEVAL_CP(_tv1, _tv2) |
#define | MB_TIMEVAL_SEC(_tv) ((_tv)->tv_sec) |
#define | MB_TIMEVAL_USEC(_tv) ((_tv)->tv_usec) |
#define | MB_TIMEVAL_LATER(a, b) |
#define | MB_TIMEVAL_LATER_INC(a, b) |
#define | MB_TIMEVAL_EQ(a, b) |
#define | MB_TIMEVAL_DIFF(a, b) |
#define | MB_TIMEVAL_ADD(a, b) |
#define | MB_TIMEVAL_DIV(a, b) |
Typedefs | |
typedef uint32_t | mbsec_t |
typedef uint32_t | mbusec_t |
typedef struct _mb_timer | mb_timer_t |
typedef struct _mb_tman | mb_tman_t |
typedef struct timeval | mb_timeval_t |
typedef void(* | mb_tmo_hdlr )(const mb_timeval_t *tmo, const mb_timeval_t *now, void *arg) |
Functions | |
mb_tman_t * | mb_tman_new (void) |
void | mb_tman_free (mb_tman_t *tman) |
mb_timer_t * | mb_tman_timeout (mb_tman_t *tman, const mb_timeval_t *tmo, mb_tmo_hdlr hdlr, void *arg) |
int | mb_tman_remove (mb_tman_t *tman, mb_timer_t *timer) |
int | mb_tman_next_timeout (mb_tman_t *tman, const mb_timeval_t *now, mb_timeval_t *tmo_after) |
Get how long to next timeout from this monent. | |
int | mb_tman_handle_timeout (mb_tman_t *tman, mb_timeval_t *now) |
void | get_now (mb_timeval_t *tmo) |
#define MB_TIMEVAL_ADD | ( | a, | |||
b | ) |
Value:
do { \ (a)->tv_sec += (b)->tv_sec; \ (a)->tv_usec += (b)->tv_usec; \ if((a)->tv_usec >= 1000000) { \ (a)->tv_sec++; \ (a)->tv_usec -= 1000000; \ } \ } while(0)
Definition at line 61 of file mb_timer.h.
#define MB_TIMEVAL_CP | ( | _tv1, | |||
_tv2 | ) |
Value:
do { \ (_tv1)->tv_sec = (_tv2)->tv_sec; \ (_tv1)->tv_usec = (_tv2)->tv_usec; \ } while(0)
Definition at line 34 of file mb_timer.h.
#define MB_TIMEVAL_DIFF | ( | a, | |||
b | ) |
Value:
do { \ (a)->tv_sec -= (b)->tv_sec; \ if((a)->tv_usec < (b)->tv_usec) { \ (a)->tv_sec--; \ (a)->tv_usec += 1000000; \ } \ (a)->tv_usec -= (b)->tv_usec; \ } while(0)
Definition at line 52 of file mb_timer.h.
#define MB_TIMEVAL_DIV | ( | a, | |||
b | ) |
Value:
(((a)->tv_sec * 1000000.0 + (a)->tv_usec) / \ ((b)->tv_sec * 1000000.0 + (b)->tv_usec))
Definition at line 70 of file mb_timer.h.
#define MB_TIMEVAL_EQ | ( | a, | |||
b | ) |
Value:
((a)->tv_sec == (b)->tv_sec && \ (a)->tv_usec == (b)->tv_usec)
Definition at line 49 of file mb_timer.h.
#define MB_TIMEVAL_LATER | ( | a, | |||
b | ) |
Value:
((a)->tv_sec > (b)->tv_sec || \ ((a)->tv_sec == (b)->tv_sec && \ (a)->tv_usec > (b)->tv_usec))
Definition at line 41 of file mb_timer.h.
#define MB_TIMEVAL_LATER_INC | ( | a, | |||
b | ) |
Value:
((a)->tv_sec > (b)->tv_sec || \ ((a)->tv_sec == (b)->tv_sec && \ (a)->tv_usec >= (b)->tv_usec))
Definition at line 45 of file mb_timer.h.
#define MB_TIMEVAL_SEC | ( | _tv | ) | ((_tv)->tv_sec) |
Definition at line 39 of file mb_timer.h.
#define MB_TIMEVAL_SET | ( | _tv, | |||
_sec, | |||||
_usec | ) |
Value:
do { \ (_tv)->tv_sec = _sec; \ (_tv)->tv_usec = _usec; \ } while(0)
Definition at line 29 of file mb_timer.h.
#define MB_TIMEVAL_USEC | ( | _tv | ) | ((_tv)->tv_usec) |
Definition at line 40 of file mb_timer.h.
typedef struct _mb_timer mb_timer_t |
Definition at line 9 of file mb_timer.h.
typedef struct timeval mb_timeval_t |
Definition at line 11 of file mb_timer.h.
Definition at line 10 of file mb_timer.h.
typedef void(* mb_tmo_hdlr)(const mb_timeval_t *tmo, const mb_timeval_t *now, void *arg) |
Definition at line 14 of file mb_timer.h.
typedef uint32_t mbsec_t |
Definition at line 7 of file mb_timer.h.
typedef uint32_t mbusec_t |
Definition at line 8 of file mb_timer.h.
void get_now | ( | mb_timeval_t * | tmo | ) |
Definition at line 57 of file timertool.c.
int mb_tman_handle_timeout | ( | mb_tman_t * | tman, | |
mb_timeval_t * | now | |||
) |
int mb_tman_next_timeout | ( | mb_tman_t * | tman, | |
const mb_timeval_t * | now, | |||
mb_timeval_t * | tmo_after | |||
) |
int mb_tman_remove | ( | mb_tman_t * | tman, | |
mb_timer_t * | timer | |||
) |
mb_timer_t* mb_tman_timeout | ( | mb_tman_t * | tman, | |
const mb_timeval_t * | tmo, | |||
mb_tmo_hdlr | hdlr, | |||
void * | arg | |||
) |