Re: [PATCH net-next v3 5/8] rust: time: Add wrapper for fsleep function
From: Andrew Lunn
Date: Fri Oct 18 2024 - 10:06:01 EST
> +/// This function can only be used in a nonatomic context.
> +pub fn fsleep(delta: time::Delta) {
> + // SAFETY: FFI call.
> + unsafe {
> + // Convert the duration to microseconds and round up to preserve
> + // the guarantee; fsleep sleeps for at least the provided duration,
> + // but that it may sleep for longer under some circumstances.
> + bindings::fsleep(
> + ((delta.as_nanos() + time::NSEC_PER_USEC - 1) / time::NSEC_PER_USEC) as c_ulong,
You add a as_sec() helper, but then don't use it? If the helper does
not do what you want, maybe the helper is wrong? This is part of why
we say all APIs should have a user.
Andrew