Is there any C++ implementation of 64-bit Unix timestamp conversions for 32-bit systems? I need to convert struct tm
to 64-bit integer and vice versa, including
64-bit time support on 32-bit Linux was first introduced in the 5.1 kernel with the addition of the new *time64 syscalls (because changing the return type of old system calls breaks old applications). Check this table and you'll see that those syscalls are only available on 32-bit platforms.
But that's only support from the kernel side. You can call clock_gettime64
directly (from inline assembly, or from C with syscall() function) to get the current time but you'll need Linux-specific code because there's no glibc support yet. For full userspace support you must be on Linux 5.6 or higher along with musl 1.2+ or glibc 2.32+. Just rebuild your code and time_t
will become 64-bit long. Now code that uses time_t
will become completely portable
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.Applications that use the system call interfaces directly need to be ported to use the
time64
syscalls added in linux-5.1 in place of the existing system calls. This impacts most users offutex()
andseccomp()
as well as programming languages that have their own runtime environment not based on libc.https://lkml.org/lkml/2020/1/29/355?anz=web
For more information read