瀏覽代碼

+ added upper limits to the heapmin and heapmax values set by the $M directive

git-svn-id: trunk@28056 -
nickysn 11 年之前
父節點
當前提交
0d4edf118e
共有 1 個文件被更改,包括 22 次插入2 次删除
  1. 22 2
      compiler/scandir.pas

+ 22 - 2
compiler/scandir.pas

@@ -703,7 +703,27 @@ unit scandir;
     procedure dir_memory;
       var
         l : longint;
+        heapsize_limit: longint;
+        maxheapsize_limit: longint;
       begin
+{$if defined(i8086)}
+        if current_settings.x86memorymodel in x86_far_data_models then
+          begin
+            heapsize_limit:=655360;
+            maxheapsize_limit:=655360;
+          end
+        else
+          begin
+            heapsize_limit:=65520;
+            maxheapsize_limit:=65520;
+          end;
+{$elseif defined(cpu16bitaddr)}
+        heapsize_limit:=65520;
+        maxheapsize_limit:=65520;
+{$else}
+        heapsize_limit:=high(heapsize);
+        maxheapsize_limit:=high(maxheapsize);
+{$endif}
         current_scanner.skipspace;
         l:=current_scanner.readval;
         if (l>=1024)
@@ -723,14 +743,14 @@ unit scandir;
             current_scanner.skipspace;
             l:=current_scanner.readval;
             if l>=1024 then
-              heapsize:=l;
+              heapsize:=min(l,heapsize_limit);
             if c=',' then
               begin
                 current_scanner.readchar;
                 current_scanner.skipspace;
                 l:=current_scanner.readval;
                 if l>=heapsize then
-                  maxheapsize:=l
+                  maxheapsize:=min(l,maxheapsize_limit)
                 else
                   Message(scan_w_heapmax_lessthan_heapmin);
               end;