瀏覽代碼

* more record alignment fixes

peter 21 年之前
父節點
當前提交
8caaa7740d
共有 10 個文件被更改,包括 103 次插入64 次删除
  1. 13 2
      compiler/globals.pas
  2. 8 1
      compiler/parser.pas
  3. 6 3
      compiler/pdecvar.pas
  4. 6 3
      compiler/psystem.pas
  5. 8 5
      compiler/ptype.pas
  6. 6 2
      compiler/rgobj.pas
  7. 20 17
      compiler/scandir.pas
  8. 7 16
      compiler/symdef.pas
  9. 23 12
      compiler/symtable.pas
  10. 6 3
      compiler/systems/i_linux.pas

+ 13 - 2
compiler/globals.pas

@@ -189,7 +189,8 @@ interface
        {$IFDEF testvarsets}
        {$IFDEF testvarsets}
         Initsetalloc,                            {0=fixed, 1 =var}
         Initsetalloc,                            {0=fixed, 1 =var}
        {$ENDIF}
        {$ENDIF}
-       initpackenum       : longint;
+       initpackrecords,
+       initpackenum       : shortint;
        initalignment      : talignmentinfo;
        initalignment      : talignmentinfo;
        initoptprocessor,
        initoptprocessor,
        initspecificoptprocessor : tprocessors;
        initspecificoptprocessor : tprocessors;
@@ -210,6 +211,7 @@ interface
        {$IFDEF testvarsets}
        {$IFDEF testvarsets}
         aktsetalloc,
         aktsetalloc,
        {$ENDIF}
        {$ENDIF}
+       aktpackrecords,
        aktpackenum        : longint;
        aktpackenum        : longint;
        aktmaxfpuregisters : longint;
        aktmaxfpuregisters : longint;
        aktalignment       : talignmentinfo;
        aktalignment       : talignmentinfo;
@@ -1734,6 +1736,7 @@ implementation
 
 
         initfputype:=fpu_x87;
         initfputype:=fpu_x87;
 
 
+        initpackrecords:=4;
         initpackenum:=4;
         initpackenum:=4;
         {$IFDEF testvarsets}
         {$IFDEF testvarsets}
         initsetalloc:=0;
         initsetalloc:=0;
@@ -1742,6 +1745,7 @@ implementation
 {$endif i386}
 {$endif i386}
 {$ifdef m68k}
 {$ifdef m68k}
         initoptprocessor:=MC68020;
         initoptprocessor:=MC68020;
+        initpackrecords:=2;
         initpackenum:=4;
         initpackenum:=4;
         {$IFDEF testvarsets}
         {$IFDEF testvarsets}
          initsetalloc:=0;
          initsetalloc:=0;
@@ -1749,6 +1753,7 @@ implementation
 {$endif m68k}
 {$endif m68k}
 {$ifdef powerpc}
 {$ifdef powerpc}
         initoptprocessor:=PPC604;
         initoptprocessor:=PPC604;
+        initpackrecords:=4;
         initpackenum:=4;
         initpackenum:=4;
         {$IFDEF testvarsets}
         {$IFDEF testvarsets}
          initsetalloc:=0;
          initsetalloc:=0;
@@ -1757,12 +1762,14 @@ implementation
 {$endif powerpc}
 {$endif powerpc}
 {$ifdef sparc}
 {$ifdef sparc}
         initoptprocessor:=SPARC_V8;
         initoptprocessor:=SPARC_V8;
+        initpackrecords:=8;
         initpackenum:=4;
         initpackenum:=4;
         {$IFDEF testvarsets}
         {$IFDEF testvarsets}
          initsetalloc:=0;
          initsetalloc:=0;
         {$ENDIF}
         {$ENDIF}
 {$endif sparc}
 {$endif sparc}
 {$ifdef arm}
 {$ifdef arm}
