From 0cef42895ccff747481b37adff6cb02d5381fd23 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 1 Oct 2017 21:31:13 -0700 Subject: [PATCH] ircd::buffer: Patch alignment related on unique_buffer. --- include/ircd/buffer.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/ircd/buffer.h b/include/ircd/buffer.h index 8e529634f..5b98341e6 100644 --- a/include/ircd/buffer.h +++ b/include/ircd/buffer.h @@ -55,7 +55,7 @@ namespace ircd::buffer struct mutable_buffer; struct const_raw_buffer; struct mutable_raw_buffer; - template struct unique_buffer; + template struct unique_buffer; template class I> using const_buffers = I; template class I> using mutable_buffers = I; @@ -282,7 +282,7 @@ struct ircd::buffer::const_raw_buffer /// /// template + uint alignment> struct ircd::buffer::unique_buffer :buffer { @@ -295,7 +295,7 @@ struct ircd::buffer::unique_buffer }; template + uint alignment> ircd::buffer::unique_buffer::unique_buffer(std::unique_ptr &&b, const size_t &size) :buffer @@ -306,21 +306,27 @@ ircd::buffer::unique_buffer::unique_buffer(std::unique_ptr + uint alignment> ircd::buffer::unique_buffer::unique_buffer(const size_t &size) :unique_buffer { std::unique_ptr { - new __attribute__((aligned(alignment))) uint8_t[size] + //TODO: Can't use a template parameter to the attribute even though + // it's known at compile time. Hardcoding this until fixed with better + // aligned dynamic memory. + //new __attribute__((aligned(alignment))) uint8_t[size] + new __attribute__((aligned(16))) uint8_t[size] }, size } { + // Alignment can only be 16 bytes for now + assert(alignment == 16); } template + uint alignment> ircd::buffer::unique_buffer::unique_buffer(unique_buffer &&other) noexcept :buffer @@ -332,7 +338,7 @@ noexcept } template + uint alignment> ircd::buffer::unique_buffer::~unique_buffer() noexcept {