From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 23 May 2024 12:39:04 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sA5qi-00F1fJ-1Y for lore@lore.pengutronix.de; Thu, 23 May 2024 12:39:04 +0200 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1sA5qi-0000MX-64; Thu, 23 May 2024 12:39:04 +0200 Received: from smtp122.ord1d.emailsrvr.com ([184.106.54.122]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sA5qM-0000Lx-SJ for ptxdist@pengutronix.de; Thu, 23 May 2024 12:38:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1716460721; bh=ApFbwxNxARh8gUzjXVOLtU/1WHfLdSNoY+a+mslVuCk=; h=Date:Subject:To:From:From; b=faSEXGscZEYMEs1gzwB2RVdNjM+0TEV0Fvc4Gwn4SIRo8cvsUEp57CLXVptRCvjbs 5I3c9bVmpQzvpusHshKfOUXHdv54GNlYMbI4DyC88Ybm7FyiKoCquT0fuzmmINn/4Z wzhKI4YXSmJdAblRwUo/xFrhhhw+ZxXwKpGhuMVE= X-Auth-ID: abbotti@mev.co.uk Received: by smtp24.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id CC953A010E; Thu, 23 May 2024 06:38:40 -0400 (EDT) Message-ID: Date: Thu, 23 May 2024 11:38:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ptxdist@pengutronix.de, Erwin Rol References: <24f03e42-a9ab-4303-9d0e-3b1ff24e0097@erwinrol.com> Content-Language: en-GB From: Ian Abbott Organization: MEV Ltd. In-Reply-To: <24f03e42-a9ab-4303-9d0e-3b1ff24e0097@erwinrol.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Classification-ID: 40271e0d-98d3-4469-b0c3-72fe851c0049-1-1 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-3.2 required=4.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [ptxdist] year 2038 Toolchain X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false 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 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 was included. -- -=( Ian Abbott || 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 )=-