Verified Commit 77d83f5b authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: add is_aligned helper

parent 04aa3138
......@@ -74,6 +74,7 @@ SEARCH_FOR_BOOST()
SET(${PROJECT_NAME}_UTILS_HEADERS
include/eigenpy/utils/scalar-name.hpp
include/eigenpy/utils/is-approx.hpp
include/eigenpy/utils/is-aligned.hpp
)
SET(${PROJECT_NAME}_SOLVERS_HEADERS
......
......@@ -8,8 +8,7 @@
#include "eigenpy/fwd.hpp"
#include "eigenpy/map.hpp"
#include "eigenpy/scalar-conversion.hpp"
#include <boost/align/is_aligned.hpp>
#include "eigenpy/utils/is-aligned.hpp"
namespace eigenpy
{
......@@ -233,7 +232,7 @@ namespace eigenpy
if(Options != Eigen::Unaligned) // we need to check whether the memory is correctly aligned and composed of a continuous segment
{
void * data_ptr = PyArray_DATA(pyArray);
if(!PyArray_ISONESEGMENT(pyArray) || !boost::alignment::is_aligned(Options,data_ptr))
if(!PyArray_ISONESEGMENT(pyArray) || !is_aligned(data_ptr,Option))
need_to_allocate |= true;
}
......
//
// Copyright (c) 2020 INRIA
//
#ifndef __eigenpy_utils_is_aligned_hpp__
#define __eigenpy_utils_is_aligned_hpp__
namespace eigenpy
{
inline bool is_aligned(void * ptr, std::size_t alignment)
{
return (reinterpret_cast<std::size_t>(ptr) & (alignment - 1)) == 0;
}
}
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment