mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
riscv: Fix the run-time checking of the RVV availability
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
parent
2b0eb78656
commit
7108843467
@ -323,7 +323,7 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
list(FIND PNG_RISCV_RVV_POSSIBLE_VALUES ${PNG_RISCV_RVV} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR "PNG_RISCV_RVV must be one of [${PNG_RISCV_RVV_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_RISCV_RVV} STREQUAL "off")
|
||||
elseif(NOT PNG_RISCV_RVV STREQUAL "off")
|
||||
check_c_compiler_flag("-march=rv64gv1p0" COMPILER_SUPPORTS_RVV)
|
||||
if(NOT COMPILER_SUPPORTS_RVV)
|
||||
message(FATAL_ERROR "Compiler does not support -march=rv64gv1p0 option")
|
||||
@ -331,9 +331,9 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
set(libpng_riscv_sources
|
||||
riscv/filter_rvv_intrinsics.c
|
||||
riscv/riscv_init.c)
|
||||
if(${PNG_RISCV_RVV} STREQUAL "on")
|
||||
if(PNG_RISCV_RVV STREQUAL "on")
|
||||
add_definitions(-DPNG_RISCV_RVV_OPT=2)
|
||||
elseif(${PNG_RISCV_RVV} STREQUAL "check")
|
||||
elseif(PNG_RISCV_RVV STREQUAL "check")
|
||||
add_definitions(-DPNG_RISCV_RVV_CHECK_SUPPORTED)
|
||||
endif()
|
||||
else()
|
||||
|
@ -12,8 +12,8 @@
|
||||
* STATUS: SUPPORTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_rvv implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
* png_have_rvv implemented for Linux by looking for COMPAT_HWCAP_ISA_V
|
||||
* via hardware capabilites API.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||
|
10
pngpriv.h
10
pngpriv.h
@ -146,14 +146,20 @@
|
||||
#ifndef PNG_RISCV_RVV_OPT
|
||||
/* RISCV_RVV optimizations are being controlled by the compiler settings,
|
||||
* typically the target compiler will define __riscv but the rvv extension
|
||||
* availability has to be explicitly stated
|
||||
* availability has to be explicitly stated. This is why if no
|
||||
* PNG_RISCV_RVV_OPT was defined then a runtime check will be executed.
|
||||
*
|
||||
* To enable RISCV_RVV optimizations, and compile the
|
||||
* To enable RISCV_RVV optimizations unconditionally, and compile the
|
||||
* associated code, pass --enable-riscv-rvv=yes or --enable-riscv-rvv=on
|
||||
* to configure or put -DPNG_RISCV_RVV_OPT=2 in CPPFLAGS.
|
||||
*/
|
||||
|
||||
# if defined(__riscv) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_RISCV_RVV_OPT 1
|
||||
# else
|
||||
# define PNG_RISCV_RVV_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
/* NEON optimizations are to be at least considered by libpng, so enable the
|
||||
|
@ -16,10 +16,6 @@
|
||||
|
||||
#include <riscv_vector.h>
|
||||
|
||||
#ifdef PNG_RISCV_RVV_CHECK_SUPPORTED
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef PNG_RISCV_RVV_CHECK_SUPPORTED /* Do run-time checks */
|
||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||
* run-time checks for CPU features if at all possible. In the case of the
|
||||
@ -28,12 +24,14 @@
|
||||
* extremely OS specific.
|
||||
*
|
||||
* You may set the macro PNG_RISCV_RVV_FILE to the file name of file containing
|
||||
* a fragment of C source code which defines the png_have_neon function. There
|
||||
* a fragment of C source code which defines the png_have_rvv function. There
|
||||
* are a number of implementations in contrib/riscv-rvv, but the only one that
|
||||
* has partial support is contrib/riscv-rvv/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpuinfo.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef PNG_RISCV_RVV_FILE
|
||||
# if defined(__linux__)
|
||||
# define PNG_RISCV_RVV_FILE "contrib/riscv-rvv/linux.c"
|
||||
|
Loading…
x
Reference in New Issue
Block a user