lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250603.225143.1147206358060510971.fujita.tomonori@gmail.com>
Date: Tue, 03 Jun 2025 22:51:43 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: a.hindborg@...nel.org
Cc: fujita.tomonori@...il.com, rust-for-linux@...r.kernel.org,
 boqun.feng@...il.com, frederic@...nel.org, lyude@...hat.com,
 tglx@...utronix.de, anna-maria@...utronix.de, jstultz@...gle.com,
 sboyd@...nel.org, ojeda@...nel.org, alex.gaynor@...il.com,
 gary@...yguo.net, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
 aliceryhl@...gle.com, tmgross@...ch.edu, dakr@...nel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 3/5] rust: time: Add HrTimerExpires trait

On Fri, 30 May 2025 15:04:00 +0200
Andreas Hindborg <a.hindborg@...nel.org> wrote:

>> +/// Defines a new `HrTimerMode` implementation with a given expiration type and C mode.
>> +#[doc(hidden)]
>> +macro_rules! define_hrtimer_mode {
>> +    (
>> +        $(#[$meta:meta])*
>> +        $vis:vis struct $name:ident<$clock:ident> {
>> +            c = $mode:ident,
>> +            expires = $expires:ty
>> +        }
>> +    ) => {
>> +        $(#[$meta])*
>> +        $vis struct $name<$clock: $crate::time::ClockSource>(
>> +            ::core::marker::PhantomData<$clock>
>> +        );
> 
> I think a macro is too much here. The code would be easier to read
> without the macro, and the macro does not remove much code here.
> 
> Could you try to do the trait implementations without the macro?

Something like the following, right? If so, I'll do in the next
version. I'm also fine with that way.

/// Timer that expires at a fixed point in time.
pub struct AbsoluteMode<C: ClockSource>(PhantomData<C>);

impl<C: ClockSource> HrTimerMode for AbsoluteMode<C> {
    const C_MODE: bindings::hrtimer_mode = bindings::hrtimer_mode_HRTIMER_MODE_ABS;

    type Clock = C;
    type Expires = Instant<C>;
}

instead of

define_hrtimer_mode! {
    /// Timer that expires at a fixed point in time.
    pub struct AbsoluteMode<C> {
        c = HRTIMER_MODE_ABS,
        expires = Instant<C>
    }
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