1 /* 2 * Copyright (c) 2023 The WebM 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 #include <stdlib.h> 12 #include <string.h> 13 14 #include "vpx_config.h" 15 #include "vpx_ports/arm.h" 16 17 #if defined(_WIN32) 18 #undef WIN32_LEAN_AND_MEAN 19 #define WIN32_LEAN_AND_MEAN 20 #undef WIN32_EXTRA_LEAN 21 #define WIN32_EXTRA_LEAN 22 #include <windows.h> 23 #endif 24 25 #ifdef WINAPI_FAMILY 26 #include <winapifamily.h> 27 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 28 #define getenv(x) NULL 29 #endif 30 #endif 31 32 #if defined(__ANDROID__) && (__ANDROID_API__ < 18) 33 #define VPX_USE_ANDROID_CPU_FEATURES 1 34 // Use getauxval() when targeting (64-bit) Android with API level >= 18. 35 // getauxval() is supported since Android API level 18 (Android 4.3.) 36 // First Android version with 64-bit support was Android 5.x (API level 21). 37 #include <cpu-features.h> 38 #endif 39 arm_cpu_env_flags(int * flags)40static INLINE int arm_cpu_env_flags(int *flags) { 41 const char *env = getenv("VPX_SIMD_CAPS"); 42 if (env && *env) { 43 *flags = (int)strtol(env, NULL, 0); 44 return 1; 45 } 46 return 0; 47 } 48 arm_cpu_env_mask(void)49static INLINE int arm_cpu_env_mask(void) { 50 const char *env = getenv("VPX_SIMD_CAPS_MASK"); 51 return env && *env ? (int)strtol(env, NULL, 0) : ~0; 52 } 53