gm2
[Top][All Lists]
Advanced

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

gettimeofday failing


From: une
Subject: gettimeofday failing
Date: Mon, 27 May 2024 22:57:04 -0300
User-agent: Cyrus-JMAP/3.11.0-alpha0-491-g033e30d24-fm-20240520.001-g033e30d2

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.



reply via email to

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