|
@@ -111,7 +111,7 @@ function DosCreateThread (var TID: cardinal; Address: pointer;
|
|
external 'DOSCALLS' index 311;
|
|
external 'DOSCALLS' index 311;
|
|
|
|
|
|
function DosCreateMutExSem (Name: PChar; var Handle: THandle; Attr: cardinal;
|
|
function DosCreateMutExSem (Name: PChar; var Handle: THandle; Attr: cardinal;
|
|
- State: boolean): cardinal; cdecl; external 'DOSCALLS' index 331;
|
|
|
|
|
|
+ State: cardinal): cardinal; cdecl; external 'DOSCALLS' index 331;
|
|
|
|
|
|
function DosCloseMutExSem (Handle: THandle): cardinal; cdecl;
|
|
function DosCloseMutExSem (Handle: THandle): cardinal; cdecl;
|
|
external 'DOSCALLS' index 333;
|
|
external 'DOSCALLS' index 333;
|
|
@@ -148,7 +148,7 @@ function DosSetPriority (Scope, TrClass: cardinal; Delta: longint;
|
|
external 'DOSCALLS' index 236;
|
|
external 'DOSCALLS' index 236;
|
|
|
|
|
|
function DosCreateEventSem (Name: PChar; var Handle: THandle;
|
|
function DosCreateEventSem (Name: PChar; var Handle: THandle;
|
|
- Attr: cardinal; State: boolean): cardinal; cdecl;
|
|
|
|
|
|
+ Attr: cardinal; State: cardinal): cardinal; cdecl;
|
|
external 'DOSCALLS' index 324;
|
|
external 'DOSCALLS' index 324;
|
|
|
|
|
|
function DosCloseEventSem (Handle: THandle): cardinal; cdecl;
|
|
function DosCloseEventSem (Handle: THandle): cardinal; cdecl;
|
|
@@ -530,7 +530,7 @@ end;
|
|
|
|
|
|
procedure SysInitCriticalSection (var CS);
|
|
procedure SysInitCriticalSection (var CS);
|
|
begin
|
|
begin
|
|
- if DosCreateMutExSem (nil, THandle (CS), 0, false) <> 0 then
|
|
|
|
|
|
+ if DosCreateMutExSem (nil, THandle (CS), 0, 0) <> 0 then
|
|
FPC_ThreadError;
|
|
FPC_ThreadError;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -598,11 +598,15 @@ begin
|
|
Attr := 0
|
|
Attr := 0
|
|
else
|
|
else
|
|
Attr := DCE_AutoReset;
|
|
Attr := DCE_AutoReset;
|
|
- RC := DosCreateEventSem (PChar (Name2), PLocalEventRec (Result)^.FHandle,
|
|
|
|
- Attr, InitialState);
|
|
|
|
|
|
+ if Name2 = '' then
|
|
|
|
+ RC := DosCreateEventSem (nil, PLocalEventRec (Result)^.FHandle,
|
|
|
|
+ Attr, cardinal (InitialState))
|
|
|
|
+ else
|
|
|
|
+ RC := DosCreateEventSem (PChar (Name2), PLocalEventRec (Result)^.FHandle,
|
|
|
|
+ Attr, cardinal (InitialState));
|
|
if RC <> 0 then
|
|
if RC <> 0 then
|
|
begin
|
|
begin
|
|
- FreeMem (Result);
|
|
|
|
|
|
+ Dispose (PLocalEventRec (Result));
|
|
FPC_ThreadError;
|
|
FPC_ThreadError;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -610,8 +614,13 @@ end;
|
|
|
|
|
|
procedure SysBasicEventDestroy (State: PEventState);
|
|
procedure SysBasicEventDestroy (State: PEventState);
|
|
begin
|
|
begin
|
|
- DosCloseEventSem (PLocalEventRec (State)^.FHandle);
|
|
|
|
- Dispose (PLocalEventRec (State));
|
|
|
|
|
|
+ if State = nil then
|
|
|
|
+ FPC_ThreadError
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ DosCloseEventSem (PLocalEventRec (State)^.FHandle);
|
|
|
|
+ Dispose (PLocalEventRec (State));
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -619,13 +628,21 @@ procedure SysBasicEventResetEvent (State: PEventState);
|
|
var
|
|
var
|
|
PostCount: cardinal;
|
|
PostCount: cardinal;
|
|
begin
|
|
begin
|
|
- DosResetEventSem (PLocalEventRec (State)^.FHandle, PostCount);
|
|
|
|
|
|
+ if State = nil then
|
|
|
|
+ FPC_ThreadError
|
|
|
|
+ else
|
|
|
|
+(* In case of later addition of error checking: *)
|
|
|
|
+(* RC 300 = Error_Already_Reset which would be OK. *)
|
|
|
|
+ DosResetEventSem (PLocalEventRec (State)^.FHandle, PostCount);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure SysBasicEventSetEvent (State: PEventState);
|
|
procedure SysBasicEventSetEvent (State: PEventState);
|
|
begin
|
|
begin
|
|
- DosPostEventSem (PLocalEventRec (State)^.FHandle);
|
|
|
|
|
|
+ if State = nil then
|
|
|
|
+ FPC_ThreadError
|
|
|
|
+ else
|
|
|
|
+ DosPostEventSem (PLocalEventRec (State)^.FHandle);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -633,23 +650,28 @@ function SysBasicEventWaitFor (Timeout: Cardinal; State: PEventState): longint;
|
|
var
|
|
var
|
|
RC: cardinal;
|
|
RC: cardinal;
|
|
begin
|
|
begin
|
|
- RC := DosWaitEventSem (PLocalEventRec (State)^.FHandle, Timeout);
|
|
|
|
- case RC of
|
|
|
|
- 0: Result := wrSignaled;
|
|
|
|
- Error_Timeout: Result := wrTimeout;
|
|
|
|
|
|
+ if State = nil then
|
|
|
|
+ FPC_ThreadError
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- Result := wrError;
|
|
|
|
- PLocalEventRec (State)^.FLastError := RC;
|
|
|
|
|
|
+ RC := DosWaitEventSem (PLocalEventRec (State)^.FHandle, Timeout);
|
|
|
|
+ case RC of
|
|
|
|
+ 0: Result := wrSignaled;
|
|
|
|
+ Error_Timeout: Result := wrTimeout;
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ Result := wrError;
|
|
|
|
+ PLocalEventRec (State)^.FLastError := RC;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
function SysRTLEventCreate: PRTLEvent;
|
|
function SysRTLEventCreate: PRTLEvent;
|
|
begin
|
|
begin
|
|
Result := PRTLEvent (-1);
|
|
Result := PRTLEvent (-1);
|
|
- DosCreateEventSem (nil, THandle (Result), dce_AutoReset, false);
|
|
|
|
|
|
+ DosCreateEventSem (nil, THandle (Result), dce_AutoReset, 0);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|