+        initpackrecords:=4;
         initpackenum:=4;
         initpackenum:=4;
         {$IFDEF testvarsets}
         {$IFDEF testvarsets}
         initsetalloc:=0;
         initsetalloc:=0;
@@ -1775,6 +1782,7 @@ implementation
 
 
         initfputype:=fpu_sse64;
         initfputype:=fpu_sse64;
 
 
+        initpackrecords:=8;
         initpackenum:=4;
         initpackenum:=4;
         {$IFDEF testvarsets}
         {$IFDEF testvarsets}
         initsetalloc:=0;
         initsetalloc:=0;
@@ -1796,7 +1804,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.122  2004-01-28 21:05:56  florian
+  Revision 1.123  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.122  2004/01/28 21:05:56  florian
     * fixed alignment of classes
     * fixed alignment of classes
 
 
   Revision 1.121  2004/01/14 23:39:05  florian
   Revision 1.121  2004/01/14 23:39:05  florian

+ 8 - 1
compiler/parser.pas

@@ -341,6 +341,7 @@ implementation
           oldaktlocalswitches  : tlocalswitches;
           oldaktlocalswitches  : tlocalswitches;
           oldaktmoduleswitches : tmoduleswitches;
           oldaktmoduleswitches : tmoduleswitches;
           oldaktfilepos      : tfileposinfo;
           oldaktfilepos      : tfileposinfo;
+          oldaktpackrecords,
           oldaktpackenum,oldaktmaxfpuregisters : longint;
           oldaktpackenum,oldaktmaxfpuregisters : longint;
           oldaktalignment  : talignmentinfo;
           oldaktalignment  : talignmentinfo;
           oldaktoutputformat : tasm;
           oldaktoutputformat : tasm;
@@ -421,6 +422,7 @@ implementation
             oldaktmoduleswitches:=aktmoduleswitches;
             oldaktmoduleswitches:=aktmoduleswitches;
             oldaktalignment:=aktalignment;
             oldaktalignment:=aktalignment;
             oldaktpackenum:=aktpackenum;
             oldaktpackenum:=aktpackenum;
+            oldaktpackrecords:=aktpackrecords;
             oldaktfputype:=aktfputype;
             oldaktfputype:=aktfputype;
             oldaktmaxfpuregisters:=aktmaxfpuregisters;
             oldaktmaxfpuregisters:=aktmaxfpuregisters;
             oldaktoutputformat:=aktoutputformat;
             oldaktoutputformat:=aktoutputformat;
@@ -478,6 +480,7 @@ implementation
          aktalignment:=initalignment;
          aktalignment:=initalignment;
          aktfputype:=initfputype;
          aktfputype:=initfputype;
          aktpackenum:=initpackenum;
          aktpackenum:=initpackenum;
+         aktpackrecords:=initpackrecords;
          aktoutputformat:=initoutputformat;
          aktoutputformat:=initoutputformat;
          set_target_asm(aktoutputformat);
          set_target_asm(aktoutputformat);
          aktoptprocessor:=initoptprocessor;
          aktoptprocessor:=initoptprocessor;
@@ -608,6 +611,7 @@ implementation
                  aktmoduleswitches:=oldaktmoduleswitches;
                  aktmoduleswitches:=oldaktmoduleswitches;
                  aktalignment:=oldaktalignment;
                  aktalignment:=oldaktalignment;
                  aktpackenum:=oldaktpackenum;
                  aktpackenum:=oldaktpackenum;
+                 aktpackrecords:=oldaktpackrecords;
                  aktmaxfpuregisters:=oldaktmaxfpuregisters;
                  aktmaxfpuregisters:=oldaktmaxfpuregisters;
                  aktoutputformat:=oldaktoutputformat;
                  aktoutputformat:=oldaktoutputformat;
                  set_target_asm(aktoutputformat);
                  set_target_asm(aktoutputformat);
