From patchwork Wed Dec 9 14:53:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 41347 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 976AE396EC90; Wed, 9 Dec 2020 14:54:23 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id ABD2F386F439 for ; Wed, 9 Dec 2020 14:54:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ABD2F386F439 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Crg6x0wBGz1ryWv; Wed, 9 Dec 2020 15:54:17 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Crg6w5zjcz1tnH8; Wed, 9 Dec 2020 15:54:16 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 6Pm_qdxHysi7; Wed, 9 Dec 2020 15:54:15 +0100 (CET) X-Auth-Info: Pqyqns5uLBv6Qi9EnGQYlAomg/LBLw2+cI5qKcS95u0= Received: from localhost.localdomain (89-64-25-12.dynamic.chello.pl [89.64.25.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 9 Dec 2020 15:54:15 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC] y2038: test: Add _Static_assert() check when __USE_TIME_BITS64 is defined Date: Wed, 9 Dec 2020 15:53:31 +0100 Message-Id: <20201209145331.18819-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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: , Cc: Florian Weimer , GNU C Library , Siddhesh Poyarekar , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This check is added to exported time/time.h file to check in the compile time if time_t and struct timespec have proper sizes and alignment. It shall prevent from compiling user programs with -D_TIME_BITS=64 when time related data structures are not supporting 64 bit time. --- time/time.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/time/time.h b/time/time.h index 9a74f01b2f..d293ff3dc5 100644 --- a/time/time.h +++ b/time/time.h @@ -446,4 +446,12 @@ extern int getdate_r (const char *__restrict __string, __END_DECLS +#define CHECK_TIME64_SIZE(__name, __len) \ + _Static_assert (sizeof (__name) == __len, "Size of " #__name " != " #__len) + +#ifdef __USE_TIME_BITS64 + CHECK_TIME64_SIZE(time_t, 8); + CHECK_TIME64_SIZE(struct timespec, 16); +#endif + #endif /* time.h. */