diff --git a/CMakeLists.txt b/CMakeLists.txt index 843aa14..7e2f480 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.10) project(PRETTY_FAST_FFT) +include(GNUInstallDirs) + # detect if pffft is the top-level project or built as a dependency if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(PFFFT_IS_TOPLEVEL ON) @@ -128,13 +130,13 @@ if (MINGW) endif() -set( SIMD_FLOAT_HDRS ${PFFFT_SOURCE_DIR}/simd/pf_float.h ${PFFFT_SOURCE_DIR}/simd/pf_sse1_float.h ${PFFFT_SOURCE_DIR}/simd/pf_altivec_float.h ${PFFFT_SOURCE_DIR}/simd/pf_neon_float.h ${PFFFT_SOURCE_DIR}/simd/pf_scalar_float.h ) -set( SIMD_DOUBLE_HDRS ${PFFFT_SOURCE_DIR}/simd/pf_double.h ${PFFFT_SOURCE_DIR}/simd/pf_avx_double.h ${PFFFT_SOURCE_DIR}/simd/pf_scalar_double.h ) +set( SIMD_FLOAT_HDRS ${PFFFT_SOURCE_DIR}/src/simd/pf_float.h ${PFFFT_SOURCE_DIR}/src/simd/pf_sse1_float.h ${PFFFT_SOURCE_DIR}/src/simd/pf_altivec_float.h ${PFFFT_SOURCE_DIR}/src/simd/pf_neon_float.h ${PFFFT_SOURCE_DIR}/src/simd/pf_scalar_float.h ) +set( SIMD_DOUBLE_HDRS ${PFFFT_SOURCE_DIR}/src/simd/pf_double.h ${PFFFT_SOURCE_DIR}/src/simd/pf_avx_double.h ${PFFFT_SOURCE_DIR}/src/simd/pf_scalar_double.h ) if (PFFFT_USE_TYPE_FLOAT) - set( FLOAT_SOURCES pffft.c pffft.h ${SIMD_FLOAT_HDRS} ) + set( FLOAT_SOURCES src/pffft.c include/pffft/pffft.h ${SIMD_FLOAT_HDRS} ) if (INSTALL_PFFFT) - set(INSTALL_HEADERS ${INSTALL_HEADERS} pffft.h) + set(INSTALL_HEADERS ${INSTALL_HEADERS} include/pffft/pffft.h) endif() else() set( FLOAT_SOURCES ) @@ -142,9 +144,9 @@ endif() if (PFFFT_USE_TYPE_DOUBLE) - set( DOUBLE_SOURCES pffft_double.c pffft_double.h ${SIMD_DOUBLE_HDRS} ) + set( DOUBLE_SOURCES src/pffft_double.c include/pffft/pffft_double.h ${SIMD_DOUBLE_HDRS} ) if (INSTALL_PFFFT) - set(INSTALL_HEADERS ${INSTALL_HEADERS} pffft_double.h) + set(INSTALL_HEADERS ${INSTALL_HEADERS} include/pffft/pffft_double.h) endif() else() set( DOUBLE_SOURCES ) @@ -152,7 +154,7 @@ endif() ###################################################### -add_library(PFFFT STATIC ${FLOAT_SOURCES} ${DOUBLE_SOURCES} pffft_common.c pffft_priv_impl.h pffft.hpp ) +add_library(PFFFT ${FLOAT_SOURCES} ${DOUBLE_SOURCES} src/pffft_common.c src/pffft_priv_impl.h include/pffft/pffft.hpp ) add_library(PFFFT::PFFFT ALIAS PFFFT) set_target_properties(PFFFT PROPERTIES OUTPUT_NAME "pffft") target_compile_definitions(PFFFT PRIVATE _USE_MATH_DEFINES) @@ -168,18 +170,30 @@ if (NOT PFFFT_USE_SIMD) target_compile_definitions(PFFFT PRIVATE PFFFT_SIMD_DISABLE=1) endif() target_link_libraries( PFFFT ${ASANLIB} ${MATHLIB} ) -set_property(TARGET PFFFT APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES - $ +target_include_directories(PFFFT + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/include/pffft +) +set_target_properties(PFFFT PROPERTIES + C_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON ) +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(PFFFT PUBLIC PFFFT_STATIC_DEFINE) +endif() if (INSTALL_PFFFT) set(INSTALL_TARGETS ${INSTALL_TARGETS} PFFFT) - set(INSTALL_HEADERS ${INSTALL_HEADERS} pffft.hpp) + set(INSTALL_HEADERS ${INSTALL_HEADERS} include/pffft/pffft.hpp) endif() ###################################################### if (PFFFT_USE_TYPE_FLOAT) - add_library(PFDSP STATIC pf_mixer.cpp pf_mixer.h pf_cplx.h pf_carrier.cpp pf_carrier.h pf_cic.cpp pf_cic.h fmv.h ) + add_library(PFDSP src/pf_mixer.cpp include/pffft/pf_mixer.h include/pffft/pf_cplx.h src/pf_carrier.cpp include/pffft/pf_carrier.h src/pf_cic.cpp include/pffft/pf_cic.h src/fmv.h ) set_property(TARGET PFDSP PROPERTY CXX_STANDARD 11) set_property(TARGET PFDSP PROPERTY CXX_STANDARD_REQUIRED ON) set_target_properties(PFDSP PROPERTIES OUTPUT_NAME "pfdsp") @@ -194,12 +208,24 @@ if (PFFFT_USE_TYPE_FLOAT) target_compile_definitions(PFDSP PRIVATE PFFFT_SIMD_DISABLE=1) endif() target_link_libraries( PFDSP ${MATHLIB} ) - set_property(TARGET PFDSP APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES - $ + target_include_directories(PFDSP + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/include/pffft ) + set_target_properties(PFDSP PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + ) + if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(PFDSP PUBLIC PFDSP_STATIC_DEFINE) + endif() if (INSTALL_PFDSP) set(INSTALL_TARGETS ${INSTALL_TARGETS} PFDSP) - set(INSTALL_HEADERS ${INSTALL_HEADERS} pf_mixer.h pf_cplx.h pf_carrier.h pf_cic.h) + set(INSTALL_HEADERS ${INSTALL_HEADERS} include/pffft/pf_mixer.h include/pffft/pf_cplx.h include/pffft/pf_carrier.h include/pffft/pf_cic.h) endif() endif() @@ -208,22 +234,22 @@ endif() if ((PFFFT_BUILD_TESTS OR PFFFT_BUILD_BENCHMARKS) AND PFFFT_USE_FFTPACK) # float / single precision - add_library(FFTPACK_FLOAT STATIC fftpack.c fftpack.h) + add_library(FFTPACK_FLOAT STATIC src/fftpack.c src/fftpack.h) target_compile_definitions(FFTPACK_FLOAT PRIVATE _USE_MATH_DEFINES) target_activate_c_compiler_warnings(FFTPACK_FLOAT) target_link_libraries( FFTPACK_FLOAT ${MATHLIB} ) - set_property(TARGET FFTPACK_FLOAT APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES - $ + target_include_directories(FFTPACK_FLOAT + PUBLIC $ ) # double precision - add_library(FFTPACK_DOUBLE STATIC fftpack.c fftpack.h) + add_library(FFTPACK_DOUBLE STATIC src/fftpack.c src/fftpack.h) target_compile_definitions(FFTPACK_DOUBLE PRIVATE _USE_MATH_DEFINES) target_compile_definitions(FFTPACK_DOUBLE PUBLIC FFTPACK_DOUBLE_PRECISION) target_activate_c_compiler_warnings(FFTPACK_DOUBLE) target_link_libraries( FFTPACK_DOUBLE ${MATHLIB} ) - set_property(TARGET FFTPACK_DOUBLE APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES - $ + target_include_directories(FFTPACK_DOUBLE + PUBLIC $ ) endif() @@ -232,7 +258,7 @@ endif() if (PFFFT_USE_TYPE_FLOAT) # only 'float' supported in PFFASTCONV - add_library(PFFASTCONV STATIC pffastconv.c pffastconv.h pffft.h ) + add_library(PFFASTCONV src/pffastconv.c include/pffft/pffastconv.h include/pffft/pffft.h ) set_target_properties(PFFASTCONV PROPERTIES OUTPUT_NAME "pffastconv") target_compile_definitions(PFFASTCONV PRIVATE _USE_MATH_DEFINES) target_activate_c_compiler_warnings(PFFASTCONV) @@ -240,20 +266,61 @@ if (PFFFT_USE_TYPE_FLOAT) target_compile_options(PFFASTCONV PRIVATE "-fsanitize=address") endif() target_link_libraries( PFFASTCONV PFFFT ${ASANLIB} ${MATHLIB} ) - set_property(TARGET PFFASTCONV APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES - $ + target_include_directories(PFFASTCONV + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include/pffft ) + set_target_properties(PFFASTCONV PROPERTIES + C_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + ) + if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(PFFASTCONV PUBLIC PFFASTCONV_STATIC_DEFINE) + endif() if (INSTALL_PFFASTCONV) set(INSTALL_TARGETS ${INSTALL_TARGETS} PFFASTCONV) - set(INSTALL_HEADERS ${INSTALL_HEADERS} pffastconv.h) + set(INSTALL_HEADERS ${INSTALL_HEADERS} include/pffft/pffastconv.h) endif() endif() ###################################################### -install( TARGETS ${INSTALL_TARGETS} DESTINATION lib) -install( FILES ${INSTALL_HEADERS} DESTINATION include) +install( TARGETS ${INSTALL_TARGETS} + EXPORT pffft-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install( FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pffft) + +install(EXPORT pffft-targets + FILE pffft-targets.cmake + NAMESPACE PFFFT:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pffft +) + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pffft-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/pffft-config.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pffft +) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/pffft-config-version.cmake" + VERSION 1.0 + COMPATIBILITY SameMajorVersion +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/pffft-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/pffft-config-version.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pffft +) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/uninstall.cmake" diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 35b317c..9988c73 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -33,7 +33,7 @@ endif() ###################################################### if (PFFFT_USE_TYPE_FLOAT) - add_executable(bench_pffft_float bench_pffft.c ${PFFFT_SOURCE_DIR}/pffft.h) + add_executable(bench_pffft_float bench_pffft.c) target_compile_definitions(bench_pffft_float PRIVATE _USE_MATH_DEFINES) target_compile_definitions(bench_pffft_float PRIVATE PFFFT_ENABLE_FLOAT) if (PFFFT_USE_DEBUG_ASAN) @@ -82,7 +82,7 @@ if (PFFFT_USE_TYPE_FLOAT) endif() if (PFFFT_USE_TYPE_DOUBLE) - add_executable(bench_pffft_double bench_pffft.c ${PFFFT_SOURCE_DIR}/pffft.h) + add_executable(bench_pffft_double bench_pffft.c) target_compile_definitions(bench_pffft_double PRIVATE _USE_MATH_DEFINES) target_compile_definitions(bench_pffft_double PRIVATE PFFFT_ENABLE_DOUBLE) if (PFFFT_USE_DEBUG_ASAN) @@ -138,20 +138,20 @@ if (PFFFT_USE_TYPE_FLOAT) ############################################################################ - add_library(pf_conv_arch_none pf_conv.cpp pf_conv.h ${PFFFT_SOURCE_DIR}/pf_cplx.h) - target_include_directories(pf_conv_arch_none PRIVATE ${PFFFT_SOURCE_DIR}) + add_library(pf_conv_arch_none pf_conv.cpp pf_conv.h ${PFFFT_SOURCE_DIR}/include/pffft/pf_cplx.h) + target_include_directories(pf_conv_arch_none PRIVATE ${PFFFT_SOURCE_DIR}/include) target_compile_definitions(pf_conv_arch_none PRIVATE CONV_ARCH_POST=none MIPP_NO_INTRINSICS=1) set_property(TARGET pf_conv_arch_none PROPERTY CXX_STANDARD 11) set_property(TARGET pf_conv_arch_none PROPERTY CXX_STANDARD_REQUIRED ON) target_activate_cxx_compiler_warnings(pf_conv_arch_none) - add_library(pf_conv_dispatcher pf_conv_dispatcher.cpp pf_conv_dispatcher.h pf_conv.h ${PFFFT_SOURCE_DIR}/pf_cplx.h) - target_include_directories(pf_conv_dispatcher PRIVATE ${PFFFT_SOURCE_DIR}) + add_library(pf_conv_dispatcher pf_conv_dispatcher.cpp pf_conv_dispatcher.h pf_conv.h ${PFFFT_SOURCE_DIR}/include/pffft/pf_cplx.h) + target_include_directories(pf_conv_dispatcher PRIVATE ${PFFFT_SOURCE_DIR}/include) set_property(TARGET pf_conv_dispatcher PROPERTY CXX_STANDARD 11) set_property(TARGET pf_conv_dispatcher PROPERTY CXX_STANDARD_REQUIRED ON) target_activate_cxx_compiler_warnings(pf_conv_dispatcher) - add_library(pf_conv_arch_dflt pf_conv.cpp pf_conv.h ${PFFFT_SOURCE_DIR}/pf_cplx.h) - target_include_directories(pf_conv_arch_dflt PRIVATE ${PFFFT_SOURCE_DIR}) + add_library(pf_conv_arch_dflt pf_conv.cpp pf_conv.h ${PFFFT_SOURCE_DIR}/include/pffft/pf_cplx.h) + target_include_directories(pf_conv_arch_dflt PRIVATE ${PFFFT_SOURCE_DIR}/include) target_compile_definitions(pf_conv_arch_dflt PRIVATE CONV_ARCH_POST=dflt) set_property(TARGET pf_conv_arch_dflt PROPERTY CXX_STANDARD 11) set_property(TARGET pf_conv_arch_dflt PROPERTY CXX_STANDARD_REQUIRED ON) @@ -214,8 +214,8 @@ if (PFFFT_USE_TYPE_FLOAT) endif() foreach (arch_opt ${PF_CONV_ARCHES}) - add_library(pf_conv_arch_${arch_opt} pf_conv.cpp pf_conv.h ${PFFFT_SOURCE_DIR}/pf_cplx.h) - target_include_directories(pf_conv_arch_${arch_opt} PRIVATE ${PFFFT_SOURCE_DIR}) + add_library(pf_conv_arch_${arch_opt} pf_conv.cpp pf_conv.h ${PFFFT_SOURCE_DIR}/include/pffft/pf_cplx.h) + target_include_directories(pf_conv_arch_${arch_opt} PRIVATE ${PFFFT_SOURCE_DIR}/include) set_property(TARGET pf_conv_arch_${arch_opt} PROPERTY CXX_STANDARD 11) set_property(TARGET pf_conv_arch_${arch_opt} PROPERTY CXX_STANDARD_REQUIRED ON) target_activate_cxx_compiler_warnings(pf_conv_arch_${arch_opt}) diff --git a/benchmarks/bench_mixers.cpp b/benchmarks/bench_mixers.cpp index c08a51a..ad067c1 100644 --- a/benchmarks/bench_mixers.cpp +++ b/benchmarks/bench_mixers.cpp @@ -5,7 +5,7 @@ */ -#include +#include #include #include diff --git a/benchmarks/bench_pffft.c b/benchmarks/bench_pffft.c index 7abb48d..263aac6 100644 --- a/benchmarks/bench_pffft.c +++ b/benchmarks/bench_pffft.c @@ -32,7 +32,7 @@ #define CONCAT_THREE_TOKENS(A, B, C) A ## B ## C #ifdef PFFFT_ENABLE_FLOAT -#include "pffft.h" +#include "pffft/pffft.h" typedef float pffft_scalar; typedef PFFFT_Setup PFFFT_SETUP; @@ -42,7 +42,7 @@ typedef PFFFT_Setup PFFFT_SETUP; /* Note: adapted for double precision dynamic range version. */ -#include "pffft_double.h" +#include "pffft/pffft_double.h" typedef double pffft_scalar; typedef PFFFTD_Setup PFFFT_SETUP; diff --git a/benchmarks/pf_conv.h b/benchmarks/pf_conv.h index 0194b98..eb77a63 100644 --- a/benchmarks/pf_conv.h +++ b/benchmarks/pf_conv.h @@ -20,7 +20,7 @@ * utilizing the target_set_cxx_arch_option() macro in the CMakeLists.txt */ -#include "pf_cplx.h" +#include "pffft/pf_cplx.h" #if defined(_MSC_VER) # define RESTRICT __restrict diff --git a/cmake/pffft-config.cmake.in b/cmake/pffft-config.cmake.in new file mode 100644 index 0000000..125d3e1 --- /dev/null +++ b/cmake/pffft-config.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/pffft-targets.cmake") + +check_required_components(pffft) diff --git a/examples/example_c_cplx_dbl_fwd.c b/examples/example_c_cplx_dbl_fwd.c index e9adcd9..9ff6d4f 100644 --- a/examples/example_c_cplx_dbl_fwd.c +++ b/examples/example_c_cplx_dbl_fwd.c @@ -1,5 +1,5 @@ -#include "pffft_double.h" +#include "pffft/pffft_double.h" #include #include diff --git a/examples/example_c_real_flt_fwd.c b/examples/example_c_real_flt_fwd.c index f52df41..d2c9c57 100644 --- a/examples/example_c_real_flt_fwd.c +++ b/examples/example_c_real_flt_fwd.c @@ -1,5 +1,5 @@ -#include "pffft.h" +#include "pffft/pffft.h" #include #include diff --git a/examples/example_cpp11_cplx_dbl_fwd.cpp b/examples/example_cpp11_cplx_dbl_fwd.cpp index e60dbc9..86bea79 100644 --- a/examples/example_cpp11_cplx_dbl_fwd.cpp +++ b/examples/example_cpp11_cplx_dbl_fwd.cpp @@ -1,5 +1,5 @@ -#include "pffft.hpp" +#include "pffft/pffft.hpp" #include #include diff --git a/examples/example_cpp11_real_dbl_fwd.cpp b/examples/example_cpp11_real_dbl_fwd.cpp index 433865a..20c6bfe 100644 --- a/examples/example_cpp11_real_dbl_fwd.cpp +++ b/examples/example_cpp11_real_dbl_fwd.cpp @@ -1,5 +1,5 @@ -#include "pffft.hpp" +#include "pffft/pffft.hpp" #include #include diff --git a/examples/example_cpp98_cplx_flt_fwd.cpp b/examples/example_cpp98_cplx_flt_fwd.cpp index 91e48cd..37a47ef 100644 --- a/examples/example_cpp98_cplx_flt_fwd.cpp +++ b/examples/example_cpp98_cplx_flt_fwd.cpp @@ -1,5 +1,5 @@ -#include "pffft.hpp" +#include "pffft/pffft.hpp" #include #include diff --git a/examples/example_cpp98_real_flt_fwd.cpp b/examples/example_cpp98_real_flt_fwd.cpp index c5ffe2b..d3a861c 100644 --- a/examples/example_cpp98_real_flt_fwd.cpp +++ b/examples/example_cpp98_real_flt_fwd.cpp @@ -1,5 +1,5 @@ -#include "pffft.hpp" +#include "pffft/pffft.hpp" #include #include diff --git a/pf_carrier.h b/include/pffft/pf_carrier.h similarity index 63% rename from pf_carrier.h rename to include/pffft/pf_carrier.h index c328ce0..2ac5bb6 100644 --- a/pf_carrier.h +++ b/include/pffft/pf_carrier.h @@ -33,6 +33,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef PFDSP_EXPORT + #ifdef PFDSP_STATIC_DEFINE + #define PFDSP_EXPORT + #elif defined(_WIN32) || defined(__CYGWIN__) + #ifdef PFDSP_EXPORTS + #define PFDSP_EXPORT __declspec(dllexport) + #else + #define PFDSP_EXPORT __declspec(dllimport) + #endif + #elif defined(PFDSP_EXPORTS) && (defined(__GNUC__) || defined(__clang__)) + #define PFDSP_EXPORT __attribute__((visibility("default"))) + #else + #define PFDSP_EXPORT + #endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -53,20 +69,20 @@ typedef struct complexf_s { float i; float q; } complexf; /* generation functions */ -void generate_dc_f(float* output, int size); -void generate_dc_s16(short* output, int size); -void generate_pos_fs4_f(float* output, int size); -void generate_pos_fs4_s16(short* output, int size); -void generate_neg_fs4_f(float* output, int size); -void generate_neg_fs4_s16(short* output, int size); - -void generate_dc_pos_fs4_s16(short* output, int size); -void generate_dc_neg_fs4_s16(short* output, int size); -void generate_pos_neg_fs4_s16(short* output, int size); -void generate_dc_pos_neg_fs4_s16(short* output, int size); - -void generate_pos_neg_fs2_s16(short* output, int size); -void generate_dc_pos_neg_fs2_s16(short* output, int size); +PFDSP_EXPORT void generate_dc_f(float* output, int size); +PFDSP_EXPORT void generate_dc_s16(short* output, int size); +PFDSP_EXPORT void generate_pos_fs4_f(float* output, int size); +PFDSP_EXPORT void generate_pos_fs4_s16(short* output, int size); +PFDSP_EXPORT void generate_neg_fs4_f(float* output, int size); +PFDSP_EXPORT void generate_neg_fs4_s16(short* output, int size); + +PFDSP_EXPORT void generate_dc_pos_fs4_s16(short* output, int size); +PFDSP_EXPORT void generate_dc_neg_fs4_s16(short* output, int size); +PFDSP_EXPORT void generate_pos_neg_fs4_s16(short* output, int size); +PFDSP_EXPORT void generate_dc_pos_neg_fs4_s16(short* output, int size); + +PFDSP_EXPORT void generate_pos_neg_fs2_s16(short* output, int size); +PFDSP_EXPORT void generate_dc_pos_neg_fs2_s16(short* output, int size); #ifdef __cplusplus diff --git a/pf_cic.h b/include/pffft/pf_cic.h similarity index 69% rename from pf_cic.h rename to include/pffft/pf_cic.h index 681ee4f..393a3d6 100644 --- a/pf_cic.h +++ b/include/pffft/pf_cic.h @@ -32,6 +32,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#ifndef PFDSP_EXPORT + #ifdef PFDSP_STATIC_DEFINE + #define PFDSP_EXPORT + #elif defined(_WIN32) || defined(__CYGWIN__) + #ifdef PFDSP_EXPORTS + #define PFDSP_EXPORT __declspec(dllexport) + #else + #define PFDSP_EXPORT __declspec(dllimport) + #endif + #elif defined(PFDSP_EXPORTS) && (defined(__GNUC__) || defined(__clang__)) + #define PFDSP_EXPORT __attribute__((visibility("default"))) + #else + #define PFDSP_EXPORT + #endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -46,11 +62,11 @@ extern "C" { typedef struct complexf_s { float i; float q; } complexf; -void *cicddc_init(int factor); -void cicddc_free(void *state); -void cicddc_s16_c(void *state, int16_t *input, complexf *output, int outsize, float rate); -void cicddc_cs16_c(void *state, int16_t *input, complexf *output, int outsize, float rate); -void cicddc_cu8_c(void *state, uint8_t *input, complexf *output, int outsize, float rate); +PFDSP_EXPORT void *cicddc_init(int factor); +PFDSP_EXPORT void cicddc_free(void *state); +PFDSP_EXPORT void cicddc_s16_c(void *state, int16_t *input, complexf *output, int outsize, float rate); +PFDSP_EXPORT void cicddc_cs16_c(void *state, int16_t *input, complexf *output, int outsize, float rate); +PFDSP_EXPORT void cicddc_cu8_c(void *state, uint8_t *input, complexf *output, int outsize, float rate); #ifdef __cplusplus } diff --git a/pf_cplx.h b/include/pffft/pf_cplx.h similarity index 100% rename from pf_cplx.h rename to include/pffft/pf_cplx.h diff --git a/pf_mixer.h b/include/pffft/pf_mixer.h similarity index 63% rename from pf_mixer.h rename to include/pffft/pf_mixer.h index e153ad0..dbacdcc 100644 --- a/pf_mixer.h +++ b/include/pffft/pf_mixer.h @@ -35,6 +35,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pf_cplx.h" +#ifndef PFDSP_EXPORT + #ifdef PFDSP_STATIC_DEFINE + #define PFDSP_EXPORT + #elif defined(_WIN32) || defined(__CYGWIN__) + #ifdef PFDSP_EXPORTS + #define PFDSP_EXPORT __declspec(dllexport) + #else + #define PFDSP_EXPORT __declspec(dllimport) + #endif + #elif defined(PFDSP_EXPORTS) && (defined(__GNUC__) || defined(__clang__)) + #define PFDSP_EXPORT __attribute__((visibility("default"))) + #else + #define PFDSP_EXPORT + #endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -42,7 +58,7 @@ extern "C" { // ================================================================================= -int have_sse_shift_mixer_impl(); +PFDSP_EXPORT int have_sse_shift_mixer_impl(); /*********************************************************************/ @@ -51,7 +67,7 @@ int have_sse_shift_mixer_impl(); /*** ALGO A ***/ /**************/ -float shift_math_cc(const complexf *input, complexf* output, int input_size, float rate, float starting_phase); +PFDSP_EXPORT float shift_math_cc(const complexf *input, complexf* output, int input_size, float rate, float starting_phase); /*********************************************************************/ @@ -66,9 +82,9 @@ typedef struct shift_table_data_s int table_size; } shift_table_data_t; -void shift_table_deinit(shift_table_data_t table_data); -shift_table_data_t shift_table_init(int table_size); -float shift_table_cc(complexf* input, complexf* output, int input_size, float rate, shift_table_data_t table_data, float starting_phase); +PFDSP_EXPORT void shift_table_deinit(shift_table_data_t table_data); +PFDSP_EXPORT shift_table_data_t shift_table_init(int table_size); +PFDSP_EXPORT float shift_table_cc(complexf* input, complexf* output, int input_size, float rate, shift_table_data_t table_data, float starting_phase); /*********************************************************************/ @@ -83,9 +99,9 @@ typedef struct shift_addfast_data_s float phase_increment; } shift_addfast_data_t; -shift_addfast_data_t shift_addfast_init(float rate); -float shift_addfast_cc(complexf *input, complexf* output, int input_size, shift_addfast_data_t* d, float starting_phase); -float shift_addfast_inp_c(complexf *in_out, int N_cplx, shift_addfast_data_t* d, float starting_phase); +PFDSP_EXPORT shift_addfast_data_t shift_addfast_init(float rate); +PFDSP_EXPORT float shift_addfast_cc(complexf *input, complexf* output, int input_size, shift_addfast_data_t* d, float starting_phase); +PFDSP_EXPORT float shift_addfast_inp_c(complexf *in_out, int N_cplx, shift_addfast_data_t* d, float starting_phase); /*********************************************************************/ @@ -102,10 +118,10 @@ typedef struct shift_unroll_data_s int size; } shift_unroll_data_t; -shift_unroll_data_t shift_unroll_init(float rate, int size); -void shift_unroll_deinit(shift_unroll_data_t* d); -float shift_unroll_cc(complexf *input, complexf* output, int size, shift_unroll_data_t* d, float starting_phase); -float shift_unroll_inp_c(complexf* in_out, int size, shift_unroll_data_t* d, float starting_phase); +PFDSP_EXPORT shift_unroll_data_t shift_unroll_init(float rate, int size); +PFDSP_EXPORT void shift_unroll_deinit(shift_unroll_data_t* d); +PFDSP_EXPORT float shift_unroll_cc(complexf *input, complexf* output, int size, shift_unroll_data_t* d, float starting_phase); +PFDSP_EXPORT float shift_unroll_inp_c(complexf* in_out, int size, shift_unroll_data_t* d, float starting_phase); /*********************************************************************/ @@ -129,11 +145,11 @@ typedef struct shift_limited_unroll_data_s float phase_increment; } shift_limited_unroll_data_t; -shift_limited_unroll_data_t shift_limited_unroll_init(float rate); +PFDSP_EXPORT shift_limited_unroll_data_t shift_limited_unroll_init(float rate); /* size must be multiple of PF_SHIFT_LIMITED_SIMD_SZ */ /* starting_phase for next call is kept internal in state */ -void shift_limited_unroll_cc(const complexf *input, complexf* output, int size, shift_limited_unroll_data_t* d); -void shift_limited_unroll_inp_c(complexf* in_out, int size, shift_limited_unroll_data_t* d); +PFDSP_EXPORT void shift_limited_unroll_cc(const complexf *input, complexf* output, int size, shift_limited_unroll_data_t* d); +PFDSP_EXPORT void shift_limited_unroll_inp_c(complexf* in_out, int size, shift_limited_unroll_data_t* d); /*********************************************************************/ @@ -157,8 +173,8 @@ typedef struct shift_limited_unroll_A_sse_data_s float phase_increment; } shift_limited_unroll_A_sse_data_t; -shift_limited_unroll_A_sse_data_t shift_limited_unroll_A_sse_init(float relative_freq, float phase_start_rad); -void shift_limited_unroll_A_sse_inp_c(complexf* in_out, int N_cplx, shift_limited_unroll_A_sse_data_t* d); +PFDSP_EXPORT shift_limited_unroll_A_sse_data_t shift_limited_unroll_A_sse_init(float relative_freq, float phase_start_rad); +PFDSP_EXPORT void shift_limited_unroll_A_sse_inp_c(complexf* in_out, int N_cplx, shift_limited_unroll_A_sse_data_t* d); /*********************************************************************/ @@ -181,8 +197,8 @@ typedef struct shift_limited_unroll_B_sse_data_s float phase_increment; } shift_limited_unroll_B_sse_data_t; -shift_limited_unroll_B_sse_data_t shift_limited_unroll_B_sse_init(float relative_freq, float phase_start_rad); -void shift_limited_unroll_B_sse_inp_c(complexf* in_out, int N_cplx, shift_limited_unroll_B_sse_data_t* d); +PFDSP_EXPORT shift_limited_unroll_B_sse_data_t shift_limited_unroll_B_sse_init(float relative_freq, float phase_start_rad); +PFDSP_EXPORT void shift_limited_unroll_B_sse_inp_c(complexf* in_out, int N_cplx, shift_limited_unroll_B_sse_data_t* d); /*********************************************************************/ @@ -204,8 +220,8 @@ typedef struct shift_limited_unroll_C_sse_data_s float phase_increment; } shift_limited_unroll_C_sse_data_t; -shift_limited_unroll_C_sse_data_t shift_limited_unroll_C_sse_init(float relative_freq, float phase_start_rad); -void shift_limited_unroll_C_sse_inp_c(complexf* in_out, int N_cplx, shift_limited_unroll_C_sse_data_t* d); +PFDSP_EXPORT shift_limited_unroll_C_sse_data_t shift_limited_unroll_C_sse_init(float relative_freq, float phase_start_rad); +PFDSP_EXPORT void shift_limited_unroll_C_sse_inp_c(complexf* in_out, int N_cplx, shift_limited_unroll_C_sse_data_t* d); @@ -231,14 +247,14 @@ typedef struct shift_recursive_osc_conf_s float k2; } shift_recursive_osc_conf_t; -void shift_recursive_osc_init(float rate, float starting_phase, shift_recursive_osc_conf_t *conf, shift_recursive_osc_t *state); -void shift_recursive_osc_update_rate(float rate, shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); +PFDSP_EXPORT void shift_recursive_osc_init(float rate, float starting_phase, shift_recursive_osc_conf_t *conf, shift_recursive_osc_t *state); +PFDSP_EXPORT void shift_recursive_osc_update_rate(float rate, shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); /* size must be multiple of PF_SHIFT_LIMITED_SIMD_SZ */ /* starting_phase for next call is kept internal in state */ -void shift_recursive_osc_cc(const complexf *input, complexf* output, int size, const shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); -void shift_recursive_osc_inp_c(complexf* output, int size, const shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); -void gen_recursive_osc_c(complexf* output, int size, const shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); +PFDSP_EXPORT void shift_recursive_osc_cc(const complexf *input, complexf* output, int size, const shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); +PFDSP_EXPORT void shift_recursive_osc_inp_c(complexf* output, int size, const shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); +PFDSP_EXPORT void gen_recursive_osc_c(complexf* output, int size, const shift_recursive_osc_conf_t *conf, shift_recursive_osc_t* state); /*********************************************************************/ @@ -259,9 +275,9 @@ typedef struct shift_recursive_osc_sse_conf_s float k2; } shift_recursive_osc_sse_conf_t; -void shift_recursive_osc_sse_init(float rate, float starting_phase, shift_recursive_osc_sse_conf_t *conf, shift_recursive_osc_sse_t *state); -void shift_recursive_osc_sse_update_rate(float rate, shift_recursive_osc_sse_conf_t *conf, shift_recursive_osc_sse_t* state); -void shift_recursive_osc_sse_inp_c(complexf* in_out, int N_cplx, const shift_recursive_osc_sse_conf_t *conf, shift_recursive_osc_sse_t* state_ext); +PFDSP_EXPORT void shift_recursive_osc_sse_init(float rate, float starting_phase, shift_recursive_osc_sse_conf_t *conf, shift_recursive_osc_sse_t *state); +PFDSP_EXPORT void shift_recursive_osc_sse_update_rate(float rate, shift_recursive_osc_sse_conf_t *conf, shift_recursive_osc_sse_t* state); +PFDSP_EXPORT void shift_recursive_osc_sse_inp_c(complexf* in_out, int N_cplx, const shift_recursive_osc_sse_conf_t *conf, shift_recursive_osc_sse_t* state_ext); #ifdef __cplusplus diff --git a/pffastconv.h b/include/pffft/pffastconv.h similarity index 85% rename from pffastconv.h rename to include/pffft/pffastconv.h index 6bc5e47..c7fc0e4 100644 --- a/pffastconv.h +++ b/include/pffft/pffastconv.h @@ -53,6 +53,22 @@ #include /* for size_t */ #include "pffft.h" +#ifndef PFFASTCONV_EXPORT + #ifdef PFFASTCONV_STATIC_DEFINE + #define PFFASTCONV_EXPORT + #elif defined(_WIN32) || defined(__CYGWIN__) + #ifdef PFFASTCONV_EXPORTS + #define PFFASTCONV_EXPORT __declspec(dllexport) + #else + #define PFFASTCONV_EXPORT __declspec(dllimport) + #endif + #elif defined(PFFASTCONV_EXPORTS) && (defined(__GNUC__) || defined(__clang__)) + #define PFFASTCONV_EXPORT __attribute__((visibility("default"))) + #else + #define PFFASTCONV_EXPORT + #endif +#endif + #ifdef __cplusplus extern "C" { @@ -126,9 +142,9 @@ extern "C" { PFFASTCONV_Setup structure can't be shared accross multiple filters or concurrent threads. */ - PFFASTCONV_Setup * pffastconv_new_setup( const float * filterCoeffs, int filterLen, int * blockLen, int flags ); + PFFASTCONV_EXPORT PFFASTCONV_Setup * pffastconv_new_setup( const float * filterCoeffs, int filterLen, int * blockLen, int flags ); - void pffastconv_destroy_setup(PFFASTCONV_Setup *); + PFFASTCONV_EXPORT void pffastconv_destroy_setup(PFFASTCONV_Setup *); /* Perform the fast convolution. @@ -155,13 +171,13 @@ extern "C" { input[]. */ - int pffastconv_apply(PFFASTCONV_Setup * s, const float *input, int inputLen, float *output, int applyFlush); + PFFASTCONV_EXPORT int pffastconv_apply(PFFASTCONV_Setup * s, const float *input, int inputLen, float *output, int applyFlush); - void *pffastconv_malloc(size_t nb_bytes); - void pffastconv_free(void *); + PFFASTCONV_EXPORT void *pffastconv_malloc(size_t nb_bytes); + PFFASTCONV_EXPORT void pffastconv_free(void *); /* return 4 or 1 wether support SSE/Altivec instructions was enabled when building pffft.c */ - int pffastconv_simd_size(); + PFFASTCONV_EXPORT int pffastconv_simd_size(); #ifdef __cplusplus diff --git a/pffft.h b/include/pffft/pffft.h similarity index 81% rename from pffft.h rename to include/pffft/pffft.h index 0fe0049..c332eab 100644 --- a/pffft.h +++ b/include/pffft/pffft.h @@ -79,13 +79,29 @@ #include /* for size_t */ +#ifndef PFFFT_EXPORT + #ifdef PFFFT_STATIC_DEFINE + #define PFFFT_EXPORT + #elif defined(_WIN32) || defined(__CYGWIN__) + #ifdef PFFFT_EXPORTS + #define PFFFT_EXPORT __declspec(dllexport) + #else + #define PFFFT_EXPORT __declspec(dllimport) + #endif + #elif defined(PFFFT_EXPORTS) && (defined(__GNUC__) || defined(__clang__)) + #define PFFFT_EXPORT __attribute__((visibility("default"))) + #else + #define PFFFT_EXPORT + #endif +#endif + #ifdef __cplusplus extern "C" { #endif /* opaque struct holding internal stuff (precomputed twiddle factors) this struct can be shared by many threads as it contains only - read-only data. + read-only data. */ typedef struct PFFFT_Setup PFFFT_Setup; @@ -105,8 +121,8 @@ extern "C" { PFFFT_Setup structure is read-only so it can safely be shared by multiple concurrent threads. */ - PFFFT_Setup *pffft_new_setup(int N, pffft_transform_t transform); - void pffft_destroy_setup(PFFFT_Setup *); + PFFFT_EXPORT PFFFT_Setup *pffft_new_setup(int N, pffft_transform_t transform); + PFFFT_EXPORT void pffft_destroy_setup(PFFFT_Setup *); /* Perform a Fourier transform , The z-domain data is stored in the most efficient order for transforming it back, or using it for @@ -140,7 +156,7 @@ extern "C" { input and output may alias. */ - void pffft_transform(PFFFT_Setup *setup, const float *input, float *output, float *work, pffft_direction_t direction); + PFFFT_EXPORT void pffft_transform(PFFFT_Setup *setup, const float *input, float *output, float *work, pffft_direction_t direction); /* Similar to pffft_transform, but makes sure that the output is @@ -149,7 +165,7 @@ extern "C" { input and output may alias. */ - void pffft_transform_ordered(PFFFT_Setup *setup, const float *input, float *output, float *work, pffft_direction_t direction); + PFFFT_EXPORT void pffft_transform_ordered(PFFFT_Setup *setup, const float *input, float *output, float *work, pffft_direction_t direction); /* call pffft_zreorder(.., PFFFT_FORWARD) after pffft_transform(..., @@ -163,7 +179,7 @@ extern "C" { input and output should not alias. */ - void pffft_zreorder(PFFFT_Setup *setup, const float *input, float *output, pffft_direction_t direction); + PFFFT_EXPORT void pffft_zreorder(PFFFT_Setup *setup, const float *input, float *output, pffft_direction_t direction); /* Perform a multiplication of the frequency components of dft_a and @@ -177,7 +193,7 @@ extern "C" { The dft_a, dft_b and dft_ab pointers may alias. */ - void pffft_zconvolve_accumulate(PFFFT_Setup *setup, const float *dft_a, const float *dft_b, float *dft_ab, float scaling); + PFFFT_EXPORT void pffft_zconvolve_accumulate(PFFFT_Setup *setup, const float *dft_a, const float *dft_b, float *dft_ab, float scaling); /* Perform a multiplication of the frequency components of dft_a and @@ -191,47 +207,47 @@ extern "C" { The dft_a, dft_b and dft_ab pointers may alias. */ - void pffft_zconvolve_no_accu(PFFFT_Setup *setup, const float *dft_a, const float *dft_b, float *dft_ab, float scaling); + PFFFT_EXPORT void pffft_zconvolve_no_accu(PFFFT_Setup *setup, const float *dft_a, const float *dft_b, float *dft_ab, float scaling); /* return 4 or 1 wether support SSE/NEON/Altivec instructions was enabled when building pffft.c */ - int pffft_simd_size(void); + PFFFT_EXPORT int pffft_simd_size(void); /* return string identifier of used architecture (SSE/NEON/Altivec/..) */ - const char * pffft_simd_arch(void); + PFFFT_EXPORT const char * pffft_simd_arch(void); /* following functions are identical to the pffftd_ functions */ /* simple helper to get minimum possible fft size */ - int pffft_min_fft_size(pffft_transform_t transform); + PFFFT_EXPORT int pffft_min_fft_size(pffft_transform_t transform); /* simple helper to determine next power of 2 - without inexact/rounding floating point operations */ - int pffft_next_power_of_two(int N); + PFFFT_EXPORT int pffft_next_power_of_two(int N); /* simple helper to determine if power of 2 - returns bool */ - int pffft_is_power_of_two(int N); + PFFFT_EXPORT int pffft_is_power_of_two(int N); /* simple helper to determine size N is valid - factorizable to pffft_min_fft_size() with factors 2, 3, 5 returns bool */ - int pffft_is_valid_size(int N, pffft_transform_t cplx); + PFFFT_EXPORT int pffft_is_valid_size(int N, pffft_transform_t cplx); /* determine nearest valid transform size (by brute-force testing) - factorizable to pffft_min_fft_size() with factors 2, 3, 5. higher: bool-flag to find nearest higher value; else lower. */ - int pffft_nearest_transform_size(int N, pffft_transform_t cplx, int higher); + PFFFT_EXPORT int pffft_nearest_transform_size(int N, pffft_transform_t cplx, int higher); /* the float buffers must have the correct alignment (16-byte boundary on intel and powerpc). This function may be used to obtain such - correctly aligned buffers. + correctly aligned buffers. */ - void *pffft_aligned_malloc(size_t nb_bytes); - void pffft_aligned_free(void *); + PFFFT_EXPORT void *pffft_aligned_malloc(size_t nb_bytes); + PFFFT_EXPORT void pffft_aligned_free(void *); #ifdef __cplusplus } diff --git a/pffft.hpp b/include/pffft/pffft.hpp similarity index 100% rename from pffft.hpp rename to include/pffft/pffft.hpp diff --git a/pffft_double.h b/include/pffft/pffft_double.h similarity index 79% rename from pffft_double.h rename to include/pffft/pffft_double.h index afa8de0..801225b 100644 --- a/pffft_double.h +++ b/include/pffft/pffft_double.h @@ -84,6 +84,22 @@ #include /* for size_t */ +#ifndef PFFFT_EXPORT + #ifdef PFFFT_STATIC_DEFINE + #define PFFFT_EXPORT + #elif defined(_WIN32) || defined(__CYGWIN__) + #ifdef PFFFT_EXPORTS + #define PFFFT_EXPORT __declspec(dllexport) + #else + #define PFFFT_EXPORT __declspec(dllimport) + #endif + #elif defined(PFFFT_EXPORTS) && (defined(__GNUC__) || defined(__clang__)) + #define PFFFT_EXPORT __attribute__((visibility("default"))) + #else + #define PFFFT_EXPORT + #endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -110,8 +126,8 @@ extern "C" { PFFFTD_Setup structure is read-only so it can safely be shared by multiple concurrent threads. */ - PFFFTD_Setup *pffftd_new_setup(int N, pffft_transform_t transform); - void pffftd_destroy_setup(PFFFTD_Setup *); + PFFFT_EXPORT PFFFTD_Setup *pffftd_new_setup(int N, pffft_transform_t transform); + PFFFT_EXPORT void pffftd_destroy_setup(PFFFTD_Setup *); /* Perform a Fourier transform , The z-domain data is stored in the most efficient order for transforming it back, or using it for @@ -132,7 +148,7 @@ extern "C" { input and output may alias. */ - void pffftd_transform(PFFFTD_Setup *setup, const double *input, double *output, double *work, pffft_direction_t direction); + PFFFT_EXPORT void pffftd_transform(PFFFTD_Setup *setup, const double *input, double *output, double *work, pffft_direction_t direction); /* Similar to pffft_transform, but makes sure that the output is @@ -141,7 +157,7 @@ extern "C" { input and output may alias. */ - void pffftd_transform_ordered(PFFFTD_Setup *setup, const double *input, double *output, double *work, pffft_direction_t direction); + PFFFT_EXPORT void pffftd_transform_ordered(PFFFTD_Setup *setup, const double *input, double *output, double *work, pffft_direction_t direction); /* call pffft_zreorder(.., PFFFT_FORWARD) after pffft_transform(..., @@ -155,7 +171,7 @@ extern "C" { input and output should not alias. */ - void pffftd_zreorder(PFFFTD_Setup *setup, const double *input, double *output, pffft_direction_t direction); + PFFFT_EXPORT void pffftd_zreorder(PFFFTD_Setup *setup, const double *input, double *output, pffft_direction_t direction); /* Perform a multiplication of the frequency components of dft_a and @@ -169,7 +185,7 @@ extern "C" { The dft_a, dft_b and dft_ab pointers may alias. */ - void pffftd_zconvolve_accumulate(PFFFTD_Setup *setup, const double *dft_a, const double *dft_b, double *dft_ab, double scaling); + PFFFT_EXPORT void pffftd_zconvolve_accumulate(PFFFTD_Setup *setup, const double *dft_a, const double *dft_b, double *dft_ab, double scaling); /* Perform a multiplication of the frequency components of dft_a and @@ -183,27 +199,27 @@ extern "C" { The dft_a, dft_b and dft_ab pointers may alias. */ - void pffftd_zconvolve_no_accu(PFFFTD_Setup *setup, const double *dft_a, const double *dft_b, double*dft_ab, double scaling); + PFFFT_EXPORT void pffftd_zconvolve_no_accu(PFFFTD_Setup *setup, const double *dft_a, const double *dft_b, double*dft_ab, double scaling); /* return 4 or 1 wether support AVX instructions was enabled when building pffft-double.c */ - int pffftd_simd_size(); + PFFFT_EXPORT int pffftd_simd_size(); /* return string identifier of used architecture (AVX/..) */ - const char * pffftd_simd_arch(); + PFFFT_EXPORT const char * pffftd_simd_arch(); /* simple helper to get minimum possible fft size */ - int pffftd_min_fft_size(pffft_transform_t transform); + PFFFT_EXPORT int pffftd_min_fft_size(pffft_transform_t transform); /* simple helper to determine size N is valid - factorizable to pffft_min_fft_size() with factors 2, 3, 5 */ - int pffftd_is_valid_size(int N, pffft_transform_t cplx); + PFFFT_EXPORT int pffftd_is_valid_size(int N, pffft_transform_t cplx); /* determine nearest valid transform size (by brute-force testing) - factorizable to pffft_min_fft_size() with factors 2, 3, 5. higher: bool-flag to find nearest higher value; else lower. */ - int pffftd_nearest_transform_size(int N, pffft_transform_t cplx, int higher); + PFFFT_EXPORT int pffftd_nearest_transform_size(int N, pffft_transform_t cplx, int higher); /* following functions are identical to the pffft_ functions - both declared */ @@ -211,22 +227,22 @@ extern "C" { /* simple helper to determine next power of 2 - without inexact/rounding floating point operations */ - int pffftd_next_power_of_two(int N); - int pffft_next_power_of_two(int N); + PFFFT_EXPORT int pffftd_next_power_of_two(int N); + PFFFT_EXPORT int pffft_next_power_of_two(int N); /* simple helper to determine if power of 2 - returns bool */ - int pffftd_is_power_of_two(int N); - int pffft_is_power_of_two(int N); + PFFFT_EXPORT int pffftd_is_power_of_two(int N); + PFFFT_EXPORT int pffft_is_power_of_two(int N); /* the double buffers must have the correct alignment (32-byte boundary on intel and powerpc). This function may be used to obtain such - correctly aligned buffers. + correctly aligned buffers. */ - void *pffftd_aligned_malloc(size_t nb_bytes); - void *pffft_aligned_malloc(size_t nb_bytes); - void pffftd_aligned_free(void *); - void pffft_aligned_free(void *); + PFFFT_EXPORT void *pffftd_aligned_malloc(size_t nb_bytes); + PFFFT_EXPORT void *pffft_aligned_malloc(size_t nb_bytes); + PFFFT_EXPORT void pffftd_aligned_free(void *); + PFFFT_EXPORT void pffft_aligned_free(void *); #ifdef __cplusplus } diff --git a/fftpack.c b/src/fftpack.c similarity index 100% rename from fftpack.c rename to src/fftpack.c diff --git a/fftpack.h b/src/fftpack.h similarity index 100% rename from fftpack.h rename to src/fftpack.h diff --git a/fmv.h b/src/fmv.h similarity index 100% rename from fmv.h rename to src/fmv.h diff --git a/pf_carrier.cpp b/src/pf_carrier.cpp similarity index 100% rename from pf_carrier.cpp rename to src/pf_carrier.cpp diff --git a/pf_cic.cpp b/src/pf_cic.cpp similarity index 100% rename from pf_cic.cpp rename to src/pf_cic.cpp diff --git a/pf_mixer.cpp b/src/pf_mixer.cpp similarity index 100% rename from pf_mixer.cpp rename to src/pf_mixer.cpp diff --git a/pffastconv.c b/src/pffastconv.c similarity index 100% rename from pffastconv.c rename to src/pffastconv.c diff --git a/pffft.c b/src/pffft.c similarity index 100% rename from pffft.c rename to src/pffft.c diff --git a/pffft_common.c b/src/pffft_common.c similarity index 64% rename from pffft_common.c rename to src/pffft_common.c index 8624ca1..955889f 100644 --- a/pffft_common.c +++ b/src/pffft_common.c @@ -44,12 +44,12 @@ static int is_power_of_two(int N) { -void *pffft_aligned_malloc(size_t nb_bytes) { return Valigned_malloc(nb_bytes); } -void pffft_aligned_free(void *p) { Valigned_free(p); } -int pffft_next_power_of_two(int N) { return next_power_of_two(N); } -int pffft_is_power_of_two(int N) { return is_power_of_two(N); } - -void *pffftd_aligned_malloc(size_t nb_bytes) { return Valigned_malloc(nb_bytes); } -void pffftd_aligned_free(void *p) { Valigned_free(p); } -int pffftd_next_power_of_two(int N) { return next_power_of_two(N); } -int pffftd_is_power_of_two(int N) { return is_power_of_two(N); } +PFFFT_EXPORT void *pffft_aligned_malloc(size_t nb_bytes) { return Valigned_malloc(nb_bytes); } +PFFFT_EXPORT void pffft_aligned_free(void *p) { Valigned_free(p); } +PFFFT_EXPORT int pffft_next_power_of_two(int N) { return next_power_of_two(N); } +PFFFT_EXPORT int pffft_is_power_of_two(int N) { return is_power_of_two(N); } + +PFFFT_EXPORT void *pffftd_aligned_malloc(size_t nb_bytes) { return Valigned_malloc(nb_bytes); } +PFFFT_EXPORT void pffftd_aligned_free(void *p) { Valigned_free(p); } +PFFFT_EXPORT int pffftd_next_power_of_two(int N) { return next_power_of_two(N); } +PFFFT_EXPORT int pffftd_is_power_of_two(int N) { return is_power_of_two(N); } diff --git a/pffft_double.c b/src/pffft_double.c similarity index 100% rename from pffft_double.c rename to src/pffft_double.c diff --git a/pffft_priv_impl.h b/src/pffft_priv_impl.h similarity index 99% rename from pffft_priv_impl.h rename to src/pffft_priv_impl.h index 6315a7a..cc88ba8 100644 --- a/pffft_priv_impl.h +++ b/src/pffft_priv_impl.h @@ -1819,7 +1819,7 @@ void FUNC_TRANSFORM_ORDERED(SETUP_STRUCT *setup, const float *input, float *outp #define assertv4(v,f0,f1,f2,f3) assert(v.f[0] == (f0) && v.f[1] == (f1) && v.f[2] == (f2) && v.f[3] == (f3)) /* detect bugs with the vector support macros */ -void FUNC_VALIDATE_SIMD_A(void) { +PFFFT_EXPORT void FUNC_VALIDATE_SIMD_A(void) { float f[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }; v4sf_union a0, a1, a2, a3, t, u; memcpy(a0.f, f, 4*sizeof(float)); @@ -1878,7 +1878,7 @@ static void pffft_assert4( vsfscalar v0, vsfscalar v1, vsfscalar v2, vsfscalar #define PFFFT_ASSERT4( V, a, b, c, d, FUNCTXT ) pffft_assert4( (V).f[0], (V).f[1], (V).f[2], (V).f[3], a, b, c, d, FUNCTXT, &numErrs, __FILE__, __LINE__ ) -int FUNC_VALIDATE_SIMD_EX(FILE * DbgOut) +PFFFT_EXPORT int FUNC_VALIDATE_SIMD_EX(FILE * DbgOut) { int numErrs = 0; @@ -2218,11 +2218,11 @@ int FUNC_VALIDATE_SIMD_EX(FILE * DbgOut) #else /* if ( SIMD_SZ == 4 ) */ -void FUNC_VALIDATE_SIMD_A() +PFFFT_EXPORT void FUNC_VALIDATE_SIMD_A() { } -int FUNC_VALIDATE_SIMD_EX(FILE * DbgOut) +PFFFT_EXPORT int FUNC_VALIDATE_SIMD_EX(FILE * DbgOut) { return -1; } diff --git a/simd/pf_altivec_float.h b/src/simd/pf_altivec_float.h similarity index 100% rename from simd/pf_altivec_float.h rename to src/simd/pf_altivec_float.h diff --git a/simd/pf_avx_double.h b/src/simd/pf_avx_double.h similarity index 100% rename from simd/pf_avx_double.h rename to src/simd/pf_avx_double.h diff --git a/simd/pf_double.h b/src/simd/pf_double.h similarity index 100% rename from simd/pf_double.h rename to src/simd/pf_double.h diff --git a/simd/pf_float.h b/src/simd/pf_float.h similarity index 100% rename from simd/pf_float.h rename to src/simd/pf_float.h diff --git a/simd/pf_neon_double.h b/src/simd/pf_neon_double.h similarity index 100% rename from simd/pf_neon_double.h rename to src/simd/pf_neon_double.h diff --git a/simd/pf_neon_double_from_avx.h b/src/simd/pf_neon_double_from_avx.h similarity index 100% rename from simd/pf_neon_double_from_avx.h rename to src/simd/pf_neon_double_from_avx.h diff --git a/simd/pf_neon_float.h b/src/simd/pf_neon_float.h similarity index 100% rename from simd/pf_neon_float.h rename to src/simd/pf_neon_float.h diff --git a/simd/pf_scalar_double.h b/src/simd/pf_scalar_double.h similarity index 100% rename from simd/pf_scalar_double.h rename to src/simd/pf_scalar_double.h diff --git a/simd/pf_scalar_float.h b/src/simd/pf_scalar_float.h similarity index 100% rename from simd/pf_scalar_float.h rename to src/simd/pf_scalar_float.h diff --git a/simd/pf_sse1_float.h b/src/simd/pf_sse1_float.h similarity index 100% rename from simd/pf_sse1_float.h rename to src/simd/pf_sse1_float.h diff --git a/simd/pf_sse2_double.h b/src/simd/pf_sse2_double.h similarity index 100% rename from simd/pf_sse2_double.h rename to src/simd/pf_sse2_double.h diff --git a/sse2neon.h b/src/sse2neon.h similarity index 100% rename from sse2neon.h rename to src/sse2neon.h diff --git a/test_fftpack_float b/test_fftpack_float deleted file mode 100755 index e62cfda..0000000 Binary files a/test_fftpack_float and /dev/null differ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0a3a087..9771ca7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1,9 @@ if (PFFFT_USE_FFTPACK) - add_executable(test_fftpack_float ${PFFFT_SOURCE_DIR}/fftpack.c ${PFFFT_SOURCE_DIR}/fftpack.h) + add_executable(test_fftpack_float ${PFFFT_SOURCE_DIR}/src/fftpack.c ${PFFFT_SOURCE_DIR}/src/fftpack.h) target_compile_definitions(test_fftpack_float PRIVATE _USE_MATH_DEFINES TESTING_FFTPACK) target_link_libraries(test_fftpack_float ${MATHLIB}) - add_executable(test_fftpack_double ${PFFFT_SOURCE_DIR}/fftpack.c ${PFFFT_SOURCE_DIR}/fftpack.h) + add_executable(test_fftpack_double ${PFFFT_SOURCE_DIR}/src/fftpack.c ${PFFFT_SOURCE_DIR}/src/fftpack.h) target_compile_definitions(test_fftpack_double PRIVATE _USE_MATH_DEFINES FFTPACK_DOUBLE_PRECISION TESTING_FFTPACK) target_link_libraries(test_fftpack_double ${MATHLIB}) endif() @@ -78,6 +78,7 @@ if (PFFFT_USE_TYPE_FLOAT) if (NOT PFFFT_USE_SIMD) target_compile_definitions(test_pffastconv PRIVATE PFFFT_SIMD_DISABLE=1) endif() + target_include_directories(test_pffastconv PRIVATE ${PFFFT_SOURCE_DIR}/src) target_link_libraries( test_pffastconv PFFASTCONV ${ASANLIB} ${MATHLIB} ) endif() diff --git a/tests/test_fft_factors.c b/tests/test_fft_factors.c index cefb2cc..8fe4a0f 100644 --- a/tests/test_fft_factors.c +++ b/tests/test_fft_factors.c @@ -1,11 +1,11 @@ #ifdef PFFFT_ENABLE_FLOAT -#include "pffft.h" +#include "pffft/pffft.h" #endif #ifdef PFFFT_ENABLE_DOUBLE -#include "pffft_double.h" +#include "pffft/pffft_double.h" #endif #include diff --git a/tests/test_pffastconv.c b/tests/test_pffastconv.c index 4fdd94d..fb6b393 100644 --- a/tests/test_pffastconv.c +++ b/tests/test_pffastconv.c @@ -5,8 +5,8 @@ #define _WANT_SNAN 1 -#include "pffft.h" -#include "pffastconv.h" +#include "pffft/pffft.h" +#include "pffft/pffastconv.h" #include #include diff --git a/tests/test_pffft.c b/tests/test_pffft.c index a86bdb4..6be85d5 100644 --- a/tests/test_pffft.c +++ b/tests/test_pffft.c @@ -25,14 +25,14 @@ */ #ifdef PFFFT_ENABLE_FLOAT -#include "pffft.h" +#include "pffft/pffft.h" typedef float pffft_scalar; #else /* Note: adapted for double precision dynamic range version. */ -#include "pffft_double.h" +#include "pffft/pffft_double.h" typedef double pffft_scalar; #endif diff --git a/tests/test_pffft.cpp b/tests/test_pffft.cpp index d388563..56d52a5 100644 --- a/tests/test_pffft.cpp +++ b/tests/test_pffft.cpp @@ -32,7 +32,7 @@ */ -#include "pffft.hpp" +#include "pffft/pffft.hpp" #include #include