From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 915833857C5A for ; Sat, 5 Dec 2020 00:12:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 915833857C5A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: EpFTQTYSmU0T/JRPasnrtCYWfI4amlu8xNlOTxmTiq/IpQtHopngxMhGxLUXYW9pZKhJEVDavS 2/zolsxqqSwr3QraJqMaYXhOkyQRhZidfkV2Rw7Hz//Qs2ePzobiyJvz8gpYOVUvloQB+6M4iN DM/mRjPM4jFflXymWCHm9erQoe0we/BKhs2HIzoHi/lUAaRCK+yUIG+v8pvRMnv7WB2jPG5WHy atLqsNR+IPafdBI/51upuUa7lma4gqfR+U+9qjlsN7tl5U8QMQv/z0sF7CL4wf6p6mQ7S1XPt8 ZpA= X-IronPort-AV: E=Sophos;i="5.78,394,1599552000"; d="scan'208";a="55964349" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 04 Dec 2020 16:12:50 -0800 IronPort-SDR: aBQz4PWaQAVJaydSk539fVpS6pZPR78ahxYD7Ak02M0B4G04SAlbDszM5AHEGkt/u9D6OK9muV ycue2ctu7Fe2TZOi6fpnhI8SYg4wNWjfvIkoW0KaXxF+w0qAhBgGLTgr7pWvWsoqab/Y1SU0wW 3jf4mrqj8EKAK7EI5lRC2BTAABvg7kb2NrgnyalA1hITP2Ir2/SB1/fywW81zjrt5l8WswYhbT zdbf0OfqehIM1Xynz2tdl1QU2T8uUtXTLxxS5xSWgYBu/3feO0y+rsR9oxCBehitsBBNX0bjYw rEw= Date: Sat, 5 Dec 2020 00:12:44 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Lukasz Majewski CC: Paul Eggert , Adhemerval Zanella , Florian Weimer , GNU C Library , Siddhesh Poyarekar , Andreas Schwab , Stepan Golosunov , Alistair Francis Subject: Re: [RFC 1/6] y2038: Introduce _TIME_BITS flag to support 64 bit time on 32 bit systems In-Reply-To: <20201204233604.7430-2-lukma@denx.de> Message-ID: References: <20201204233604.7430-1-lukma@denx.de> <20201204233604.7430-2-lukma@denx.de> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3124.8 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Dec 2020 00:12:53 -0000 On Sat, 5 Dec 2020, Lukasz Majewski wrote: > This change introduces new compile time, supported by glibc flag - namely > _TIME_BITS, which then is responsible for exporting __USE_TIME_BITS64 only As a major new user-visible feature, this needs to be mentioned in NEWS. > +/* We need to know the word size in order to check the time size. */ > +#include > + > +#if defined _TIME_BITS > +# if _TIME_BITS == 64 > +# if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64 > +# error _TIME_BITS==64 is allowed only when _FILE_OFFSET_BITS==64 > +# elif __WORDSIZE == 32 > +# define __USE_TIME_BITS64 1 > +# endif __WORDSIZE isn't the right thing to check. On ARC or RV32 or x32, _TIME_BITS == 64 should be a no-op, because time_t has always been 64-bit for those glibc ports. That is, you should be checking __TIMESIZE, not __WORDSIZE. > +# elif _TIME_BITS == 32 > +# if __WORDSIZE > 32 > +# error _TIME_BITS=32 is not compatible with __WORDSIZE > 32 Likewise, __TIMESIZE should be checked here, not __WORDSIZE. > +@defvr Macro _TIME_BITS > +This macro determines the bit size of @code{time_t} (and therefore the > +bit size of all @code{time_t} derived types and the prototypes of all > +related functions). If @code{_TIME_BITS} is undefined, the bit size of > +time_t equals the bit size of the architecture. Apart from "bit size of the architecture" not being well-defined, that's not right for ARC or RV32, 32-bit architectures with 64-bit time_t. Note there should be two spaces after "." in Texinfo manuals. > +If @code{_TIME_BITS} is undefined, or if @code{_TIME_BITS} is defined > +to the value @code{32} and @code{__WORDSIZE} is defined to the value > +@code{32}, or or if @code{_TIME_BITS} is defined to the value @code{64} > +and @code{__WORDSIZE} is defined to the value @code{64}, nothing changes. __WORDSIZE (and __TIMESIZE after the fix above) is not a user-visible interface, it's a glibc header implementation detail. The manual (other than maint.texi) should not mention either such internal macro; you need to talk about a concept of word size / default time_t size that's explained purely in user-level interfaces, not glibc internal macros. > +If @code{_TIME_BITS} is defined to the value @code{64} and if > +@code{__WORDSIZE} is defined to the value @code{32}, then the @w{64 bit} > +time API and implementation are used even though the architecture word > +size is @code{32}. Also, if the kernel provides @w{64 bit} time support, > +it is used; otherwise, the @w{32 bit} kernel time support is used (with > +no provision to address kernel Y2038 shortcomings). Use "32-bit" and "64-bit" (with hyphen) as adjectives. -- Joseph S. Myers joseph@codesourcery.com