Module std_detect::detect

source ·
🔬This is a nightly-only experimental API. (stdsimd)
Expand description

This module implements run-time feature detection.

The is_{arch}_feature_detected!("feature-name") macros take the name of a feature as a string-literal, and return a boolean indicating whether the feature is enabled at run-time or not.

These macros do two things:

  • map the string-literal into an integer stored as a Feature enum,
  • call a os::check_for(x: Feature) function that returns true if the feature is enabled.

The Feature enums are also implemented in the arch/{target_arch}.rs modules.

The check_for functions are, in general, Operating System dependent. Most architectures do not allow user-space programs to query the feature bits due to security concerns (x86 is the big exception). These functions are implemented in the os/{target_os}.rs modules.

Modules

  • arch 🔒 Experimental
  • bit 🔒 Experimental
    Bit manipulation utilities.
  • cache 🔒 Experimental
    Caches run-time feature detection so that it only needs to be computed once.
  • macros 🔒 Experimental
  • os 🔒 Experimental
    x86 run-time feature detection is OS independent.

Functions

  • check_for 🔒 Experimental
    Performs run-time feature detection.
  • featuresExperimental
    Returns an Iterator<Item=(&'static str, bool)> where Item.0 is the feature name, and Item.1 is a bool which is true if the feature is supported by the host and false otherwise.