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

fix: Guard ADX Feature #7

Merged
merged 1 commit into from
Jan 8, 2024
Merged

fix: Guard ADX Feature #7

merged 1 commit into from
Jan 8, 2024

Conversation

winston-h-zhang
Copy link
Member

No description provided.

Copy link
Member

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

This is good.

While we're at it, can we delete the obsolete dont-implement-sort feature?

build.rs Outdated
Comment on lines 76 to 92
match (cfg!(feature = "portable"), cfg!(feature = "force-adx")) {
(true, false) => Some(default_def.to_string()),
(false, true) if target_arch == "x86_64" => Some("__ADX__".to_string()),
(false, false)
if target_arch == "x86_64"
&& std::is_x86_feature_detected!("adx") =>
{
Some("__ADX__".to_string())
(false, false) => {
#[cfg(target_arch = "x86_64")]
if target_arch == "x86_64" && std::is_x86_feature_detected!("adx") {
Some("__ADX__".to_string())
} else {
None
}
#[cfg(not(target_arch = "x86_64"))]
None
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: perhaps?

fn determine_cc_def(target_arch: &str, default_def: &str) -> Option<String> {
    if cfg!(feature = "portable") && cfg!(feature = "force-adx") {
        panic!("Cannot compile with both `portable` and `force-adx` features");
    }

    if cfg!(feature = "portable") {
        return Some(default_def.to_string());
    }

    if cfg!(feature = "force-adx") && target_arch == "x86_64" {
        return Some("__ADX__".to_string());
    }

    #[cfg(target_arch = "x86_64")]
    {
        if target_arch == "x86_64" && std::is_x86_feature_detected!("adx") {
            return Some("__ADX__".to_string());
        }
    }

    None
}

@winston-h-zhang
Copy link
Member Author

Done

@huitseeker huitseeker merged commit 311ec73 into dev Jan 8, 2024
2 checks passed
winston-h-zhang added a commit that referenced this pull request Jan 11, 2024
Co-authored-by: Hanting Zhang <winston@lurk-lab.com>
@winston-h-zhang winston-h-zhang deleted the guard-adx branch March 15, 2024 09:47
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