Support large alignment requests

The linux kernel has some structures that are page aligned,
i.e. 4096.  Instead of enlarging the bit fields to specify this,
use the fact that alignment is always power of two, and store only
the log2 minus 1 of it.  The 5 bits are enough to specify an alignment
of 1 << 30.
This commit is contained in:
Michael Matz
2016-10-09 02:41:34 +02:00
parent d815a0f658
commit 8859dc9e6d
3 changed files with 38 additions and 7 deletions

View File

@ -1048,6 +1048,11 @@ int pad1;
a copy of it).
struct aligntest7 altest7[2] __attribute__((aligned(16)));*/
struct aligntest8
{
int i;
} __attribute__((aligned(4096)));
struct Large {
unsigned long flags;
union {
@ -1129,6 +1134,8 @@ void struct_test()
sizeof(struct aligntest6), __alignof__(struct aligntest6));
printf("aligntest7 sizeof=%d alignof=%d\n",
sizeof(struct aligntest7), __alignof__(struct aligntest7));
printf("aligntest8 sizeof=%d alignof=%d\n",
sizeof(struct aligntest8), __alignof__(struct aligntest8));
printf("altest5 sizeof=%d alignof=%d\n",
sizeof(altest5), __alignof__(altest5));
printf("altest6 sizeof=%d alignof=%d\n",