Skip to content

cpufeatures: cfg_select!-like macro #1529

Description

@nazar-pc

More than once I wrote a piece of code that has the following shape:

cpufeatures::new!(has_avx512f_vaes, "avx512f", "vaes");
if has_avx512f_vaes::get() {
    return /* .. */;
}

cpufeatures::new!(has_avx2_vaes, "avx2", "vaes");
if has_avx2_vaes::get() {
    return /* .. */;
}

cpufeatures::new!(has_aes_sse41, "aes", "sse4.1");
if has_aes_sse41::get() {
    return /* .. */;
}

// Fallback

It'd be great to have something that can replace multiple individual atomic reads with a single one in such cases.

The shape of cfg_select! seems perfect for this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions