Skip to content

Commit d3a55ff

Browse files
committed
core: fixed TMultiLightLock alignment on Windows
- ensure is two pointers
1 parent 3fe0f98 commit d3a55ff

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/core/mormot.core.os.pas

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,9 +4261,9 @@ TMultiLightLock = record
42614261
TMultiLightLock = object
42624262
{$endif USERECORDWITHMETHODS}
42634263
private
4264-
Flags: PtrUInt; // is also the reentrant > 0 counter
4265-
ThreadID: TThreadID; // pointer on POSIX, DWord on Windows
4266-
procedure LockSpin; // called by the Lock method when inlined
4264+
Flags: PtrUInt; // is also the reentrant > 0 counter
4265+
ThreadID: pointer; // TThreadID is pointer on POSIX, DWord on Windows
4266+
procedure LockSpin; // called by the Lock method when inlined
42674267
public
42684268
/// to be called if the instance has not been filled with 0
42694269
// - e.g. not needed if TMultiLightLock is defined as a class field
@@ -10494,13 +10494,13 @@ procedure TCachedValue.Cache(Call: TCachedValueCall; CallParam: pointer;
1049410494
procedure TMultiLightLock.Init;
1049510495
begin
1049610496
Flags := 0;
10497-
ThreadID := TThreadID(0);
10497+
ThreadID := nil;
1049810498
end;
1049910499

1050010500
procedure TMultiLightLock.Done;
1050110501
begin
10502-
Flags := PtrUInt(-1);
10503-
ThreadID := TThreadID(0); // invalid combination to let TryLock fail
10502+
Flags := MaxInt;
10503+
ThreadID := nil; // invalid combination to let TryLock fail
1050410504
end;
1050510505

1050610506
procedure TMultiLightLock.Lock;
@@ -10512,15 +10512,15 @@ procedure TMultiLightLock.Lock;
1051210512
procedure TMultiLightLock.UnLock;
1051310513
begin
1051410514
if Flags = 1 then
10515-
ThreadID := TThreadID(0); // paranoid
10515+
ThreadID := nil; // paranoid
1051610516
LockedDec(Flags, 1);
1051710517
end;
1051810518

1051910519
function TMultiLightLock.TryLock: boolean;
1052010520
var
10521-
tid: TThreadID;
10521+
tid: pointer;
1052210522
begin
10523-
tid := GetCurrentThreadId;
10523+
tid := pointer(GetCurrentThreadId);
1052410524
if Flags = 0 then // is not locked
1052510525
if LockedExc(Flags, {to=}1, {from=}0) then // try atomic acquisition
1052610526
begin
@@ -10541,7 +10541,7 @@ function TMultiLightLock.TryLock: boolean;
1054110541
procedure TMultiLightLock.ForceLock;
1054210542
begin
1054310543
Flags := MaxInt; // forced acquisition, whatever the current state is
10544-
ThreadID := GetCurrentThreadId;
10544+
ThreadID := pointer(GetCurrentThreadId);
1054510545
end;
1054610546

1054710547
function TMultiLightLock.IsLocked: boolean;

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.4.14829'
1+
'2.4.14830'

0 commit comments

Comments
 (0)