mirror of
https://github.com/matrix-construct/construct
synced 2024-12-29 08:54:02 +01:00
ircd::buffer: Patch alignment related on unique_buffer.
This commit is contained in:
parent
9c712486a1
commit
0cef42895c
1 changed files with 13 additions and 7 deletions
|
@ -55,7 +55,7 @@ namespace ircd::buffer
|
|||
struct mutable_buffer;
|
||||
struct const_raw_buffer;
|
||||
struct mutable_raw_buffer;
|
||||
template<class buffer, size_t align> struct unique_buffer;
|
||||
template<class buffer, uint align = 16> struct unique_buffer;
|
||||
|
||||
template<template<class> class I> using const_buffers = I<const_buffer>;
|
||||
template<template<class> class I> using mutable_buffers = I<mutable_buffer>;
|
||||
|
@ -282,7 +282,7 @@ struct ircd::buffer::const_raw_buffer
|
|||
///
|
||||
///
|
||||
template<class buffer,
|
||||
size_t align = 16>
|
||||
uint alignment>
|
||||
struct ircd::buffer::unique_buffer
|
||||
:buffer
|
||||
{
|
||||
|
@ -295,7 +295,7 @@ struct ircd::buffer::unique_buffer
|
|||
};
|
||||
|
||||
template<class buffer,
|
||||
size_t alignment>
|
||||
uint alignment>
|
||||
ircd::buffer::unique_buffer<buffer, alignment>::unique_buffer(std::unique_ptr<uint8_t[]> &&b,
|
||||
const size_t &size)
|
||||
:buffer
|
||||
|
@ -306,21 +306,27 @@ ircd::buffer::unique_buffer<buffer, alignment>::unique_buffer(std::unique_ptr<ui
|
|||
}
|
||||
|
||||
template<class buffer,
|
||||
size_t alignment>
|
||||
uint alignment>
|
||||
ircd::buffer::unique_buffer<buffer, alignment>::unique_buffer(const size_t &size)
|
||||
:unique_buffer<buffer, alignment>
|
||||
{
|
||||
std::unique_ptr<uint8_t[]>
|
||||
{
|
||||
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<class buffer,
|
||||
size_t alignment>
|
||||
uint alignment>
|
||||
ircd::buffer::unique_buffer<buffer, alignment>::unique_buffer(unique_buffer &&other)
|
||||
noexcept
|
||||
:buffer
|
||||
|
@ -332,7 +338,7 @@ noexcept
|
|||
}
|
||||
|
||||
template<class buffer,
|
||||
size_t alignment>
|
||||
uint alignment>
|
||||
ircd::buffer::unique_buffer<buffer, alignment>::~unique_buffer()
|
||||
noexcept
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue