aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/util
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-08-20 15:58:01 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-08-20 15:58:01 +0000
commitc501c7a4efb78a458c66c1333d52dde429c6e81e (patch)
treef7faa0de74b11551ea16cb8c508b64074fe0b71e /Eigen/src/Core/util
parent752ec27293827b5aebf15af54d808656c38f13bf (diff)
* Fix CMakeLists.txt issue with SVD
* Fix on stack memory allocation issues
Diffstat (limited to 'Eigen/src/Core/util')
-rw-r--r--Eigen/src/Core/util/Macros.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h
index c50aef9a6..1489a6be1 100644
--- a/Eigen/src/Core/util/Macros.h
+++ b/Eigen/src/Core/util/Macros.h
@@ -150,12 +150,16 @@ friend class Eigen::MatrixBase<Derived>;
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
#define EIGEN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
+/* ei_alloc_stack(TYPE,SIZE) allocates sizeof(TYPE)*SIZE bytes on the stack if sizeof(TYPE)*SIZE is smaller
+ * than EIGEN_STACK_ALLOCATION_LIMIT. Otherwise the memory is allocated using the operator new.
+ * Data allocated with ei_alloc_stack must be freed calling ei_free_stack(PTR,TYPE,SIZE)
+ */
#ifdef __linux__
-# define EIGEN_USE_ALLOCA 1
-# define ei_alloca_or_malloc(condition, size) (condition?alloca(size):malloc(size))
+# define ei_alloc_stack(TYPE,SIZE) ((sizeof(TYPE)*(SIZE)>16000000) ? new TYPE[SIZE] : (TYPE*)alloca(sizeof(TYPE)*(SIZE)))
+# define ei_free_stack(PTR,TYPE,SIZE) if (sizeof(TYPE)*SIZE>16000000) delete[] PTR
#else
-# define EIGEN_USE_ALLOCA 0
-# define ei_alloca_or_malloc(condition, size) malloc(size)
+# define ei_alloc_stack(TYPE,SIZE) new TYPE[SIZE]
+# define ei_free_stack(PTR,TYPE,SIZE) delete[] PTR
#endif
#endif // EIGEN_MACROS_H