This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 554
Collapse All | Expand All

(-)a/Eigen/src/Core/util/Memory.h (-5 / +12 lines)
Lines 53-72 Link Here
53
 || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED
53
 || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED
54
  #define EIGEN_MALLOC_ALREADY_ALIGNED 1
54
  #define EIGEN_MALLOC_ALREADY_ALIGNED 1
55
#else
55
#else
56
  #define EIGEN_MALLOC_ALREADY_ALIGNED 0
56
  #define EIGEN_MALLOC_ALREADY_ALIGNED 0
57
#endif
57
#endif
58
58
59
#endif
59
#endif
60
60
61
#if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) \
61
// See bug 554 (http://eigen.tuxfamily.org/bz/show_bug.cgi?id=554)
62
 && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
62
// It seems to be unsafe to check _POSIX_ADVISORY_INFO without including unistd.h first.
63
  #define EIGEN_HAS_POSIX_MEMALIGN 1
63
// Currently, let's include it only on unix systems:
64
#else
64
#ifdef __unix___
65
  #include <unistd.h>
66
  #if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
67
    #define EIGEN_HAS_POSIX_MEMALIGN 1
68
  #endif
69
#endif
70
71
#ifndef EIGEN_HAS_POSIX_MEMALIGN
65
  #define EIGEN_HAS_POSIX_MEMALIGN 0
72
  #define EIGEN_HAS_POSIX_MEMALIGN 0
66
#endif
73
#endif
67
74
68
#ifdef EIGEN_VECTORIZE_SSE
75
#ifdef EIGEN_VECTORIZE_SSE
69
  #define EIGEN_HAS_MM_MALLOC 1
76
  #define EIGEN_HAS_MM_MALLOC 1
70
#else
77
#else
71
  #define EIGEN_HAS_MM_MALLOC 0
78
  #define EIGEN_HAS_MM_MALLOC 0
72
#endif
79
#endif
Lines 210-226 inline void* aligned_malloc(size_t size) Link Here
210
  #if !EIGEN_ALIGN
217
  #if !EIGEN_ALIGN
211
    result = std::malloc(size);
218
    result = std::malloc(size);
212
  #elif EIGEN_MALLOC_ALREADY_ALIGNED
219
  #elif EIGEN_MALLOC_ALREADY_ALIGNED
213
    result = std::malloc(size);
220
    result = std::malloc(size);
214
  #elif EIGEN_HAS_POSIX_MEMALIGN
221
  #elif EIGEN_HAS_POSIX_MEMALIGN
215
    if(posix_memalign(&result, 16, size)) result = 0;
222
    if(posix_memalign(&result, 16, size)) result = 0;
216
  #elif EIGEN_HAS_MM_MALLOC
223
  #elif EIGEN_HAS_MM_MALLOC
217
    result = _mm_malloc(size, 16);
224
    result = _mm_malloc(size, 16);
218
#elif defined(_MSC_VER) && (!defined(_WIN32_WCE))
225
  #elif defined(_MSC_VER) && (!defined(_WIN32_WCE))
219
    result = _aligned_malloc(size, 16);
226
    result = _aligned_malloc(size, 16);
220
  #else
227
  #else
221
    result = handmade_aligned_malloc(size);
228
    result = handmade_aligned_malloc(size);
222
  #endif
229
  #endif
223
230
224
  if(!result && size)
231
  if(!result && size)
225
    throw_std_bad_alloc();
232
    throw_std_bad_alloc();
226
233

Return to bug 554