• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025, 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 <fcntl.h>
13 #include <unistd.h>
14 #include <stdint.h>
15 
16 #include "config/aom_config.h"
17 
18 #include "aom_ports/riscv.h"
19 
20 #if CONFIG_RUNTIME_CPU_DETECT
21 
22 #include <sys/auxv.h>
23 
24 #define HWCAP_RVV (1 << ('v' - 'a'))
25 
riscv_simd_caps(void)26 int riscv_simd_caps(void) {
27   int flags = 0;
28 #if HAVE_RVV
29   unsigned long hwcap = getauxval(AT_HWCAP);
30   if (hwcap & HWCAP_RVV) flags |= HAS_RVV;
31 #endif
32   return flags;
33 }
34 #else
35 // If there is no RTCD the function pointers are not used and can not be
36 // changed.
riscv_simd_caps(void)37 int riscv_simd_caps(void) { return 0; }
38 #endif  // CONFIG_RUNTIME_CPU_DETECT
39