[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250117.165326.1882417578898126323.fujita.tomonori@gmail.com>
Date: Fri, 17 Jan 2025 16:53:26 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: aliceryhl@...gle.com
Cc: fujita.tomonori@...il.com, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, netdev@...r.kernel.org, andrew@...n.ch,
hkallweit1@...il.com, tmgross@...ch.edu, ojeda@...nel.org,
alex.gaynor@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me, a.hindborg@...sung.com, anna-maria@...utronix.de,
frederic@...nel.org, tglx@...utronix.de, arnd@...db.de,
jstultz@...gle.com, sboyd@...nel.org, mingo@...hat.com,
peterz@...radead.org, juri.lelli@...hat.com, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, vschneid@...hat.com
Subject: Re: [PATCH v8 4/7] rust: time: Add wrapper for fsleep function
On Thu, 16 Jan 2025 10:27:02 +0100
Alice Ryhl <aliceryhl@...gle.com> wrote:
>> +/// This function can only be used in a nonatomic context.
>> +pub fn fsleep(delta: Delta) {
>> + // The argument of fsleep is an unsigned long, 32-bit on 32-bit architectures.
>> + // Considering that fsleep rounds up the duration to the nearest millisecond,
>> + // set the maximum value to u32::MAX / 2 microseconds.
>> + const MAX_DURATION: Delta = Delta::from_micros(u32::MAX as i64 >> 1);
>
> Hmm, is this value correct on 64-bit platforms?
You meant that the maximum can be longer on 64-bit platforms? 2147484
milliseconds is long enough for fsleep's duration?
If you prefer, I use different maximum durations for 64-bit and 32-bit
platforms, respectively.
>> + let duration = if delta > MAX_DURATION || delta.is_negative() {
>> + // TODO: add WARN_ONCE() when it's supported.
>> + MAX_DURATION
>> + } else {
>> + delta
>> + };
>> +
>> + // SAFETY: FFI call.
>> + unsafe {
>
> This safety comment is incomplete. You can say this:
>
> // SAFETY: It is always safe to call fsleep with any duration.
Thanks, I'll use your safety comment.
Powered by blists - more mailing lists