[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettimeofday failing

From: Fischlin Andreas
Subject: Re: gettimeofday failing
Date: Tue, 28 May 2024 15:39:30 +0000


The M2 code seems fine, while I do not know what the procedures you call from module wraptime ought to do in any detail. If you encounter problems, this has merely something to do with the implementaton of module wraptime and perhaps the interactions with your system.

Andreas Fischlin

ETH Zurich
Prof. em. Dr. Andreas Fischlin
Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics
CHN E 24
Universitaetstrasse 16
8092 Zurich

+41 44 633-6090 phone
+41 79 595-4050 mobile

             Make it as simple as possible, but distrust it!

On 28 May 2024, at 03:57, une <> wrote:


I'm new to modula2. I tried to compile the following code on my debian-x86_64:

MODULE hello5;

FROM StrIO IMPORT WriteString, WriteLn;
FROM NumberIO IMPORT WriteInt;
FROM wraptime IMPORT timeval, InitTimeval, KillTimeval, gettimeofday, timezone, InitTimezone, KillTimezone, localtime_r, tm, InitTM, KillTM, GetYear, GetMonth, GetDay;

VAR tv: timeval;
   tz: timezone;
   i: INTEGER;
   m: tm;


   tv := InitTimeval();
   tz := InitTimezone();
   m  := InitTM();
   i  := gettimeofday(tv, tz);
   m  := localtime_r(tv, m);

   WriteString("i = ");
   WriteInt(i, 0);
   WriteString("Year = ");
   WriteInt(GetYear(m), 0);
   WriteString("Month = ");
   WriteInt(GetMonth(m), 0);
   WriteString("Day = ");
   WriteInt(GetDay(m), 0);

   m  := KillTM(m);
   tv := KillTimeval(tv);
   tz := KillTimezone(tz);
END hello5.

Compiler version:
$ gm2 --version
gm2 (Debian 12.2.0-14) 12.2.0

Compilation result: success.
Execution result:
i = -1
Year = -1
Month = -1
Day = -1

Then I tried gm2/gcc-14.1.0 built from the release tarball.
$ gm2 --version
gm2 (GCC) 14.1.0

Compilation result: success.
Execution result:
RTExceptions.mod:650:35: In invalidloc
RTExceptions.mod:650:35:invalid address referenced

A quick look at it appears that my system is failing at `HAVE_STRUCT_TIMEZONE` and `HAVE_STRUCT_TM`.

I handcoded
#define HAVE_STRUCT_TM 1
and rebuilt. I'm aware that hardcoding is not a good practice, it's just quick test.

Execution result:
i = 0
Year = 124
Month = 4
Day = 28



Attachment: smime.p7s
Description: S/MIME cryptographic signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]