aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-09-29 17:18:16 +0100
committerGaius Mulley <gaiusmod2@gmail.com>2023-09-29 17:18:16 +0100
commit5f2408712a4e3994ad903c2f72af19c5a473ef5d (patch)
treed2b7758a72547e03abff9957f8b363e8f9f81dee /gcc
parent0f184b4141e9d285c19b3a3d02bffa45bc0d8f07 (diff)
downloadgcc-5f2408712a4e3994ad903c2f72af19c5a473ef5d.zip
gcc-5f2408712a4e3994ad903c2f72af19c5a473ef5d.tar.gz
gcc-5f2408712a4e3994ad903c2f72af19c5a473ef5d.tar.bz2
modula2: iso library SysClock.mod and wrapclock.cc fixes.
This patch corrects the C equivalent of m2 LONGINT parameters in wrapclock.cc and corrects the SysClock.mod module. wrapclock.cc uses a typedef long long int longint_t to match m2 LONGINT (rather than unsigned long). These fixes prevent calls to SysClock hanging spinning on an (incorrect) large day count from the epoch. gcc/m2/ChangeLog: * gm2-compiler/M2Quads.mod (EndBuildFor): Improve block comments. * gm2-libs-iso/SysClock.mod (ExtractDate): Replace testDays with yearOfDays. New local variable monthOfDays. libgm2/ChangeLog: * libm2iso/wrapclock.cc (longint_t): New declaration. (GetTimespec): Replace types for sec and nano with longint_t. (SetTimespec): Replace types for sec and nano with longint_t. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/m2/gm2-compiler/M2Quads.mod6
-rw-r--r--gcc/m2/gm2-libs-iso/SysClock.mod20
2 files changed, 15 insertions, 11 deletions
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index 95ca15a..f3a5c05 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -4625,7 +4625,7 @@ BEGIN
BuildRange (InitForLoopEndRangeCheck (tsym, BySym)) ; (* --fixme-- pass endpostok. *)
IncQuad := NextQuad ;
(* we have explicitly checked using the above and also
- this addition can legally overflow if a cardinal type
+ this addition can legitimately overflow if a cardinal type
is counting down. The above test will generate a more
precise error message, so we suppress overflow detection
here. *)
@@ -4636,7 +4636,7 @@ BEGIN
BuildRange (InitForLoopEndRangeCheck (IdSym, BySym)) ;
IncQuad := NextQuad ;
(* we have explicitly checked using the above and also
- this addition can legally overflow if a cardinal type
+ this addition can legitimately overflow if a cardinal type
is counting down. The above test will generate a more
precise error message, so we suppress overflow detection
here. *)
@@ -5548,7 +5548,7 @@ END IsReallyPointer ;
(*
- LegalUnboundedParam - returns TRUE if the parameter, Actual, can legally be
+ LegalUnboundedParam - returns TRUE if the parameter, Actual, can legitimately be
passed to ProcSym, i, the, Formal, parameter.
*)
diff --git a/gcc/m2/gm2-libs-iso/SysClock.mod b/gcc/m2/gm2-libs-iso/SysClock.mod
index 56d5503..5f2c377 100644
--- a/gcc/m2/gm2-libs-iso/SysClock.mod
+++ b/gcc/m2/gm2-libs-iso/SysClock.mod
@@ -137,7 +137,8 @@ END daysInYear ;
(*
- ExtractDate - extracts the year, month, day from days.
+ ExtractDate - extracts the year, month, day from secs. days is the
+ total days since 1970.
*)
PROCEDURE ExtractDate (days: LONGCARD;
@@ -145,28 +146,29 @@ PROCEDURE ExtractDate (days: LONGCARD;
VAR
testMonth,
testYear : CARDINAL ;
- testDays : LONGCARD ;
+ monthOfDays,
+ yearOfDays : LONGCARD ;
BEGIN
testYear := 1970 ;
LOOP
- testDays := daysInYear (31, 12, testYear) ;
- IF days < testDays
+ yearOfDays := daysInYear (31, 12, testYear) ;
+ IF days < yearOfDays
THEN
year := testYear ;
testMonth := 1 ;
LOOP
- testDays := daysInMonth (year, testMonth) ;
- IF days < testDays
+ monthOfDays := daysInMonth (year, testMonth) ;
+ IF days < monthOfDays
THEN
day := VAL (Day, days) + MIN (Day) ;
month := VAL (Month, testMonth) ;
RETURN
END ;
- DEC (days, testDays) ;
+ DEC (days, monthOfDays) ;
INC (testMonth)
END
ELSE
- DEC (days, testDays) ;
+ DEC (days, yearOfDays) ;
INC (testYear)
END
END
@@ -218,6 +220,8 @@ BEGIN
printf ("getclock = %ld\n", sec)
END ;
WITH userData DO
+ (* Here we keep dividing sec by max seconds, minutes, hours
+ to convert sec into total days since epoch. *)
second := VAL (Sec, DivMod (sec, MAX (Sec) + 1)) ;
minute := VAL (Min, DivMod (sec, MAX (Min) + 1)) ;
hour := VAL (Hour, DivMod (sec, MAX (Hour) + 1)) ;