mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 11:39:24 +02:00
amicommon: fixed sysdir.inc/do_chdir() to actually work on AROS
- fixed all Amiga-like system units to not leak the last directory lock while changing back to the original dir in System_exit; (a bug found by Marcus Sackrow, thanks!) * renamed AOS_origDir to ASYS_origDir git-svn-id: trunk@28537 -
This commit is contained in:
parent
1e11e34f42
commit
ef5f1b7ed2
@ -69,10 +69,10 @@ begin
|
|||||||
FIB:=nil;
|
FIB:=nil;
|
||||||
new(FIB);
|
new(FIB);
|
||||||
|
|
||||||
if (Examine(tmpLock,FIB)>0) and (FIB^.fib_DirEntryType>0) then begin
|
if (Examine(tmpLock,FIB)<>0) and (FIB^.fib_DirEntryType>0) then begin
|
||||||
tmpLock:=CurrentDir(tmpLock);
|
tmpLock:=CurrentDir(tmpLock);
|
||||||
if AOS_OrigDir=0 then begin
|
if ASYS_OrigDir=0 then begin
|
||||||
AOS_OrigDir:=tmpLock;
|
ASYS_OrigDir:=tmpLock;
|
||||||
tmpLock:=0;
|
tmpLock:=0;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
|
@ -78,7 +78,7 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
ASYS_heapPool : Pointer; { pointer for the OS pool for growing the heap }
|
ASYS_heapPool : Pointer; { pointer for the OS pool for growing the heap }
|
||||||
AOS_origDir : LongInt; { original directory on startup }
|
ASYS_origDir : LongInt; { original directory on startup }
|
||||||
AOS_wbMsg : Pointer; public name '_WBenchMsg'; { the "public" part is amunits compatibility kludge }
|
AOS_wbMsg : Pointer; public name '_WBenchMsg'; { the "public" part is amunits compatibility kludge }
|
||||||
_WBenchMsg : Pointer; external name '_WBenchMsg'; { amunits compatibility kludge }
|
_WBenchMsg : Pointer; external name '_WBenchMsg'; { amunits compatibility kludge }
|
||||||
AOS_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
|
AOS_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
|
||||||
@ -132,6 +132,8 @@ implementation
|
|||||||
procedure haltproc(e:longint);cdecl;external name '_haltproc';
|
procedure haltproc(e:longint);cdecl;external name '_haltproc';
|
||||||
|
|
||||||
procedure System_exit;
|
procedure System_exit;
|
||||||
|
var
|
||||||
|
oldDirLock: LongInt;
|
||||||
begin
|
begin
|
||||||
{ We must remove the CTRL-C FLAG here because halt }
|
{ We must remove the CTRL-C FLAG here because halt }
|
||||||
{ may call I/O routines, which in turn might call }
|
{ may call I/O routines, which in turn might call }
|
||||||
@ -145,8 +147,11 @@ begin
|
|||||||
CloseList(ASYS_fileList);
|
CloseList(ASYS_fileList);
|
||||||
|
|
||||||
{ Changing back to original directory if changed }
|
{ Changing back to original directory if changed }
|
||||||
if AOS_origDir<>0 then begin
|
if ASYS_origDir<>0 then begin
|
||||||
CurrentDir(AOS_origDir);
|
oldDirLock:=CurrentDir(ASYS_origDir);
|
||||||
|
{ unlock our lock if its safe, so we won't leak the lock }
|
||||||
|
if (oldDirLock<>0) and (oldDirLock<>ASYS_origDir) then
|
||||||
|
Unlock(oldDirLock);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF AMIGAOS4}
|
{$IFDEF AMIGAOS4}
|
||||||
@ -393,7 +398,7 @@ begin
|
|||||||
StackBottom := Sptr - StackLength;
|
StackBottom := Sptr - StackLength;
|
||||||
{ OS specific startup }
|
{ OS specific startup }
|
||||||
AOS_wbMsg:=nil;
|
AOS_wbMsg:=nil;
|
||||||
AOS_origDir:=0;
|
ASYS_origDir:=0;
|
||||||
ASYS_fileList:=nil;
|
ASYS_fileList:=nil;
|
||||||
envp:=nil;
|
envp:=nil;
|
||||||
SysInitAmigaOS;
|
SysInitAmigaOS;
|
||||||
|
@ -66,7 +66,7 @@ var
|
|||||||
|
|
||||||
|
|
||||||
ASYS_heapPool : Pointer; { pointer for the OS pool for growing the heap }
|
ASYS_heapPool : Pointer; { pointer for the OS pool for growing the heap }
|
||||||
AOS_origDir : LongInt; { original directory on startup }
|
ASYS_origDir : LongInt; { original directory on startup }
|
||||||
AOS_wbMsg : Pointer;
|
AOS_wbMsg : Pointer;
|
||||||
AOS_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
|
AOS_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
|
||||||
AOS_ConHandle: THandle;
|
AOS_ConHandle: THandle;
|
||||||
@ -114,7 +114,7 @@ procedure haltproc(e:longint); cdecl; external name '_haltproc';
|
|||||||
|
|
||||||
procedure System_exit;
|
procedure System_exit;
|
||||||
var
|
var
|
||||||
a: LongInt;
|
oldDirLock: LongInt;
|
||||||
begin
|
begin
|
||||||
if Killed then
|
if Killed then
|
||||||
Exit;
|
Exit;
|
||||||
@ -125,8 +125,11 @@ begin
|
|||||||
if AOS_wbMsg <> nil then
|
if AOS_wbMsg <> nil then
|
||||||
ReplyMsg(AOS_wbMsg);
|
ReplyMsg(AOS_wbMsg);
|
||||||
{ Changing back to original directory if changed }
|
{ Changing back to original directory if changed }
|
||||||
if AOS_OrigDir <> 0 then begin
|
if ASYS_OrigDir <> 0 then begin
|
||||||
CurrentDir(AOS_origDir);
|
oldDirLock:=CurrentDir(ASYS_origDir);
|
||||||
|
{ unlock our lock if its safe, so we won't leak the lock }
|
||||||
|
if (oldDirLock<>0) and (oldDirLock<>ASYS_origDir) then
|
||||||
|
Unlock(oldDirLock);
|
||||||
end;
|
end;
|
||||||
if AOS_UtilityBase <> nil then
|
if AOS_UtilityBase <> nil then
|
||||||
CloseLibrary(AOS_UtilityBase);
|
CloseLibrary(AOS_UtilityBase);
|
||||||
@ -448,7 +451,7 @@ begin
|
|||||||
StackBottom := Sptr - StackLength;
|
StackBottom := Sptr - StackLength;
|
||||||
{ OS specific startup }
|
{ OS specific startup }
|
||||||
AOS_wbMsg := nil;
|
AOS_wbMsg := nil;
|
||||||
AOS_origDir := 0;
|
ASYS_origDir := 0;
|
||||||
ASYS_fileList := nil;
|
ASYS_fileList := nil;
|
||||||
envp := nil;
|
envp := nil;
|
||||||
SysInitAmigaOS;
|
SysInitAmigaOS;
|
||||||
|
@ -63,7 +63,7 @@ var
|
|||||||
MOS_UtilityBase: Pointer;
|
MOS_UtilityBase: Pointer;
|
||||||
|
|
||||||
ASYS_heapPool : Pointer; { pointer for the OS pool for growing the heap }
|
ASYS_heapPool : Pointer; { pointer for the OS pool for growing the heap }
|
||||||
AOS_origDir : LongInt; { original directory on startup }
|
ASYS_origDir : LongInt; { original directory on startup }
|
||||||
MOS_ambMsg : Pointer;
|
MOS_ambMsg : Pointer;
|
||||||
MOS_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
|
MOS_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
|
||||||
MOS_ConHandle: LongInt;
|
MOS_ConHandle: LongInt;
|
||||||
@ -93,6 +93,8 @@ implementation
|
|||||||
procedure haltproc(e:longint);cdecl;external name '_haltproc';
|
procedure haltproc(e:longint);cdecl;external name '_haltproc';
|
||||||
|
|
||||||
procedure System_exit;
|
procedure System_exit;
|
||||||
|
var
|
||||||
|
oldDirLock: LongInt;
|
||||||
begin
|
begin
|
||||||
{ We must remove the CTRL-C FLAG here because halt }
|
{ We must remove the CTRL-C FLAG here because halt }
|
||||||
{ may call I/O routines, which in turn might call }
|
{ may call I/O routines, which in turn might call }
|
||||||
@ -106,8 +108,11 @@ begin
|
|||||||
CloseList(ASYS_fileList);
|
CloseList(ASYS_fileList);
|
||||||
|
|
||||||
{ Changing back to original directory if changed }
|
{ Changing back to original directory if changed }
|
||||||
if AOS_origDir<>0 then begin
|
if ASYS_origDir<>0 then begin
|
||||||
CurrentDir(AOS_origDir);
|
oldDirLock:=CurrentDir(ASYS_origDir);
|
||||||
|
{ unlock our lock if its safe, so we won't leak the lock }
|
||||||
|
if (oldDirLock<>0) and (oldDirLock<>ASYS_origDir) then
|
||||||
|
Unlock(oldDirLock);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Closing CON: when in Ambient mode }
|
{ Closing CON: when in Ambient mode }
|
||||||
@ -405,7 +410,7 @@ begin
|
|||||||
StackBottom := Sptr - StackLength;
|
StackBottom := Sptr - StackLength;
|
||||||
{ OS specific startup }
|
{ OS specific startup }
|
||||||
MOS_ambMsg:=nil;
|
MOS_ambMsg:=nil;
|
||||||
AOS_origDir:=0;
|
ASYS_origDir:=0;
|
||||||
ASYS_fileList:=nil;
|
ASYS_fileList:=nil;
|
||||||
envp:=nil;
|
envp:=nil;
|
||||||
SysInitMorphOS;
|
SysInitMorphOS;
|
||||||
|
Loading…
Reference in New Issue
Block a user