Skip to content

Commit 77d83f5

Browse files
committed
core: add is_aligned helper
1 parent 04aa313 commit 77d83f5

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ SEARCH_FOR_BOOST()
7474
SET(${PROJECT_NAME}_UTILS_HEADERS
7575
include/eigenpy/utils/scalar-name.hpp
7676
include/eigenpy/utils/is-approx.hpp
77+
include/eigenpy/utils/is-aligned.hpp
7778
)
7879

7980
SET(${PROJECT_NAME}_SOLVERS_HEADERS

include/eigenpy/eigen-allocator.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#include "eigenpy/fwd.hpp"
99
#include "eigenpy/map.hpp"
1010
#include "eigenpy/scalar-conversion.hpp"
11-
12-
#include <boost/align/is_aligned.hpp>
11+
#include "eigenpy/utils/is-aligned.hpp"
1312

1413
namespace eigenpy
1514
{
@@ -233,7 +232,7 @@ namespace eigenpy
233232
if(Options != Eigen::Unaligned) // we need to check whether the memory is correctly aligned and composed of a continuous segment
234233
{
235234
void * data_ptr = PyArray_DATA(pyArray);
236-
if(!PyArray_ISONESEGMENT(pyArray) || !boost::alignment::is_aligned(Options,data_ptr))
235+
if(!PyArray_ISONESEGMENT(pyArray) || !is_aligned(data_ptr,Option))
237236
need_to_allocate |= true;
238237
}
239238

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Copyright (c) 2020 INRIA
3+
//
4+
5+
#ifndef __eigenpy_utils_is_aligned_hpp__
6+
#define __eigenpy_utils_is_aligned_hpp__
7+
8+
namespace eigenpy
9+
{
10+
inline bool is_aligned(void * ptr, std::size_t alignment)
11+
{
12+
return (reinterpret_cast<std::size_t>(ptr) & (alignment - 1)) == 0;
13+
}
14+
}
15+
16+
#endif

0 commit comments

Comments
 (0)