gm2
[Top][All Lists]
Advanced

[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

Hi,

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.

Regards,
Andreas Fischlin


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


+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 <une@fastmail.fm> wrote:

Hi.

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;

BEGIN

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

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

   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
Aborted
`

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

I handcoded
#define HAVE_STRUCT_TIMEZONE 1
#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
`

👍

Carlos.


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


reply via email to

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