diff --git a/Eigen/Core b/Eigen/Core index a2d66c6b8..e5bf2f207 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -15,7 +15,9 @@ #endif #endif -#ifdef __GNUC__ +// FIXME: this check should not be against __QNXNTO__, which is also defined +// while compiling with GCC for QNX target. Better solution is welcome! +#if defined(__GNUC__) && !defined(__QNXNTO__) #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x) #else #define EIGEN_GNUC_AT_LEAST(x,y) 0 diff --git a/Eigen/NewStdVector b/Eigen/NewStdVector index f37de5ff6..153f7bd5c 100644 --- a/Eigen/NewStdVector +++ b/Eigen/NewStdVector @@ -36,8 +36,8 @@ template class aligned_allocator_indirection : public aligned_allocator { public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; diff --git a/Eigen/src/Core/CacheFriendlyProduct.h b/Eigen/src/Core/CacheFriendlyProduct.h index b1362b0a8..40c6984dc 100644 --- a/Eigen/src/Core/CacheFriendlyProduct.h +++ b/Eigen/src/Core/CacheFriendlyProduct.h @@ -84,7 +84,7 @@ static void ei_cache_friendly_product( MaxL2BlockSize = ei_L2_block_traits::width }; - const bool resIsAligned = (PacketSize==1) || (((resStride%PacketSize) == 0) && (size_t(res)%16==0)); + const bool resIsAligned = (PacketSize==1) || (((resStride%PacketSize) == 0) && (std::size_t(res)%16==0)); const int remainingSize = depth % PacketSize; const int size = depth - remainingSize; // third dimension of the product clamped to packet boundaries @@ -92,7 +92,7 @@ static void ei_cache_friendly_product( const int l2BlockCols = MaxL2BlockSize > cols ? cols : MaxL2BlockSize; const int l2BlockSize = MaxL2BlockSize > size ? size : MaxL2BlockSize; const int l2BlockSizeAligned = (1 + std::max(l2BlockSize,l2BlockCols)/PacketSize)*PacketSize; - const bool needRhsCopy = (PacketSize>1) && ((rhsStride%PacketSize!=0) || (size_t(rhs)%16!=0)); + const bool needRhsCopy = (PacketSize>1) && ((rhsStride%PacketSize!=0) || (std::size_t(rhs)%16!=0)); Scalar* EIGEN_RESTRICT block = 0; const int allocBlockSize = l2BlockRows*size; block = ei_aligned_stack_new(Scalar, allocBlockSize); @@ -172,7 +172,7 @@ static void ei_cache_friendly_product( for(int l1j=l2j; l1j1) { - ei_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(Packet)==0 || size1) { - ei_internal_assert(size_t(lhs+lhsAlignmentOffset)%sizeof(Packet)==0 || sizealignedStart) { // process aligned rhs coeffs - if ((size_t(lhs0+alignedStart)%sizeof(Packet))==0) + if ((std::size_t(lhs0+alignedStart)%sizeof(Packet))==0) for (int j = alignedStart;j( (PacketSize - (Integer((size_t(array)/sizeof(Scalar))) & PacketAlignedMask)) + return std::min( (PacketSize - (Integer((std::size_t(array)/sizeof(Scalar))) & PacketAlignedMask)) & PacketAlignedMask, size); } } diff --git a/Eigen/src/Sparse/AmbiVector.h b/Eigen/src/Sparse/AmbiVector.h index f279e80f0..87398f5d5 100644 --- a/Eigen/src/Sparse/AmbiVector.h +++ b/Eigen/src/Sparse/AmbiVector.h @@ -98,7 +98,7 @@ template class AmbiVector int allocSize = m_allocatedElements * sizeof(ListEl); allocSize = allocSize/sizeof(Scalar) + (allocSize%sizeof(Scalar)>0?1:0); Scalar* newBuffer = new Scalar[allocSize]; - memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl)); + std::memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl)); delete[] m_buffer; m_buffer = newBuffer; } diff --git a/Eigen/src/Sparse/CompressedStorage.h b/Eigen/src/Sparse/CompressedStorage.h index 4dbd32309..fea55e1e2 100644 --- a/Eigen/src/Sparse/CompressedStorage.h +++ b/Eigen/src/Sparse/CompressedStorage.h @@ -37,7 +37,7 @@ class CompressedStorage : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) {} - CompressedStorage(size_t size) + CompressedStorage(std::size_t size) : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) { resize(size); @@ -52,8 +52,8 @@ class CompressedStorage CompressedStorage& operator=(const CompressedStorage& other) { resize(other.size()); - memcpy(m_values, other.m_values, m_size * sizeof(Scalar)); - memcpy(m_indices, other.m_indices, m_size * sizeof(int)); + std::memcpy(m_values, other.m_values, m_size * sizeof(Scalar)); + std::memcpy(m_indices, other.m_indices, m_size * sizeof(int)); return *this; } @@ -71,9 +71,9 @@ class CompressedStorage delete[] m_indices; } - void reserve(size_t size) + void reserve(std::size_t size) { - size_t newAllocatedSize = m_size + size; + std::size_t newAllocatedSize = m_size + size; if (newAllocatedSize > m_allocatedSize) reallocate(newAllocatedSize); } @@ -84,10 +84,10 @@ class CompressedStorage reallocate(m_size); } - void resize(size_t size, float reserveSizeFactor = 0) + void resize(std::size_t size, float reserveSizeFactor = 0) { if (m_allocatedSizestart) { - size_t mid = (end+start)>>1; + std::size_t mid = (end+start)>>1; if (m_indices[mid]=m_size || m_indices[id]!=key) { resize(m_size+1,1); - for (size_t j=m_size-1; j>id; --j) + for (std::size_t j=m_size-1; j>id; --j) { m_indices[j] = m_indices[j-1]; m_values[j] = m_values[j-1]; @@ -187,9 +187,9 @@ class CompressedStorage void prune(Scalar reference, RealScalar epsilon = precision()) { - size_t k = 0; - size_t n = size(); - for (size_t i=0; i=innerSize // TODO std::cerr << "not implemented yet\n"; - exit(2); + std::exit(2); } if (m_data.size() != outerSize) { diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index 65c609686..f61577fd8 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -122,7 +122,7 @@ class SparseMatrix { m_data.clear(); //if (m_outerSize) - memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int)); + std::memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int)); // for (int i=0; i check with valgrind for(int j = 0; j < i; j++) p[j]=0; ei_handmade_aligned_free(p); @@ -47,7 +47,7 @@ void check_aligned_malloc() for(int i = 1; i < 1000; i++) { char *p = (char*)ei_aligned_malloc(i); - VERIFY(size_t(p)%ALIGNMENT==0); + VERIFY(std::size_t(p)%ALIGNMENT==0); // if the buffer is wrongly allocated this will give a bad write --> check with valgrind for(int j = 0; j < i; j++) p[j]=0; ei_aligned_free(p); @@ -59,7 +59,7 @@ void check_aligned_new() for(int i = 1; i < 1000; i++) { float *p = ei_aligned_new(i); - VERIFY(size_t(p)%ALIGNMENT==0); + VERIFY(std::size_t(p)%ALIGNMENT==0); // if the buffer is wrongly allocated this will give a bad write --> check with valgrind for(int j = 0; j < i; j++) p[j]=0; ei_aligned_delete(p,i); @@ -71,7 +71,7 @@ void check_aligned_stack_alloc() for(int i = 1; i < 1000; i++) { float *p = ei_aligned_stack_new(float,i); - VERIFY(size_t(p)%ALIGNMENT==0); + VERIFY(std::size_t(p)%ALIGNMENT==0); // if the buffer is wrongly allocated this will give a bad write --> check with valgrind for(int j = 0; j < i; j++) p[j]=0; ei_aligned_stack_delete(float,p,i); @@ -98,7 +98,7 @@ class MyClassA template void check_dynaligned() { T* obj = new T; - VERIFY(size_t(obj)%ALIGNMENT==0); + VERIFY(std::size_t(obj)%ALIGNMENT==0); delete obj; } @@ -121,15 +121,15 @@ void test_dynalloc() // check static allocation, who knows ? { - MyStruct foo0; VERIFY(size_t(foo0.avec.data())%ALIGNMENT==0); - MyClassA fooA; VERIFY(size_t(fooA.avec.data())%ALIGNMENT==0); + MyStruct foo0; VERIFY(std::size_t(foo0.avec.data())%ALIGNMENT==0); + MyClassA fooA; VERIFY(std::size_t(fooA.avec.data())%ALIGNMENT==0); } // dynamic allocation, single object for (int i=0; iavec.data())%ALIGNMENT==0); - MyClassA *fooA = new MyClassA(); VERIFY(size_t(fooA->avec.data())%ALIGNMENT==0); + MyStruct *foo0 = new MyStruct(); VERIFY(std::size_t(foo0->avec.data())%ALIGNMENT==0); + MyClassA *fooA = new MyClassA(); VERIFY(std::size_t(fooA->avec.data())%ALIGNMENT==0); delete foo0; delete fooA; } @@ -138,8 +138,8 @@ void test_dynalloc() const int N = 10; for (int i=0; iavec.data())%ALIGNMENT==0); - MyClassA *fooA = new MyClassA[N]; VERIFY(size_t(fooA->avec.data())%ALIGNMENT==0); + MyStruct *foo0 = new MyStruct[N]; VERIFY(std::size_t(foo0->avec.data())%ALIGNMENT==0); + MyClassA *fooA = new MyClassA[N]; VERIFY(std::size_t(fooA->avec.data())%ALIGNMENT==0); delete[] foo0; delete[] fooA; } diff --git a/test/first_aligned.cpp b/test/first_aligned.cpp index c6631fb42..f630e42f9 100644 --- a/test/first_aligned.cpp +++ b/test/first_aligned.cpp @@ -28,7 +28,7 @@ template void test_first_aligned_helper(Scalar *array, int size) { const int packet_size = sizeof(Scalar) * ei_packet_traits::size; - VERIFY(((size_t(array) + sizeof(Scalar) * ei_alignmentOffset(array, size)) % packet_size) == 0); + VERIFY(((std::size_t(array) + sizeof(Scalar) * ei_alignmentOffset(array, size)) % packet_size) == 0); } template @@ -54,7 +54,7 @@ void test_first_aligned() test_first_aligned_helper(array_double+1, 50); test_first_aligned_helper(array_double+2, 50); - double *array_double_plus_4_bytes = (double*)(size_t(array_double)+4); + double *array_double_plus_4_bytes = (double*)(std::size_t(array_double)+4); test_none_aligned_helper(array_double_plus_4_bytes, 50); test_none_aligned_helper(array_double_plus_4_bytes+1, 50); diff --git a/test/main.h b/test/main.h index ec6724ffd..996e15895 100644 --- a/test/main.h +++ b/test/main.h @@ -142,7 +142,7 @@ namespace Eigen #define VERIFY(a) do { if (!(a)) { \ std::cerr << "Test " << g_test_stack.back() << " failed in "EI_PP_MAKE_STRING(__FILE__) << " (" << EI_PP_MAKE_STRING(__LINE__) << ")" \ << std::endl << " " << EI_PP_MAKE_STRING(a) << std::endl << std::endl; \ - exit(2); \ + std::exit(2); \ } } while (0) #define VERIFY_IS_APPROX(a, b) VERIFY(test_ei_isApprox(a, b)) @@ -257,7 +257,7 @@ int main(int argc, char *argv[]) std::cout << "Argument " << argv[i] << " conflicting with a former argument" << std::endl; return 1; } - repeat = atoi(argv[i]+1); + repeat = std::atoi(argv[i]+1); has_set_repeat = true; if(repeat <= 0) { @@ -272,7 +272,7 @@ int main(int argc, char *argv[]) std::cout << "Argument " << argv[i] << " conflicting with a former argument" << std::endl; return 1; } - seed = int(strtoul(argv[i]+1, 0, 10)); + seed = int(std::strtoul(argv[i]+1, 0, 10)); has_set_seed = true; bool ok = seed!=0; if(!ok) @@ -295,11 +295,11 @@ int main(int argc, char *argv[]) return 1; } - if(!has_set_seed) seed = (unsigned int) time(NULL); + if(!has_set_seed) seed = (unsigned int) std::time(NULL); if(!has_set_repeat) repeat = DEFAULT_REPEAT; std::cout << "Initializing random number generator with seed " << seed << std::endl; - srand(seed); + std::srand(seed); std::cout << "Repeating each test " << repeat << " times" << std::endl; Eigen::g_repeat = repeat; diff --git a/test/map.cpp b/test/map.cpp index 98bc0180e..ebdfbc8ed 100644 --- a/test/map.cpp +++ b/test/map.cpp @@ -34,7 +34,7 @@ template void map_class_vector(const VectorType& m) Scalar* array1 = ei_aligned_new(size); Scalar* array2 = ei_aligned_new(size); Scalar* array3 = new Scalar[size+1]; - Scalar* array3unaligned = size_t(array3)%16 == 0 ? array3+1 : array3; + Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3; Map(array1, size) = VectorType::Random(size); Map(array2, size) = Map(array1, size); @@ -63,7 +63,7 @@ template void map_class_matrix(const MatrixType& m) for(int i = 0; i < size; i++) array2[i] = Scalar(1); Scalar* array3 = new Scalar[size+1]; for(int i = 0; i < size+1; i++) array3[i] = Scalar(1); - Scalar* array3unaligned = size_t(array3)%16 == 0 ? array3+1 : array3; + Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3; Map(array1, rows, cols) = MatrixType::Ones(rows,cols); Map(array2, rows, cols) = Map(array1, rows, cols); Map(array3unaligned, rows, cols) = Map(array1, rows, cols); @@ -88,7 +88,7 @@ template void map_static_methods(const VectorType& m) Scalar* array1 = ei_aligned_new(size); Scalar* array2 = ei_aligned_new(size); Scalar* array3 = new Scalar[size+1]; - Scalar* array3unaligned = size_t(array3)%16 == 0 ? array3+1 : array3; + Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3; VectorType::MapAligned(array1, size) = VectorType::Random(size); VectorType::Map(array2, size) = VectorType::Map(array1, size); diff --git a/test/newstdvector.cpp b/test/newstdvector.cpp index 7d1909df9..5862ee27b 100644 --- a/test/newstdvector.cpp +++ b/test/newstdvector.cpp @@ -50,7 +50,7 @@ void check_stdvector_matrix(const MatrixType& m) VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); - VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(MatrixType)); + VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(MatrixType)); // do a lot of push_back such that the vector gets internally resized // (with memory reallocation) @@ -85,7 +85,7 @@ void check_stdvector_transform(const TransformType&) VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); - VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(TransformType)); + VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(TransformType)); // do a lot of push_back such that the vector gets internally resized // (with memory reallocation) @@ -120,7 +120,7 @@ void check_stdvector_quaternion(const QuaternionType&) VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); - VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(QuaternionType)); + VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(QuaternionType)); // do a lot of push_back such that the vector gets internally resized // (with memory reallocation) diff --git a/test/stdvector.cpp b/test/stdvector.cpp index 998945a6e..8d205f310 100644 --- a/test/stdvector.cpp +++ b/test/stdvector.cpp @@ -49,7 +49,7 @@ void check_stdvector_matrix(const MatrixType& m) VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); - VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(MatrixType)); + VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(MatrixType)); // do a lot of push_back such that the vector gets internally resized // (with memory reallocation) @@ -84,7 +84,7 @@ void check_stdvector_transform(const TransformType&) VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); - VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(TransformType)); + VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(TransformType)); // do a lot of push_back such that the vector gets internally resized // (with memory reallocation) @@ -119,7 +119,7 @@ void check_stdvector_quaternion(const QuaternionType&) VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); - VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(QuaternionType)); + VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(QuaternionType)); // do a lot of push_back such that the vector gets internally resized // (with memory reallocation) diff --git a/test/unalignedassert.cpp b/test/unalignedassert.cpp index 9447ea85c..cf6f1bdf6 100644 --- a/test/unalignedassert.cpp +++ b/test/unalignedassert.cpp @@ -98,7 +98,7 @@ void check_unalignedassert_bad() { float buf[sizeof(T)+16]; float *unaligned = buf; - while((reinterpret_cast(unaligned)&0xf)==0) ++unaligned; // make sure unaligned is really unaligned + while((reinterpret_cast(unaligned)&0xf)==0) ++unaligned; // make sure unaligned is really unaligned T *x = ::new(static_cast(unaligned)) T; x->~T(); }