|
@@ -31,7 +31,7 @@ struct eloop_sock {
|
|
|
|
|
|
struct eloop_timeout {
|
|
struct eloop_timeout {
|
|
struct dl_list list;
|
|
struct dl_list list;
|
|
- struct os_time time;
|
|
|
|
|
|
+ struct os_reltime time;
|
|
void *eloop_data;
|
|
void *eloop_data;
|
|
void *user_data;
|
|
void *user_data;
|
|
eloop_timeout_handler handler;
|
|
eloop_timeout_handler handler;
|
|
@@ -484,7 +484,7 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
|
|
timeout = os_zalloc(sizeof(*timeout));
|
|
timeout = os_zalloc(sizeof(*timeout));
|
|
if (timeout == NULL)
|
|
if (timeout == NULL)
|
|
return -1;
|
|
return -1;
|
|
- if (os_get_time(&timeout->time) < 0) {
|
|
|
|
|
|
+ if (os_get_reltime(&timeout->time) < 0) {
|
|
os_free(timeout);
|
|
os_free(timeout);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -514,7 +514,7 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
|
|
|
|
|
|
/* Maintain timeouts in order of increasing time */
|
|
/* Maintain timeouts in order of increasing time */
|
|
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
|
|
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
|
|
- if (os_time_before(&timeout->time, &tmp->time)) {
|
|
|
|
|
|
+ if (os_reltime_before(&timeout->time, &tmp->time)) {
|
|
dl_list_add(tmp->list.prev, &timeout->list);
|
|
dl_list_add(tmp->list.prev, &timeout->list);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -558,13 +558,13 @@ int eloop_cancel_timeout(eloop_timeout_handler handler,
|
|
|
|
|
|
int eloop_cancel_timeout_one(eloop_timeout_handler handler,
|
|
int eloop_cancel_timeout_one(eloop_timeout_handler handler,
|
|
void *eloop_data, void *user_data,
|
|
void *eloop_data, void *user_data,
|
|
- struct os_time *remaining)
|
|
|
|
|
|
+ struct os_reltime *remaining)
|
|
{
|
|
{
|
|
struct eloop_timeout *timeout, *prev;
|
|
struct eloop_timeout *timeout, *prev;
|
|
int removed = 0;
|
|
int removed = 0;
|
|
- struct os_time now;
|
|
|
|
|
|
+ struct os_reltime now;
|
|
|
|
|
|
- os_get_time(&now);
|
|
|
|
|
|
+ os_get_reltime(&now);
|
|
remaining->sec = remaining->usec = 0;
|
|
remaining->sec = remaining->usec = 0;
|
|
|
|
|
|
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
|
|
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
|
|
@@ -573,8 +573,8 @@ int eloop_cancel_timeout_one(eloop_timeout_handler handler,
|
|
(timeout->eloop_data == eloop_data) &&
|
|
(timeout->eloop_data == eloop_data) &&
|
|
(timeout->user_data == user_data)) {
|
|
(timeout->user_data == user_data)) {
|
|
removed = 1;
|
|
removed = 1;
|
|
- if (os_time_before(&now, &timeout->time))
|
|
|
|
- os_time_sub(&timeout->time, &now, remaining);
|
|
|
|
|
|
+ if (os_reltime_before(&now, &timeout->time))
|
|
|
|
+ os_reltime_sub(&timeout->time, &now, remaining);
|
|
eloop_remove_timeout(timeout);
|
|
eloop_remove_timeout(timeout);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -603,7 +603,7 @@ int eloop_deplete_timeout(unsigned int req_secs, unsigned int req_usecs,
|
|
eloop_timeout_handler handler, void *eloop_data,
|
|
eloop_timeout_handler handler, void *eloop_data,
|
|
void *user_data)
|
|
void *user_data)
|
|
{
|
|
{
|
|
- struct os_time now, requested, remaining;
|
|
|
|
|
|
+ struct os_reltime now, requested, remaining;
|
|
struct eloop_timeout *tmp;
|
|
struct eloop_timeout *tmp;
|
|
|
|
|
|
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
|
|
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
|
|
@@ -612,9 +612,9 @@ int eloop_deplete_timeout(unsigned int req_secs, unsigned int req_usecs,
|
|
tmp->user_data == user_data) {
|
|
tmp->user_data == user_data) {
|
|
requested.sec = req_secs;
|
|
requested.sec = req_secs;
|
|
requested.usec = req_usecs;
|
|
requested.usec = req_usecs;
|
|
- os_get_time(&now);
|
|
|
|
- os_time_sub(&tmp->time, &now, &remaining);
|
|
|
|
- if (os_time_before(&requested, &remaining)) {
|
|
|
|
|
|
+ os_get_reltime(&now);
|
|
|
|
+ os_reltime_sub(&tmp->time, &now, &remaining);
|
|
|
|
+ if (os_reltime_before(&requested, &remaining)) {
|
|
eloop_cancel_timeout(handler, eloop_data,
|
|
eloop_cancel_timeout(handler, eloop_data,
|
|
user_data);
|
|
user_data);
|
|
eloop_register_timeout(requested.sec,
|
|
eloop_register_timeout(requested.sec,
|
|
@@ -634,7 +634,7 @@ int eloop_replenish_timeout(unsigned int req_secs, unsigned int req_usecs,
|
|
eloop_timeout_handler handler, void *eloop_data,
|
|
eloop_timeout_handler handler, void *eloop_data,
|
|
void *user_data)
|
|
void *user_data)
|
|
{
|
|
{
|
|
- struct os_time now, requested, remaining;
|
|
|
|
|
|
+ struct os_reltime now, requested, remaining;
|
|
struct eloop_timeout *tmp;
|
|
struct eloop_timeout *tmp;
|
|
|
|
|
|
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
|
|
dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
|
|
@@ -643,9 +643,9 @@ int eloop_replenish_timeout(unsigned int req_secs, unsigned int req_usecs,
|
|
tmp->user_data == user_data) {
|
|
tmp->user_data == user_data) {
|
|
requested.sec = req_secs;
|
|
requested.sec = req_secs;
|
|
requested.usec = req_usecs;
|
|
requested.usec = req_usecs;
|
|
- os_get_time(&now);
|
|
|
|
- os_time_sub(&tmp->time, &now, &remaining);
|
|
|
|
- if (os_time_before(&remaining, &requested)) {
|
|
|
|
|
|
+ os_get_reltime(&now);
|
|
|
|
+ os_reltime_sub(&tmp->time, &now, &remaining);
|
|
|
|
+ if (os_reltime_before(&remaining, &requested)) {
|
|
eloop_cancel_timeout(handler, eloop_data,
|
|
eloop_cancel_timeout(handler, eloop_data,
|
|
user_data);
|
|
user_data);
|
|
eloop_register_timeout(requested.sec,
|
|
eloop_register_timeout(requested.sec,
|
|
@@ -776,7 +776,7 @@ void eloop_run(void)
|
|
struct timeval _tv;
|
|
struct timeval _tv;
|
|
#endif /* CONFIG_ELOOP_POLL */
|
|
#endif /* CONFIG_ELOOP_POLL */
|
|
int res;
|
|
int res;
|
|
- struct os_time tv, now;
|
|
|
|
|
|
+ struct os_reltime tv, now;
|
|
|
|
|
|
#ifndef CONFIG_ELOOP_POLL
|
|
#ifndef CONFIG_ELOOP_POLL
|
|
rfds = os_malloc(sizeof(*rfds));
|
|
rfds = os_malloc(sizeof(*rfds));
|
|
@@ -793,9 +793,9 @@ void eloop_run(void)
|
|
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
|
|
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
|
|
list);
|
|
list);
|
|
if (timeout) {
|
|
if (timeout) {
|
|
- os_get_time(&now);
|
|
|
|
- if (os_time_before(&now, &timeout->time))
|
|
|
|
- os_time_sub(&timeout->time, &now, &tv);
|
|
|
|
|
|
+ os_get_reltime(&now);
|
|
|
|
+ if (os_reltime_before(&now, &timeout->time))
|
|
|
|
+ os_reltime_sub(&timeout->time, &now, &tv);
|
|
else
|
|
else
|
|
tv.sec = tv.usec = 0;
|
|
tv.sec = tv.usec = 0;
|
|
#ifdef CONFIG_ELOOP_POLL
|
|
#ifdef CONFIG_ELOOP_POLL
|
|
@@ -837,8 +837,8 @@ void eloop_run(void)
|
|
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
|
|
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
|
|
list);
|
|
list);
|
|
if (timeout) {
|
|
if (timeout) {
|
|
- os_get_time(&now);
|
|
|
|
- if (!os_time_before(&now, &timeout->time)) {
|
|
|
|
|
|
+ os_get_reltime(&now);
|
|
|
|
+ if (!os_reltime_before(&now, &timeout->time)) {
|
|
void *eloop_data = timeout->eloop_data;
|
|
void *eloop_data = timeout->eloop_data;
|
|
void *user_data = timeout->user_data;
|
|
void *user_data = timeout->user_data;
|
|
eloop_timeout_handler handler =
|
|
eloop_timeout_handler handler =
|
|
@@ -883,9 +883,9 @@ void eloop_terminate(void)
|
|
void eloop_destroy(void)
|
|
void eloop_destroy(void)
|
|
{
|
|
{
|
|
struct eloop_timeout *timeout, *prev;
|
|
struct eloop_timeout *timeout, *prev;
|
|
- struct os_time now;
|
|
|
|
|
|
+ struct os_reltime now;
|
|
|
|
|
|
- os_get_time(&now);
|
|
|
|
|
|
+ os_get_reltime(&now);
|
|
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
|
|
dl_list_for_each_safe(timeout, prev, &eloop.timeout,
|
|
struct eloop_timeout, list) {
|
|
struct eloop_timeout, list) {
|
|
int sec, usec;
|
|
int sec, usec;
|