From d4ca70b6379bf90913587db0408a16842cf6bf33 Mon Sep 17 00:00:00 2001 From: Bradley Lowekamp Date: Thu, 11 Jan 2018 10:43:12 -0500 Subject: [PATCH] ENH: update C+11 headers and try compile for headers The try compiles for "stddef.h" and "sys/types.h" are not used in ITK so they were removed. The try compile for stdint.h has been removed for the expected C+11 standard cstdint. fenv.h remains used in itkFloatingPointExceptions.cxx because the usage is low level and system specific as opposed to complying with a standard usage. Change-Id: I9e176ae02de2eb9c7ec59bcb66ed884f16c61dab --- Modules/Core/Common/CMakeLists.txt | 5 -- Modules/Core/Common/include/itkIntTypes.h | 58 +-------------------- Modules/Core/Common/include/itkMathDetail.h | 31 +++++------ Modules/Core/Common/src/itkConfigure.h.in | 9 ---- 4 files changed, 14 insertions(+), 89 deletions(-) diff --git a/Modules/Core/Common/CMakeLists.txt b/Modules/Core/Common/CMakeLists.txt index b1105580f64..80db892d7f5 100644 --- a/Modules/Core/Common/CMakeLists.txt +++ b/Modules/Core/Common/CMakeLists.txt @@ -34,11 +34,6 @@ include(CheckIncludeFiles) check_include_files(fenv.h HAVE_FENV_H) # check if the platform has some widely used header files check_include_files("unistd.h" HAVE_UNISTD_H) -# check if the platform has the header file "stdint.h" which has been added as part of the C99 standard -check_include_files("stdint.h" HAVE_STDINT_H) -# every system should have this header -check_include_files("stddef.h" HAVE_STDDEF_H) -check_include_files("sys/types.h" HAVE_SYS_TYPES_H) # Check if this platform support the sse2 rounding functions for 32 and 64 bits diff --git a/Modules/Core/Common/include/itkIntTypes.h b/Modules/Core/Common/include/itkIntTypes.h index bebcd90b654..ad91afe8e4c 100644 --- a/Modules/Core/Common/include/itkIntTypes.h +++ b/Modules/Core/Common/include/itkIntTypes.h @@ -20,25 +20,11 @@ #include "itkMacro.h" -#if defined( ITK_HAVE_STDINT_H ) -#include -#else -// the system doesn't have the C or C++ version of stdint so lets use -// KWIML's macros for fixed widths -#include "itk_kwiml.h" - -#ifdef ITK_HAVE_STDDEF_H -#include -#endif //ITK_HAVE_STDDEF_H - -#endif // ITK_HAVE_CSTDINT - +#include #include namespace itk { -#if defined( ITK_HAVE_STDINT_H ) - // Note: these types are technically optional in C99 stdint.h file. As // such a try complile for their existence may be needed. typedef::int8_t int8_t; @@ -76,48 +62,6 @@ typedef::uintmax_t uintmax_t; typedef::intptr_t intptr_t; typedef::uintptr_t uintptr_t; -#else // ITK_HAVE_STDINT_H - -/** Fixed width integer types. */ -typedef KWIML_INT_int8_t int8_t; -typedef KWIML_INT_uint8_t uint8_t; -typedef KWIML_INT_int16_t int16_t; -typedef KWIML_INT_uint16_t uint16_t; -typedef KWIML_INT_int32_t int32_t; -typedef KWIML_INT_uint32_t uint32_t; -typedef KWIML_INT_int64_t int64_t; -typedef KWIML_INT_uint64_t uint64_t; - -/** Types which are at least a certain size, these are preferred over - * fixed width. */ -typedef int8_t int_least8_t; -typedef uint8_t uint_least8_t; -typedef int16_t int_least16_t; -typedef uint16_t uint_least16_t; -typedef int32_t int_least32_t; -typedef uint32_t uint_least32_t; -typedef int64_t int_least64_t; -typedef uint64_t uint_least64_t; - -/** Types which are at least a certain size but may be greater if - * performace benefits, these are preferred over fixed width. */ -typedef int8_t int_fast8_t; -typedef uint8_t uint_fast8_t; -typedef int16_t int_fast16_t; -typedef uint16_t uint_fast16_t; -typedef int32_t int_fast32_t; -typedef uint32_t uint_fast32_t; -typedef int64_t int_fast64_t; -typedef uint64_t uint_fast64_t; - -/** Types which contain the largest represetable integer. */ -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - -typedef::ptrdiff_t intptr_t; -typedef::size_t uintptr_t; - -#endif // ITK_HAVE_STDINT_H #if defined(ITK_USE_64BITS_IDS) && ((ULLONG_MAX != ULONG_MAX) || (LLONG_MAX != LONG_MAX)) diff --git a/Modules/Core/Common/include/itkMathDetail.h b/Modules/Core/Common/include/itkMathDetail.h index 02292be07c7..8c604139712 100644 --- a/Modules/Core/Common/include/itkMathDetail.h +++ b/Modules/Core/Common/include/itkMathDetail.h @@ -31,12 +31,7 @@ #include "itkIntTypes.h" #include "itkNumericTraits.h" -#ifdef ITK_HAVE_FENV_H -// The Sun Studio CC compiler seems to have a bug where if cstdio is -// included stdio.h must also be included before fenv.h -#include -#include -#endif /* ITK_HAVE_FENV_H */ +#include #if defined( ITK_HAVE_EMMINTRIN_H ) && !defined( ITK_WRAPPING_PARSER ) #include // sse 2 intrinsics @@ -175,7 +170,7 @@ CLANG_PRAGMA_POP inline int32_t RoundHalfIntegerToEven_32(double x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif return _mm_cvtsd_si32( _mm_set_sd(x) ); @@ -183,7 +178,7 @@ inline int32_t RoundHalfIntegerToEven_32(double x) inline int32_t RoundHalfIntegerToEven_32(float x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif return _mm_cvtss_si32( _mm_set_ss(x) ); @@ -193,7 +188,7 @@ inline int32_t RoundHalfIntegerToEven_32(float x) inline int32_t RoundHalfIntegerToEven_32(double x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int32_t r; @@ -203,7 +198,7 @@ inline int32_t RoundHalfIntegerToEven_32(double x) inline int32_t RoundHalfIntegerToEven_32(float x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int32_t r; @@ -215,7 +210,7 @@ inline int32_t RoundHalfIntegerToEven_32(float x) inline int32_t RoundHalfIntegerToEven_32(double x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int32_t r; @@ -229,7 +224,7 @@ inline int32_t RoundHalfIntegerToEven_32(double x) inline int32_t RoundHalfIntegerToEven_32(float x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int32_t r; @@ -279,7 +274,7 @@ inline int32_t Ceil_32(float x) { return Ceil_base< int32_t, float >(x); } inline int64_t RoundHalfIntegerToEven_64(double x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif return _mm_cvtsd_si64( _mm_set_sd(x) ); @@ -287,7 +282,7 @@ inline int64_t RoundHalfIntegerToEven_64(double x) inline int64_t RoundHalfIntegerToEven_64(float x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif return _mm_cvtss_si64( _mm_set_ss(x) ); @@ -297,7 +292,7 @@ inline int64_t RoundHalfIntegerToEven_64(float x) inline int64_t RoundHalfIntegerToEven_64(double x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int64_t r; @@ -307,7 +302,7 @@ inline int64_t RoundHalfIntegerToEven_64(double x) inline int64_t RoundHalfIntegerToEven_64(float x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int64_t r; @@ -319,7 +314,7 @@ inline int64_t RoundHalfIntegerToEven_64(float x) inline int64_t RoundHalfIntegerToEven_64(double x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int64_t r; @@ -333,7 +328,7 @@ inline int64_t RoundHalfIntegerToEven_64(double x) inline int64_t RoundHalfIntegerToEven_64(float x) { - #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) && defined( HAVE_FENV_H ) + #if defined( ITK_CHECK_FPU_ROUNDING_MODE ) itkAssertInDebugAndIgnoreInReleaseMacro(fegetround() == FE_TONEAREST); #endif int64_t r; diff --git a/Modules/Core/Common/src/itkConfigure.h.in b/Modules/Core/Common/src/itkConfigure.h.in index a4c25298421..1e9c1bf9a66 100644 --- a/Modules/Core/Common/src/itkConfigure.h.in +++ b/Modules/Core/Common/src/itkConfigure.h.in @@ -147,15 +147,6 @@ #if ITK_CMAKEDEFINE_VAR_@HAVE_FENV_H@ # define ITK_HAVE_FENV_H #endif /* HAVE_FENV_H */ -#if ITK_CMAKEDEFINE_VAR_@HAVE_SYS_TYPES_H@ -# define ITK_HAVE_SYS_TYPES_H -#endif /* HAVE_SYS_TYPES_H */ -#if ITK_CMAKEDEFINE_VAR_@HAVE_STDINT_H@ -# define ITK_HAVE_STDINT_H -#endif /* HAVE_STDINT_H */ -#if ITK_CMAKEDEFINE_VAR_@HAVE_STDDEF_H@ -# define ITK_HAVE_STDDEF_H -#endif /* HAVE_STDDEF_H */ #if ITK_CMAKEDEFINE_VAR_@HAVE_UNISTD_H@ # define ITK_HAVE_UNISTD_H #endif /* HAVE_UNISTD_H */