On 2014-10-17 10:03:45, Anthony PERARD wrote:This patch imports publics headers in order to use features from Xen like XenStore, PV Block... There is only the necessary header files and there are only a few modifications in order to facilitate future merge of more recent header (that would be necessary to access new features).
There is little modification compared to the original files: - Removed most of the unused part of the headers - Use of ZeroMem() instead of memset() - using #pragma pack(4) for IA32 compilation.
Usually EDK II uses pack(1) when concerned about structure layout. I'mnot saying you need to change this, but it does stand out.
#pack(4) is not the same as #pack(1).
I think the pack(4) will prevent EFI packing rules from conflicting with the Unix packing rules. For EFI a 64-bit item is always aligned on a 64-bit boundary, this is not the case for most Unixes.
For clang we have to add flags to change the structure packing default rules for i386, and the #pragma pack(4) undoes that change.
~/work/Compiler>cat pack.c #include <stdio.h>
//#pragma pack(4)
struct a { int a; long long b; int c; };
int main () { struct a *p = (void *)0;
printf ("a 0x%p\n", &p->a); printf ("b 0x%p\n", &p->b); printf ("b 0x%p\n", &p->c); printf ("sizeof a = %lu\n", sizeof(struct a)); return 0; } ~/work/Compiler> ~/work/Compiler>clang -arch i386 pack.c ~/work/Compiler>./a.out a 0x0x0 b 0x0x4 b 0x0xc sizeof a = 16 ~/work/Compiler>clang -arch i386 pack.c -mms-bitfields ~/work/Compiler>./a.out a 0x0x0 b 0x0x8 b 0x0x10 sizeof a = 24
Add in #pragma pack(4)
~/work/Compiler>clang -arch i386 pack.c -mms-bitfields ~/work/Compiler>./a.out a 0x0x0 b 0x0x4 b 0x0xc sizeof a = 16
|