aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-08-09 09:35:13 +0100
committerGaius Mulley <gaiusmod2@gmail.com>2023-08-09 09:35:13 +0100
commite3476ed2233911e6a578488899179bd91e818947 (patch)
treeef67c0a577509902889645f64aecc0914791a803 /gcc
parent6ef7956e9df910fa49bd5106139a7d26c9d51fdf (diff)
downloadgcc-e3476ed2233911e6a578488899179bd91e818947.zip
gcc-e3476ed2233911e6a578488899179bd91e818947.tar.gz
gcc-e3476ed2233911e6a578488899179bd91e818947.tar.bz2
PR modula2/110779: libgm2 fix solaris bootstrap check for tm_gmtoff
This patch defensively checks for every C function and every struct used in wrapclock.cc. It adds return values to GetTimespec and SetTimespec to allow the module to return a code representing unavailable. gcc/m2/ChangeLog: PR modula2/110779 * gm2-libs-iso/SysClock.mod (GetClock): Test GetTimespec return value. (SetClock): Test SetTimespec return value. * gm2-libs-iso/wrapclock.def (GetTimespec): Add integer return type. (SetTimespec): Add integer return type. libgm2/ChangeLog: PR modula2/110779 * config.h.in: Regenerate. * configure: Regenerate. * configure.ac (AC_CACHE_CHECK): Check for tm_gmtoff field in struct tm. (GM2_CHECK_LIB): Check for daylight, timezone and tzname. * libm2iso/wrapclock.cc (timezone): Guard against absence of struct tm and tm_gmtoff. (daylight): Check for daylight. (timezone): Check for timezone. (isdst): Check for isdst. (tzname): Check for tzname. (GetTimeRealtime): Check for struct timespec. (SetTimeRealtime): Check for struct timespec. (InitTimespec): Check for struct timespec. (KillTimespec): Check for struct timespec. (SetTimespec): Check for struct timespec. (GetTimespec): Check for struct timespec. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/m2/gm2-libs-iso/SysClock.mod45
-rw-r--r--gcc/m2/gm2-libs-iso/wrapclock.def10
2 files changed, 32 insertions, 23 deletions
diff --git a/gcc/m2/gm2-libs-iso/SysClock.mod b/gcc/m2/gm2-libs-iso/SysClock.mod
index 60261f2..3313309 100644
--- a/gcc/m2/gm2-libs-iso/SysClock.mod
+++ b/gcc/m2/gm2-libs-iso/SysClock.mod
@@ -185,25 +185,29 @@ BEGIN
ts := InitTimespec () ;
IF GetTimeRealtime (ts) = 0
THEN
- GetTimespec (ts, sec, nano) ;
- offset := timezone () ;
- IF Debugging
+ IF GetTimespec (ts, sec, nano) = 1
THEN
- printf ("getclock = %ld\n", sec)
- END ;
- sec := VAL (LONGINT, sec) + offset ;
- IF Debugging
- THEN
- printf ("getclock = %ld\n", sec)
- END ;
- WITH userData DO
- second := VAL (Sec, DivMod (sec, MAX (Sec) + 1)) ;
- minute := VAL (Min, DivMod (sec, MAX (Min) + 1)) ;
- hour := VAL (Hour, DivMod (sec, MAX (Hour) + 1)) ;
- ExtractDate (sec, year, month, day) ;
- fractions := nano DIV ((1000 * 1000 * 1000) DIV maxSecondParts) ;
- zone := - (offset DIV 60) ;
- summerTimeFlag := (isdst () = 1)
+ offset := timezone () ;
+ IF Debugging
+ THEN
+ printf ("getclock = %ld\n", sec)
+ END ;
+ sec := VAL (LONGINT, sec) + offset ;
+ IF Debugging
+ THEN
+ printf ("getclock = %ld\n", sec)
+ END ;
+ WITH userData DO
+ second := VAL (Sec, DivMod (sec, MAX (Sec) + 1)) ;
+ minute := VAL (Min, DivMod (sec, MAX (Min) + 1)) ;
+ hour := VAL (Hour, DivMod (sec, MAX (Hour) + 1)) ;
+ ExtractDate (sec, year, month, day) ;
+ fractions := nano DIV ((1000 * 1000 * 1000) DIV maxSecondParts) ;
+ zone := - (offset DIV 60) ;
+ summerTimeFlag := (isdst () = 1)
+ END
+ ELSE
+ HALT
END
ELSE
HALT
@@ -306,7 +310,10 @@ BEGIN
userData.month, userData.year) ;
offset := timezone () ;
sec := VAL (LONGINT, sec) - offset ;
- SetTimespec (ts, sec, nano) ;
+ IF SetTimespec (ts, sec, nano) = 0
+ THEN
+ HALT
+ END ;
IF SetTimeRealtime (ts) # 0
THEN
HALT
diff --git a/gcc/m2/gm2-libs-iso/wrapclock.def b/gcc/m2/gm2-libs-iso/wrapclock.def
index 9e1644b..1dd12e1 100644
--- a/gcc/m2/gm2-libs-iso/wrapclock.def
+++ b/gcc/m2/gm2-libs-iso/wrapclock.def
@@ -88,18 +88,20 @@ PROCEDURE KillTimespec (tv: timespec) : timespec ;
(*
GetTimespec - retrieves the number of seconds and nanoseconds
- from the timespec.
+ from the timespec. A return value of 0 means timespec
+ is unavailable and a return value of 1 indicates success.
*)
-PROCEDURE GetTimespec (ts: timespec; VAR sec, nano: LONGCARD) ;
+PROCEDURE GetTimespec (ts: timespec; VAR sec, nano: LONGCARD) : INTEGER ;
(*
SetTimespec - sets the number of seconds and nanoseconds
- into timespec.
+ into timespec. A return value of 0 means timespec
+ is unavailable and a return value of 1 indicates success.
*)
-PROCEDURE SetTimespec (ts: timespec; sec, nano: LONGCARD) ;
+PROCEDURE SetTimespec (ts: timespec; sec, nano: LONGCARD) : INTEGER ;
(*