On 1/3/25 18:59, p...@debian.org wrote:
Le 2025-01-03 17:43, Helge Deller a écrit :
On 1/3/25 15:55, p...@debian.org wrote:
You were right about the gmtime() function being involved. It
appears that on powerpc and hppa it returns 01/01/1970. I've set up a
reproducer (attached).
That's what I needed.
Thanks!
On powerpc / hppa:
$ gfortran -g -o test_gmtime test_gmtime.F90
$ ./test_gmtime
time8: 1735915109
Year: 1970
Month: 1
Day: 1
Hour: 0
Minute: 0
Second: 0
On amd64:
$ gfortran -g -o test_gmtime test_gmtime.F90
0 ;) pini@pinibrem14:~/tmp/h5gmtime
$ ./test_gmtime
time8: 1735915041
Year: 2025
Month: 1
Day: 3
Hour: 14
Minute: 37
Second: 21
I don't know how to solve this yet.
Ok, I know how to fix it:
In your fortran example, replace
FUNCTION gmtime_c(stdtime_t) BIND(C, NAME='gmtime')
by:
FUNCTION gmtime_c(stdtime_t) BIND(C, NAME='__gmtime64')
On 32-bit platforms, glibc provides "gmtime" for 32-bit time_t,
and __gmtime64 for 64-bit time_t. At compile time depending
on defines, one or the other is used.
Is it possible to detect during config time, if that function
is exported by glibc, and then use it if it's available?
I'm not sure that would be the correct solution. I think there is
now an inconsistency between gcc and gfortran on hppa and powerpc,
the former using __gmtime64 as the default for gmtime, and the
latter sticking to its legacy 32-bit implementation.
No. Both use the 64-bit implementation on debian, since debian
defines _TIME_BITS=64 on all 32-bit platforms (beside x86 due to
compatibility).
The rule should be:
if H5_SIZEOF_TIME_T == 8
use __gmtime64 if glibc provides it, else
use gmtime which is the default.
else
use gmtime
This works for all: 32- and 64-bit, big- and little-endian.
This problem doesn't exist on litte-endian 32-bit architectures.
Yes, it does.
The only difference is, that on little-endian the lower 32-bits of
the time_t value is stored in the first 4 bytes (and thus have the correct
value), while on big endian the upper 32bits (which are zero) are stored
in the lower 4 bytes - which is why you get here the wrong date.