Browse Source

* fix rtti unit for targets with FPC_REQUIRES_PROPER_ALIGNMENT set

git-svn-id: trunk@35219 -
florian 8 years ago
parent
commit
be9f055c33
1 changed files with 16 additions and 1 deletions
  1. 16 1
      packages/rtl-objpas/src/inc/rtti.pp

+ 16 - 1
packages/rtl-objpas/src/inc/rtti.pp

@@ -927,6 +927,21 @@ function aligntoptr(p : pointer) : pointer;inline;
 {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
 {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
    end;
    end;
 
 
+function aligntoqword(p : pointer) : pointer;inline;
+  type
+    TAlignCheck = record
+      b : byte;
+      q : qword;
+    end;
+  begin
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+    result:=align(p,PtrInt(@TAlignCheck(nil^).q))
+{$else FPC_REQUIRES_PROPER_ALIGNMENT}
+    result:=p;
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+  end;
+
+
 function TRttiType.GetProperties: specialize TArray<TRttiProperty>;
 function TRttiType.GetProperties: specialize TArray<TRttiProperty>;
 type
 type
   PPropData = ^TPropData;
   PPropData = ^TPropData;
@@ -952,7 +967,7 @@ begin
 
 
         // published properties count for this object
         // published properties count for this object
         // skip the attribute-info if available
         // skip the attribute-info if available
-        PPD := PPropData(pointer(@TD^.UnitName)+PByte(@TD^.UnitName)^+1);
+        PPD := aligntoptr(PPropData(pointer(@TD^.UnitName)+PByte(@TD^.UnitName)^+1));
         Count:=PPD^.PropCount;
         Count:=PPD^.PropCount;
         // Now point TP to first propinfo record.
         // Now point TP to first propinfo record.
         TP:=PPropInfo(@PPD^.PropList);
         TP:=PPropInfo(@PPD^.PropList);