niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ |
| 12 | #define SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Niels Möller | a12c42a | 2018-07-25 16:05:48 +0200 | [diff] [blame] | 14 | #include <stdint.h> |
| 15 | |
Mirko Bonadei | bef022b | 2020-09-06 16:07:15 +0200 | [diff] [blame] | 16 | namespace webrtc { |
| 17 | |
kma@webrtc.org | b59c031 | 2011-12-03 18:34:50 +0000 | [diff] [blame] | 18 | // List of features in x86. |
Zhaoliang Ma | 72e4321 | 2020-08-17 17:13:41 +0800 | [diff] [blame] | 19 | typedef enum { kSSE2, kSSE3, kAVX2 } CPUFeature; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
kma@webrtc.org | b59c031 | 2011-12-03 18:34:50 +0000 | [diff] [blame] | 21 | // List of features in ARM. |
| 22 | enum { |
Karl Wiberg | 79eb1d9 | 2017-11-08 12:26:07 +0100 | [diff] [blame] | 23 | kCPUFeatureARMv7 = (1 << 0), |
| 24 | kCPUFeatureVFPv3 = (1 << 1), |
| 25 | kCPUFeatureNEON = (1 << 2), |
| 26 | kCPUFeatureLDREXSTREX = (1 << 3) |
kma@webrtc.org | b59c031 | 2011-12-03 18:34:50 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 29 | // Returns true if the CPU supports the feature. |
Mirko Bonadei | bef022b | 2020-09-06 16:07:15 +0200 | [diff] [blame] | 30 | int GetCPUInfo(CPUFeature feature); |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 31 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | // No CPU feature is available => straight C path. |
Mirko Bonadei | bef022b | 2020-09-06 16:07:15 +0200 | [diff] [blame] | 33 | int GetCPUInfoNoASM(CPUFeature feature); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
kma@webrtc.org | b59c031 | 2011-12-03 18:34:50 +0000 | [diff] [blame] | 35 | // Return the features in an ARM device. |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 36 | // It detects the features in the hardware platform, and returns supported |
kma@webrtc.org | b59c031 | 2011-12-03 18:34:50 +0000 | [diff] [blame] | 37 | // values in the above enum definition as a bitmask. |
Mirko Bonadei | bef022b | 2020-09-06 16:07:15 +0200 | [diff] [blame] | 38 | uint64_t GetCPUFeaturesARM(void); |
| 39 | |
| 40 | } // namespace webrtc |
kma@webrtc.org | b59c031 | 2011-12-03 18:34:50 +0000 | [diff] [blame] | 41 | |
Karl Wiberg | 79eb1d9 | 2017-11-08 12:26:07 +0100 | [diff] [blame] | 42 | #endif // SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ |