mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
reconstructible: respect alignment of payload
If one has an object X that has a minimum alignment requirement specified through 'alignas' this requirement is normally inherited by objects that have object X as member, and by those that have objects as member that have X as member, and so on... . However, this chain used to get silently interrupted (dropping the minimum alignment requirement to 8 again) at objects that are managed with Genode::Reconstructible or Genode::Constructible. In order to fix this, the commit ensures that Genode::Reconstructible (and therefore also Genode::Constructible) has at least the minimum alignment requirement (using 'alignas') as the object it manages. Ref #4217
This commit is contained in:
parent
64e2912a2f
commit
ebd140cacb
@ -15,6 +15,7 @@
|
||||
#define _INCLUDE__UTIL__RECONSTRUCTIBLE_H_
|
||||
|
||||
#include <util/construct_at.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <base/stdint.h>
|
||||
#include <util/noncopyable.h>
|
||||
|
||||
@ -36,14 +37,15 @@ namespace Genode {
|
||||
* \param MT type
|
||||
*/
|
||||
template <typename MT>
|
||||
class Genode::Reconstructible : Noncopyable
|
||||
class alignas(Genode::max(alignof(MT), sizeof(Genode::addr_t)))
|
||||
Genode::Reconstructible : Noncopyable
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Static reservation of memory for the embedded object
|
||||
*/
|
||||
char _space[sizeof(MT)] __attribute__((aligned(sizeof(addr_t))));
|
||||
char _space[sizeof(MT)] alignas(sizeof(addr_t));
|
||||
|
||||
/**
|
||||
* True if the volatile object contains a constructed object
|
||||
|
Loading…
Reference in New Issue
Block a user