@@ -691,7 +695,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.58  2003-10-29 21:02:51  peter
+  Revision 1.59  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.58  2003/10/29 21:02:51  peter
     * set ms_compiled after the program/unit is parsed
     * set ms_compiled after the program/unit is parsed
     * check for ms_compiled before checking preproc matches
     * check for ms_compiled before checking preproc matches
 
 

+ 6 - 3
compiler/pdecvar.pas

@@ -1064,7 +1064,7 @@ implementation
               if not(is_ordinal(casetype.def)) or is_64bitint(casetype.def)  then
               if not(is_ordinal(casetype.def)) or is_64bitint(casetype.def)  then
                Message(type_e_ordinal_expr_expected);
                Message(type_e_ordinal_expr_expected);
               consume(_OF);
               consume(_OF);
-              UnionSymtable:=trecordsymtable.create;
+              UnionSymtable:=trecordsymtable.create(aktpackrecords);
               Unionsymtable.next:=symtablestack;
               Unionsymtable.next:=symtablestack;
               registerdef:=false;
               registerdef:=false;
               UnionDef:=trecorddef.create(unionsymtable);
               UnionDef:=trecorddef.create(unionsymtable);
@@ -1114,7 +1114,7 @@ implementation
               symtablestack:=symtablestack.next;
               symtablestack:=symtablestack.next;
               { we do NOT call symtablestack.insert
               { we do NOT call symtablestack.insert
                on purpose PM }
                on purpose PM }
-              if aktalignment.recordalignmax=-1 then
+              if trecordsymtable(symtablestack).usefieldalignment=-1 then
                begin
                begin
 {$ifdef i386}
 {$ifdef i386}
                  if maxalignment>2 then
                  if maxalignment>2 then
@@ -1152,7 +1152,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2004-01-28 20:30:18  peter
+  Revision 1.61  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.60  2004/01/28 20:30:18  peter
     * record alignment splitted in fieldalignment and recordalignment,
     * record alignment splitted in fieldalignment and recordalignment,
       the latter is used when this record is inserted in another record.
       the latter is used when this record is inserted in another record.
 
 

+ 6 - 3
compiler/psystem.pas

@@ -198,7 +198,7 @@ implementation
         addtype('$s80real',s80floattype);
         addtype('$s80real',s80floattype);
         addtype('$s64currency',s64currencytype);
         addtype('$s64currency',s64currencytype);
         { Add a type for virtual method tables }
         { Add a type for virtual method tables }
-        hrecst:=trecordsymtable.create;
+        hrecst:=trecordsymtable.create(aktpackrecords);
         vmttype.setdef(trecorddef.create(hrecst));
         vmttype.setdef(trecorddef.create(hrecst));
         pvmttype.setdef(tpointerdef.create(vmttype));
         pvmttype.setdef(tpointerdef.create(vmttype));
         hrecst.insertfield(tvarsym.create('$parent',vs_value,pvmttype),true);
         hrecst.insertfield(tvarsym.create('$parent',vs_value,pvmttype),true);
@@ -213,7 +213,7 @@ implementation
         tarraydef(vmtarraytype.def).setelementtype(pvmttype);
         tarraydef(vmtarraytype.def).setelementtype(pvmttype);
         addtype('$vtblarray',vmtarraytype);
         addtype('$vtblarray',vmtarraytype);
         { Add a type for methodpointers }
         { Add a type for methodpointers }
-        hrecst:=trecordsymtable.create;
+        hrecst:=trecordsymtable.create(1);
         hrecst.insertfield(tvarsym.create('$proc',vs_value,voidpointertype),true);
         hrecst.insertfield(tvarsym.create('$proc',vs_value,voidpointertype),true);
         hrecst.insertfield(tvarsym.create('$self',vs_value,voidpointertype),true);
         hrecst.insertfield(tvarsym.create('$self',vs_value,voidpointertype),true);
         methodpointertype.setdef(trecorddef.create(hrecst));
         methodpointertype.setdef(trecorddef.create(hrecst));
