Prechádzať zdrojové kódy

* cutils.pas (size_2_align): Move to..
globals.pas (size_2_align): ...here.
Change parameter type to asizeuint to avoid overflows.
(var_align_size, const_align_size): Also change parameter type to asizeuint.
i386/cpupara.pas, i8086/cpupara.pas, x86_64/cpupara.pas: Add globals
to implementation uses clause because of size_2_align move.

git-svn-id: trunk@43022 -

pierre 5 rokov pred
rodič
commit
0fa70759a2

+ 0 - 18
compiler/cutils.pas

@@ -78,7 +78,6 @@ interface
 
     function used_align(varalign,minalign,maxalign:longint):longint;
     function isbetteralignedthan(new, org, limit: cardinal): boolean;
-    function size_2_align(len : longint) : longint;
     function packedbitsloadsize(bitlen: int64) : int64;
     procedure Replace(var s:string;s1:string;const s2:string);
     procedure Replace(var s:AnsiString;s1:string;const s2:AnsiString);
@@ -390,23 +389,6 @@ implementation
       end;
 
 
-    function size_2_align(len : longint) : longint;
-      begin
-         if len>16 then
-           size_2_align:=32
-         else if len>8 then
-           size_2_align:=16
-         else if len>4 then
-           size_2_align:=8
-         else if len>2 then
-           size_2_align:=4
-         else if len>1 then
-           size_2_align:=2
-         else
-           size_2_align:=1;
-      end;
-
-
     function packedbitsloadsize(bitlen: int64) : int64;
       begin
          case bitlen of

+ 22 - 4
compiler/globals.pas

@@ -613,12 +613,13 @@ interface
 
     {# Routine to get the required alignment for size of data, which will
        be placed in bss segment, according to the current alignment requirements }
+    function size_2_align(len : asizeuint) : longint;
     function var_align(want_align: longint): shortint;
-    function var_align_size(siz: longint): shortint;
+    function var_align_size(siz: asizeuint): shortint;
     {# Routine to get the required alignment for size of data, which will
        be placed in data/const segment, according to the current alignment requirements }
     function const_align(want_align: longint): shortint;
-    function const_align_size(siz: longint): shortint;
+    function const_align_size(siz: asizeuint): shortint;
 {$ifdef ARM}
     function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
 {$endif ARM}
@@ -1370,13 +1371,30 @@ implementation
       end;
 
 
+    function size_2_align(len : asizeuint) : longint;
+      begin
+         if len>16 then
+           size_2_align:=32
+         else if len>8 then
+           size_2_align:=16
+         else if len>4 then
+           size_2_align:=8
+         else if len>2 then
+           size_2_align:=4
+         else if len>1 then
+           size_2_align:=2
+         else
+           size_2_align:=1;
+      end;
+
+
     function var_align(want_align: longint): shortint;
       begin
         var_align := used_align(want_align,current_settings.alignment.varalignmin,current_settings.alignment.varalignmax);
       end;
 
 
-    function var_align_size(siz: longint): shortint;
+    function var_align_size(siz: asizeuint): shortint;
       begin
         siz := size_2_align(siz);
         var_align_size := var_align(siz);
@@ -1389,7 +1407,7 @@ implementation
       end;
 
 
-    function const_align_size(siz: longint): shortint;
+    function const_align_size(siz: asizeuint): shortint;
       begin
         siz := size_2_align(siz);
         const_align_size := const_align(siz);

+ 1 - 1
compiler/i386/cpupara.pas

@@ -57,7 +57,7 @@ unit cpupara;
        cutils,sysutils,
        systems,verbose,
        symtable,
-       defutil;
+       globals,defutil;
 
       const
         parasupregs : array[0..2] of tsuperregister = (RS_EAX,RS_EDX,RS_ECX);

+ 1 - 1
compiler/i8086/cpupara.pas

@@ -70,7 +70,7 @@ unit cpupara;
        cutils,
        systems,verbose,
        symtable,symcpu,
-       defutil;
+       globals,defutil;
 
       const
         parasupregs : array[0..2] of tsuperregister = (RS_AX,RS_DX,RS_BX);

+ 1 - 1
compiler/x86_64/cpupara.pas

@@ -55,7 +55,7 @@ unit cpupara;
     uses
        cutils,verbose,
        systems,
-       defutil,
+       globals,defutil,
        symtable,
        cpupi,
        cgx86,cgobj,cgcpu;