Browse Source

* disable generic threadvar handling if section thread vars are available

git-svn-id: trunk@40270 -
florian 6 years ago
parent
commit
9c041afc7c
2 changed files with 9 additions and 1 deletions
  1. 5 1
      rtl/inc/threadvr.inc
  2. 4 0
      rtl/unix/cthreads.pp

+ 5 - 1
rtl/inc/threadvr.inc

@@ -19,7 +19,7 @@
                            Threadvar support
                            Threadvar support
 *****************************************************************************}
 *****************************************************************************}
 
 
-
+{$ifndef FPC_SECTION_THREADVARS}
 type
 type
   pltvInitEntry = ^ltvInitEntry;
   pltvInitEntry = ^ltvInitEntry;
   ppltvInitEntry = ^pltvInitEntry;
   ppltvInitEntry = ^pltvInitEntry;
@@ -100,10 +100,12 @@ begin
       copy_unit_threadvars (tables[i]{$ifndef ver3_0}^{$endif});
       copy_unit_threadvars (tables[i]{$ifndef ver3_0}^{$endif});
   end;
   end;
 end;
 end;
+{$endif FPC_SECTION_THREADVARS}
 
 
 procedure InitThreadVars(RelocProc : TRelocateThreadVarHandler);
 procedure InitThreadVars(RelocProc : TRelocateThreadVarHandler);
 
 
 begin
 begin
+{$ifndef FPC_SECTION_THREADVARS}
    { initialize threadvars }
    { initialize threadvars }
    init_all_unit_threadvars;
    init_all_unit_threadvars;
    { allocate mem for main thread threadvars }
    { allocate mem for main thread threadvars }
@@ -112,6 +114,8 @@ begin
    copy_all_unit_threadvars;
    copy_all_unit_threadvars;
    { install threadvar handler }
    { install threadvar handler }
    fpc_threadvar_relocate_proc:=RelocProc;
    fpc_threadvar_relocate_proc:=RelocProc;
+{$endif FPC_SECTION_THREADVARS}
+
 {$ifdef FPC_HAS_FEATURE_HEAP}
 {$ifdef FPC_HAS_FEATURE_HEAP}
 {$ifndef HAS_MEMORYMANAGER}
 {$ifndef HAS_MEMORYMANAGER}
 {$ifndef FPC_NO_DEFAULT_HEAP}
 {$ifndef FPC_NO_DEFAULT_HEAP}

+ 4 - 0
rtl/unix/cthreads.pp

@@ -159,6 +159,7 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
       var
       var
         dataindex : pointer;
         dataindex : pointer;
       begin
       begin
+{$ifndef FPC_SECTION_THREADVARS}
         { we've to allocate the memory from system  }
         { we've to allocate the memory from system  }
         { because the FPC heap management uses      }
         { because the FPC heap management uses      }
         { exceptions which use threadvars but       }
         { exceptions which use threadvars but       }
@@ -167,6 +168,7 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
         DataIndex:=Pointer(Fpmmap(nil,threadvarblocksize,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0));
         DataIndex:=Pointer(Fpmmap(nil,threadvarblocksize,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0));
         FillChar(DataIndex^,threadvarblocksize,0);
         FillChar(DataIndex^,threadvarblocksize,0);
         pthread_setspecific(tlskey,dataindex);
         pthread_setspecific(tlskey,dataindex);
+{$endif FPC_SECTION_THREADVARS}
       end;
       end;
 
 
 
 
@@ -321,7 +323,9 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
       begin
       begin
         { We're still running in single thread mode, setup the TLS }
         { We're still running in single thread mode, setup the TLS }
         pthread_key_create(@TLSKey,nil);
         pthread_key_create(@TLSKey,nil);
+{$ifndef FPC_SECTION_THREADVARS}
         InitThreadVars(@CRelocateThreadvar);
         InitThreadVars(@CRelocateThreadvar);
+{$endif FPC_SECTION_THREADVARS}
         { used to clean up threads that we did not create ourselves:
         { used to clean up threads that we did not create ourselves:
            a) the default value for a key (and hence also this one) in
            a) the default value for a key (and hence also this one) in
               new threads is NULL, and if it's still like that when the
               new threads is NULL, and if it's still like that when the