@@ -521,7 +521,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2004-01-20 12:59:37  florian
+  Revision 1.60  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.59  2004/01/20 12:59:37  florian
     * common addnode code for x86-64 and i386
     * common addnode code for x86-64 and i386
 
 
   Revision 1.58  2003/11/29 16:19:54  peter
   Revision 1.58  2003/11/29 16:19:54  peter

+ 8 - 5
compiler/ptype.pas

@@ -226,7 +226,7 @@ implementation
          old_object_option : tsymoptions;
          old_object_option : tsymoptions;
       begin
       begin
          { create recdef }
          { create recdef }
-         symtable:=trecordsymtable.create;
+         symtable:=trecordsymtable.create(aktpackrecords);
          record_dec:=trecorddef.create(symtable);
          record_dec:=trecorddef.create(symtable);
          { update symtable stack }
          { update symtable stack }
          symtable.next:=symtablestack;
          symtable.next:=symtablestack;
@@ -582,13 +582,13 @@ implementation
                   array_dec
                   array_dec
                 else
                 else
                   begin
                   begin
-                    oldaktpackrecords:=aktalignment.recordalignmax;
-                    aktalignment.recordalignmax:=1;
+                    oldaktpackrecords:=aktpackrecords;
+                    aktpackrecords:=1;
                     if token in [_CLASS,_OBJECT] then
                     if token in [_CLASS,_OBJECT] then
                       tt.setdef(object_dec(name,nil))
                       tt.setdef(object_dec(name,nil))
                     else
                     else
                       tt.setdef(record_dec);
                       tt.setdef(record_dec);
-                    aktalignment.recordalignmax:=oldaktpackrecords;
+                    aktpackrecords:=oldaktpackrecords;
                   end;
                   end;
               end;
               end;
             _CLASS,
             _CLASS,
@@ -644,7 +644,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.61  2004-01-28 20:30:18  peter
+  Revision 1.62  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.61  2004/01/28 20:30:18  peter
     * record alignment splitted in fieldalignment and recordalignment,
     * record alignment splitted in fieldalignment and recordalignment,
       the latter is used when this record is inserted in another record.
       the latter is used when this record is inserted in another record.
 
 

+ 6 - 2
compiler/rgobj.pas

@@ -425,6 +425,7 @@ implementation
       spillworklist.done;
       spillworklist.done;
       coalescednodes.done;
       coalescednodes.done;
       selectstack.done;
       selectstack.done;
+      live_registers.done;
       worklist_moves.free;
       worklist_moves.free;
       dispose_reginfo;
       dispose_reginfo;
     end;
     end;
@@ -1562,7 +1563,7 @@ implementation
             p:=Tai(p.previous);
             p:=Tai(p.previous);
           end;
           end;
         live_registers.done;
         live_registers.done;
-        live_registers.copyfrom(back);
+        live_registers:=back;
       end;
       end;
 
 
 
 
@@ -1862,7 +1863,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.115  2004-01-26 17:40:11  florian
+  Revision 1.116  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.115  2004/01/26 17:40:11  florian
     * made DoSpill* overrideable
     * made DoSpill* overrideable
     + add_cpu_interferences added
     + add_cpu_interferences added
 
 

+ 20 - 17
compiler/scandir.pas

@@ -119,22 +119,22 @@ implementation
            { Support also the ON and OFF as switch }
            { Support also the ON and OFF as switch }
            hs:=current_scanner.readid;
            hs:=current_scanner.readid;
            if (hs='ON') then
            if (hs='ON') then
-            aktalignment.recordalignmax:=4
+            aktpackrecords:=4
            else
            else
             if (hs='OFF') then
             if (hs='OFF') then
-             aktalignment.recordalignmax:=1
+             aktpackrecords:=1
            else
            else
             Message(scan_w_only_pack_records);
             Message(scan_w_only_pack_records);
          end
          end
         else
         else
          begin
          begin
            case current_scanner.readval of
            case current_scanner.readval of
