11 |
|
cWriterBusyEventSemaphore = 8; |
12 |
|
cDefaultTimeout = 1; { 1 seconds } |
13 |
|
|
14 |
+ |
{$IF FPC_FULLVERSION = 30000 } |
15 |
+ |
{Fix regression in FPC 3.0.0 ipc.pp unit. Expected to be fixed in fpc 3.0.2} |
16 |
+ |
{$IF defined(darwin) } |
17 |
+ |
SEM_GETNCNT = 3; { Return the value of sempid (READ) } |
18 |
+ |
SEM_GETPID = 4; { Return the value of semval (READ) } |
19 |
+ |
SEM_GETVAL = 5; { Return semvals into arg.array (READ) } |
20 |
+ |
SEM_GETALL = 6; { Return the value of semzcnt (READ) } |
21 |
+ |
SEM_GETZCNT = 7; { Set the value of semval to arg.val (ALTER) } |
22 |
+ |
SEM_SETVAL = 8; { Set semvals from arg.array (ALTER) } |
23 |
+ |
SEM_SETALL = 9; |
24 |
+ |
{$ENDIF} |
25 |
+ |
{$ENDIF} |
26 |
+ |
|
27 |
|
{ |
28 |
|
The call to semctl in ipc is broken in FPC release 2.4.2 and earlier. Hence |
29 |
|
need to replace with a working libc call. semtimedop is not present in 2.4.2 and earlier. |
30 |
|
} |
31 |
|
|
19 |
– |
{$IF FPC_FULLVERSION <= 20402 } |
20 |
– |
Function real_semctl(semid:cint; semnum:cint; cmd:cint): cint; cdecl; varargs; external clib name 'semctl'; |
21 |
– |
|
22 |
– |
Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint; |
23 |
– |
begin |
24 |
– |
semctl := real_semctl(semid,semnum,cmd,pointer(arg)); |
25 |
– |
end; |
26 |
– |
{$IFDEF HAS_SEMTIMEDOP} |
27 |
– |
Function semtimedop(semid:cint; sops: psembuf; nsops: cuint; timeOut: ptimespec): cint; cdecl; external clib name 'semtimedop'; |
28 |
– |
{$ENDIF} |
29 |
– |
Function semget(key:Tkey; nsems:cint; semflg:cint): cint; cdecl; external clib name 'semget'; |
30 |
– |
Function semop(semid:cint; sops: psembuf; nsops: cuint): cint; cdecl; external clib name 'semop'; |
31 |
– |
|
32 |
– |
function GetLastErrno: cint; |
33 |
– |
begin |
34 |
– |
Result := fpgetCerrno |
35 |
– |
end; |
36 |
– |
{$ELSE} |
32 |
|
function GetLastErrno: cint; |
33 |
|
begin |
34 |
|
Result := fpgetErrno |
35 |
|
end; |
36 |
|
|
42 |
– |
{$ENDIF} |
43 |
– |
|
37 |
|
type |
38 |
|
TGlobalInterface = class; |
39 |
|
{Interprocess Communication Objects. All platform dependent IPC is abstracted |
249 |
|
F := fpOpen(IPCFileName, O_WrOnly or O_Creat or O_Excl); |
250 |
|
if F < 0 then |
251 |
|
begin |
252 |
< |
if fpgetErrno = 17 {EEXIST} then |
252 |
> |
if fpgetErrno = ESysEEXIST {EEXIST} then |
253 |
|
begin |
254 |
|
{ looks like it already exists} |
255 |
|
Sleep(100); |
256 |
|
F := fpOpen(IPCFileName,O_RdOnly); |
257 |
< |
if (F < 0) and (fpgetErrno = 2 {ENOENT}) then |
257 |
> |
if (F < 0) and (fpgetErrno = ESysENOENT {ENOENT}) then |
258 |
|
{probably just got deleted } |
259 |
|
else |
260 |
|
if F < 0 then |