diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2023-03-16 20:34:32 +0000 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2023-03-16 20:34:32 +0000 |
commit | 77924dff144cf934e7a73417d237a99f0d9d66ed (patch) | |
tree | 370f9c28221b8b47a07d2e744129e705373c6d9a | |
parent | acff89c7d7b3af3553a4fb878b2fd767dd27d830 (diff) | |
download | gcc-77924dff144cf934e7a73417d237a99f0d9d66ed.zip gcc-77924dff144cf934e7a73417d237a99f0d9d66ed.tar.gz gcc-77924dff144cf934e7a73417d237a99f0d9d66ed.tar.bz2 |
PR 107630 runtime libs should be self-contained
This is a patch to improve the layering of libgm2.
It removes the m2cor Debug.{def,mod} (the codebase will use
m2pim Debug instead). It also layers SysStorage under
both m2pim Storage and m2iso Storage. SysStorage is now
a dependant of m2pim Storage.mod. Halt parameters for
Debug.mod and M2RTS.mod now have the same order.
gcc/m2/ChangeLog:
* gm2-compiler/SymbolKey.mod (PutSymKey): Halt parameters
reordered.
(DelSymKey): Ditto.
* gm2-compiler/ppg.mod (GetEpsilon): Ditto.
(GetReachEnd): Ditto.
(GetFollow): Ditto.
(CodeCondition): Ditto.
(CodeThenDo): Ditto.
(CodeEnd): Ditto.
(RecoverCondition): Ditto.
(ConditionIndent): Ditto.
* gm2-libs-ch/m2rts.h (M2RTS_Halt): Ditto.
* gm2-libs-coroutines/Executive.mod (Assert): Ditto.
(Resume): Remove redundant comments.
(Wait): Remove redundant comments.
* gm2-libs-coroutines/SYSTEM.mod (TRANSFER): Halt parameters
reordered.
(IOTransferHandler): Ditto.
(Finished): Ditto.
(localInit): Ditto.
* gm2-libs-coroutines/TimerHandler.mod (WaitOn): Halt parameters
reordered.
(Cancel): Ditto.
(ReArmEvent): Ditto.
(OnActiveQueue): Ditto.
* gm2-libs-iso/COROUTINES.mod (NEWCOROUTINE): Ditto.
(Transfer): Ditto.
(IOTRANSFER): Ditto.
* gm2-libs-iso/EXCEPTIONS.mod (RAISE): Correct Halt parameters.
* gm2-libs-iso/M2RTS.def (Halt): Halt parameters reordered.
(HaltC): Ditto.
* gm2-libs-iso/M2RTS.mod: Ditto.
* gm2-libs-iso/RTentity.mod (PutKey): Ditto.
(DelKey): Ditto.
(findChildAndParent): Ditto.
(assert): Ditto.
* gm2-libs-iso/Storage.mod (ALLOCATE): Add DebugTrace.
Add UseMallocFree test.
(DEALLOCATE): Add DebugTrace. Add UseMallocFree test.
(assert): Halt parameters reordered.
* gm2-libs-log/Termbase.mod (Read): Ditto.
(KeyPressed): Ditto.
(Write): Ditto.
(Init): Ditto.
* gm2-libs/Debug.def (Halt): Halt parameters reordered.
* gm2-libs/Debug.mod (Halt): Ditto.
* gm2-libs/DynamicStrings.def (PopAllocation): Improve comment.
* gm2-libs/DynamicStrings.mod (PopAllocation): Improve comment.
Halt parameters reordered.
* gm2-libs/M2RTS.def (Halt): Ditto.
(HaltC): Ditto.
* gm2-libs/M2RTS.mod (Halt): Ditto.
(HaltC): Ditto.
* gm2-libs/PushBackInput.mod (PutStr): Ditto.
(PutString): Ditto.
(PutCh): Ditto.
* gm2-libs/RTExceptions.mod (GetBaseExceptionBlock): Ditto.
* gm2-libs/RTint.mod (ReArmTimeVector): Ditto.
(GetTimeVector): Ditto.
(AttachVector): Ditto.
(IncludeVector): Ditto.
(Listen): Ditto.
* gm2-libs/SysStorage.mod (ALLOCATE): Ditto.
(DEALLOCATE): Ditto.
(REALLOCATE): Ditto.
* gm2-libs-coroutines/Debug.def: Removed.
* gm2-libs-coroutines/Debug.mod: Removed.
libgm2/ChangeLog:
* libm2cor/Makefile.am: Remove
* libm2cor/Makefile.in: Rebuild.
* libm2iso/RTco.cc (newSem): Halt parameters reordered.
(currentThread): Ditto.
(never): Ditto.
(defined): Ditto.
(initThread): Ditto.
* libm2iso/m2rts.h (m2iso_M2RTS_HaltC): Ditto.
gcc/testsuite/ChangeLog:
* gm2/complex/pass/arith3.mod: Halt parameters reordered.
* gm2/complex/run/pass/arith3.mod: Ditto.
* gm2/complex/run/pass/arith4.mod: Ditto.
* gm2/complex/run/pass/arith5.mod: Ditto.
* gm2/isolib/run/pass/real2.mod: Ditto.
* gm2/isolib/run/pass/real3.mod: Ditto.
* gm2/isolib/run/pass/realconv.mod: Ditto.
* gm2/isolib/run/pass/realconv2.mod: Ditto.
* gm2/pim/pass/testshort.mod: Ditto.
* gm2/projects/pim/run/pass/tower/AdvSystem.mod: Ditto.
* gm2/projects/pim/run/pass/tower/DrawL.mod: Ditto.
* gm2/warnings/returntype/pass/Termbase.mod: Ditto.
* gm2/warnings/returntype/pass/keypressedsimple.mod: Ditto.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
42 files changed, 247 insertions, 458 deletions
diff --git a/gcc/m2/gm2-compiler/SymbolKey.mod b/gcc/m2/gm2-compiler/SymbolKey.mod index fb15da7..b9fa87f 100644 --- a/gcc/m2/gm2-compiler/SymbolKey.mod +++ b/gcc/m2/gm2-compiler/SymbolKey.mod @@ -153,7 +153,7 @@ BEGIN KeyName := NameKey END ELSE - Halt('symbol already stored', __LINE__, __FILE__) + Halt('symbol already stored', __FILE__, __FUNCTION__, __LINE__) END END PutSymKey ; @@ -220,7 +220,7 @@ BEGIN END ELSE Halt('trying to delete a symbol that is not in the tree - the compiler never expects this to occur', - __LINE__, __FILE__) + __FILE__, __FUNCTION__, __LINE__) END END DelSymKey ; @@ -237,7 +237,8 @@ BEGIN parent := t ; IF t=NIL THEN - Halt('parameter t should never be NIL', __LINE__, __FILE__) + Halt('parameter t should never be NIL', + __FILE__, __FUNCTION__, __LINE__) END ; Assert (t^.Right = NIL) ; child := t^.Left ; diff --git a/gcc/m2/gm2-compiler/ppg.mod b/gcc/m2/gm2-compiler/ppg.mod index aa3a57e..a17227f 100644 --- a/gcc/m2/gm2-compiler/ppg.mod +++ b/gcc/m2/gm2-compiler/ppg.mod @@ -380,7 +380,8 @@ PROCEDURE GetEpsilon (f: FollowDesc) : TraverseResult ; BEGIN IF f=NIL THEN - Halt('why is the follow info NIL?', __LINE__, __FILE__) + Halt('why is the follow info NIL?', + __FILE_, __FUNCTION__, __LINE__) ELSE RETURN( f^.epsilon ) END @@ -414,7 +415,8 @@ PROCEDURE GetReachEnd (f: FollowDesc) : TraverseResult ; BEGIN IF f=NIL THEN - Halt('why is the follow info NIL?', __LINE__, __FILE__) + Halt('why is the follow info NIL?', + __FILE_, __FUNCTION__, __LINE__) ELSE RETURN( f^.reachend ) END @@ -430,7 +432,8 @@ BEGIN WITH f^ DO IF calcfollow THEN - Halt('why are we reassigning this follow set?', __LINE__, __FILE__) + Halt('why are we reassigning this follow set?', + __FILE_, __FUNCTION__, __LINE__) END ; follow := s ; calcfollow := TRUE @@ -446,14 +449,16 @@ PROCEDURE GetFollow (f: FollowDesc) : SetDesc ; BEGIN IF f=NIL THEN - Halt('why is the follow info NIL?', __LINE__, __FILE__) + Halt ('why is the follow info NIL?', + __FILE_, __FUNCTION__, __LINE__) ELSE WITH f^ DO IF calcfollow THEN RETURN( follow ) ELSE - Halt('not calculated the follow set yet..', __LINE__, __FILE__) + Halt('not calculated the follow set yet..', + __FILE_, __FUNCTION__, __LINE__) END END END @@ -2496,7 +2501,8 @@ BEGIN m2while: IndentString('WHILE ') ELSE - Halt('unrecognised m2condition', __LINE__, __FILE__) + Halt('unrecognised m2condition', + __FILE_, __FUNCTION__, __LINE__) END END CodeCondition ; @@ -2521,7 +2527,8 @@ BEGIN Output.WriteLn ELSE - Halt('unrecognised m2condition', __LINE__, __FILE__) + Halt('unrecognised m2condition', + __FILE_, __FUNCTION__, __LINE__) END ; OnLineStart := TRUE END CodeThenDo ; @@ -2604,7 +2611,8 @@ BEGIN m2while: IndentString('END ; (* while *)') ELSE - Halt('unrecognised m2condition', __LINE__, __FILE__) + Halt('unrecognised m2condition', + __FILE_, __FUNCTION__, __LINE__) END ; OnLineStart := FALSE END CodeEnd ; @@ -2861,7 +2869,8 @@ BEGIN m2while: IndentString('WHILE ') ELSE - Halt('unrecognised m2condition', __LINE__, __FILE__) + Halt('unrecognised m2condition', + __FILE_, __FUNCTION__, __LINE__) END END RecoverCondition ; @@ -2880,7 +2889,8 @@ BEGIN m2while: RETURN( 6 ) ELSE - Halt('unrecognised m2condition', __LINE__, __FILE__) + Halt('unrecognised m2condition', + __FILE_, __FUNCTION__, __LINE__) END END ConditionIndent ; @@ -3938,7 +3948,8 @@ BEGIN WasNoError := FALSE ELSE - Halt('unknown element in enumeration type', __LINE__, __FILE__) + Halt('unknown element in enumeration type', + __FILE_, __FUNCTION__, __LINE__) END END ; from := from^.next diff --git a/gcc/m2/gm2-libs-ch/m2rts.h b/gcc/m2/gm2-libs-ch/m2rts.h index e9e4b99..f8f85d1 100644 --- a/gcc/m2/gm2-libs-ch/m2rts.h +++ b/gcc/m2/gm2-libs-ch/m2rts.h @@ -38,4 +38,4 @@ extern "C" void M2RTS_ConstructModules (const void *, extern "C" void M2RTS_Terminate (void); extern "C" void M2RTS_DeconstructModules (void); -extern "C" void M2RTS_Halt (const char *, int, const char *, const char *) __attribute__ ((noreturn)); +extern "C" void M2RTS_Halt (const char *, const char *, const char *, int) __attribute__ ((noreturn)); diff --git a/gcc/m2/gm2-libs-coroutines/Debug.def b/gcc/m2/gm2-libs-coroutines/Debug.def deleted file mode 100644 index a4f5b68..0000000 --- a/gcc/m2/gm2-libs-coroutines/Debug.def +++ /dev/null @@ -1,79 +0,0 @@ -(* Debug.def provides some simple debugging routines. - -Copyright (C) 2002-2023 Free Software Foundation, Inc. -Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. - -This file is part of GNU Modula-2. - -GNU Modula-2 is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GNU Modula-2 is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -<http://www.gnu.org/licenses/>. *) - -DEFINITION MODULE Debug ; - -(* - Title : Debug - Author : Gaius Mulley - System : UNIX (gm2) - Date : Sat Aug 13 19:41:57 1994 - Last edit : Sat Aug 13 19:41:57 1994 - Description: provides some simple debugging routines. -*) - -EXPORT QUALIFIED Halt, DebugString, PushOutput ; - -TYPE - WriteP = PROCEDURE (CHAR) ; - - -(* - Halt - writes a message in the format: - Module:Line:Message - - It then terminates by calling HALT. -*) - -PROCEDURE Halt (File : ARRAY OF CHAR; - LineNo : CARDINAL; - Function, - Message : ARRAY OF CHAR) <* noreturn *> ; - - -(* - DebugString - writes a string to the debugging device (Scn.Write). - It interprets \n as carriage return, linefeed. -*) - -PROCEDURE DebugString (a: ARRAY OF CHAR) ; - - -(* - PushOutput - pushes the output procedure, p, which is used Debug. -*) - -PROCEDURE PushOutput (p: WriteP) ; - - -(* - PopOutput - pops the current output procedure from the stack. -*) - -PROCEDURE PopOutput ; - - -END Debug. diff --git a/gcc/m2/gm2-libs-coroutines/Debug.mod b/gcc/m2/gm2-libs-coroutines/Debug.mod deleted file mode 100644 index 9708c41..0000000 --- a/gcc/m2/gm2-libs-coroutines/Debug.mod +++ /dev/null @@ -1,180 +0,0 @@ -(* Debug.mod provides some simple debugging routines. - -Copyright (C) 2002-2023 Free Software Foundation, Inc. -Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. - -This file is part of GNU Modula-2. - -GNU Modula-2 is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GNU Modula-2 is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -<http://www.gnu.org/licenses/>. *) - -IMPLEMENTATION MODULE Debug ; - - -FROM ASCII IMPORT cr, nul, lf ; -FROM NumberIO IMPORT CardToStr ; -FROM libc IMPORT exit, write ; -FROM SYSTEM IMPORT ADR ; - - -CONST - MaxStack = 10 ; - -VAR - Stack: ARRAY [1..MaxStack] OF WriteP ; - Ptr : CARDINAL ; - - -PROCEDURE Write (ch: CHAR) ; -BEGIN - IF Ptr>0 - THEN - Stack[Ptr](ch) - ELSE - LocalWrite(ch) - END -END Write ; - - -PROCEDURE LocalWrite (ch: CHAR) ; -VAR - r: INTEGER ; -BEGIN - r := write(2, ADR(ch), 1) -END LocalWrite ; - - -(* - PushOutput - pushes the output procedure, p, which is used Debug. -*) - -PROCEDURE PushOutput (p: WriteP) ; -BEGIN - IF Ptr=MaxStack - THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'stack exceeded') - ELSE - INC(Ptr) ; - Stack[Ptr] := p - END -END PushOutput ; - - -(* - PopOutput - pops the current output procedure from the stack. -*) - -PROCEDURE PopOutput ; -BEGIN - IF Ptr>1 - THEN - DEC(Ptr) - END -END PopOutput ; - - -(* - Halt - writes a message in the format: - Module:Line:Message - - It then terminates by calling HALT. -*) - -PROCEDURE Halt (File : ARRAY OF CHAR; - LineNo : CARDINAL; - Function, - Message : ARRAY OF CHAR) ; -CONST - MaxNoOfDigits = 12 ; (* should be large enough for most source files.. *) -VAR - No : ARRAY [0..MaxNoOfDigits] OF CHAR ; -BEGIN - DebugString(File) ; - CardToStr(LineNo, 0, No) ; - DebugString(':') ; - DebugString(No) ; - DebugString(':') ; - DebugString(Function) ; - DebugString(':') ; - DebugString(Message) ; - DebugString('\n') ; - HALT -END Halt ; - - -(* - DebugString - writes a string to the debugging device (Scn.Write). - It interprets \n as carriage return, linefeed. -*) - -PROCEDURE DebugString (a: ARRAY OF CHAR) ; -VAR - n, high: CARDINAL ; -BEGIN - high := HIGH( a ) ; - n := 0 ; - WHILE (n <= high) AND (a[n] # nul) DO - IF a[n]='\' - THEN - IF n+1<=high - THEN - IF a[n+1]='n' - THEN - WriteLn ; - INC(n) - ELSIF a[n+1]='\' - THEN - Write('\') ; - INC(n) - END - END - ELSE - Write( a[n] ) - END ; - INC( n ) - END -END DebugString ; - - -(* - WriteLn - writes a carriage return and a newline - character. -*) - -PROCEDURE WriteLn ; -BEGIN - Write(cr) ; - Write(lf) -END WriteLn ; - - -(* - Init - initialises this module. -*) - -PROCEDURE Init ; -BEGIN - Ptr := 0 ; - PushOutput(LocalWrite) -END Init ; - - -BEGIN - Init -END Debug. diff --git a/gcc/m2/gm2-libs-coroutines/Executive.mod b/gcc/m2/gm2-libs-coroutines/Executive.mod index 8dec311..0e0b3ee 100644 --- a/gcc/m2/gm2-libs-coroutines/Executive.mod +++ b/gcc/m2/gm2-libs-coroutines/Executive.mod @@ -105,7 +105,7 @@ BEGIN IF NOT c THEN Ps ; - Halt(file, line, function, 'assert failed') + Halt ('assert failed', file, function, line) END END Assert ; @@ -178,23 +178,21 @@ VAR ToOldState: PROTECTION ; BEGIN (* ToOldState := TurnInterrupts(MAX(PROTECTION)) ; (* disable interrupts *) *) - - (* your code needs to go here *) - WITH d^ DO (* remove for student *) - IF Status=Suspended (* remove for student *) - THEN (* remove for student *) - (* legal state transition *) (* remove for student *) - Status := Runnable ; (* change status *) (* remove for student *) - AddToReady(d) ; (* add to run queue *) (* remove for student *) - RunQueue[RunPriority] := d ; (* make d at top of q *) (* remove for student *) - Reschedule (* check whether this process has a higher run priority *) (* remove for student *) - ELSE (* remove for student *) - (* we are trying to Resume a process which is *) (* remove for student *) - Halt(__FILE__, __LINE__, __FUNCTION__, (* remove for student *) - 'trying to resume a process which is not suspended') ; (* remove for student *) - RETURN( NIL ) (* not held in a Suspended state - error *) (* remove for student *) - END (* remove for student *) - END ; (* remove for student *) + WITH d^ DO + IF Status=Suspended + THEN + (* legal state transition *) + Status := Runnable ; (* change status *) + AddToReady(d) ; (* add to run queue *) + RunQueue[RunPriority] := d ; (* make d at top of q *) + Reschedule (* check whether this process has a higher run priority *) + ELSE + (* we are trying to Resume a process which is *) + Halt ('trying to resume a process which is not suspended', + __FILE__, __FUNCTION__, __LINE__) ; + RETURN( NIL ) (* not held in a Suspended state - error *) + END + END ; (* ToOldState := TurnInterrupts(ToOldState) ; (* restore interrupts *) *) RETURN( d ) END Resume ; @@ -255,25 +253,24 @@ VAR ToOldState: PROTECTION ; BEGIN (* ToOldState := TurnInterrupts(MAX(PROTECTION)) ; (* disable interrupts *) *) - - (* your code needs to go here *) - WITH s^ DO (* remove for student *) - IF Value>0 (* remove for student *) - THEN (* remove for student *) - DEC( Value ) (* remove for student *) - ELSE (* remove for student *) - SubFromReady(CurrentProcess) ; (* remove from run q *) (* remove for student *) + WITH s^ DO + IF Value>0 + THEN + DEC( Value ) + ELSE + SubFromReady(CurrentProcess) ; (* remove from run q *) IF Who=CurrentProcess THEN Ps ; - Halt(__FILE__, __LINE__, __FUNCTION__, 'we are already on sem') + Halt ('we are already on sem', + __FILE__, __FUNCTION__, __LINE__) END ; - AddToSemaphore(Who, CurrentProcess) ; (* add to semaphore q *) (* remove for student *) - CurrentProcess^.Status := WaitOnSem ; (* set new status *) (* remove for student *) - CurrentProcess^.Which := s ; (* debugging aid *) (* remove for student *) - Reschedule (* find next process *) (* remove for student *) - END (* remove for student *) - END ; (* remove for student *) + AddToSemaphore(Who, CurrentProcess) ; (* add to semaphore q *) + CurrentProcess^.Status := WaitOnSem ; (* set new status *) + CurrentProcess^.Which := s ; (* debugging aid *) + Reschedule (* find next process *) + END + END ; (* ToOldState := TurnInterrupts(ToOldState) (* restore interrupts *) *) END Wait ; diff --git a/gcc/m2/gm2-libs-coroutines/SYSTEM.mod b/gcc/m2/gm2-libs-coroutines/SYSTEM.mod index 4a19de8..3652dec 100644 --- a/gcc/m2/gm2-libs-coroutines/SYSTEM.mod +++ b/gcc/m2/gm2-libs-coroutines/SYSTEM.mod @@ -66,8 +66,8 @@ BEGIN localMain (p1) ; IF p1.context=p2.context THEN - Halt(__FILE__, __LINE__, __FUNCTION__, - 'error when attempting to context switch to the same process') + Halt('error when attempting to context switch to the same process', + __FILE__, __FUNCTION__, __LINE__) END ; transfer (p1.context, p2.context) END TRANSFER ; @@ -130,15 +130,15 @@ VAR BEGIN IF l=NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'no processes attached to this interrupt vector which is associated with IOTRANSFER') + Halt ('no processes attached to this interrupt vector which is associated with IOTRANSFER', + __FILE__, __FUNCTION__, __LINE__) ELSE WITH l^ DO old := AttachVector (InterruptNo, next) ; IF old#l THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'inconsistancy of return result') + Halt ('inconsistancy of return result', + __FILE__, __FUNCTION__, __LINE__) END ; IF next=NIL THEN @@ -210,7 +210,8 @@ END TurnInterrupts ; PROCEDURE Finished (p: ADDRESS) ; BEGIN - Halt(__FILE__, __LINE__, __FUNCTION__, 'process terminated illegally') + Halt('process terminated illegally', + __FILE__, __FUNCTION__, __LINE__) END Finished ; @@ -225,7 +226,8 @@ BEGIN initGTh := TRUE ; IF init () # 0 THEN - Halt (__FILE__, __LINE__, __FUNCTION__, "gthr did not initialize") + Halt ("gthr did not initialize", + __FILE__, __FUNCTION__, __LINE__) END ; RTint.Init END diff --git a/gcc/m2/gm2-libs-coroutines/TimerHandler.mod b/gcc/m2/gm2-libs-coroutines/TimerHandler.mod index 2cebf3c..d3dee31 100644 --- a/gcc/m2/gm2-libs-coroutines/TimerHandler.mod +++ b/gcc/m2/gm2-libs-coroutines/TimerHandler.mod @@ -162,8 +162,8 @@ BEGIN (* ToOldState := TurnInterrupts(MAX(PROTECTION)) ; (* disable interrupts *) *) IF e=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, - 'event should never be NIL') + Halt ('event should never be NIL', + __FILE__, __FUNCTION__, __LINE__) ELSE WITH e^ DO (* we will just check to see whether someone has cancelled this *) @@ -215,8 +215,8 @@ BEGIN Cancelled := NOT WasCancelled ; IF WasCancelled THEN - Halt(__FILE__, __LINE__, __FUNCTION__, - 'inconsistancy event has been cancelled and it is on queue') + Halt ('inconsistancy event has been cancelled and it is on queue', + __FILE__, __FUNCTION__, __LINE__) END ; OnSoloQueue(e) ; WasCancelled := TRUE ; @@ -265,8 +265,8 @@ BEGIN NoOfTicks := t ; (* give it a new time *) OnActiveQueue(e) (* back on queue *) ELSE - Halt(__FILE__, __LINE__, __FUNCTION__, - 'ReArm should not be asked to ReArm a dead event') + Halt ('ReArm should not be asked to ReArm a dead event', + __FILE__, __FUNCTION__, __LINE__) END END ; (* ToOldState := TurnInterrupts(ToOldState) ; (* restore interrupts *) *) @@ -472,7 +472,8 @@ BEGIN THEN IF IsOnDeadQueue(e) THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'illegal state change') + Halt ('illegal state change', + __FILE__, __FUNCTION__, __LINE__) ELSIF IsOnSoloQueue(e) THEN RelativeAddToActive(e) ; diff --git a/gcc/m2/gm2-libs-iso/COROUTINES.mod b/gcc/m2/gm2-libs-iso/COROUTINES.mod index b17aedf..e09646f 100644 --- a/gcc/m2/gm2-libs-iso/COROUTINES.mod +++ b/gcc/m2/gm2-libs-iso/COROUTINES.mod @@ -115,7 +115,7 @@ BEGIN tp := initThread (procBody, size, initProtection) ; IF tp = -1 THEN - Halt (__FILE__, __LINE__, __FUNCTION__, 'unable to create a new thread') + Halt ('unable to create a new thread', __FILE__, __FUNCTION__, __LINE__) END ; NEW (cr) ; WITH cr^ DO @@ -170,8 +170,8 @@ BEGIN from := currentCoRoutine ; IF to^.context = from^.context THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'error when attempting to context switch to the same process') + Halt ('error when attempting to context switch to the same process', + __FILE__, __FUNCTION__, __LINE__) END ; from^.inexcept := SetExceptionState (to^.inexcept) ; from^.source := GetExceptionSource () ; @@ -225,8 +225,8 @@ BEGIN Init ; IF init () # 0 THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'failed to initialize RTco') + Halt ('failed to initialize RTco', + __FILE__, __FUNCTION__, __LINE__) END ; RTint.Init ; initCo := TRUE @@ -252,8 +252,8 @@ BEGIN old := TurnInterrupts (MAX (PROTECTION)) ; IF from = to THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - "error IOTRANSFER cannot transfer control to the running COROUTINE") + Halt ("error IOTRANSFER cannot transfer control to the running COROUTINE", + __FILE__, __FUNCTION__, __LINE__) END ; wait (lock) ; l := currentCoRoutine^.attached ; @@ -511,8 +511,8 @@ BEGIN localInit ; IF l = NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'no coroutine attached to this interrupt vector which was initiated by IOTRANSFER') + Halt ('no coroutine attached to this interrupt vector which was initiated by IOTRANSFER', + __FILE__, __FUNCTION__, __LINE__) ELSE IF Debugging THEN @@ -536,8 +536,8 @@ BEGIN ourself := AttachVector (InterruptNo, chain) ; IF ourself # l THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'inconsistancy of return result') + Halt ('inconsistancy of return result', + __FILE__, __FUNCTION__, __LINE__) END ; IF chain = NIL THEN diff --git a/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod b/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod index 56745d9..b06594f 100644 --- a/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod +++ b/gcc/m2/gm2-libs-iso/EXCEPTIONS.mod @@ -64,7 +64,8 @@ BEGIN RTExceptions.SetExceptionBlock(source^.eh) ; RTExceptions.Raise(number, ADR(__FILE__), __LINE__, __COLUMN__, ADR(__FUNCTION__), ADR(message)) ; (* we should never reach here as Raise should jump to the exception handler *) - M2RTS.Halt(__FILE__, __LINE__, __FUNCTION__, 'should never return from RTException.Raise') + M2RTS.Halt('should never return from RTException.Raise', + __FILE__, __FUNCTION__, __LINE__) END RAISE ; diff --git a/gcc/m2/gm2-libs-iso/M2RTS.def b/gcc/m2/gm2-libs-iso/M2RTS.def index 343dab7..ee12e6f 100644 --- a/gcc/m2/gm2-libs-iso/M2RTS.def +++ b/gcc/m2/gm2-libs-iso/M2RTS.def @@ -116,9 +116,8 @@ PROCEDURE HALT ([exitcode: INTEGER = -1]) <* noreturn *> ; to stderr and calls exit (1). *) -PROCEDURE Halt (filename: ARRAY OF CHAR; line: CARDINAL; - function: ARRAY OF CHAR; description: ARRAY OF CHAR) - <* noreturn *> ; +PROCEDURE Halt (description, filename, function: ARRAY OF CHAR; + line: CARDINAL) <* noreturn *> ; (* @@ -127,8 +126,9 @@ PROCEDURE Halt (filename: ARRAY OF CHAR; line: CARDINAL; to stderr and calls exit (1). *) -PROCEDURE HaltC (filename: ADDRESS; line: CARDINAL; - function, description: ADDRESS) <* noreturn *> ; +PROCEDURE HaltC (description, filename, function: ADDRESS; + line: CARDINAL) <* noreturn *> ; + (* diff --git a/gcc/m2/gm2-libs-iso/M2RTS.mod b/gcc/m2/gm2-libs-iso/M2RTS.mod index a59735a..958744d 100644 --- a/gcc/m2/gm2-libs-iso/M2RTS.mod +++ b/gcc/m2/gm2-libs-iso/M2RTS.mod @@ -337,8 +337,7 @@ END ErrorMessageC ; to stderr and calls exit (1). *) -PROCEDURE HaltC (filename: ADDRESS; line: CARDINAL; - function, description: ADDRESS) ; +PROCEDURE HaltC (description, filename, function: ADDRESS; line: CARDINAL) ; BEGIN ErrorMessageC (description, filename, line, function) END HaltC ; @@ -350,8 +349,7 @@ END HaltC ; to stderr and calls exit (1). *) -PROCEDURE Halt (filename: ARRAY OF CHAR; line: CARDINAL; - function: ARRAY OF CHAR; description: ARRAY OF CHAR) ; +PROCEDURE Halt (description, filename, function: ARRAY OF CHAR; line: CARDINAL) ; BEGIN ErrorMessage (description, filename, line, function) END Halt ; diff --git a/gcc/m2/gm2-libs-iso/RTentity.mod b/gcc/m2/gm2-libs-iso/RTentity.mod index e60188b..ee6a97a 100644 --- a/gcc/m2/gm2-libs-iso/RTentity.mod +++ b/gcc/m2/gm2-libs-iso/RTentity.mod @@ -137,8 +137,8 @@ BEGIN entityKey := key END ELSE - Halt (__FILE__, __LINE__, __FUNCTION__, - 'internal runtime error, entity already stored') + Halt ('internal runtime error, entity already stored', + __FILE__, __FUNCTION__, __LINE__) END ; signal (mutex) END PutKey ; @@ -221,8 +221,8 @@ BEGIN free (child) END ELSE - Halt(__FILE__, __LINE__, __FUNCTION__, - 'internal runtime error, trying to delete an entity which is not in the tree') + Halt('internal runtime error, trying to delete an entity which is not in the tree', + __FILE__, __FUNCTION__, __LINE__) END ; signal (mutex) END DelKey ; @@ -241,8 +241,8 @@ BEGIN parent := t ; IF t = NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'internal runtime error, RTentity is either corrupt or the module storage has not been initialized yet') + Halt ('internal runtime error, RTentity is either corrupt or the module storage has not been initialized yet', + __FILE__, __FUNCTION__, __LINE__) END ; child := t^.left ; IF child # NIL @@ -270,8 +270,8 @@ PROCEDURE assert (condition: BOOLEAN) ; BEGIN IF NOT condition THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'internal runtime error, RTentity is either corrupt or the module storage has not been initialized yet') + Halt ('internal runtime error, RTentity is either corrupt or the module storage has not been initialized yet', + __FILE__, __FUNCTION__, __LINE__) END END assert ; diff --git a/gcc/m2/gm2-libs-iso/Storage.mod b/gcc/m2/gm2-libs-iso/Storage.mod index ec2f581..ed7d285 100644 --- a/gcc/m2/gm2-libs-iso/Storage.mod +++ b/gcc/m2/gm2-libs-iso/Storage.mod @@ -26,7 +26,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see IMPLEMENTATION MODULE Storage ; -FROM libc IMPORT malloc, free, memcpy ; +FROM libc IMPORT memcpy, abort, malloc, free, printf ; + +IMPORT SysStorage ; + FROM M2RTS IMPORT Halt ; FROM SYSTEM IMPORT TSIZE ; FROM M2EXCEPTION IMPORT M2Exceptions ; @@ -37,11 +40,28 @@ FROM EXCEPTIONS IMPORT ExceptionNumber, RAISE, IsExceptionalExecution ; +CONST + DebugTrace = FALSE ; + UseMallocFree = FALSE ; + PROCEDURE ALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL) ; BEGIN Init ; - addr := malloc (amount) ; + IF DebugTrace + THEN + printf ("request m2iso:Storage.ALLOCATE (..., %d bytes)\n", amount) + END ; + IF UseMallocFree + THEN + addr := malloc (amount) + ELSE + SysStorage.ALLOCATE (addr, amount) + END ; + IF DebugTrace + THEN + printf ("return m2iso:Storage.ALLOCATE (%p, %d bytes)\n", addr, amount) + END ; IF addr#NIL THEN PutKey (storageTree, addr, amount) @@ -52,9 +72,18 @@ END ALLOCATE ; PROCEDURE DEALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL) ; BEGIN assert (initialized) ; + IF DebugTrace + THEN + printf ("m2iso:Storage.DEALLOCATE (%p, %d bytes)\n", addr, amount) + END ; IF VerifyDeallocate (addr, amount) THEN - free (addr) ; + IF UseMallocFree + THEN + free (addr) + ELSE + SysStorage.DEALLOCATE (addr, amount) + END ; addr := NIL END END DEALLOCATE ; @@ -115,7 +144,7 @@ PROCEDURE VerifyDeallocate (addr: SYSTEM.ADDRESS; amount: CARDINAL) : BOOLEAN ; VAR a: CARDINAL ; BEGIN - + Init ; IF addr=NIL THEN RAISE (storageException, ORD(nilDeallocation), 'deallocating pointer whose value is NIL') ; @@ -146,8 +175,8 @@ PROCEDURE assert (condition: BOOLEAN) ; BEGIN IF NOT condition THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'internal runtime error, module Storage has not been initialized yet') + Halt ('internal runtime error, module Storage has not been initialized yet', + __FILE__, __FUNCTION__, __LINE__) END END assert ; diff --git a/gcc/m2/gm2-libs-log/Termbase.mod b/gcc/m2/gm2-libs-log/Termbase.mod index 0b47826..aa29e43 100644 --- a/gcc/m2/gm2-libs-log/Termbase.mod +++ b/gcc/m2/gm2-libs-log/Termbase.mod @@ -106,7 +106,7 @@ PROCEDURE Read (VAR ch: CHAR) ; BEGIN IF rStack=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active read procedure') + Halt ('no active read procedure', __FILE__, __FUNCTION__, __LINE__) ELSE rStack^.r(ch) END @@ -121,7 +121,7 @@ PROCEDURE KeyPressed () : BOOLEAN ; BEGIN IF rStack=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active status procedure') + Halt ('no active status procedure', __FILE__, __FUNCTION__, __LINE__) ELSE RETURN( rStack^.s() ) END @@ -185,7 +185,7 @@ PROCEDURE Write (VAR ch: CHAR) ; BEGIN IF wStack=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active write procedure') + Halt ('no active write procedure', __FILE__, __FUNCTION__, __LINE__) ELSE wStack^.w(ch) END @@ -205,12 +205,12 @@ BEGIN AssignRead(Keyboard.Read, Keyboard.KeyPressed, Done) ; IF NOT Done THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'failed to assign read routines from module Keyboard') + Halt ('failed to assign read routines from module Keyboard', __FILE__, __FUNCTION__, __LINE__) END ; AssignWrite(Display.Write, Done) ; IF NOT Done THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'failed to assign write routine from module Display') + Halt ('failed to assign write routine from module Display', __FILE__, __FUNCTION__, __LINE__) END END Init ; diff --git a/gcc/m2/gm2-libs/Debug.def b/gcc/m2/gm2-libs/Debug.def index c134e99..1887c69 100644 --- a/gcc/m2/gm2-libs/Debug.def +++ b/gcc/m2/gm2-libs/Debug.def @@ -40,14 +40,15 @@ EXPORT QUALIFIED Halt, DebugString ; (* Halt - writes a message in the format: - Module:Line:Message + Module:Function:Line:Message It then terminates by calling HALT. *) -PROCEDURE Halt (Message: ARRAY OF CHAR; - LineNo: CARDINAL; - Module: ARRAY OF CHAR) ; +PROCEDURE Halt (Message, + Module, + Function: ARRAY OF CHAR ; + LineNo : CARDINAL) ; (* diff --git a/gcc/m2/gm2-libs/Debug.mod b/gcc/m2/gm2-libs/Debug.mod index 14164e3b..f213378 100644 --- a/gcc/m2/gm2-libs/Debug.mod +++ b/gcc/m2/gm2-libs/Debug.mod @@ -34,20 +34,24 @@ FROM libc IMPORT exit ; (* Halt - writes a message in the format: - Module:Line:Message + Module:Function:Line:Message It then terminates by calling HALT. *) -PROCEDURE Halt (Message: ARRAY OF CHAR; - LineNo: CARDINAL; - Module: ARRAY OF CHAR) ; +PROCEDURE Halt (Message, + Module, + Function: ARRAY OF CHAR ; + LineNo : CARDINAL) ; CONST MaxNoOfDigits = 12 ; (* should be large enough for most source files.. *) VAR No : ARRAY [0..MaxNoOfDigits] OF CHAR ; BEGIN DebugString(Module) ; + DebugString(':') ; + DebugString(Function) ; + DebugString(':') ; CardToStr(LineNo, 0, No) ; DebugString(':') ; DebugString(No) ; diff --git a/gcc/m2/gm2-libs/DynamicStrings.def b/gcc/m2/gm2-libs/DynamicStrings.def index bd99010..90930a9 100644 --- a/gcc/m2/gm2-libs/DynamicStrings.def +++ b/gcc/m2/gm2-libs/DynamicStrings.def @@ -361,9 +361,9 @@ PROCEDURE PopAllocation (halt: BOOLEAN) ; (* PopAllocationExemption - test to see that all strings are - deallocated, except string, e, since + deallocated, except string e since the last push. - Then it pops to the previous + Post-condition: it pops to the previous allocation/deallocation lists. If halt is true then the application diff --git a/gcc/m2/gm2-libs/DynamicStrings.mod b/gcc/m2/gm2-libs/DynamicStrings.mod index a109e7a..68e9320 100644 --- a/gcc/m2/gm2-libs/DynamicStrings.mod +++ b/gcc/m2/gm2-libs/DynamicStrings.mod @@ -153,8 +153,8 @@ END stop ; (* PopAllocationExemption - test to see that all strings are deallocated, except - string, e, since the last push. - Then it pops to the previous allocation/deallocation + string e since the last push. + Post-condition: it pops to the previous allocation/deallocation lists. If halt is true then the application terminates @@ -173,8 +173,8 @@ BEGIN IF frameHead = NIL THEN stop ; - Halt (__FILE__, __LINE__, __FUNCTION__, - "mismatched number of PopAllocation's compared to PushAllocation's") + Halt ("mismatched number of PopAllocation's compared to PushAllocation's", + __FILE__, __FUNCTION__, __LINE__) ; (* writeString ("mismatched number of PopAllocation's compared to PushAllocation's") *) ELSE IF frameHead^.alloc # NIL diff --git a/gcc/m2/gm2-libs/M2RTS.def b/gcc/m2/gm2-libs/M2RTS.def index ca6010b..2b84c8c 100644 --- a/gcc/m2/gm2-libs/M2RTS.def +++ b/gcc/m2/gm2-libs/M2RTS.def @@ -125,9 +125,8 @@ PROCEDURE HALT ([exitcode: INTEGER = -1]) <* noreturn *> ; to stderr and calls exit (1). *) -PROCEDURE Halt (filename: ARRAY OF CHAR; line: CARDINAL; - function: ARRAY OF CHAR; description: ARRAY OF CHAR) - <* noreturn *> ; +PROCEDURE Halt (description, filename, function: ARRAY OF CHAR; + line: CARDINAL) <* noreturn *> ; (* @@ -136,8 +135,8 @@ PROCEDURE Halt (filename: ARRAY OF CHAR; line: CARDINAL; to stderr and calls exit (1). *) -PROCEDURE HaltC (filename: ADDRESS; line: CARDINAL; - function, description: ADDRESS) <* noreturn *> ; +PROCEDURE HaltC (description, filename, function: ADDRESS; + line: CARDINAL) <* noreturn *> ; (* diff --git a/gcc/m2/gm2-libs/M2RTS.mod b/gcc/m2/gm2-libs/M2RTS.mod index d01f6a6..f941a32 100644 --- a/gcc/m2/gm2-libs/M2RTS.mod +++ b/gcc/m2/gm2-libs/M2RTS.mod @@ -336,8 +336,7 @@ END ErrorMessageC ; to stderr and calls exit (1). *) -PROCEDURE HaltC (filename: ADDRESS; line: CARDINAL; - function, description: ADDRESS) ; +PROCEDURE HaltC (description, filename, function: ADDRESS; line: CARDINAL) ; BEGIN ErrorMessageC (description, filename, line, function) END HaltC ; @@ -349,8 +348,7 @@ END HaltC ; to stderr and calls exit (1). *) -PROCEDURE Halt (filename: ARRAY OF CHAR; line: CARDINAL; - function: ARRAY OF CHAR; description: ARRAY OF CHAR) ; +PROCEDURE Halt (description, filename, function: ARRAY OF CHAR; line: CARDINAL) ; BEGIN ErrorMessage (description, filename, line, function) END Halt ; diff --git a/gcc/m2/gm2-libs/PushBackInput.mod b/gcc/m2/gm2-libs/PushBackInput.mod index b74320e..90c0bae 100644 --- a/gcc/m2/gm2-libs/PushBackInput.mod +++ b/gcc/m2/gm2-libs/PushBackInput.mod @@ -110,7 +110,7 @@ BEGIN DEC (i) ; IF PutCh (char (s, i)) # char (s, i) THEN - Halt('assert failed', __LINE__, __FILE__) + Halt('assert failed', __FILE__, __FUNCTION__, __LINE__) END END END PutStr ; @@ -129,7 +129,7 @@ BEGIN DEC (l) ; IF PutCh (a[l]) # a[l] THEN - Halt ('assert failed', __LINE__, __FILE__) + Halt ('assert failed', __FILE__, __FUNCTION__, __LINE__) END END END PutString ; @@ -147,7 +147,8 @@ BEGIN CharStack[StackPtr] := ch ; INC(StackPtr) ELSE - Halt('max push back stack exceeded, increase MaxPushBackStack', __LINE__, __FILE__) + Halt('max push back stack exceeded, increase MaxPushBackStack', + __FILE__, __FUNCTION__, __LINE__) END ; RETURN( ch ) END PutCh ; diff --git a/gcc/m2/gm2-libs/RTExceptions.mod b/gcc/m2/gm2-libs/RTExceptions.mod index 8d3dc04..f28e4d8 100644 --- a/gcc/m2/gm2-libs/RTExceptions.mod +++ b/gcc/m2/gm2-libs/RTExceptions.mod @@ -596,7 +596,8 @@ PROCEDURE GetBaseExceptionBlock () : EHBlock ; BEGIN IF currentEHB=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'currentEHB has not been initialized yet') + Halt('currentEHB has not been initialized yet', + __FILE__, __FUNCTION__, __LINE__) ELSE RETURN( currentEHB ) END diff --git a/gcc/m2/gm2-libs/RTint.mod b/gcc/m2/gm2-libs/RTint.mod index 97fdee2..aec5a82 100644 --- a/gcc/m2/gm2-libs/RTint.mod +++ b/gcc/m2/gm2-libs/RTint.mod @@ -283,8 +283,8 @@ BEGIN vptr := FindVectorNo (vec) ; IF vptr = NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'cannot find vector supplied') + Halt ('cannot find vector supplied', + __FILE__, __FUNCTION__, __LINE__) ELSE WITH vptr^ DO SetTime (rel, secs + DebugTime, micro) @@ -309,8 +309,8 @@ BEGIN vptr := FindVectorNo (vec) ; IF vptr=NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'cannot find vector supplied') + Halt ('cannot find vector supplied', + __FILE__, __FUNCTION__, __LINE__) ELSE WITH vptr^ DO GetTime (rel, secs, micro) ; @@ -336,7 +336,8 @@ BEGIN vptr := FindVectorNo (vec) ; IF vptr = NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, 'cannot find vector supplied') + Halt ( 'cannot find vector supplied', + __FILE__, __FUNCTION__, __LINE__) ELSE prevArg := vptr^.arg ; vptr^.arg := ptr ; @@ -369,8 +370,8 @@ BEGIN vptr := FindVectorNo (vec) ; IF vptr = NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'cannot find vector supplied') ; + Halt ('cannot find vector supplied', + __FILE__, __FUNCTION__, __LINE__) ELSE (* printf('including vector %d (fd = %d)\n', vec, v^.File) ; *) vptr^.pending := Pending[vptr^.priority] ; @@ -411,8 +412,8 @@ BEGIN vptr := FindPendingVector (vec) ; IF vptr = NIL THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'cannot find pending vector supplied') + Halt ('cannot find pending vector supplied', + __FILE__, __FUNCTION__, __LINE__) ELSE (* printf('excluding vector %d\n', vec) ; *) IF Pending[vptr^.priority] = vptr @@ -727,8 +728,8 @@ BEGIN END ; IF untilInterrupt AND (inSet=NIL) AND (outSet=NIL) AND (NOT found) THEN - Halt (__FILE__, __LINE__, __FUNCTION__, - 'deadlock found, no more processes to run and no interrupts active') + Halt ('deadlock found, no more processes to run and no interrupts active', + __FILE__, __FUNCTION__, __LINE__) END ; (* printf('timeval = 0x%x\n', timeval) ; *) (* printf('}\n') ; *) diff --git a/gcc/m2/gm2-libs/SysStorage.mod b/gcc/m2/gm2-libs/SysStorage.mod index 624748c..2277f93 100644 --- a/gcc/m2/gm2-libs/SysStorage.mod +++ b/gcc/m2/gm2-libs/SysStorage.mod @@ -33,8 +33,8 @@ FROM SYSTEM IMPORT ADR ; CONST enableDeallocation = TRUE ; - enableZero = FALSE ; - enableTrace = FALSE ; + enableZero = TRUE ; + enableTrace = TRUE ; VAR callno: CARDINAL ; @@ -47,7 +47,8 @@ BEGIN a := malloc (size) ; IF a = NIL THEN - Halt ('out of memory error', __LINE__, __FILE__) + Halt ('out of memory error', + __FILE__, __FUNCTION__, __LINE__) END ; IF enableTrace AND trace THEN @@ -73,7 +74,8 @@ BEGIN END ; IF memset (a, 0, size) # a THEN - Halt ('memset should have returned the first parameter', __LINE__, __FILE__) + Halt ('memset should have returned the first parameter', + __FILE__, __FUNCTION__, __LINE__) END END ; IF enableDeallocation @@ -116,7 +118,8 @@ BEGIN a := realloc (a, size) ; IF a = NIL THEN - Halt ('out of memory error', __LINE__, __FILE__) + Halt ('out of memory error', + __FILE__, __FUNCTION__, __LINE__) END ; IF enableTrace AND trace THEN diff --git a/gcc/testsuite/gm2/complex/pass/arith3.mod b/gcc/testsuite/gm2/complex/pass/arith3.mod index 564487a..834119b 100644 --- a/gcc/testsuite/gm2/complex/pass/arith3.mod +++ b/gcc/testsuite/gm2/complex/pass/arith3.mod @@ -28,7 +28,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, 'failed') + Halt ('failed', __FILE__, __FUNCTION__, __LINE__) END END Assert ; diff --git a/gcc/testsuite/gm2/complex/run/pass/arith3.mod b/gcc/testsuite/gm2/complex/run/pass/arith3.mod index 066eb66..09191cf 100644 --- a/gcc/testsuite/gm2/complex/run/pass/arith3.mod +++ b/gcc/testsuite/gm2/complex/run/pass/arith3.mod @@ -29,7 +29,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, 'failure') + Halt ('failure', __FILE__, __FUNCTION__, l) END END Assert ; @@ -42,7 +42,7 @@ VAR a, b, c: COMPLEX ; BEGIN printf ("main module starting\n"); - printf ("a := i\n"); + printf ("a := i\n"); a := i ; printf ("b := a*getOne()\n"); b := a*getOne() ; diff --git a/gcc/testsuite/gm2/complex/run/pass/arith4.mod b/gcc/testsuite/gm2/complex/run/pass/arith4.mod index 950674a..8d39f83 100644 --- a/gcc/testsuite/gm2/complex/run/pass/arith4.mod +++ b/gcc/testsuite/gm2/complex/run/pass/arith4.mod @@ -28,7 +28,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, 'failure') + Halt ('failure', __FILE__, __FUNCTION__, l) END END Assert ; diff --git a/gcc/testsuite/gm2/complex/run/pass/arith5.mod b/gcc/testsuite/gm2/complex/run/pass/arith5.mod index c7a7955..7fe3918 100644 --- a/gcc/testsuite/gm2/complex/run/pass/arith5.mod +++ b/gcc/testsuite/gm2/complex/run/pass/arith5.mod @@ -33,7 +33,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, 'failure') + Halt ('failure', __FILE__, __FUNCTION__, l) END END Assert ; diff --git a/gcc/testsuite/gm2/isolib/run/pass/real2.mod b/gcc/testsuite/gm2/isolib/run/pass/real2.mod index cdee23e..9db92bd 100644 --- a/gcc/testsuite/gm2/isolib/run/pass/real2.mod +++ b/gcc/testsuite/gm2/isolib/run/pass/real2.mod @@ -25,7 +25,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, "assert failed") + Halt ('assert failed', __FILE__, __FUNCTION__, l) END END Assert ; diff --git a/gcc/testsuite/gm2/isolib/run/pass/real3.mod b/gcc/testsuite/gm2/isolib/run/pass/real3.mod index dbef803..8a25d5a 100644 --- a/gcc/testsuite/gm2/isolib/run/pass/real3.mod +++ b/gcc/testsuite/gm2/isolib/run/pass/real3.mod @@ -25,7 +25,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, "assert failed") + Halt ('assert failed', __FILE__, __FUNCTION__, l) END END Assert ; diff --git a/gcc/testsuite/gm2/isolib/run/pass/realconv.mod b/gcc/testsuite/gm2/isolib/run/pass/realconv.mod index 802dd06..03bc641 100644 --- a/gcc/testsuite/gm2/isolib/run/pass/realconv.mod +++ b/gcc/testsuite/gm2/isolib/run/pass/realconv.mod @@ -25,7 +25,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, "assert failed") + Halt ('assert failed', __FILE__, __FUNCTION__, l) END END Assert ; diff --git a/gcc/testsuite/gm2/isolib/run/pass/realconv2.mod b/gcc/testsuite/gm2/isolib/run/pass/realconv2.mod index b346de3..eedb233 100644 --- a/gcc/testsuite/gm2/isolib/run/pass/realconv2.mod +++ b/gcc/testsuite/gm2/isolib/run/pass/realconv2.mod @@ -25,7 +25,7 @@ PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ; BEGIN IF NOT b THEN - Halt(__FILE__, l, __FUNCTION__, "assert failed") + Halt ('assert failed', __FILE__, __FUNCTION__, l) END END Assert ; diff --git a/gcc/testsuite/gm2/pim/pass/testshort.mod b/gcc/testsuite/gm2/pim/pass/testshort.mod index 1b53ed3..bb22e24 100644 --- a/gcc/testsuite/gm2/pim/pass/testshort.mod +++ b/gcc/testsuite/gm2/pim/pass/testshort.mod @@ -23,7 +23,7 @@ PROCEDURE promote (i: SHORTINT) ; BEGIN IF i#-1 THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'promotion failed') + Halt ('promotion failed', __FILE__, __FUNCTION__, __LINE__) END END promote ; diff --git a/gcc/testsuite/gm2/projects/pim/run/pass/tower/AdvSystem.mod b/gcc/testsuite/gm2/projects/pim/run/pass/tower/AdvSystem.mod index fc21516..67a3e51 100644 --- a/gcc/testsuite/gm2/projects/pim/run/pass/tower/AdvSystem.mod +++ b/gcc/testsuite/gm2/projects/pim/run/pass/tower/AdvSystem.mod @@ -67,7 +67,7 @@ BEGIN END ; INC(i) END ; - Halt(__FILE__, __LINE__, __FUNCTION__, 'increase MaxNoOfProcesses') + Halt ('increase MaxNoOfProcesses', __FILE__, __FUNCTION__, __LINE__) END AssignOutputTo ; @@ -111,8 +111,8 @@ BEGIN END ; INC(i) END ; - Halt(__FILE__, __LINE__, __FUNCTION__, - 'process has never has a player assigned to its output') + Halt ('process has never has a player assigned to its output', + __FILE__, __FUNCTION__, __LINE__) END ProcessToPlayer ; @@ -259,8 +259,8 @@ BEGIN RETURN( i ) END END ; - Halt(__FILE__, __LINE__, __FUNCTION__, - 'process calling is not a player process') + Halt ('process calling is not a player process', + __FILE__, __FUNCTION__, __LINE__) END PlayerNo ; diff --git a/gcc/testsuite/gm2/projects/pim/run/pass/tower/DrawL.mod b/gcc/testsuite/gm2/projects/pim/run/pass/tower/DrawL.mod index e6753c9..c1f479a 100644 --- a/gcc/testsuite/gm2/projects/pim/run/pass/tower/DrawL.mod +++ b/gcc/testsuite/gm2/projects/pim/run/pass/tower/DrawL.mod @@ -382,7 +382,7 @@ BEGIN 3: StrPoint('Eman', x, y) ELSE - Halt(__FILE__, __LINE__, __FUNCTION__, 'unexpected direction') + Halt ('unexpected direction', __FILE__, __FUNCTION__, __LINE__) END ELSE CASE dir OF @@ -393,7 +393,7 @@ BEGIN 3: StrPoint('eman', x, y) ELSE - Halt(__FILE__, __LINE__, __FUNCTION__, 'unexpected direction') + Halt ('unexpected direction', __FILE__, __FUNCTION__, __LINE__) END END END DrawMan ; @@ -409,7 +409,7 @@ BEGIN 3: StrPoint('ear', x, y) ELSE - Halt(__FILE__, __LINE__, __FUNCTION__, 'unexpected direction') + Halt ('unexpected direction', __FILE__, __FUNCTION__, __LINE__) END END DArrow ; diff --git a/gcc/testsuite/gm2/warnings/returntype/pass/Termbase.mod b/gcc/testsuite/gm2/warnings/returntype/pass/Termbase.mod index 0b47826..a45b883 100644 --- a/gcc/testsuite/gm2/warnings/returntype/pass/Termbase.mod +++ b/gcc/testsuite/gm2/warnings/returntype/pass/Termbase.mod @@ -106,7 +106,7 @@ PROCEDURE Read (VAR ch: CHAR) ; BEGIN IF rStack=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active read procedure') + Halt ('no active read procedure', __FILE__, __FUNCTION__, __LINE__) ELSE rStack^.r(ch) END @@ -121,7 +121,7 @@ PROCEDURE KeyPressed () : BOOLEAN ; BEGIN IF rStack=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active status procedure') + Halt ('no active status procedure', __FILE__, __FUNCTION__, __LINE__) ELSE RETURN( rStack^.s() ) END @@ -185,7 +185,7 @@ PROCEDURE Write (VAR ch: CHAR) ; BEGIN IF wStack=NIL THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active write procedure') + Halt('no active write procedure', __FILE__, __FUNCTION__, __LINE__) ELSE wStack^.w(ch) END @@ -205,12 +205,12 @@ BEGIN AssignRead(Keyboard.Read, Keyboard.KeyPressed, Done) ; IF NOT Done THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'failed to assign read routines from module Keyboard') + Halt ('failed to assign read routines from module Keyboard', __FILE__, __FUNCTION__, __LINE__) END ; AssignWrite(Display.Write, Done) ; IF NOT Done THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'failed to assign write routine from module Display') + Halt ('failed to assign write routine from module Display', __FILE__, __FUNCTION__, __LINE__) END END Init ; diff --git a/gcc/testsuite/gm2/warnings/returntype/pass/keypressedsimple.mod b/gcc/testsuite/gm2/warnings/returntype/pass/keypressedsimple.mod index 30d5347..11e494b 100644 --- a/gcc/testsuite/gm2/warnings/returntype/pass/keypressedsimple.mod +++ b/gcc/testsuite/gm2/warnings/returntype/pass/keypressedsimple.mod @@ -7,7 +7,7 @@ PROCEDURE KeyPressed () : BOOLEAN ; BEGIN IF Narg () < 0 THEN - Halt(__FILE__, __LINE__, __FUNCTION__, 'no active status procedure') + Halt ('no active status procedure', __FILE__, __FUNCTION__, __LINE__) ELSE RETURN FALSE END diff --git a/libgm2/libm2cor/Makefile.am b/libgm2/libm2cor/Makefile.am index 25a5f00..8e68272 100644 --- a/libgm2/libm2cor/Makefile.am +++ b/libgm2/libm2cor/Makefile.am @@ -97,11 +97,11 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) if BUILD_CORLIB -M2DEFS = Debug.def Executive.def \ +M2DEFS = Executive.def \ KeyBoardLEDs.def SYSTEM.def \ TimerHandler.def -M2MODS = Debug.mod Executive.mod \ +M2MODS = Executive.mod \ SYSTEM.mod TimerHandler.mod toolexeclib_LTLIBRARIES = libm2cor.la diff --git a/libgm2/libm2cor/Makefile.in b/libgm2/libm2cor/Makefile.in index 869924b..f92dd941 100644 --- a/libgm2/libm2cor/Makefile.in +++ b/libgm2/libm2cor/Makefile.in @@ -153,7 +153,7 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" LTLIBRARIES = $(toolexeclib_LTLIBRARIES) libm2cor_la_LIBADD = -@BUILD_CORLIB_TRUE@am__objects_1 = Debug.lo Executive.lo SYSTEM.lo \ +@BUILD_CORLIB_TRUE@am__objects_1 = Executive.lo SYSTEM.lo \ @BUILD_CORLIB_TRUE@ TimerHandler.lo @BUILD_CORLIB_TRUE@am_libm2cor_la_OBJECTS = $(am__objects_1) \ @BUILD_CORLIB_TRUE@ KeyBoardLEDs.lo @@ -450,11 +450,11 @@ AM_MAKEFLAGS = \ # Subdir rules rely on $(FLAGS_TO_PASS) FLAGS_TO_PASS = $(AM_MAKEFLAGS) -@BUILD_CORLIB_TRUE@M2DEFS = Debug.def Executive.def \ +@BUILD_CORLIB_TRUE@M2DEFS = Executive.def \ @BUILD_CORLIB_TRUE@ KeyBoardLEDs.def SYSTEM.def \ @BUILD_CORLIB_TRUE@ TimerHandler.def -@BUILD_CORLIB_TRUE@M2MODS = Debug.mod Executive.mod \ +@BUILD_CORLIB_TRUE@M2MODS = Executive.mod \ @BUILD_CORLIB_TRUE@ SYSTEM.mod TimerHandler.mod @BUILD_CORLIB_TRUE@toolexeclib_LTLIBRARIES = libm2cor.la diff --git a/libgm2/libm2iso/RTco.cc b/libgm2/libm2iso/RTco.cc index 33da586..71d4f4b 100644 --- a/libgm2/libm2iso/RTco.cc +++ b/libgm2/libm2iso/RTco.cc @@ -182,8 +182,8 @@ newSem (void) = (threadSem *)malloc (sizeof (threadSem)); nSemaphores += 1; if (nSemaphores == SEM_POOL) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "too many semaphores created"); + m2iso_M2RTS_HaltC ("too many semaphores created", + __FILE__, __FUNCTION__, __LINE__); #else threadSem *sem = (threadSem *)malloc (sizeof (threadSem)); @@ -239,8 +239,8 @@ currentThread (void) for (tid = 0; tid < nThreads; tid++) if (pthread_self () == threadArray[tid].p) return tid; - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "failed to find currentThread"); + m2iso_M2RTS_HaltC ("failed to find currentThread", + __FILE__, __FUNCTION__, __LINE__); } extern "C" int @@ -290,8 +290,8 @@ EXPORT(turnInterrupts) (unsigned int newLevel) static void never (void) { - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "the main thread should never call here"); + m2iso_M2RTS_HaltC ("the main thread should never call here", + __FILE__, __FUNCTION__, __LINE__); } static void * @@ -327,8 +327,8 @@ execThread (void *t) #if 0 m2iso_M2RTS_CoroutineException ( __FILE__, __LINE__, __COLUMN__, __FUNCTION__, "coroutine finishing"); #endif - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "execThread should never finish"); + m2iso_M2RTS_HaltC ("execThread should never finish", + __FILE__, __FUNCTION__, __LINE__); return NULL; } @@ -338,8 +338,8 @@ newThread (void) #if defined(POOL) nThreads += 1; if (nThreads == THREAD_POOL) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "too many threads created"); + m2iso_M2RTS_HaltC ("too many threads created", + __FILE__, __FUNCTION__, __LINE__); return nThreads - 1; #else if (nThreads == 0) @@ -376,15 +376,15 @@ initThread (void (*proc) (void), unsigned int stackSize, /* Set thread creation attributes. */ result = pthread_attr_init (&attr); if (result != 0) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "failed to create thread attribute"); + m2iso_M2RTS_HaltC ("failed to create thread attribute", + __FILE__, __FUNCTION__, __LINE__); if (stackSize > 0) { result = pthread_attr_setstacksize (&attr, stackSize); if (result != 0) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "failed to set stack size attribute"); + m2iso_M2RTS_HaltC ("failed to set stack size attribute", + __FILE__, __FUNCTION__, __LINE__); } tprintf ("initThread [%d] function = 0x%p (arg = 0x%p)\n", tid, proc, @@ -392,7 +392,8 @@ initThread (void (*proc) (void), unsigned int stackSize, result = pthread_create (&threadArray[tid].p, &attr, execThread, (void *)&threadArray[tid]); if (result != 0) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, "thread_create failed"); + m2iso_M2RTS_HaltC ("thread_create failed", + __FILE__, __FUNCTION__, __LINE__); tprintf (" created thread [%d] function = 0x%p 0x%p\n", tid, proc, (void *)&threadArray[tid]); return tid; @@ -422,13 +423,13 @@ EXPORT(transfer) (int *p1, int p2) { int current = currentThread (); if (!initialized) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "cannot transfer to a process before the process has been created"); + m2iso_M2RTS_HaltC ("cannot transfer to a process before the process has been created", + __FILE__, __FUNCTION__, __LINE__); if (current == p2) { /* Error. */ - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "attempting to transfer to ourself"); + m2iso_M2RTS_HaltC ("attempting to transfer to ourself", + __FILE__, __FUNCTION__, __LINE__); } else { @@ -473,8 +474,8 @@ EXPORT(transfer) (int *p1, int p2) } tprintf ("end, context back to %d\n", current); if (current != old) - m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, - "wrong process id"); + m2iso_M2RTS_HaltC ("wrong process id", + __FILE__, __FUNCTION__, __LINE__); } } __gthread_mutex_unlock (&lock); diff --git a/libgm2/libm2iso/m2rts.h b/libgm2/libm2iso/m2rts.h index 97612c1..481df9b 100644 --- a/libgm2/libm2iso/m2rts.h +++ b/libgm2/libm2iso/m2rts.h @@ -44,6 +44,5 @@ extern "C" void m2iso_M2RTS_ConstructModules (const char *modulename, const char extern "C" void m2iso_M2RTS_Terminate (void); extern "C" void m2iso_M2RTS_DeconstructModules (void); -extern "C" void m2iso_M2RTS_HaltC (const char *filename, int line, - const char *functionname, const char *desc) - __attribute__ ((noreturn)); +extern "C" void m2iso_M2RTS_HaltC (const char *desc, const char *filename, + const char *functionname, int line) __attribute__ ((noreturn)); |