qemu-rust
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC 07/13] rust: add bindings for timer


From: Richard Henderson
Subject: Re: [RFC 07/13] rust: add bindings for timer
Date: Thu, 5 Dec 2024 12:18:23 -0600
User-agent: Mozilla Thunderbird

On 12/5/24 00:07, Zhao Liu wrote:
The bindgen supports `static inline` function binding since v0.64.0 as
an experimental feature (`--wrap-static-fns`), and stabilizes it after
v0.70.0.

But the oldest version of bindgen supported by QEMU is v0.60.1, so
there's no way to generate the bindings for timer_new() and its variants
which are `static inline` (in include/qemu/timer.h).

Manually implement bindings to help create new timers in Rust.
Additionally, wrap timer_mod(), timer_del() and
qemu_clock_get_virtual_ns() as safe functions to make timer interfaces
more Rust-idiomatic.

In addition, for timer_new() and its variants, to convert the idiomatic
Rust callback into a C-style callback QEMUTimerCB, introduce a trait
QEMUTimerImpl. For any object needs to initialize a new timer, it needs
to implement QEMUTimerImpl trait and define a handler.

It might be cleaner to move all of those static inline into timer.c.
I don't see anything performance sensitive there...


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]