Closed TheWire closed 1 year ago
Hi, Do you mean the registers order, like which one comes before which one? I am not sure. Please bother to clarify. But the attribute((packed)) has nothing to do with it, as all the values are unsigned 32-bit integers and has no need of data padding or alignment, as it's already been aligned. You can research on structure data padding and alignment for more clarification.
I am closing this issue because the structure is already aligned therefore packing the structure is not so important. Thank you anyway it does not hurt to add it to the structure to be more clear about it but it is not so important.
I noticed a bug in my own PeachOS code which turned out to be to do with the order of registers in task.h struct registers. The order of cause matters because struct registers gets passed to assembly functions: task_return and restore_general_purpose_registers.
It follows if the order in memory matters then struct registers should be attribute((packed)) to ensure no compiler optimisations.