Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lkl: host: drop unused timer callback parameter #562

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arch/lkl/include/uapi/asm/host_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ enum lkl_prot {
* @page_alloc - allocate page aligned memory
* @page_free - free memory allocated by page_alloc
*
* @timer_create - allocate a host timer that runs fn(arg) when the timer
* @timer_create - allocate a host timer that runs fn() when the timer
* fires.
* @timer_free - disarms and free the timer
* @timer_set_oneshot - arm the timer to fire once, after delta ns.
Expand Down Expand Up @@ -169,7 +169,7 @@ struct lkl_host_operations {

unsigned long long (*time)(void);

void* (*timer_alloc)(void (*fn)(void *), void *arg);
void* (*timer_alloc)(void (*fn)(void));
int (*timer_set_oneshot)(void *timer, unsigned long delta);
void (*timer_free)(void *timer);

Expand Down
4 changes: 2 additions & 2 deletions arch/lkl/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void *timer;

static int timer_irq;

static void timer_fn(void *arg)
static void timer_fn(void)
{
lkl_trigger_irq(timer_irq);
}
Expand All @@ -82,7 +82,7 @@ static int clockevent_set_state_shutdown(struct clock_event_device *evt)

static int clockevent_set_state_oneshot(struct clock_event_device *evt)
{
timer = lkl_ops->timer_alloc(timer_fn, NULL);
timer = lkl_ops->timer_alloc(timer_fn);
if (!timer)
return -ENOMEM;

Expand Down
8 changes: 3 additions & 5 deletions tools/lkl/lib/nt-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ static unsigned long long time_ns(void)

struct timer {
HANDLE queue;
void (*callback)(void *);
void *arg;
void (*callback)(void);
};

static void *timer_alloc(void (*fn)(void *), void *arg)
static void *timer_alloc(void (*fn)(void))
{
struct timer *t;

Expand All @@ -197,7 +196,6 @@ static void *timer_alloc(void (*fn)(void *), void *arg)
}

t->callback = fn;
t->arg = arg;

return t;
}
Expand All @@ -207,7 +205,7 @@ static void CALLBACK timer_callback(void *arg, BOOLEAN TimerOrWaitFired)
struct timer *t = (struct timer *)arg;

if (TimerOrWaitFired)
t->callback(t->arg);
t->callback();
}

static int timer_set_oneshot(void *timer, unsigned long ns)
Expand Down
42 changes: 15 additions & 27 deletions tools/lkl/lib/posix-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,62 +396,50 @@ static unsigned long long time_ns(void)
return 1e9*ts.tv_sec + ts.tv_nsec;
}

struct lkl_timer {
timer_t timer;
void (*fn)(void *arg);
void *arg;
};

static void lkl_timer_callback(union sigval sv)
{
struct lkl_timer *lt = (struct lkl_timer *)sv.sival_ptr;
void (*fn)(void) = sv.sival_ptr;

lt->fn(lt->arg);
fn();
}

static void *timer_alloc(void (*fn)(void *), void *arg)
static void *timer_alloc(void (*fn)(void))
{
int err;
timer_t timer;
struct sigevent se = {
.sigev_notify = SIGEV_THREAD,
.sigev_value = {
.sival_ptr = fn,
},
.sigev_notify_function = lkl_timer_callback,
};
struct lkl_timer *pt;


pt = malloc(sizeof(*pt));
if (!pt)
return NULL;

pt->fn = fn;
pt->arg = arg;
se.sigev_value.sival_ptr = pt;
err = timer_create(CLOCK_REALTIME, &se, &pt->timer);
err = timer_create(CLOCK_REALTIME, &se, &timer);
if (err)
return NULL;

return pt;
return (void *)(long)timer;
}

static int timer_set_oneshot(void *timer, unsigned long ns)
static int timer_set_oneshot(void *_timer, unsigned long ns)
{
struct lkl_timer *lt = timer;
timer_t timer = (timer_t)(long)_timer;
struct itimerspec ts = {
.it_value = {
.tv_sec = ns / 1000000000,
.tv_nsec = ns % 1000000000,
},
};

return timer_settime(lt->timer, 0, &ts, NULL);
return timer_settime(timer, 0, &ts, NULL);
}

static void timer_free(void *timer)
static void timer_free(void *_timer)
{
struct lkl_timer *lt = timer;
timer_t timer = (timer_t)(long)_timer;

timer_delete(lt->timer);
free(lt);
timer_delete(timer);
}

static void panic(void)
Expand Down
Loading