tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

arm_cpudetect.h (1622B)


      1 /*
      2 * Copyright (c) 2023, Alliance for Open Media. All rights reserved.
      3 *
      4 * This source code is subject to the terms of the BSD 2 Clause License and
      5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6 * was not distributed with this source code in the LICENSE file, you can
      7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8 * Media Patent License 1.0 was not distributed with this source code in the
      9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10 */
     11 
     12 #include "aom_ports/arm.h"
     13 #include "config/aom_config.h"
     14 
     15 #include <stdbool.h>
     16 #include <stdlib.h>
     17 #include <string.h>
     18 
     19 #if defined(_WIN32)
     20 #undef WIN32_LEAN_AND_MEAN
     21 #define WIN32_LEAN_AND_MEAN
     22 #undef WIN32_EXTRA_LEAN
     23 #define WIN32_EXTRA_LEAN
     24 #include <windows.h>
     25 #endif
     26 
     27 #ifdef WINAPI_FAMILY
     28 #include <winapifamily.h>
     29 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
     30 #define getenv(x) NULL
     31 #endif
     32 #endif
     33 
     34 #if defined(__ANDROID__) && (__ANDROID_API__ < 18)
     35 #define AOM_USE_ANDROID_CPU_FEATURES 1
     36 // Use getauxval() when targeting (64-bit) Android with API level >= 18.
     37 // getauxval() is supported since Android API level 18 (Android 4.3.)
     38 // First Android version with 64-bit support was Android 5.x (API level 21).
     39 #include <cpu-features.h>
     40 #endif
     41 
     42 static bool arm_cpu_env_flags(int *flags) {
     43  const char *env = getenv("AOM_SIMD_CAPS");
     44  if (env && *env) {
     45    *flags = (int)strtol(env, NULL, 0);
     46    return true;
     47  }
     48  return false;
     49 }
     50 
     51 static int arm_cpu_env_mask(void) {
     52  const char *env = getenv("AOM_SIMD_CAPS_MASK");
     53  return env && *env ? (int)strtol(env, NULL, 0) : ~0;
     54 }