mirror of
https://github.com/google/cpu_features.git
synced 2025-04-28 07:23:37 +02:00
Add <stdbool.h> to examples where needed, pluse minor stylistic touch-up.
This commit is contained in:
parent
f7e0a6d066
commit
36df25b7bc
@ -55,6 +55,7 @@ then query for the specific features you care about. Below, we store all the ARM
|
|||||||
features and then check whether AES and NEON are supported.
|
features and then check whether AES and NEON are supported.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
#include <stdbool.h>
|
||||||
#include "cpuinfo_arm.h"
|
#include "cpuinfo_arm.h"
|
||||||
|
|
||||||
static const ArmFeatures features = GetArmInfo().features;
|
static const ArmFeatures features = GetArmInfo().features;
|
||||||
@ -73,6 +74,7 @@ The following code determines whether the compiler was told to use the AVX
|
|||||||
instruction set (e.g., `g++ -mavx`) and sets `has_avx` accordingly.
|
instruction set (e.g., `g++ -mavx`) and sets `has_avx` accordingly.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
#include <stdbool.h>
|
||||||
#include "cpuinfo_x86.h"
|
#include "cpuinfo_x86.h"
|
||||||
|
|
||||||
static const X86Features features = GetX86Info().features;
|
static const X86Features features = GetX86Info().features;
|
||||||
@ -87,13 +89,14 @@ use AVX and 0 otherwise, combining compile time and runtime knowledge.
|
|||||||
### Rejecting poor hardware implementations based on microarchitecture
|
### Rejecting poor hardware implementations based on microarchitecture
|
||||||
|
|
||||||
On x86, the first incarnation of a feature in a microarchitecture might not be
|
On x86, the first incarnation of a feature in a microarchitecture might not be
|
||||||
the most efficient (e.g., AVX on Sandy Bridge). We provide a function to
|
the most efficient (e.g. AVX on Sandy Bridge). We provide a function to retrieve
|
||||||
retrieve the underlying microarchitecture so you can decide whether to use it.
|
the underlying microarchitecture so you can decide whether to use it.
|
||||||
|
|
||||||
Below, `has_fast_avx` is set to 1 if the CPU supports the AVX instruction
|
Below, `has_fast_avx` is set to 1 if the CPU supports the AVX instruction
|
||||||
set—but only if it's not Sandy Bridge.
|
set—but only if it's not Sandy Bridge.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
#include <stdbool.h>
|
||||||
#include "cpuinfo_x86.h"
|
#include "cpuinfo_x86.h"
|
||||||
|
|
||||||
static const X86Info info = GetX86Info();
|
static const X86Info info = GetX86Info();
|
||||||
@ -154,4 +157,4 @@ See [LICENSE](LICENSE) for more information.
|
|||||||
<a name="cmake"></a>
|
<a name="cmake"></a>
|
||||||
## Build with CMake
|
## Build with CMake
|
||||||
|
|
||||||
Please check the [CMake build instructions](cmake/README.md)
|
Please check the [CMake build instructions](cmake/README.md).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user