Selaa lähdekoodia

* AIX-specific struct alignment rules
o doubles are aligned to 8 bytes outside records, but to 4 bytes
inside them
o same as for Darwin/PPC: if the first field of a record has 8 byte
alignment (including double!), then the struct itself gets 8 byte
alignment

git-svn-id: trunk@20791 -

Jonas Maebe 13 vuotta sitten
vanhempi
commit
57908f528b
2 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 1 1
      compiler/pdecvar.pas
  2. 8 0
      compiler/symtable.pas

+ 1 - 1
compiler/pdecvar.pas

@@ -1596,7 +1596,7 @@ implementation
                  (32-bit) alignment, in which case the alignment is determined by
                  the alignment of the first field.  */
              }
-             if (target_info.system in [system_powerpc_darwin, system_powerpc_macos, system_powerpc64_darwin]) and
+             if (target_info.abi=abi_powerpc_aix) and
                 is_first_type and
                 (symtablestack.top.symtabletype=recordsymtable) and
                 (trecordsymtable(symtablestack.top).usefieldalignment=C_alignment) then

+ 8 - 0
compiler/symtable.pas

@@ -946,6 +946,14 @@ implementation
         l:=sym.getsize;
         vardef:=sym.vardef;
         varalign:=vardef.alignment;
+{$if defined(powerpc) or defined(powerpc64)}
+        { aix is really annoying: the recommended scalar alignment for both
+          int64 and double is 64 bits, but in structs int64 has to be aligned
+          to 8 bytes and double to 4 bytes }
+        if (target_info.system in systems_aix) and
+           is_double(vardef) then
+          varalign:=4;
+{$endif powerpc or powerpc64}
 
         case usefieldalignment of
           bit_alignment: