Open
Conversation
- Consolidated `use` statements and added `#![warn(clippy::all)]` for stricter linting - Added compile-time check for Linux x86_64 targets. - Use `hlt` instruction instead of empty loops to avoid wasting CPU. - Replaced `as _` casts with explicit ones for clarity - Improved `main_impl` error messages to better mimic GNU sleep - Apply `rustfmt` to the code.
Per `execve(2)`, `argv` is an array of string pointers terminated by NULL. Individual entries `argv[0]..argv[argc-1]` are guaranteed non-null, only the terminator `argv[argc]` is NULL. We trust this kernel guarantee without runtime checks, so `NonNull` provides no safety/optimization benefit. Source: https://man7.org/linux/man-pages/man2/execve.2.html
SYSCALL masks RFLAGS on entry (via IA32_FMASK) and restores from R11 on exit, so flags are not preserved. Using `preserves_flags` is wrong. Source: https://www.felixcloutier.com/x86/syscall
…lls FFI boundaries
Since these are used in never-return paths it doesn't matter. Also, more consistent with other `asm!` blocks.
- runtime/ABI glue (panic handler, personality) - raw syscall primitives - small utility helpers - error reporting policy - pure program logic (main_impl) - ABI-facing main and _start
Owner
|
what in the AI slop is this shit |
Author
|
If my way of writing longer than average commit messages comes off as LLM slop there's nothing I can do about that I'm afraid. If this is about me linking sources in some commits, it's because for some changes I had to look at actual docs since I wasn't familiar with some of the ASM flags used here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves
sleep.rs, focusing on safety, idiomatic Rust, and robust error handling.Each commit message should explain why I did these changes, with annexed sources for more techinical ones.
Key improvements include:
hltinstruction.SleepErrorenum andreport_errorfunction.Note: I believe that the Rust implementation could benefit from providing
Cargo.tomland.cargo/config.toml.Personally I settled with the following versions:
It would be possible to have a structure like this, but it is out of scope.
Thanks for the informative YouTube video regarding this topic, I found it quite nice.