From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5B7071F45E for ; Sat, 15 Feb 2020 13:57:50 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=uMOEk FFxUB7wx4/Hh/8nqCa+0M7MNTLBG2cQ9XbNFqCiW6ROzbDRNjJemdpr/a2DGNVlj EnNWavUxzUeJyRETtuKl4U1h82SRdE5i71JP4ZJQZACdLYINk0PsMetHjIKYKC6V HsJEDdPa2JvR/kQR+fxPS23Biu6GeKDx+KhC44= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=4iTHICSORfB 0c65a6qud1Rg/AcE=; b=daDJrkbdyiD2TQ0bp4PHyHNV/Suq4StWa5ZetWTOJXj 8xCTl+coNMF0BPqu3/S8iywKfOn9M7EkWghMI8jx0BWiiwfn62jGuQeelpkeZvhw MmdhJtVocQs4LoqlaM7XsPGIJ/ae2CIfgcuBawz45Zz92NjKKYOOwuN2Q2SpfUQc = Received: (qmail 19907 invoked by alias); 15 Feb 2020 13:57:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 19876 invoked by uid 89); 15 Feb 2020 13:57:43 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-out.m-online.net Date: Sat, 15 Feb 2020 14:57:36 +0100 From: Lukasz Majewski To: Alistair Francis Cc: libc-alpha@sourceware.org, alistair23@gmail.com Subject: Re: [PATCH v3 2/8] time: Add a timeval with a 32-bit tv_sec and tv_usec Message-ID: <20200215145736.4ccd87a2@jawa> In-Reply-To: <20200214163134.31601-3-alistair.francis@wdc.com> References: <20200214163134.31601-1-alistair.francis@wdc.com> <20200214163134.31601-3-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/en0fOCcw+rLw4AKIAlYxsWB"; protocol="application/pgp-signature" --Sig_/en0fOCcw+rLw4AKIAlYxsWB Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 14 Feb 2020 08:31:28 -0800 Alistair Francis wrote: > On y2038 safe 32-bit systems the Linux kernel expects itimerval to > use a 32-bit time_t, even though the other time_t's are 64-bit. To > address this let's add a __timeval32 struct to be used internally. Reviewed-by: Lukasz Majewski > --- > include/time.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) >=20 > diff --git a/include/time.h b/include/time.h > index 73f66277ac..ddc0ded640 100644 > --- a/include/time.h > +++ b/include/time.h > @@ -400,6 +400,51 @@ timespec64_to_timeval64 (const struct > __timespec64 ts64) return tv64; > } > =20 > +/* A version of 'struct timeval' with 32-bit time_t > + and suseconds_t. */ > +struct __timeval32 > +{ > + __int32_t tv_sec; /* Seconds. */ > + __int32_t tv_usec; /* Microseconds. */ > +}; > + > +/* Conversion functions for converting to/from __timeval32 */ > +static inline struct __timeval64 > +valid_timeval32_to_timeval64 (const struct __timeval32 tv) > +{ > + return (struct __timeval64) { tv.tv_sec, tv.tv_usec }; > +} > + > +static inline struct __timeval32 > +valid_timeval64_to_timeval32 (const struct __timeval64 tv64) > +{ > + return (struct __timeval32) { tv64.tv_sec, tv64.tv_usec }; > +} > + > +static inline struct timeval > +valid_timeval32_to_timeval (const struct __timeval32 tv) > +{ > + return (struct timeval) { tv.tv_sec, tv.tv_usec }; > +} > + > +static inline struct __timeval32 > +valid_timeval_to_timeval32 (const struct timeval tv) > +{ > + return (struct __timeval32) { tv.tv_sec, tv.tv_usec }; > +} > + > +static inline struct timespec > +valid_timeval32_to_timespec (const struct __timeval32 tv) > +{ > + return (struct timespec) { tv.tv_sec, tv.tv_usec * 1000 }; > +} > + > +static inline struct __timeval32 > +valid_timespec_to_timeval32 (const struct timespec ts) > +{ > + return (struct __timeval32) { (time_t) ts.tv_sec, ts.tv_nsec / > 1000 }; +} > + > /* Check if a value is in the valid nanoseconds range. Return true if > it is, false otherwise. */ > static inline bool Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/en0fOCcw+rLw4AKIAlYxsWB Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl5H+NAACgkQAR8vZIA0 zr2a2Af6A/A85Fq25Yqa5H05JLZU4eJmcDRjljR6gKg6+ldR7g2vZtZ2Ud7/KD3L FEf/tQFf0ZiiOUqtsFt7QY9+SYjHH+AbOEaglmy4NQw+GTu4XpW8VToHT9Q2kWOK OjrYPD51TLP0BdoqYM4YoMqccVMfAqKBXaToH5UWhSuhsywXSkDATVd7C8MU6wmM arCUe59plw1DqAz+reoX5t2iwRz7AdwBDeJBfTtw7vpCay9QnW1V6vjuDz4PtfWV vz3r3jUYH687G0YXUOnY9XhmueNq1FAm+35Hq3JXO36fckao8imxCOZnbQ9iP73k jwOVr4Oqr+DWzFKeAiHxmGi3Ht/Uvg== =Tt1Y -----END PGP SIGNATURE----- --Sig_/en0fOCcw+rLw4AKIAlYxsWB--