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:
Károly Balogh 2014-08-30 00:58:42 +00:00
parent 1e11e34f42
commit ef5f1b7ed2
4 changed files with 29 additions and 16 deletions

View File

@ -69,10 +69,10 @@ begin
FIB:=nil;
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);
if AOS_OrigDir=0 then begin
AOS_OrigDir:=tmpLock;
if ASYS_OrigDir=0 then begin
ASYS_OrigDir:=tmpLock;
tmpLock:=0;
end;
end else begin

View File

@ -78,7 +78,7 @@ var
{$ENDIF}
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 }
_WBenchMsg : Pointer; external name '_WBenchMsg'; { amunits compatibility kludge }
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 System_exit;
var
oldDirLock: LongInt;
begin
{ We must remove the CTRL-C FLAG here because halt }
{ may call I/O routines, which in turn might call }
@ -145,8 +147,11 @@ begin
CloseList(ASYS_fileList);
{ Changing back to original directory if changed }
if AOS_origDir<>0 then begin
CurrentDir(AOS_origDir);
if ASYS_origDir<>0 then begin
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;
{$IFDEF AMIGAOS4}
@ -393,7 +398,7 @@ begin
StackBottom := Sptr - StackLength;
{ OS specific startup }
AOS_wbMsg:=nil;
AOS_origDir:=0;
ASYS_origDir:=0;
ASYS_fileList:=nil;
envp:=nil;
SysInitAmigaOS;

View File

@ -66,7 +66,7 @@ var
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_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
AOS_ConHandle: THandle;
@ -114,7 +114,7 @@ procedure haltproc(e:longint); cdecl; external name '_haltproc';
procedure System_exit;
var
a: LongInt;
oldDirLock: LongInt;
begin
if Killed then
Exit;
@ -125,8 +125,11 @@ begin
if AOS_wbMsg <> nil then
ReplyMsg(AOS_wbMsg);
{ Changing back to original directory if changed }
if AOS_OrigDir <> 0 then begin
CurrentDir(AOS_origDir);
if ASYS_OrigDir <> 0 then begin
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;
if AOS_UtilityBase <> nil then
CloseLibrary(AOS_UtilityBase);
@ -448,7 +451,7 @@ begin
StackBottom := Sptr - StackLength;
{ OS specific startup }
AOS_wbMsg := nil;
AOS_origDir := 0;
ASYS_origDir := 0;
ASYS_fileList := nil;
envp := nil;
SysInitAmigaOS;

View File

@ -63,7 +63,7 @@ var
MOS_UtilityBase: Pointer;
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_ConName : PChar ='CON:10/30/620/100/FPC Console Output/AUTO/CLOSE/WAIT';
MOS_ConHandle: LongInt;
@ -93,6 +93,8 @@ implementation
procedure haltproc(e:longint);cdecl;external name '_haltproc';
procedure System_exit;
var
oldDirLock: LongInt;
begin
{ We must remove the CTRL-C FLAG here because halt }
{ may call I/O routines, which in turn might call }
@ -106,8 +108,11 @@ begin
CloseList(ASYS_fileList);
{ Changing back to original directory if changed }
if AOS_origDir<>0 then begin
CurrentDir(AOS_origDir);
if ASYS_origDir<>0 then begin
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;
{ Closing CON: when in Ambient mode }
@ -405,7 +410,7 @@ begin
StackBottom := Sptr - StackLength;
{ OS specific startup }
MOS_ambMsg:=nil;
AOS_origDir:=0;
ASYS_origDir:=0;
ASYS_fileList:=nil;
envp:=nil;
SysInitMorphOS;