mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
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>
This commit is contained in:
parent
0f184b4141
commit
5f2408712a
@ -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.
|
||||
*)
|
||||
|
||||
|
@ -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)) ;
|
||||
|
@ -75,6 +75,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
typedef long long int longint_t;
|
||||
|
||||
|
||||
/* GetTimeRealtime performs return gettime (CLOCK_REALTIME, ts).
|
||||
gettime returns 0 on success and -1 on failure. If the underlying
|
||||
@ -175,7 +177,7 @@ EXPORT(KillTimespec) (void *ts)
|
||||
|
||||
#if defined(HAVE_STRUCT_TIMESPEC)
|
||||
extern "C" int
|
||||
EXPORT(GetTimespec) (timespec *ts, unsigned long *sec, unsigned long *nano)
|
||||
EXPORT(GetTimespec) (timespec *ts, longint_t *sec, longint_t *nano)
|
||||
{
|
||||
#if defined(HAVE_STRUCT_TIMESPEC)
|
||||
*sec = ts->tv_sec;
|
||||
@ -188,7 +190,7 @@ EXPORT(GetTimespec) (timespec *ts, unsigned long *sec, unsigned long *nano)
|
||||
|
||||
#else
|
||||
extern "C" int
|
||||
EXPORT(GetTimespec) (void *ts, unsigned long *sec, unsigned long *nano)
|
||||
EXPORT(GetTimespec) (void *ts, longint_t *sec, longint_t *nano)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -199,7 +201,7 @@ EXPORT(GetTimespec) (void *ts, unsigned long *sec, unsigned long *nano)
|
||||
|
||||
#if defined(HAVE_STRUCT_TIMESPEC)
|
||||
extern "C" int
|
||||
EXPORT(SetTimespec) (timespec *ts, unsigned long sec, unsigned long nano)
|
||||
EXPORT(SetTimespec) (timespec *ts, longint_t sec, longint_t nano)
|
||||
{
|
||||
#if defined(HAVE_STRUCT_TIMESPEC)
|
||||
ts->tv_sec = sec;
|
||||
@ -213,13 +215,13 @@ EXPORT(SetTimespec) (timespec *ts, unsigned long sec, unsigned long nano)
|
||||
#else
|
||||
|
||||
extern "C" int
|
||||
EXPORT(SetTimespec) (void *ts, unsigned long sec, unsigned long nano)
|
||||
EXPORT(SetTimespec) (void *ts, longint_t sec, longint_t nano)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" long int
|
||||
extern "C" longint_t
|
||||
EXPORT(timezone) (void)
|
||||
{
|
||||
#if defined(HAVE_STRUCT_TIMESPEC)
|
||||
|
Loading…
Reference in New Issue
Block a user