Procházet zdrojové kódy

* naturally align threadvar lists/tables
o required for (future) Darwin arm64e target, and a good idea elsewhere too
(on constrained targets, it won't make a difference because the alignment
of pointers won't be > sizeof(longint))

git-svn-id: trunk@47115 -

Jonas Maebe před 4 roky
rodič
revize
d0d07dc3bf
3 změnil soubory, kde provedl 6 přidání a 8 odebrání
  1. 2 5
      compiler/ngenutil.pas
  2. 1 0
      compiler/options.pas
  3. 3 3
      rtl/inc/threadvr.inc

+ 2 - 5
compiler/ngenutil.pas

@@ -1217,9 +1217,7 @@ implementation
         exit;
       count:=0;
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
-      tcb.begin_anonymous_record('',1,sizeof(pint),
-        targetinfos[target_info.system]^.alignment.recordalignmin
-      );
+      tcb.begin_anonymous_record('',default_settings.packrecords,voidpointertype.alignment,targetinfos[target_info.system]^.alignment.recordalignmin);
       placeholder:=tcb.emit_placeholder(u32inttype);
 
       hp:=tused_unit(usedunits.first);
@@ -1293,8 +1291,7 @@ implementation
        if (tf_section_threadvars in target_info.flags) then
          exit;
        tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
-       tabledef:=tcb.begin_anonymous_record('',1,sizeof(pint),
-         targetinfos[target_info.system]^.alignment.recordalignmin);
+       tabledef:=tcb.begin_anonymous_record('',default_settings.packrecords,voidpointertype.alignment,targetinfos[target_info.system]^.alignment.recordalignmin);
        if assigned(current_module.globalsymtable) then
          current_module.globalsymtable.SymList.ForEachCall(@AddToThreadvarList,tcb);
        current_module.localsymtable.SymList.ForEachCall(@AddToThreadvarList,tcb);

+ 1 - 0
compiler/options.pas

@@ -3939,6 +3939,7 @@ begin
   def_system_macro('FPC_DYNARRAYCOPY_FIXED');
   def_system_macro('FPC_HAS_MEMBAR');
   def_system_macro('FPC_SETBASE_USED');
+  def_system_macro('FPC_ALIGNED_THREADVARTABLES');
 
   { don't remove this, it's also for fpdoc necessary (FK) }
   def_system_macro('FPC_HAS_FEATURE_SUPPORT');

+ 3 - 3
rtl/inc/threadvr.inc

@@ -23,14 +23,14 @@
 type
   pltvInitEntry = ^ltvInitEntry;
   ppltvInitEntry = ^pltvInitEntry;
-  ltvInitEntry = packed record
+  ltvInitEntry = {$ifndef FPC_ALIGNED_THREADVARTABLES}packed{$endif} record
      varaddr : {$ifdef cpu16}pword{$else}pdword{$endif};
      size    : longint;
   end;
 
-  TltvInitTablesTable = packed record
+  TltvInitTablesTable = {$ifndef FPC_ALIGNED_THREADVARTABLES}packed{$endif} record
     count  : dword;
-    tables : packed array [1..{$ifdef cpu16}16{$else}32767{$endif}] of {$ifdef ver3_0}pltvInitEntry{$else}ppltvInitEntry{$endif};
+    tables : {$ifndef FPC_ALIGNED_THREADVARTABLES}packed{$endif} array [1..{$ifdef cpu16}16{$else}32767{$endif}] of {$ifdef ver3_0}pltvInitEntry{$else}ppltvInitEntry{$endif};
   end;
   PltvInitTablesTable = ^TltvInitTablesTable;