Skip to content

Commit a5741ed

Browse files
authored
Merge branch 'master' into version
2 parents ce0946e + 6d4d797 commit a5741ed

6 files changed

Lines changed: 53 additions & 6 deletions

File tree

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ matrix:
5151
- g++-7
5252
- libfftw3-dev
5353
env: COMPILER=gcc GCC=7
54+
- os: linux
55+
addons:
56+
apt:
57+
sources:
58+
- ubuntu-toolchain-r-test
59+
packages:
60+
- g++-7
61+
- libfftw3-dev
62+
env: COMPILER=gcc GCC=7 DISABLE_EXCEPTION=1
5463
- os: linux
5564
addons:
5665
apt:

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ OPTION(BENCHMARK_ENABLE_TESTING "Build tests for Google Benchmark" OFF)
4545
OPTION(FIX_RPATH "Correctly set rpath for the linker" OFF)
4646
OPTION(DEFAULT_COLUMN_MAJOR "Set xtensor default layout to column major. This is currently not supported, since FFTW demands row major layout." OFF)
4747
OPTION(COVERAGE "Enable coverage compile flags (gcc only!)" OFF)
48+
OPTION(DISABLE_EXCEPTIONS "Disable C++ exceptions" OFF)
4849

4950
if (COVERAGE)
5051
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU")

include/xtensor-fftw/basic.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#include <fftw3.h>
3434

35+
#include "xtensor-fftw_config.hpp"
36+
3537
#ifdef __CLING__
3638
#pragma cling load("fftw3")
3739
#endif
@@ -386,7 +388,8 @@ namespace xt {
386388

387389
auto plan = fftw_plan_dft_caller<dim, fftw_direction, fftw_123dim, input_t, output_t, fftw_plan_dft, half_plus_one_out, half_plus_one_in>(input, output, FFTW_ESTIMATE, odd_last_dim);
388390
if (plan == nullptr) {
389-
throw std::runtime_error("Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
391+
XTENSOR_FFTW_THROW(std::runtime_error,
392+
"Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
390393
}
391394

392395
fftw_execute(plan);
@@ -414,7 +417,8 @@ namespace xt {
414417

415418
auto plan = fftw_plan_dft_caller<dim, fftw_direction, fftw_123dim, input_t, output_t, fftw_plan_dft, half_plus_one_out, half_plus_one_in>(input, output, FFTW_ESTIMATE, odd_last_dim);
416419
if (plan == nullptr) {
417-
throw std::runtime_error("Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
420+
XTENSOR_FFTW_THROW(std::runtime_error,
421+
"Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
418422
}
419423

420424
fftw_execute(plan);
@@ -446,7 +450,8 @@ namespace xt {
446450

447451
auto plan = fftw_plan_dft_caller<dim, fftw_direction, fftw_123dim, input_t, output_t, fftw_plan_dft, half_plus_one_out, half_plus_one_in>(input_conj, output, FFTW_ESTIMATE);
448452
if (plan == nullptr) {
449-
throw std::runtime_error("Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
453+
XTENSOR_FFTW_THROW(std::runtime_error,
454+
"Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
450455
}
451456

452457
fftw_execute(plan);
@@ -474,7 +479,8 @@ namespace xt {
474479

475480
auto plan = fftw_plan_dft_caller<dim, fftw_direction, fftw_123dim, input_t, output_t, fftw_plan_dft, half_plus_one_out, half_plus_one_in>(input, output, FFTW_ESTIMATE);
476481
if (plan == nullptr) {
477-
throw std::runtime_error("Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
482+
XTENSOR_FFTW_THROW(std::runtime_error,
483+
"Plan creation returned nullptr. This usually means FFTW cannot create a plan for the given arguments (e.g. a non-destructive multi-dimensional real FFT is impossible in FFTW).");
478484
}
479485

480486
fftw_execute(plan);

include/xtensor-fftw/xtensor-fftw_config.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,22 @@
1313
#define XTENSOR_FFTW_VERSION_MINOR 2
1414
#define XTENSOR_FFTW_VERSION_PATCH 5
1515

16+
// Define if the library is going to be using exceptions.
17+
#if (!defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND))
18+
#undef XTENSOR_FFTW_DISABLE_EXCEPTIONS
19+
#define XTENSOR_FFTW_DISABLE_EXCEPTIONS
20+
#endif
21+
22+
// Exception support.
23+
#if defined(XTENSOR_FFTW_DISABLE_EXCEPTIONS)
24+
#include <iostream>
25+
#define XTENSOR_FFTW_THROW(_, msg) \
26+
{ \
27+
std::cerr << msg << std::endl; \
28+
std::abort(); \
29+
}
30+
#else
31+
#define XTENSOR_FFTW_THROW(exception, msg) throw exception(msg)
32+
#endif
33+
1634
#endif //XTENSOR_FFTW_CONFIG_HPP

test/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,25 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
3333

3434
set(CMAKE_CXX_STANDARD 14)
3535

36+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT WIN32))
37+
if (DISABLE_EXCEPTIONS)
38+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
39+
endif()
40+
endif()
41+
3642
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3743
add_compile_options(-ftemplate-backtrace-limit=0)
44+
if (DISABLE_EXCEPTIONS)
45+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
46+
endif()
3847
endif()
3948

4049
if(MSVC)
41-
add_compile_options(/EHsc /MP /bigobj)
50+
if (DISABLE_EXCEPTIONS)
51+
add_compile_options(/EHs-c- /MP /bigobj)
52+
else()
53+
add_compile_options(/EHsc /MP /bigobj)
54+
endif()
4255
set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO)
4356
foreach(flag_var
4457
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE

test/basic_interface_fft.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ TYPED_TEST(TransformAndInvert_FFT, FFT_4D_xtensor) {
106106
assert_results_complex(a, a_fourier, should_be_a);
107107
}
108108
109-
*/
109+
*/

0 commit comments

Comments
 (0)