version 1.1, 2017/08/22 12:33:54
|
version 1.1.1.2, 2021/03/17 19:50:23
|
Line 19 typedef struct timer {
|
Line 19 typedef struct timer {
|
resource r; |
resource r; |
void (*hook)(struct timer *); |
void (*hook)(struct timer *); |
void *data; |
void *data; |
unsigned randomize; /* Amount of randomization */ | uint randomize; /* Amount of randomization */ |
unsigned recurrent; /* Timer recurrence */ | uint recurrent; /* Timer recurrence */ |
node n; /* Internal link */ |
node n; /* Internal link */ |
bird_clock_t expires; /* 0=inactive */ |
bird_clock_t expires; /* 0=inactive */ |
} timer; |
} timer; |
|
|
timer *tm_new(pool *); |
timer *tm_new(pool *); |
void tm_start(timer *, unsigned after); | void tm_start(timer *, uint after); |
void tm_stop(timer *); |
void tm_stop(timer *); |
void tm_dump_all(void); |
void tm_dump_all(void); |
|
|
Line 47 tm_remains(timer *t)
|
Line 47 tm_remains(timer *t)
|
} |
} |
|
|
static inline void |
static inline void |
tm_start_max(timer *t, unsigned after) | tm_start_max(timer *t, bird_clock_t after) |
{ |
{ |
bird_clock_t rem = tm_remains(t); |
bird_clock_t rem = tm_remains(t); |
tm_start(t, (rem > after) ? rem : after); |
tm_start(t, (rem > after) ? rem : after); |
} |
} |
|
|
static inline timer * |
static inline timer * |
tm_new_set(pool *p, void (*hook)(struct timer *), void *data, unsigned rand, unsigned rec) | tm_new_set(pool *p, void (*hook)(struct timer *), void *data, uint rand, uint rec) |
{ |
{ |
timer *t = tm_new(p); |
timer *t = tm_new(p); |
t->hook = hook; |
t->hook = hook; |
Line 74 bird_clock_t tm_parse_date(char *); /* Convert date to
|
Line 74 bird_clock_t tm_parse_date(char *); /* Convert date to
|
bird_clock_t tm_parse_datetime(char *); /* Convert date to bird_clock_t */ |
bird_clock_t tm_parse_datetime(char *); /* Convert date to bird_clock_t */ |
|
|
#define TM_DATETIME_BUFFER_SIZE 32 /* Buffer size required by tm_format_datetime */ |
#define TM_DATETIME_BUFFER_SIZE 32 /* Buffer size required by tm_format_datetime */ |
void |
|
tm_format_datetime(char *x, struct timeformat *fmt_spec, bird_clock_t t); |
|
|
|
#ifdef TIME_T_IS_64BIT | void tm_format_datetime(char *x, struct timeformat *fmt_spec, bird_clock_t t); |
#define TIME_INFINITY 0x7fffffffffffffff | int tm_format_real_time(char *x, size_t max, const char *fmt, bird_clock_t t); |
#else | |
#ifdef TIME_T_IS_SIGNED | #define TIME_T_IS_64BIT (sizeof(time_t) == 8) |
#define TIME_INFINITY 0x7fffffff | #define TIME_T_IS_SIGNED ((time_t) -1 < 0) |
#else | |
#define TIME_INFINITY 0xffffffff | #define TIME_INFINITY \ |
#endif | ((time_t) (TIME_T_IS_SIGNED ? \ |
#endif | (TIME_T_IS_64BIT ? 0x7fffffffffffffff : 0x7fffffff): \ |
| (TIME_T_IS_64BIT ? 0xffffffffffffffff : 0xffffffff))) |
|
|
#endif |
#endif |