On 23/05/2024 07:41, Erwin Rol wrote:
Hey all,
I am working on arm32 (imx6ul) and need to support dates beyond 2038.
With the new ptxdist 2038 support it seems to work in C, but I ran into
problems with C++.
The following code;
auto t = std::chrono::system_clock::now();
does not seem to work correctly. When the system date is less than 2038
it works and gives back the correct time, but for dates > 2038 it seems
to return some 1970 date.
Conversion functions on the other hand seem to work;
auto t = std::chrono::system_clock::from_time_t(time(nullptr));
does a correct conversion of dates > 2038.
The defines like _TIME_BITS=64 are set correctly, and time_t is 64bit.
Also calls like gettimeofday() works correctly.
Since the C++ std lib is part of the Toolchain, can it be that the
Toolchain is not build correctly ?
Anybody any experience with y2038 in C++ on ptxdist ?
best regards,
Erwin
I guess that libstdc++ in the toolchain would need to be rebuilt with
64-bit time_t support. Although <chrono> uses a 64-bit integer type
internally, some of the functions such as
std::chrono::system_clock::now() use compiled in code that picks up the
C system time ABI at the time libstdc++ was built. So now() will read
the system time using the 32-bit system time ABI (so will suffer from
Y2038 problems) and convert it to its own internal 64-bit integer type.
Other functions such as
std::chrono::system_clock::from_time_t(std::time_t) are not compiled in
so will use whatever C system time ABI was selected when <chrono> was
included.
--
-=( Ian Abbott <[email protected]> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-