From de18cd413d27eca1fea9818349543e390f577cc1 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 24 Apr 2015 11:26:51 +0200 Subject: [PATCH] Disable posix_memalign on Solaris and SunOS, and allows to by-pass built-in posix_memalign detection rules. --- Eigen/src/Core/util/Macros.h | 13 +++++++++++++ Eigen/src/Core/util/Memory.h | 24 +++++++++++++----------- doc/PreprocessorDirectives.dox | 3 +++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index e01f09373..aaa4dcbd4 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -283,6 +283,19 @@ #define EIGEN_OS_WIN_STRICT 0 #endif +/// \internal EIGEN_OS_SUN set to 1 if the OS is SUN +#if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__)) + #define EIGEN_OS_SUN 1 +#else + #define EIGEN_OS_SUN 0 +#endif + +/// \internal EIGEN_OS_SOLARIS set to 1 if the OS is Solaris +#if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)) + #define EIGEN_OS_SOLARIS 1 +#else + #define EIGEN_OS_SOLARIS 0 +#endif diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 16f8cc1b0..62f329984 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -59,18 +59,20 @@ #endif -// See bug 554 (http://eigen.tuxfamily.org/bz/show_bug.cgi?id=554) -// It seems to be unsafe to check _POSIX_ADVISORY_INFO without including unistd.h first. -// Currently, let's include it only on unix systems: -#if EIGEN_OS_UNIX - #include - #if (EIGEN_OS_QNX || (defined _GNU_SOURCE) || EIGEN_COMP_PGI || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0) - #define EIGEN_HAS_POSIX_MEMALIGN 1 - #endif -#endif - #ifndef EIGEN_HAS_POSIX_MEMALIGN - #define EIGEN_HAS_POSIX_MEMALIGN 0 + // See bug 554 (http://eigen.tuxfamily.org/bz/show_bug.cgi?id=554) + // It seems to be unsafe to check _POSIX_ADVISORY_INFO without including unistd.h first. + // Currently, let's include it only on unix systems: + #if EIGEN_OS_UNIX && !(EIGEN_OS_SUN || EIGEN_OS_SOLARIS) + #include + #if (EIGEN_OS_QNX || (defined _GNU_SOURCE) || EIGEN_COMP_PGI || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0) + #define EIGEN_HAS_POSIX_MEMALIGN 1 + #endif + #endif + + #ifndef EIGEN_HAS_POSIX_MEMALIGN + #define EIGEN_HAS_POSIX_MEMALIGN 0 + #endif #endif #if defined EIGEN_VECTORIZE_SSE || defined EIGEN_VECTORIZE_AVX diff --git a/doc/PreprocessorDirectives.dox b/doc/PreprocessorDirectives.dox index 4be2167ef..6ffa2fc26 100644 --- a/doc/PreprocessorDirectives.dox +++ b/doc/PreprocessorDirectives.dox @@ -87,6 +87,9 @@ run time. However, these assertions do cost time and can thus be turned off. - \b EIGEN_STACK_ALLOCATION_LIMIT - defines the maximum bytes for a buffer to be allocated on the stack. For internal temporary buffers, dynamic memory allocation is employed as a fall back. For fixed-size matrices or arrays, exceeding this threshold raises a compile time assertion. Use 0 to set no limit. Default is 128 KB. + - \b EIGEN_HAS_POSIX_MEMALIGN - defines whether aligned memory allocation can be performed through the \c posix_memalign + function. The availability of \c posix_memalign is automatically checked on most platform, but this option allows to + by-pass %Eigen's built-in rules. \section TopicPreprocessorDirectivesPlugins Plugins