mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 20:20:16 +02:00
* fix for Mantis #36950: apply (slightly adjusted) patch by Bi0T1N to implement SetThreadDebugNameA and -U for Linux and Android targets
git-svn-id: trunk@45233 -
This commit is contained in:
parent
3d2945726a
commit
0906714aa4
@ -191,6 +191,7 @@ Type
|
|||||||
function sem_getvalue (__sem:Psem_t; __sval:Plongint):longint;cdecl;external;
|
function sem_getvalue (__sem:Psem_t; __sval:Plongint):longint;cdecl;external;
|
||||||
|
|
||||||
function pthread_mutexattr_settype (__attr: Ppthread_mutexattr_t; Kind:Integer): Integer; cdecl;external;
|
function pthread_mutexattr_settype (__attr: Ppthread_mutexattr_t; Kind:Integer): Integer; cdecl;external;
|
||||||
|
function pthread_setname_np(thread: pthread_t; name: PAnsiChar):cint;cdecl;external;
|
||||||
|
|
||||||
{$else}
|
{$else}
|
||||||
Var
|
Var
|
||||||
@ -272,6 +273,7 @@ Var
|
|||||||
sem_getvalue : function (__sem:Psem_t; __sval:Plongint):longint;cdecl;
|
sem_getvalue : function (__sem:Psem_t; __sval:Plongint):longint;cdecl;
|
||||||
|
|
||||||
pthread_mutexattr_settype : function(__attr: Ppthread_mutexattr_t; Kind:Integer): Integer; cdecl;
|
pthread_mutexattr_settype : function(__attr: Ppthread_mutexattr_t; Kind:Integer): Integer; cdecl;
|
||||||
|
pthread_setname_np : function(thread: pthread_t; name: PAnsiChar):cint;cdecl;
|
||||||
|
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -363,6 +365,7 @@ begin
|
|||||||
Pointer(sem_post ) := dlsym(PthreadDLL,'sem_post');
|
Pointer(sem_post ) := dlsym(PthreadDLL,'sem_post');
|
||||||
Pointer(sem_getvalue ) := dlsym(PthreadDLL,'sem_getvalue');
|
Pointer(sem_getvalue ) := dlsym(PthreadDLL,'sem_getvalue');
|
||||||
Pointer(pthread_mutexattr_settype) := dlsym(PthreadDLL,'pthread_mutexattr_settype');
|
Pointer(pthread_mutexattr_settype) := dlsym(PthreadDLL,'pthread_mutexattr_settype');
|
||||||
|
Pointer(pthread_setname_np) := dlsym(PthreadDLL,'pthread_setname_np');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function UnLoadPthreads : Boolean;
|
Function UnLoadPthreads : Boolean;
|
||||||
|
@ -488,14 +488,45 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
|||||||
|
|
||||||
|
|
||||||
procedure CSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
|
procedure CSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
|
||||||
|
{$if defined(Linux) or defined(Android)}
|
||||||
|
var
|
||||||
|
CuttedName: AnsiString;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
{$Warning SetThreadDebugName needs to be implemented}
|
{$if defined(Linux) or defined(Android)}
|
||||||
|
{$ifdef dynpthreads}
|
||||||
|
if Assigned(pthread_setname_np) then
|
||||||
|
{$endif dynpthreads}
|
||||||
|
begin
|
||||||
|
// length restricted to 16 characters including terminating null byte
|
||||||
|
CuttedName:=Copy(ThreadName, 1, 15);
|
||||||
|
if threadHandle=TThreadID(-1) then
|
||||||
|
begin
|
||||||
|
pthread_setname_np(pthread_self(), @CuttedName[1]);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
pthread_setname_np(pthread_t(threadHandle), @CuttedName[1]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
|
{$Warning SetThreadDebugName needs to be implemented}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure CSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
|
procedure CSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
|
||||||
begin
|
begin
|
||||||
{$Warning SetThreadDebugName needs to be implemented}
|
{$if defined(Linux) or defined(Android)}
|
||||||
|
{$ifdef dynpthreads}
|
||||||
|
if Assigned(pthread_setname_np) then
|
||||||
|
{$endif dynpthreads}
|
||||||
|
begin
|
||||||
|
CSetThreadDebugNameA(threadHandle, AnsiString(ThreadName));
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
|
{$Warning SetThreadDebugName needs to be implemented}
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user