aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-08-12 18:17:41 +0100
committerGaius Mulley <gaiusmod2@gmail.com>2023-08-12 18:17:41 +0100
commit63fb0bedb8077ac1e6b6337f198b4eae30813fbc (patch)
tree5a66a3f4f6f25ab7d12256efaa1afe1d2be13b13 /gcc
parent46905fcde00fd84eb06b6bd1a6e788171d32865b (diff)
downloadgcc-63fb0bedb8077ac1e6b6337f198b4eae30813fbc.zip
gcc-63fb0bedb8077ac1e6b6337f198b4eae30813fbc.tar.gz
gcc-63fb0bedb8077ac1e6b6337f198b4eae30813fbc.tar.bz2
PR modula2/110779 SysClock can not read the clock (Darwin portability fixes)
This patch adds corrections to defensively check against glibc functions, structures and contains fallbacks. These fixes were required under Darwin. gcc/m2/ChangeLog: PR modula2/110779 * gm2-libs-iso/SysClock.mod (EpochTime): New procedure. (GetClock): Call EpochTime if the C time functions are unavailable. * gm2-libs-iso/wrapclock.def (istimezone): New function definition. libgm2/ChangeLog: PR modula2/110779 * configure: Regenerate. * configure.ac: Provide special case test for Darwin cross configuration. (GLIBCXX_CONFIGURE): New statement. (GLIBCXX_CHECK_GETTIMEOFDAY): New statement. (GLIBCXX_ENABLE_LIBSTDCXX_TIME): New statement. * libm2iso/wrapclock.cc: New sys/time.h conditional include. (sys/syscall.h): Conditional include. (unistd.h): Conditional include. (GetTimeRealtime): Re-implement. (SetTimeRealtime): Re-implement. (timezone): Re-implement. (istimezone): New function. (daylight): Re-implement. (isdst): Re-implement. (tzname): Re-implement. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/m2/gm2-libs-iso/SysClock.mod34
-rw-r--r--gcc/m2/gm2-libs-iso/wrapclock.def12
2 files changed, 38 insertions, 8 deletions
diff --git a/gcc/m2/gm2-libs-iso/SysClock.mod b/gcc/m2/gm2-libs-iso/SysClock.mod
index 3313309..56d5503 100644
--- a/gcc/m2/gm2-libs-iso/SysClock.mod
+++ b/gcc/m2/gm2-libs-iso/SysClock.mod
@@ -173,6 +173,26 @@ BEGIN
END ExtractDate ;
+(*
+ EpochTime - assigns all fields of userData to 0 or FALSE.
+*)
+
+PROCEDURE EpochTime (VAR userData: DateTime) ;
+BEGIN
+ WITH userData DO
+ second := 0 ;
+ minute := 0 ;
+ hour := 0 ;
+ year := 0 ;
+ month := 0 ;
+ day := 0 ;
+ fractions := 0 ;
+ zone := 0 ;
+ summerTimeFlag := FALSE
+ END
+END EpochTime ;
+
+
PROCEDURE GetClock (VAR userData: DateTime) ;
(* Assigns local date and time of the day to userData *)
VAR
@@ -207,10 +227,10 @@ BEGIN
summerTimeFlag := (isdst () = 1)
END
ELSE
- HALT
+ EpochTime (userData)
END
ELSE
- HALT
+ EpochTime (userData)
END ;
ts := KillTimespec (ts)
END
@@ -310,13 +330,11 @@ BEGIN
userData.month, userData.year) ;
offset := timezone () ;
sec := VAL (LONGINT, sec) - offset ;
- IF SetTimespec (ts, sec, nano) = 0
- THEN
- HALT
- END ;
- IF SetTimeRealtime (ts) # 0
+ IF SetTimespec (ts, sec, nano) = 1
THEN
- HALT
+ IF SetTimeRealtime (ts) = 0
+ THEN
+ END
END ;
ts := KillTimespec (ts)
END
diff --git a/gcc/m2/gm2-libs-iso/wrapclock.def b/gcc/m2/gm2-libs-iso/wrapclock.def
index 1dd12e1..9f5f286 100644
--- a/gcc/m2/gm2-libs-iso/wrapclock.def
+++ b/gcc/m2/gm2-libs-iso/wrapclock.def
@@ -36,12 +36,24 @@ TYPE
timezone - return the glibc timezone value.
This contains the difference between UTC and the latest
local standard time, in seconds west of UTC.
+ If the underlying timezone is unavailable and
+ clock_gettime, localtime_r, tm_gmtoff
+ is unavailable then 0 is returned.
*)
PROCEDURE timezone () : LONGINT ;
(*
+ istimezone returns 1 if timezone in wrapclock.cc can resolve the
+ timezone value using the timezone C library call or by using
+ clock_gettime, localtime_r and tm_gmtoff.
+*)
+
+PROCEDURE istimezone () : INTEGER ;
+
+
+(*
daylight - return the glibc daylight value.
This variable has a nonzero value if Daylight Saving
Time rules apply.