-             1 : aktalignment.recordalignmax:=1;
-             2 : aktalignment.recordalignmax:=2;
-             4 : aktalignment.recordalignmax:=4;
-             8 : aktalignment.recordalignmax:=8;
-            16 : aktalignment.recordalignmax:=16;
-            32 : aktalignment.recordalignmax:=32;
+             1 : aktpackrecords:=1;
+             2 : aktpackrecords:=2;
+             4 : aktpackrecords:=4;
+             8 : aktpackrecords:=8;
+            16 : aktpackrecords:=16;
+            32 : aktpackrecords:=32;
            else
            else
             Message(scan_w_only_pack_records);
             Message(scan_w_only_pack_records);
            end;
            end;
@@ -602,22 +602,22 @@ implementation
            hs:=current_scanner.readid;
            hs:=current_scanner.readid;
            { C has the special recordalignmax of -1 }
            { C has the special recordalignmax of -1 }
            if (hs='C') then
            if (hs='C') then
-            aktalignment.recordalignmax:=-1
+            aktpackrecords:=-1
            else
            else
             if (hs='NORMAL') or (hs='DEFAULT') then
             if (hs='NORMAL') or (hs='DEFAULT') then
-             aktalignment.recordalignmax:=2
+             aktpackrecords:=2
            else
            else
             Message(scan_w_only_pack_records);
             Message(scan_w_only_pack_records);
          end
          end
         else
         else
          begin
          begin
            case current_scanner.readval of
            case current_scanner.readval of
-             1 : aktalignment.recordalignmax:=1;
-             2 : aktalignment.recordalignmax:=2;
-             4 : aktalignment.recordalignmax:=4;
-             8 : aktalignment.recordalignmax:=8;
-            16 : aktalignment.recordalignmax:=16;
-            32 : aktalignment.recordalignmax:=32;
+             1 : aktpackrecords:=1;
+             2 : aktpackrecords:=2;
+             4 : aktpackrecords:=4;
+             8 : aktpackrecords:=8;
+            16 : aktpackrecords:=16;
+            32 : aktpackrecords:=32;
            else
            else
             Message(scan_w_only_pack_records);
             Message(scan_w_only_pack_records);
            end;
            end;
@@ -992,7 +992,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.29  2003-12-25 01:07:09  florian
+  Revision 1.30  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.29  2003/12/25 01:07:09  florian
     + $fputype directive support
     + $fputype directive support
     + single data type operations with sse unit
     + single data type operations with sse unit
     * fixed more x86-64 stuff
     * fixed more x86-64 stuff

+ 7 - 16
compiler/symdef.pas

@@ -3044,12 +3044,6 @@ implementation
          deftype:=recorddef;
          deftype:=recorddef;
          symtable:=p;
          symtable:=p;
          symtable.defowner:=self;
          symtable.defowner:=self;
-         { recordalign -1 means C record packing, that starts
-           with an alignment of 1 }
-         if aktalignment.recordalignmax=-1 then
-           trecordsymtable(symtable).fieldalignment:=1
-         else
-           trecordsymtable(symtable).fieldalignment:=aktalignment.recordalignmax;
          isunion:=false;
          isunion:=false;
       end;
       end;
 
 
@@ -3059,7 +3053,7 @@ implementation
          inherited ppuloaddef(ppufile);
          inherited ppuloaddef(ppufile);
          deftype:=recorddef;
          deftype:=recorddef;
          savesize:=ppufile.getlongint;
          savesize:=ppufile.getlongint;
-         symtable:=trecordsymtable.create;
+         symtable:=trecordsymtable.create(0);
          trecordsymtable(symtable).datasize:=ppufile.getlongint;
          trecordsymtable(symtable).datasize:=ppufile.getlongint;
          trecordsymtable(symtable).fieldalignment:=ppufile.getbyte;
          trecordsymtable(symtable).fieldalignment:=ppufile.getbyte;
          trecordsymtable(symtable).recordalignment:=ppufile.getbyte;
          trecordsymtable(symtable).recordalignment:=ppufile.getbyte;
