Refactor cpu_features_wrapper.h functions from C to C++.
As mentioned on https://webrtc-review.googlesource.com/c/src/+/183380,
then relanded as https://webrtc-review.googlesource.com/c/src/+/183444,
functions in cpu_features_wrapper.h should be refactored to use
C++ features like namespaces and drop the WebRtc_ prefix.
Bug: None
Change-Id: I3e83e1668f9bf48a5d8e85d809f006666b7fa45e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183445
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32045}
diff --git a/system_wrappers/source/cpu_features.cc b/system_wrappers/source/cpu_features.cc
index 40110ed..e40c65a 100644
--- a/system_wrappers/source/cpu_features.cc
+++ b/system_wrappers/source/cpu_features.cc
@@ -17,6 +17,8 @@
#include <intrin.h>
#endif
+namespace webrtc {
+
// No CPU feature is available => straight C path.
int GetCPUInfoNoASM(CPUFeature feature) {
(void)feature;
@@ -65,7 +67,7 @@
#if defined(WEBRTC_ARCH_X86_FAMILY)
// Actual feature detection for x86.
-static int GetCPUInfo(CPUFeature feature) {
+int GetCPUInfo(CPUFeature feature) {
int cpu_info[4];
__cpuid(cpu_info, 1);
if (feature == kSSE2) {
@@ -102,11 +104,10 @@
}
#else
// Default to straight C for other platforms.
-static int GetCPUInfo(CPUFeature feature) {
+int GetCPUInfo(CPUFeature feature) {
(void)feature;
return 0;
}
#endif
-WebRtc_CPUInfo WebRtc_GetCPUInfo = GetCPUInfo;
-WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM = GetCPUInfoNoASM;
+} // namespace webrtc
diff --git a/system_wrappers/source/cpu_features_android.cc b/system_wrappers/source/cpu_features_android.cc
index 0cb3a6c..95cc609 100644
--- a/system_wrappers/source/cpu_features_android.cc
+++ b/system_wrappers/source/cpu_features_android.cc
@@ -10,6 +10,10 @@
#include <cpu-features.h>
-uint64_t WebRtc_GetCPUFeaturesARM(void) {
+namespace webrtc {
+
+uint64_t GetCPUFeaturesARM(void) {
return android_getCpuFeatures();
}
+
+} // namespace webrtc
diff --git a/system_wrappers/source/cpu_features_linux.cc b/system_wrappers/source/cpu_features_linux.cc
index 05ff9b3..335bed4 100644
--- a/system_wrappers/source/cpu_features_linux.cc
+++ b/system_wrappers/source/cpu_features_linux.cc
@@ -33,7 +33,9 @@
#if defined(WEBRTC_ARCH_ARM_FAMILY)
#include <asm/hwcap.h>
-uint64_t WebRtc_GetCPUFeaturesARM(void) {
+namespace webrtc {
+
+uint64_t GetCPUFeaturesARM(void) {
uint64_t result = 0;
int architecture = 0;
uint64_t hwcap = 0;
@@ -89,4 +91,6 @@
result |= kCPUFeatureLDREXSTREX;
return result;
}
+
+} // namespace webrtc
#endif // WEBRTC_ARCH_ARM_FAMILY