0

I'm trying to port my 32-bit ARM architecture to 64-bit time values.

Reading the answers from 64-bit time_t in Linux Kernel it tells me the following:

All user space must be compiled with a 64-bit time_t, which will be supported in the coming musl-1.2 and glibc-2.32 releases, along with installed kernel headers from linux-5.6 or higher.

I'm using a custom Linux kernel version 5.10.10 and build my own gcc toolchain with crosstool-ng using glibc version 2.32.

To test the time sizes, I wrote a simple print:

printf("Timesize = %d\n", __TIMESIZE);
printf("sizeof time_t = %d\n", sizeof(tv.tv_sec));

Which gives me the output:

Timesize = 32
sizeof time_t = 4

Following the defines and typedefs in glibc-2.32, I can see the relevant types defined as follows:

#define __TIMESIZE __WORDSIZE

#define __TIME_T_TYPE __SLONGWORD_TYPE

#define __SLONGWORD_TYPE long int

But __WORDSIZE and __SLONGWORD_TYPE are both 32-bit in size for my architecture.

Is it possible to have time_t defined as 64-bit on my 32-bit architecture target?

phuclv
  • 37,963
  • 15
  • 156
  • 475
D. Smith
  • 53
  • 1
  • 5
  • 1
    I guess you will need to add "sysdeps/unix/sysv/linux/arm/bits/timesize.h" (with include guard macros) to define `__TIMESIZE` as `64`. For 32-bit ARM Linux, the definition of `__TIME_T_TYPE` will come from "sysdeps/unix/sysv/linux/generic/bits/timesize.h". For glibc-2.32, if `__TIMESIZE == 64` and `__WORDSIZE == 32`, then `__TIME_T_TYPE` will be defined as `__SQUAD_TYPE` (a 64-bit signed integer type). – Ian Abbott Jun 09 '21 at 15:26
  • 1
    I believe the overall plan in glibc is for architectures that currently use 32-bit `time_t` to have a dual 32-bit/64-bit `time_t` interface selectable at application compile time with the `-D_TIME_BITS=32` or `-D_TIME_BITS=64` compiler command-line option (similar to the existing `-D_FILE_OFFSET_BITS=64` option for large file support). There is ongoing work in the "origin/azanella/y2038" branch of glibc's git repository. – Ian Abbott Jun 09 '21 at 15:53

0 Answers0