freebsd_network: Clean up struct callout.

* Remove unused flags field.
 * Rename internal members to have c_ at the beginning, like FreeBSD.
This commit is contained in:
Augustin Cavalier 2022-07-07 14:57:23 -04:00
parent af11bc7bc7
commit a73773b24e
2 changed files with 13 additions and 15 deletions

View File

@ -52,12 +52,12 @@ callout_thread(void* /*data*/)
if (c == NULL)
break;
if (c->due < system_time()) {
if (c->c_due < system_time()) {
struct mtx *mutex = c->c_mtx;
// execute timer
list_remove_item(&sTimers, c);
c->due = -1;
c->c_due = -1;
sCurrentCallout = c;
mutex_unlock(&sLock);
@ -79,8 +79,8 @@ callout_thread(void* /*data*/)
// restart scanning as we unlocked the list
} else {
// calculate new timeout
if (c->due < timeout)
timeout = c->due;
if (c->c_due < timeout)
timeout = c->c_due;
}
}
@ -164,8 +164,7 @@ callout_init(struct callout *callout, int mpsafe)
void
callout_init_mtx(struct callout *c, struct mtx *mtx, int flags)
{
c->due = 0;
c->flags = 0;
c->c_due = 0;
c->c_arg = NULL;
c->c_func = NULL;
@ -188,13 +187,13 @@ callout_reset(struct callout *c, int _ticks, void (*func)(void *), void *arg)
if (_ticks >= 0) {
// reschedule or add this timer
if (c->due <= 0)
if (c->c_due <= 0)
list_add_item(&sTimers, c);
c->due = system_time() + TICKS_2_USEC(_ticks);
c->c_due = system_time() + TICKS_2_USEC(_ticks);
// notify timer about the change if necessary
if (sTimeout > c->due)
if (sTimeout > c->c_due)
release_sem(sWaitSem);
}
@ -228,12 +227,12 @@ _callout_stop_safe(struct callout *c, int safe)
return 0;
}
if (c->due <= 0)
if (c->c_due <= 0)
return -1;
// this timer is scheduled, cancel it
list_remove_item(&sTimers, c);
c->due = 0;
c->c_due = 0;
return 1;
}
@ -241,7 +240,7 @@ _callout_stop_safe(struct callout *c, int safe)
int
callout_pending(struct callout *c)
{
return c->due > 0;
return c->c_due > 0;
}

View File

@ -12,9 +12,8 @@
struct callout {
struct list_link link;
bigtime_t due;
uint32 flags;
struct list_link c_link;
bigtime_t c_due;
void * c_arg;
void (*c_func)(void *);