summaryrefslogtreecommitdiff
path: root/libgm2
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 /libgm2
parent0f184b4141e9d285c19b3a3d02bffa45bc0d8f07 (diff)
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 'libgm2')
-rw-r--r--libgm2/libm2iso/wrapclock.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/libgm2/libm2iso/wrapclock.cc b/libgm2/libm2iso/wrapclock.cc
index 1f4ca8c325d..a4d62b7085c 100644
--- a/libgm2/libm2iso/wrapclock.cc
+++ b/libgm2/libm2iso/wrapclock.cc
@@ -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)