> Alignment affects the members of the struct. If you want the entire struct to be aligned on a 4k boundary then you simply need to allocate it that way.
If declared at compile time, it affects the structure alignment as well. See
Code:
typedef struct page_struct{
unsigned int entry[1024];
}__attribute__((aligned(4096))) page_dir_t, page_table_t; /* athough their uses are different, they have the same structure */
int main()
{
page_table_t t;
printf("%p", &t);
return 0;
}
Always prints 0x*000.
BTW, I don't even have a malloc yet. I'll probably ask you quite a few questions when I start on it. Such as: Does malloc return addresses from a common pool of memory(system wide) or process specific pool?