From: Ian Abbott <abbotti@mev.co.uk>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] year 2038 Toolchain
Date: Fri, 24 May 2024 09:41:30 +0100 [thread overview]
Message-ID: <cf591c88-779a-45a7-a82c-e5452540f62d@mev.co.uk> (raw)
In-Reply-To: <d27639a9-411e-4b87-add9-4619b8627908@erwinrol.com>
On 23/05/2024 12:52, Erwin Rol wrote:
> On 5/23/24 12:38, Ian Abbott wrote:
>> On 23/05/2024 07:41, Erwin Rol wrote:
>
>>> 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.
>>>
>>
>> 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.
>>
>
> I believe libstd++ uses gettimeofday internally, which should use time_t
> for the seconds field, which should be 64bit if _TIME_BITS=64 is
> defined. I just hacked the Toolchain to try it, but it is a slow
> process, build toolchain -> build project -> test :-)
>
> If I figure it out I'll let you guys know (so it can be added to the
> official Toolchain)
Rememember to define _FILE_OFFSET_BITS=64 too if it is not already
defined. _TIME_BITS=64 is ineffective when _FILE_OFFSET_BITS=32 for
Glibc policy reasons.
--
-=( Ian Abbott <abbotti@mev.co.uk> || 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 )=-
next prev parent reply other threads:[~2024-05-24 8:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 6:41 Erwin Rol
2024-05-23 10:38 ` Ian Abbott
2024-05-23 11:52 ` Erwin Rol
2024-05-24 8:41 ` Ian Abbott [this message]
2024-05-24 9:04 ` Erwin Rol
2024-05-24 10:19 ` Michael Olbrich
2024-05-27 8:32 ` Erwin Rol
2024-05-27 10:34 ` Christian Melki
2024-05-23 6:57 Erwin Rol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cf591c88-779a-45a7-a82c-e5452540f62d@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox