mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 11:39:40 +01:00 
			
		
		
		
	* cleans up linux leftovers in other BSD targets
git-svn-id: trunk@4844 -
This commit is contained in:
		
							parent
							
								
									e70a5f1ae7
								
							
						
					
					
						commit
						0ce5904349
					
				@ -95,9 +95,6 @@ end;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  ThreadsInited: boolean = false;
 | 
			
		||||
{$IFDEF LINUX}
 | 
			
		||||
  GMainPID: LongInt = 0;
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
const
 | 
			
		||||
  // stupid, considering its not even implemented...
 | 
			
		||||
  Priorities: array [TThreadPriority] of Integer =
 | 
			
		||||
@ -107,9 +104,6 @@ procedure InitThreads;
 | 
			
		||||
begin
 | 
			
		||||
  if not ThreadsInited then begin
 | 
			
		||||
    ThreadsInited := true;
 | 
			
		||||
    {$IFDEF LINUX}
 | 
			
		||||
    GMainPid := fpgetpid();
 | 
			
		||||
    {$ENDIF}
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
@ -134,12 +128,6 @@ var
 | 
			
		||||
begin
 | 
			
		||||
  WRITE_DEBUG('ThreadFunc is here...');
 | 
			
		||||
  LThread := TThread(parameter);
 | 
			
		||||
  {$IFDEF LINUX}
 | 
			
		||||
  // save the PID of the "thread"
 | 
			
		||||
  // this is different from the PID of the main thread if
 | 
			
		||||
  // the LinuxThreads implementation is used
 | 
			
		||||
  LThread.FPid := fpgetpid();
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  WRITE_DEBUG('thread initing, parameter = ', LongInt(LThread));
 | 
			
		||||
  try
 | 
			
		||||
    if LThread.FInitialSuspended then begin
 | 
			
		||||
@ -235,22 +223,7 @@ begin
 | 
			
		||||
      SemaphoreWait(FSem);
 | 
			
		||||
    end else begin
 | 
			
		||||
      FSuspendedExternal := true;
 | 
			
		||||
{$IFDEF LINUX}
 | 
			
		||||
      // naughty hack if the user doesn't have Linux with NPTL...
 | 
			
		||||
      // in that case, the PID of threads will not be identical
 | 
			
		||||
      // to the other threads, which means that our thread is a normal
 | 
			
		||||
      // process that we can suspend via SIGSTOP...
 | 
			
		||||
      // this violates POSIX, but is the way it works on the
 | 
			
		||||
      // LinuxThreads pthread implementation. Not with NPTL, but in that case
 | 
			
		||||
      // getpid(2) also behaves properly and returns the same PID for
 | 
			
		||||
      // all threads. Thats actually (FINALLY!) native thread support :-)
 | 
			
		||||
      if FPid <> GMainPID then begin
 | 
			
		||||
        FSuspended := true;
 | 
			
		||||
        fpkill(FPid, SIGSTOP);
 | 
			
		||||
      end;
 | 
			
		||||
{$ELSE}
 | 
			
		||||
      SuspendThread(FHandle);
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
@ -105,9 +105,6 @@ end;
 | 
			
		||||
 | 
			
		||||
var
 | 
			
		||||
  ThreadsInited: boolean = false;
 | 
			
		||||
{$IFDEF LINUX}
 | 
			
		||||
  GMainPID: LongInt = 0;
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
const
 | 
			
		||||
  // stupid, considering its not even implemented...
 | 
			
		||||
  Priorities: array [TThreadPriority] of Integer =
 | 
			
		||||
@ -117,9 +114,6 @@ procedure InitThreads;
 | 
			
		||||
begin
 | 
			
		||||
  if not ThreadsInited then begin
 | 
			
		||||
    ThreadsInited := true;
 | 
			
		||||
    {$IFDEF LINUX}
 | 
			
		||||
    GMainPid := fpgetpid();
 | 
			
		||||
    {$ENDIF}
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
@ -144,12 +138,6 @@ var
 | 
			
		||||
begin
 | 
			
		||||
  WRITE_DEBUG('ThreadFunc is here...');
 | 
			
		||||
  LThread := TThread(parameter);
 | 
			
		||||
  {$IFDEF LINUX}
 | 
			
		||||
  // save the PID of the "thread"
 | 
			
		||||
  // this is different from the PID of the main thread if
 | 
			
		||||
  // the LinuxThreads implementation is used
 | 
			
		||||
  LThread.FPid := fpgetpid();
 | 
			
		||||
  {$ENDIF}
 | 
			
		||||
  WRITE_DEBUG('thread initing, parameter = ', LongInt(LThread));
 | 
			
		||||
  try
 | 
			
		||||
    if LThread.FInitialSuspended then begin
 | 
			
		||||
@ -244,22 +232,7 @@ begin
 | 
			
		||||
      SemaphoreWait(FSem);
 | 
			
		||||
    end else begin
 | 
			
		||||
      FSuspendedExternal := true;
 | 
			
		||||
{$IFDEF LINUX}
 | 
			
		||||
      // naughty hack if the user doesn't have Linux with NPTL...
 | 
			
		||||
      // in that case, the PID of threads will not be identical
 | 
			
		||||
      // to the other threads, which means that our thread is a normal
 | 
			
		||||
      // process that we can suspend via SIGSTOP...
 | 
			
		||||
      // this violates POSIX, but is the way it works on the
 | 
			
		||||
      // LinuxThreads pthread implementation. Not with NPTL, but in that case
 | 
			
		||||
      // getpid(2) also behaves properly and returns the same PID for
 | 
			
		||||
      // all threads. Thats actually (FINALLY!) native thread support :-)
 | 
			
		||||
      if FPid <> GMainPID then begin
 | 
			
		||||
        FSuspended := true;
 | 
			
		||||
        fpkill(FPid, SIGSTOP);
 | 
			
		||||
      end;
 | 
			
		||||
{$ELSE}
 | 
			
		||||
      SuspendThread(FHandle);
 | 
			
		||||
{$ENDIF}
 | 
			
		||||
    end;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user