@@ -4667,16 +4661,10 @@ implementation
         deftype:=objectdef;
         deftype:=objectdef;
         objectoptions:=[];
         objectoptions:=[];
         childof:=nil;
         childof:=nil;
-        symtable:=tobjectsymtable.create(n);
+        symtable:=tobjectsymtable.create(n,aktpackrecords);
         { create space for vmt !! }
         { create space for vmt !! }
         vmt_offset:=0;
         vmt_offset:=0;
         symtable.defowner:=self;
         symtable.defowner:=self;
-        { recordalign -1 means C record packing, that starts
-          with an alignment of 1 }
-        if aktalignment.recordalignmax=-1 then
-         tobjectsymtable(symtable).fieldalignment:=1
-        else
-         tobjectsymtable(symtable).fieldalignment:=aktalignment.recordalignmax;
         lastvtableindex:=0;
         lastvtableindex:=0;
         set_parent(c);
         set_parent(c);
         objname:=stringdup(upper(n));
         objname:=stringdup(upper(n));
@@ -4735,7 +4723,7 @@ implementation
          else
          else
            implementedinterfaces:=nil;
            implementedinterfaces:=nil;
 
 
-         symtable:=tobjectsymtable.create(objrealname^);
+         symtable:=tobjectsymtable.create(objrealname^,aktpackrecords);
          tobjectsymtable(symtable).datasize:=ppufile.getlongint;
          tobjectsymtable(symtable).datasize:=ppufile.getlongint;
          tobjectsymtable(symtable).fieldalignment:=ppufile.getbyte;
          tobjectsymtable(symtable).fieldalignment:=ppufile.getbyte;
          tobjectsymtable(symtable).recordalignment:=ppufile.getbyte;
          tobjectsymtable(symtable).recordalignment:=ppufile.getbyte;
@@ -6164,7 +6152,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.212  2004-01-28 21:05:56  florian
+  Revision 1.213  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.212  2004/01/28 21:05:56  florian
     * fixed alignment of classes
     * fixed alignment of classes
 
 
   Revision 1.211  2004/01/28 20:30:18  peter
   Revision 1.211  2004/01/28 20:30:18  peter

+ 23 - 12
compiler/symtable.pas

@@ -93,9 +93,10 @@ interface
        tabstractrecordsymtable = class(tstoredsymtable)
        tabstractrecordsymtable = class(tstoredsymtable)
        public
        public
           datasize       : longint;
           datasize       : longint;
+          usefieldalignment,     { alignment to use for fields (PACKRECORDS value), -1 is C style }
           recordalignment,       { alignment required when inserting this record }
           recordalignment,       { alignment required when inserting this record }
