Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUST_TAG in wdk-alloc #12

Closed
Xiphoseer opened this issue Sep 25, 2023 · 1 comment · Fixed by #21
Closed

RUST_TAG in wdk-alloc #12

Xiphoseer opened this issue Sep 25, 2023 · 1 comment · Fixed by #21

Comments

@Xiphoseer
Copy link

lazy_static! {
static ref RUST_TAG: ULONG = u32::from_ne_bytes(
#[allow(clippy::string_lit_as_bytes)] // A u8 slice is required here
"rust"
.as_bytes()
.try_into()
.expect("tag string.as_bytes() should be able to convert into [u8; 4]"),
);
}

Is there a reason this uses lazy_static instead of just a const and a byte string literal (of type &[u8;4])? u32::from_ne_bytes is const stable since 1.44.

C.f. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2be24215859c818308542b6893f36ca2

@jxy-s
Copy link

jxy-s commented Sep 25, 2023

In general on on use of lazy_static!. Something that I doubt is considered by the lazy_static crate, or the standard Rust libraries in general, is interrupts that end up preempting code execution. An example of this is APC delivery preempting some region of code that expects not to be interrupted.

For example, APC delivery could preempt some control flow. Most synchronization schemes or primitives in the kernel require you to call KeEnterCriticalRegion and KeLeaveCriticalRegion or KeEnterGuardedRegion and KeLeaveGuardedRegion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants