mirror of
https://github.com/mborgerding/kissfft.git
synced 2026-11-18 20:09:30 -05:00
- kiss_fft_alloc(0) passed the overflow check and computed
sizeof(kiss_fft_cpx)*(nfft-1) with nfft-1 == -1, returning a config.
Reject nfft <= 0 (negative sizes were only rejected by accident of the
signed/unsigned comparison, which is now an explicit cast).
- kiss_fftr_alloc(0) halved 0 and built a config around a NULL
sub-state. Reject nfft <= 0 along with odd sizes, and compute
nfft*3/2 in size_t.
- kiss_fftnd_alloc multiplied the dimensions in an int, so {65536,65536}
wrapped to 0 and {46342,46342} to a negative value: the size query
reported a bogus size and a far too small buffer was accepted. Reject
dims <= 0 and products that do not fit in an int (st->dimprod) or whose
buffer size overflows size_t, reporting *lenmem = (size_t)-1 as
kiss_fftndr_alloc does.
- kiss_fft_next_fast_size incremented n past INT_MAX for
n > 2125764000 (the largest 2,3,5-smooth int) and returned a negative
value. It now returns n itself there (documented in kiss_fft.h): no
2,3,5-smooth int >= n exists, and n is still a valid, if slower, size
for callers that pass the result straight to an alloc.
- kfc.c read an uninitialized length when the size query rejected nfft;
it now returns NULL for an invalid size.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ
79 lines
2.4 KiB
CMake
79 lines
2.4 KiB
CMake
function(add_kissfft_test_executable NAME)
|
|
add_kissfft_executable(${NAME} ${ARGN})
|
|
target_include_directories(${NAME} PRIVATE ..)
|
|
|
|
if(HAVE_LASX)
|
|
target_compile_options(${NAME} PRIVATE -mlasx)
|
|
endif()
|
|
|
|
if(HAVE_LSX)
|
|
target_compile_options(${NAME} PRIVATE -mlsx)
|
|
endif()
|
|
|
|
add_test(NAME ${NAME} COMMAND ${NAME})
|
|
set_tests_properties(${NAME} PROPERTIES TIMEOUT 3600)
|
|
endfunction()
|
|
|
|
set(KISSFFT_TEST_NUMFFTS 10000)
|
|
|
|
#
|
|
# Add tools-independent fastfilt_* (../tools/fft_*) executable without adding a test
|
|
#
|
|
|
|
add_kissfft_executable(fastfilt ../tools/fftutil.c)
|
|
target_include_directories(fastfilt PRIVATE ..)
|
|
|
|
#
|
|
# Add test executables and define tests
|
|
#
|
|
|
|
add_kissfft_test_executable(bm_kiss benchkiss.c pstats.c)
|
|
# add_test(NAME benchmar COMMAND ${NAME})
|
|
# set_tests_properties(${NAME} PROPERTIES TIMEOUT 3600)
|
|
|
|
include(FindPkgConfig)
|
|
if(KISSFFT_FLOAT)
|
|
set(fftw3_pkg fftw3f)
|
|
else()
|
|
set(fftw3_pkg fftw3)
|
|
endif()
|
|
pkg_check_modules(fftw3 REQUIRED IMPORTED_TARGET ${fftw3_pkg})
|
|
add_kissfft_test_executable(bm_fftw benchfftw.c pstats.c)
|
|
target_link_libraries(bm_fftw PRIVATE PkgConfig::fftw3)
|
|
|
|
add_kissfft_test_executable(st twotonetest.c)
|
|
|
|
add_kissfft_test_executable(tkfc twotonetest.c)
|
|
target_compile_definitions(tkfc PRIVATE KFC_TEST)
|
|
|
|
add_kissfft_test_executable(ffr twotonetest.c)
|
|
add_kissfft_test_executable(tr test_real.c)
|
|
add_kissfft_test_executable(tsizeval test_size_validation.c)
|
|
|
|
add_kissfft_test_executable(next_fast_size next_fast_size.c)
|
|
|
|
add_kissfft_test_executable(testcpp testcpp.cc)
|
|
|
|
if(KISSFFT_DATATYPE MATCHES "^simd$")
|
|
add_kissfft_test_executable(tsimd test_simd.c)
|
|
target_compile_definitions(tsimd PRIVATE USE_SIMD)
|
|
if(HAVE_LASX)
|
|
target_compile_options(kissfft PRIVATE -mlasx)
|
|
elseif(HAVE_LSX)
|
|
target_compile_options(kissfft PRIVATE -mlsx)
|
|
elseif(NOT MSVC)
|
|
target_compile_options(kissfft PRIVATE -msse)
|
|
else()
|
|
target_compile_options(kissfft PRIVATE "/arch:SSE")
|
|
endif()
|
|
endif()
|
|
|
|
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
add_test(NAME testkiss.py COMMAND "${Python3_INTERPRETER}" "${CMAKE_CURRENT_SOURCE_DIR}/testkiss.py")
|
|
list(APPEND TESTKISS_PY_ENV "KISSFFT_DATATYPE=${KISSFFT_DATATYPE}")
|
|
list(APPEND TESTKISS_PY_ENV "KISSFFT_OPENMP=${KISSFFT_OPENMP}")
|
|
set_tests_properties(testkiss.py PROPERTIES
|
|
TIMEOUT 3600
|
|
ENVIRONMENT "${TESTKISS_PY_ENV}"
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|