-          fieldalignment : byte; { alignment used when fields are inserted }
-          constructor create(const n:string);
+          fieldalignment : shortint; { alignment current alignment used when fields are inserted }
+          constructor create(const n:string;usealign:shortint);
           procedure ppuload(ppufile:tcompilerppufile);override;
           procedure ppuload(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
           procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
@@ -105,13 +106,13 @@ interface
 
 
        trecordsymtable = class(tabstractrecordsymtable)
        trecordsymtable = class(tabstractrecordsymtable)
        public
        public
-          constructor create;
+          constructor create(usealign:shortint);
           procedure insert_in(tsymt : trecordsymtable;offset : longint);
           procedure insert_in(tsymt : trecordsymtable;offset : longint);
        end;
        end;
 
 
        tobjectsymtable = class(tabstractrecordsymtable)
        tobjectsymtable = class(tabstractrecordsymtable)
        public
        public
-          constructor create(const n:string);
+          constructor create(const n:string;usealign:shortint);
           procedure insert(sym : tsymentry);override;
           procedure insert(sym : tsymentry);override;
        end;
        end;
 
 
@@ -975,11 +976,18 @@ implementation
                           TAbstractRecordSymtable
                           TAbstractRecordSymtable
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tabstractrecordsymtable.create(const n:string);
+    constructor tabstractrecordsymtable.create(const n:string;usealign:shortint);
       begin
       begin
         inherited create(n);
         inherited create(n);
         datasize:=0;
         datasize:=0;
-        fieldalignment:=1;
+        recordalignment:=1;
+        usefieldalignment:=usealign;
+        { recordalign -1 means C record packing, that starts
+          with an alignment of 1 }
+        if usealign=-1 then
+          fieldalignment:=1
+        else
+          fieldalignment:=usealign;
       end;
       end;
 
 
 
 
@@ -1057,7 +1065,7 @@ implementation
         vardef:=tvarsym(sym).vartype.def;
         vardef:=tvarsym(sym).vartype.def;
         varalign:=vardef.alignment;
         varalign:=vardef.alignment;
         { Calc the alignment size for C style records }
         { Calc the alignment size for C style records }
-        if (aktalignment.recordalignmax=-1) then
+        if (usefieldalignment=-1) then
          begin
          begin
            if (varalign>4) and
            if (varalign>4) and
               ((varalign mod 4)<>0) and
               ((varalign mod 4)<>0) and
@@ -1098,9 +1106,9 @@ implementation
                               TRecordSymtable
                               TRecordSymtable
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor trecordsymtable.create;
+    constructor trecordsymtable.create(usealign:shortint);
       begin
       begin
-        inherited create('');
+        inherited create('',usealign);
         symtabletype:=recordsymtable;
         symtabletype:=recordsymtable;
       end;
       end;
 
 
@@ -1156,9 +1164,9 @@ implementation
                               TObjectSymtable
                               TObjectSymtable
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tobjectsymtable.create(const n:string);
+    constructor tobjectsymtable.create(const n:string;usealign:shortint);
       begin
       begin
-        inherited create(n);
+        inherited create(n,usealign);
         symtabletype:=objectsymtable;
         symtabletype:=objectsymtable;
       end;
       end;
 
 
@@ -2302,7 +2310,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.127  2004-01-28 20:30:18  peter
+  Revision 1.128  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.127  2004/01/28 20:30:18  peter
     * record alignment splitted in fieldalignment and recordalignment,
     * record alignment splitted in fieldalignment and recordalignment,
       the latter is used when this record is inserted in another record.
       the latter is used when this record is inserted in another record.
 
 

+ 6 - 3
compiler/systems/i_linux.pas

@@ -81,7 +81,7 @@ unit i_linux;
                 localalignmin   : 4;
                 localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
-                recordalignmax  : 2;
+                recordalignmax  : 4;
                 maxCrecordalign : 4
                 maxCrecordalign : 4
               );
               );
             first_parm_offset : 8;
             first_parm_offset : 8;
@@ -207,7 +207,7 @@ unit i_linux;
                 localalignmin   : 4;
                 localalignmin   : 4;
                 localalignmax   : 4;
                 localalignmax   : 4;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
-                recordalignmax  : 2;
+                recordalignmax  : 4;
                 maxCrecordalign : 8
                 maxCrecordalign : 8
               );
               );
             first_parm_offset : 8;
             first_parm_offset : 8;
@@ -514,7 +514,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.22  2004-01-28 15:36:47  florian
+  Revision 1.23  2004-01-28 22:16:31  peter
+    * more record alignment fixes
+
+  Revision 1.22  2004/01/28 15:36:47  florian
     * fixed another couple of arm bugs
     * fixed another couple of arm bugs
 
 
   Revision 1.21  2004/01/26 19:05:56  florian
   Revision 1.21  2004/01/26 19:05:56  florian