mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 23:19:24 +02:00
+ Added missing criticalsection handlers
git-svn-id: trunk@946 -
This commit is contained in:
parent
1c9a8396b7
commit
539436ed57
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1299,6 +1299,7 @@ packages/base/libc/printfh.inc svneol=native#text/plain
|
||||
packages/base/libc/proutedh.inc svneol=native#text/plain
|
||||
packages/base/libc/prwhodh.inc svneol=native#text/plain
|
||||
packages/base/libc/ptalkdh.inc svneol=native#text/plain
|
||||
packages/base/libc/pthread.inc svneol=native#text/plain
|
||||
packages/base/libc/pthreadh.inc svneol=native#text/plain
|
||||
packages/base/libc/pthreadtypesh.inc svneol=native#text/plain
|
||||
packages/base/libc/ptimedh.inc svneol=native#text/plain
|
||||
|
@ -249,5 +249,6 @@ uses kernelioctl;
|
||||
{$i nif_ether.inc} // netinet/if_ether.h macros.
|
||||
{$i nicmp6.inc} // netinet/icmp6.h macros.
|
||||
{$i nip_icmp.inc} // netinet/ip_icmp.h macros.
|
||||
{$i pthread.inc} // pthread.h Kylix compatibility.
|
||||
|
||||
end.
|
||||
|
23
packages/base/libc/pthread.inc
Normal file
23
packages/base/libc/pthread.inc
Normal file
@ -0,0 +1,23 @@
|
||||
Function InitializeCriticalSection(var lpCriticalSection: TRTLCriticalSection): Integer;
|
||||
|
||||
var
|
||||
Attr : pthread_mutexattr_t;
|
||||
|
||||
begin
|
||||
Result:=pthread_mutexattr_init(Attr);
|
||||
if Result=0 then
|
||||
Try
|
||||
Result:=pthread_mutexattr_settype(Attr,PTHREAD_MUTEX_RECURSIVE);
|
||||
if Result=0 then
|
||||
Result:=pthread_mutex_init(lpCriticalSection, Attr);
|
||||
Finally
|
||||
pthread_mutexattr_destroy(Attr);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TryEnterCriticalSection(var lpCriticalSection: TRTLCriticalSection): Boolean;
|
||||
begin
|
||||
Result:=EBUSY<>pthread_mutex_trylock(lpCriticalSection);
|
||||
end;
|
||||
|
||||
|
@ -255,7 +255,12 @@ function pthread_sigmask(__how:longint; var __newmask:__sigset_t; var __oldmask:
|
||||
{ Borland compatibility }
|
||||
|
||||
function GetCurrentThreadID: TTHreadID ; cdecl; external threadslib name 'pthread_self';
|
||||
|
||||
function InitializeCriticalSection(var lpCriticalSection: TRTLCriticalSection): Integer;
|
||||
function EnterCriticalSection(var lpCriticalSection: TRTLCriticalSection): Integer; cdecl; external threadslib name 'pthread_mutex_lock';
|
||||
function LeaveCriticalSection(var lpCriticalSection: TRTLCriticalSection): Integer; cdecl; external threadslib name 'pthread_mutex_unlock';
|
||||
function TryEnterCriticalSection(var lpCriticalSection: TRTLCriticalSection): Boolean;
|
||||
function DeleteCriticalSection(var lpCriticalSection: TRTLCriticalSection): Integer; cdecl; external threadslib name 'pthread_mutex_destroy';
|
||||
|
||||
Type
|
||||
TPThreadFunc = function(Parameter: Pointer): Integer; cdecl;
|
||||
PPthreadCleanupBuffer = ^_pthread_cleanup_buffer;
|
Loading…
Reference in New Issue
Block a user