LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/system_wrappers/source - cpu_features.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 13 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      11             : // Parts of this file derived from Chromium's base/cpu.cc.
      12             : 
      13             : #include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
      14             : 
      15             : #if defined(WEBRTC_ARCH_X86_FAMILY) && defined(_MSC_VER)
      16             : #include <intrin.h>
      17             : #endif
      18             : 
      19             : #include "webrtc/typedefs.h"
      20             : 
      21             : // No CPU feature is available => straight C path.
      22           0 : int GetCPUInfoNoASM(CPUFeature feature) {
      23             :   (void)feature;
      24           0 :   return 0;
      25             : }
      26             : 
      27             : #if defined(WEBRTC_ARCH_X86_FAMILY)
      28             : #ifndef _MSC_VER
      29             : // Intrinsic for "cpuid".
      30             : #if defined(__pic__) && defined(__i386__)
      31             : static inline void __cpuid(int cpu_info[4], int info_type) {
      32             :   __asm__ volatile(
      33             :     "mov %%ebx, %%edi\n"
      34             :     "cpuid\n"
      35             :     "xchg %%edi, %%ebx\n"
      36             :     : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
      37             :     : "a"(info_type));
      38             : }
      39             : #else
      40           0 : static inline void __cpuid(int cpu_info[4], int info_type) {
      41             :   __asm__ volatile(
      42             :     "cpuid\n"
      43           0 :     : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
      44           0 :     : "a"(info_type));
      45           0 : }
      46             : #endif
      47             : #endif  // _MSC_VER
      48             : #endif  // WEBRTC_ARCH_X86_FAMILY
      49             : 
      50             : #if defined(WEBRTC_ARCH_X86_FAMILY)
      51             : // Actual feature detection for x86.
      52           0 : static int GetCPUInfo(CPUFeature feature) {
      53             :   int cpu_info[4];
      54           0 :   __cpuid(cpu_info, 1);
      55           0 :   if (feature == kSSE2) {
      56           0 :     return 0 != (cpu_info[3] & 0x04000000);
      57             :   }
      58           0 :   if (feature == kSSE3) {
      59           0 :     return 0 != (cpu_info[2] & 0x00000001);
      60             :   }
      61           0 :   return 0;
      62             : }
      63             : #else
      64             : // Default to straight C for other platforms.
      65             : static int GetCPUInfo(CPUFeature feature) {
      66             :   (void)feature;
      67             :   return 0;
      68             : }
      69             : 
      70             : #if !defined(WEBRTC_GONK) && !defined(ANDROID)
      71             : #ifdef WEBRTC_ARCH_ARM_V7
      72             : uint64_t WebRtc_GetCPUFeaturesARM(void) {
      73             :   return kCPUFeatureARMv7
      74             : #ifdef WEBRTC_ARCH_ARM_NEON
      75             :          | kCPUFeatureNEON
      76             : #endif
      77             :          | kCPUFeatureVFPv3;
      78             : }
      79             : #endif // WEBRTC_ARCH_ARM_V7
      80             : #endif // !WEBRTC_GONK && !ANDROID
      81             : 
      82             : #endif
      83             : 
      84             : WebRtc_CPUInfo WebRtc_GetCPUInfo = GetCPUInfo;
      85             : WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM = GetCPUInfoNoASM;

Generated by: LCOV version 1.13