diff --git a/include/eigenpy/alignment.hpp b/include/eigenpy/alignment.hpp
index b04a7d63a00fb90f43f192b0c1a86a13d1160814..bb888b8dc54dc1c20989861746ee94f5e166b02e 100644
--- a/include/eigenpy/alignment.hpp
+++ b/include/eigenpy/alignment.hpp
@@ -29,6 +29,18 @@ struct aligned_instance {
   typename aligned_storage<sizeof(Data)>::type storage;
 };
 
+inline void *aligned_malloc(
+    std::size_t size, std::size_t alignment = EIGENPY_DEFAULT_ALIGN_BYTES) {
+  void *original = std::malloc(size + alignment);
+  if (original == 0) return 0;
+  void *aligned =
+      reinterpret_cast<void *>((reinterpret_cast<std::size_t>(original) &
+                                ~(std::size_t(alignment - 1))) +
+                               alignment);
+  *(reinterpret_cast<void **>(aligned) - 1) = original;
+  return aligned;
+}
+
 }  // namespace eigenpy
 
 namespace boost {