Yes, of course the __packed__ attribute only affects internal alignments. Are you sure that the C compiler is not allowed to reorganize the members of the structure? I don't think that is part of the ANSI C standard though I did not check that.kmcguire wrote:Structures that have member fields that you do not want padded to maintain alignment on word boundaries need to use the __attribute__((__packed__)) expression. The C compiler should never reorganize the members of a structure! The padding increases the performance of data access (if you have ever noticed inside the manuals for a processor's instruction set it will hint to performance decreases on unaligned memory accesses for some stuff).Korona wrote:I don't know if that causes any problem in this case but generally structures that the compiler must not align or reorganize should be marked with __attribute((__packed__)).
The alignment of the structure it's self comes from it's creation. Such that if you create the structure as a local variable then it is automatically aligned by the stack's word size. While, if you create the structure using a pointer, then the structure may or may not be aligned no matter if you used the __packed__ attribute or not.
Making bootsector for USB pen
Re: Making bootsector for USB pen
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].