mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-25 11:42:10 +02: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
|
var
|
||||||
ThreadsInited: boolean = false;
|
ThreadsInited: boolean = false;
|
||||||
{$IFDEF LINUX}
|
|
||||||
GMainPID: LongInt = 0;
|
|
||||||
{$ENDIF}
|
|
||||||
const
|
const
|
||||||
// stupid, considering its not even implemented...
|
// stupid, considering its not even implemented...
|
||||||
Priorities: array [TThreadPriority] of Integer =
|
Priorities: array [TThreadPriority] of Integer =
|
||||||
@ -107,9 +104,6 @@ procedure InitThreads;
|
|||||||
begin
|
begin
|
||||||
if not ThreadsInited then begin
|
if not ThreadsInited then begin
|
||||||
ThreadsInited := true;
|
ThreadsInited := true;
|
||||||
{$IFDEF LINUX}
|
|
||||||
GMainPid := fpgetpid();
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -134,12 +128,6 @@ var
|
|||||||
begin
|
begin
|
||||||
WRITE_DEBUG('ThreadFunc is here...');
|
WRITE_DEBUG('ThreadFunc is here...');
|
||||||
LThread := TThread(parameter);
|
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));
|
WRITE_DEBUG('thread initing, parameter = ', LongInt(LThread));
|
||||||
try
|
try
|
||||||
if LThread.FInitialSuspended then begin
|
if LThread.FInitialSuspended then begin
|
||||||
@ -235,22 +223,7 @@ begin
|
|||||||
SemaphoreWait(FSem);
|
SemaphoreWait(FSem);
|
||||||
end else begin
|
end else begin
|
||||||
FSuspendedExternal := true;
|
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);
|
SuspendThread(FHandle);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -105,9 +105,6 @@ end;
|
|||||||
|
|
||||||
var
|
var
|
||||||
ThreadsInited: boolean = false;
|
ThreadsInited: boolean = false;
|
||||||
{$IFDEF LINUX}
|
|
||||||
GMainPID: LongInt = 0;
|
|
||||||
{$ENDIF}
|
|
||||||
const
|
const
|
||||||
// stupid, considering its not even implemented...
|
// stupid, considering its not even implemented...
|
||||||
Priorities: array [TThreadPriority] of Integer =
|
Priorities: array [TThreadPriority] of Integer =
|
||||||
@ -117,9 +114,6 @@ procedure InitThreads;
|
|||||||
begin
|
begin
|
||||||
if not ThreadsInited then begin
|
if not ThreadsInited then begin
|
||||||
ThreadsInited := true;
|
ThreadsInited := true;
|
||||||
{$IFDEF LINUX}
|
|
||||||
GMainPid := fpgetpid();
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -144,12 +138,6 @@ var
|
|||||||
begin
|
begin
|
||||||
WRITE_DEBUG('ThreadFunc is here...');
|
WRITE_DEBUG('ThreadFunc is here...');
|
||||||
LThread := TThread(parameter);
|
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));
|
WRITE_DEBUG('thread initing, parameter = ', LongInt(LThread));
|
||||||
try
|
try
|
||||||
if LThread.FInitialSuspended then begin
|
if LThread.FInitialSuspended then begin
|
||||||
@ -244,22 +232,7 @@ begin
|
|||||||
SemaphoreWait(FSem);
|
SemaphoreWait(FSem);
|
||||||
end else begin
|
end else begin
|
||||||
FSuspendedExternal := true;
|
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);
|
SuspendThread(FHandle);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user