소스 검색

+ create a default heap on embedded targets and register this default heap
* sysutils for the embedded target depends on a working heap manager

git-svn-id: trunk@23853 -

florian 12 년 전
부모
커밋
380bc56e32
6개의 변경된 파일34개의 추가작업 그리고 9개의 파일을 삭제
  1. 10 3
      compiler/ngenutil.pas
  2. 13 0
      compiler/options.pas
  3. 1 1
      rtl/embedded/Makefile
  4. 1 1
      rtl/embedded/Makefile.fpc
  5. 8 3
      rtl/embedded/heapmgr.pp
  6. 1 1
      rtl/embedded/sysutils.pp

+ 10 - 3
compiler/ngenutil.pas

@@ -907,7 +907,16 @@ implementation
       new_section(current_asmdata.asmlists[al_globals],sec_data,'__heapsize',sizeof(pint));
       current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global('__heapsize',AT_DATA,sizeof(pint)));
       current_asmdata.asmlists[al_globals].concat(Tai_const.Create_pint(heapsize));
-      { Initial heapsize }
+
+      { allocate an initial heap on embedded systems }
+      if target_info.system in systems_embedded then
+        begin
+          maybe_new_object_file(current_asmdata.asmlists[al_globals]);
+          new_section(current_asmdata.asmlists[al_globals],sec_data,'__fpc_initialheap',current_settings.alignment.varalignmax);
+          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create_global('__fpc_initialheap',heapsize));
+        end;
+
+      { Valgrind usage }
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       new_section(current_asmdata.asmlists[al_globals],sec_data,'__fpc_valgrind',sizeof(boolean));
       current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global('__fpc_valgrind',AT_DATA,sizeof(boolean)));
@@ -915,8 +924,6 @@ implementation
     end;
 
 
-
-
    class procedure tnodeutils.add_main_procdef_paras(pd: tdef);
      begin
        { no parameters by default }

+ 13 - 0
compiler/options.pas

@@ -2970,6 +2970,19 @@ begin
         utilsprefix:='i686-linux-android-';
     end;
 
+  { Set up default value for the heap }
+  if target_info.system in systems_embedded then
+    begin
+      case target_info.system of
+        system_avr_embedded:
+          heapsize:=128;
+        system_arm_embedded:
+          heapsize:=256;
+        else
+          heapsize:=256;
+      end;
+    end;
+
   { read configuration file }
   if (not disable_configfile) and
      (ppccfg<>'') then

+ 1 - 1
rtl/embedded/Makefile

@@ -2166,7 +2166,7 @@ dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
 objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
-		    objpas$(PPUEXT) sysconst$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+		    objpas$(PPUEXT) sysconst$(PPUEXT) heapmgr$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
 		   sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT) types$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

+ 1 - 1
rtl/embedded/Makefile.fpc

@@ -156,7 +156,7 @@ objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 #
 
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
-                    objpas$(PPUEXT) sysconst$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
+                    objpas$(PPUEXT) sysconst$(PPUEXT) heapmgr$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
 
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \

+ 8 - 3
rtl/embedded/heapmgr.pp

@@ -99,7 +99,7 @@ Unit heapmgr;
       end;
 
     procedure InternalFreeMem(Addr: Pointer; Size: ptruint);
-      var 
+      var
         b, p, prev: PHeapBlock;
         concatenated: boolean;
       begin
@@ -143,7 +143,7 @@ Unit heapmgr;
                         concatenated:=true;
                         break;
                       end;
-                    
+
                     prev := p;
                     p := p^.next;
                   end;
@@ -178,7 +178,7 @@ Unit heapmgr;
         sz := Align(FindSize(addr)+SizeOf(ptruint), sizeof(pointer));
 
         InternalFreeMem(@pptruint(addr)[-1], sz);
-        
+
         result := sz;
       end;
 
@@ -239,9 +239,14 @@ Unit heapmgr;
         GetFPCHeapStatus: nil;
       );
 
+var
+  initialheap : record end; external name '__fpc_initialheap';
+  heapsize : PtrInt; external name '__heapsize';
+
 
 initialization
   SetMemoryManager(MyMemoryManager);
+  RegisterHeapBlock(@initialheap,heapsize);
 finalization
   //FinalizeHeap;
 end.

+ 1 - 1
rtl/embedded/sysutils.pp

@@ -26,7 +26,7 @@ interface
 implementation
 
 uses
-  sysconst;
+  sysconst,heapmgr;
 
   { Include platform independent implementation part }
   {$i sysutils.inc}