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

Sample of how to generate the function #1531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

labbott
Copy link
Collaborator

@labbott labbott commented Sep 14, 2023

No description provided.

#[proc_macro]
pub fn dynamic_hashcrypt(_item: TokenStream) -> TokenStream {
let code = quote! {
static mut USE_ROM: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicBool::new(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: improve readability w/ use core::sync::atomic::AtomicBool;


pub fn set_hashcrypt_default() {
unsafe {
USE_ROM.store(false, core::sync::atomic::Ordering::Relaxed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: improve readability w/ use core::sync::atomic::Ordering


pub fn set_hashcrypt_rom() {
unsafe {
USE_ROM.store(true, core::sync::atomic::Ordering::Relaxed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

#[allow(non_snake_case)]
#[no_mangle]
pub unsafe extern "C" fn HASHCRYPT() {
if USE_ROM.load(core::sync::atomic::Ordering::Relaxed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

} else {
kern::arch::DefaultHandler();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace

}

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace

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 this pull request may close these issues.

None yet

2 participants