Align after template expansion

Clang Cannot align template structs. Also, cannot cast void* to addr_t
in constexpr function.

Issue #3564
This commit is contained in:
Emery Hemingway 2019-09-26 12:37:45 +02:00 committed by Christian Helmuth
parent 2c510bb7f9
commit 648382db74
2 changed files with 19 additions and 9 deletions

View File

@ -57,13 +57,6 @@ namespace Hw
template <typename ENTRY, unsigned PAGE_SIZE_LOG2, unsigned SIZE_LOG2>
class Page_directory;
using Level_3_translation_table =
Page_directory<Level_4_translation_table,
SIZE_LOG2_2MB, SIZE_LOG2_1GB>;
using Level_2_translation_table =
Page_directory<Level_3_translation_table,
SIZE_LOG2_1GB, SIZE_LOG2_512GB>;
/**
* IA-32e common descriptor.
*
@ -489,7 +482,24 @@ class Hw::Page_directory
*/
void remove_translation(addr_t vo, size_t size, Allocator & alloc) {
_range_op(vo, 0, size, Remove_func(alloc)); }
} __attribute__((aligned(1 << ALIGNM_LOG2)));
};
namespace Hw {
struct Level_3_translation_table :
Page_directory<
Level_4_translation_table,
SIZE_LOG2_2MB, SIZE_LOG2_1GB>
{ } __attribute__((aligned(1 << ALIGNM_LOG2)));
struct Level_2_translation_table :
Page_directory<
Level_3_translation_table,
SIZE_LOG2_1GB, SIZE_LOG2_512GB>
{ } __attribute__((aligned(1 << ALIGNM_LOG2)));
}
class Hw::Pml4_table

View File

@ -56,7 +56,7 @@ namespace Hw
* \param p pointer
* \param alignm_log2 log2 of the required alignment
*/
constexpr bool aligned(void * const p, addr_t alignm_log2) {
inline bool aligned(void * const p, addr_t alignm_log2) {
return (addr_t)p == trunc((addr_t)p, alignm_log2); }
/**