android_cpufeatures_sys/
lib.rs

1//! # android-cpufeatures-sys
2//!
3//! Raw bindings to Android NDK's `cpufeatures` library for Rust.
4//!
5//! [Check-out the library's official docs](https://developer.android.com/ndk/guides/cpu-features.html). It is not duplicated here.
6//!
7//! Don't miss `android_getCpuIdArm()` and `android_setCpuArm()` - since they are filtered with
8//! `#[cfg(target_arch="arm")]`, they don't appear in this generated documentation.  
9//! Therefore, it's advisable to take a look at `src/lib.rs`.
10
11// Generated by bindgen, then hand-edited.
12
13#![doc(html_root_url = "https://docs.rs/android-cpufeatures-sys/2.0.0")]
14#![allow(non_camel_case_types)]
15#![allow(non_upper_case_globals)]
16
17
18use std::os::raw::c_int;
19
20#[link(name = "cpufeatures")]
21extern {
22    pub fn android_getCpuCount() -> c_int;
23    pub fn android_getCpuFamily() -> AndroidCpuFamily;
24    pub fn android_getCpuFeatures() -> u64;
25    pub fn android_setCpu(cpu_count: c_int, cpu_features: u64) -> c_int;
26}
27#[link(name = "cpufeatures")]
28#[cfg(target_arch="arm")]
29extern {
30    pub fn android_getCpuIdArm() -> u32;
31    pub fn android_setCpuArm(cpu_count: c_int, cpu_features: u64, cpu_id: u32) -> c_int;
32}
33
34
35#[repr(u32)]
36#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
37pub enum AndroidCpuFamily {
38    ANDROID_CPU_FAMILY_UNKNOWN = 0,
39    ANDROID_CPU_FAMILY_ARM = 1,
40    ANDROID_CPU_FAMILY_X86 = 2,
41    ANDROID_CPU_FAMILY_MIPS = 3,
42    ANDROID_CPU_FAMILY_ARM64 = 4,
43    ANDROID_CPU_FAMILY_X86_64 = 5,
44    ANDROID_CPU_FAMILY_MIPS64 = 6,
45    ANDROID_CPU_FAMILY_MAX = 7,
46}
47
48#[repr(u32)]
49#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
50pub enum ArmFeature {
51    ANDROID_CPU_ARM_FEATURE_ARMv7 = 1,
52    ANDROID_CPU_ARM_FEATURE_VFPv3 = 2,
53    ANDROID_CPU_ARM_FEATURE_NEON = 4,
54    ANDROID_CPU_ARM_FEATURE_LDREX_STREX = 8,
55    ANDROID_CPU_ARM_FEATURE_VFPv2 = 16,
56    ANDROID_CPU_ARM_FEATURE_VFP_D32 = 32,
57    ANDROID_CPU_ARM_FEATURE_VFP_FP16 = 64,
58    ANDROID_CPU_ARM_FEATURE_VFP_FMA = 128,
59    ANDROID_CPU_ARM_FEATURE_NEON_FMA = 256,
60    ANDROID_CPU_ARM_FEATURE_IDIV_ARM = 512,
61    ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 = 1024,
62    ANDROID_CPU_ARM_FEATURE_iWMMXt = 2048,
63    ANDROID_CPU_ARM_FEATURE_AES = 4096,
64    ANDROID_CPU_ARM_FEATURE_PMULL = 8192,
65    ANDROID_CPU_ARM_FEATURE_SHA1 = 16384,
66    ANDROID_CPU_ARM_FEATURE_SHA2 = 32768,
67    ANDROID_CPU_ARM_FEATURE_CRC32 = 65536,
68}
69#[repr(u32)]
70#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
71pub enum Arm64Feature {
72    ANDROID_CPU_ARM64_FEATURE_FP = 1,
73    ANDROID_CPU_ARM64_FEATURE_ASIMD = 2,
74    ANDROID_CPU_ARM64_FEATURE_AES = 4,
75    ANDROID_CPU_ARM64_FEATURE_PMULL = 8,
76    ANDROID_CPU_ARM64_FEATURE_SHA1 = 16,
77    ANDROID_CPU_ARM64_FEATURE_SHA2 = 32,
78    ANDROID_CPU_ARM64_FEATURE_CRC32 = 64,
79}
80#[repr(u32)]
81#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
82pub enum X86Feature {
83    ANDROID_CPU_X86_FEATURE_SSSE3 = 1,
84    ANDROID_CPU_X86_FEATURE_POPCNT = 2,
85    ANDROID_CPU_X86_FEATURE_MOVBE = 4,
86    ANDROID_CPU_X86_FEATURE_SSE4_1 = 8,
87    ANDROID_CPU_X86_FEATURE_SSE4_2 = 16,
88    ANDROID_CPU_X86_FEATURE_AES_NI = 32,
89    ANDROID_CPU_X86_FEATURE_AVX = 64,
90    ANDROID_CPU_X86_FEATURE_RDRAND = 128,
91    ANDROID_CPU_X86_FEATURE_AVX2 = 256,
92    ANDROID_CPU_X86_FEATURE_SHA_NI = 512,
93}
94#[repr(u32)]
95#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
96pub enum MipsFeature {
97    ANDROID_CPU_MIPS_FEATURE_R6 = 1,
98    ANDROID_CPU_MIPS_FEATURE_MSA = 2,
99}