Change log:95336cb92b..191d55580eFull diff:95336cb92b..191d55580eRoll chromium third_party 4e16929f46..3a8f2a9e1e Change log:4e16929f46..3a8f2a9e1eChanged dependencies: * src/tools:c44a3f5eca..f524a53b81DEPS diff:95336cb92b..191d55580e/DEPS No update to Clang. TBR=titovartem@google.com, BUG=None CQ_INCLUDE_TRYBOTS=master.internal.tryserver.corp.webrtc:linux_internal Change-Id: Ic9c4a62b050383646e9fcf5cc07a5653c14ac06e Reviewed-on: https://webrtc-review.googlesource.com/76120 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23205}
61 lines
1.7 KiB
C
61 lines
1.7 KiB
C
/* arm_features.c -- ARM processor features detection.
|
|
*
|
|
* Copyright 2018 The Chromium Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the Chromium source repository LICENSE file.
|
|
*/
|
|
#include "arm_features.h"
|
|
|
|
#include "zutil.h"
|
|
#include <pthread.h>
|
|
#include <stdint.h>
|
|
|
|
#if defined(ARMV8_OS_ANDROID)
|
|
#include <cpu-features.h>
|
|
#elif defined(ARMV8_OS_LINUX)
|
|
#include <asm/hwcap.h>
|
|
#include <sys/auxv.h>
|
|
#else
|
|
#error ### No ARM CPU features detection in your platform/OS
|
|
#endif
|
|
|
|
int ZLIB_INTERNAL arm_cpu_enable_crc32 = 0;
|
|
int ZLIB_INTERNAL arm_cpu_enable_pmull = 0;
|
|
|
|
static pthread_once_t cpu_check_inited_once = PTHREAD_ONCE_INIT;
|
|
|
|
static void init_arm_features(void)
|
|
{
|
|
uint64_t flag_crc32 = 0, flag_pmull = 0, capabilities = 0;
|
|
|
|
#if defined(ARMV8_OS_ANDROID)
|
|
flag_crc32 = ANDROID_CPU_ARM_FEATURE_CRC32;
|
|
flag_pmull = ANDROID_CPU_ARM_FEATURE_PMULL;
|
|
capabilities = android_getCpuFeatures();
|
|
#elif defined(ARMV8_OS_LINUX)
|
|
#if defined(__aarch64__)
|
|
flag_crc32 = HWCAP_CRC32;
|
|
flag_pmull = HWCAP_PMULL;
|
|
capabilities = getauxval(AT_HWCAP);
|
|
#elif defined(__ARM_NEON) || defined(__ARM_NEON__)
|
|
/* The use of HWCAP2 is for getting features of newer ARMv8-A SoCs
|
|
* while running in 32bits mode (i.e. aarch32).
|
|
*/
|
|
flag_crc32 = HWCAP2_CRC32;
|
|
flag_pmull = HWCAP2_PMULL;
|
|
capabilities = getauxval(AT_HWCAP2);
|
|
#endif
|
|
#endif
|
|
|
|
if (capabilities & flag_crc32)
|
|
arm_cpu_enable_crc32 = 1;
|
|
|
|
if (capabilities & flag_pmull)
|
|
arm_cpu_enable_pmull = 1;
|
|
}
|
|
|
|
void ZLIB_INTERNAL arm_check_features(void)
|
|
{
|
|
pthread_once(&cpu_check_inited_once, init_arm_features);
|
|
}
|