From patchwork Wed Nov 18 09:43:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 41092 X-Patchwork-Delegate: l.majewski@majess.pl 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 3D1603986818; Wed, 18 Nov 2020 09:44:01 +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 610D8398680F for ; Wed, 18 Nov 2020 09:43:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 610D8398680F 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 4CbdDY433Xz1s00C; Wed, 18 Nov 2020 10:43:57 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CbdDY2Nvdz1r4PQ; Wed, 18 Nov 2020 10:43:57 +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 x7p8UQwJOgXb; Wed, 18 Nov 2020 10:43:55 +0100 (CET) X-Auth-Info: tyy7LtUxqDektMkTvR3n8TmSf6OeoygyoSYO8Z4ET50= Received: from localhost.localdomain (89-64-5-98.dynamic.chello.pl [89.64.5.98]) (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, 18 Nov 2020 10:43:55 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH] tst: y2038: Add test to check sizes of struct timespec and time_t Date: Wed, 18 Nov 2020 10:43:30 +0100 Message-Id: <20201118094330.27186-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, 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 , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --- time/Makefile | 2 +- time/tst-y2038-sizes.c | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 time/tst-y2038-sizes.c diff --git a/time/Makefile b/time/Makefile index f27a75a115..e09d17f231 100644 --- a/time/Makefile +++ b/time/Makefile @@ -48,7 +48,7 @@ tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \ tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \ tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3 \ tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1 \ - tst-adjtime + tst-adjtime tst-y2038-sizes include ../Rules diff --git a/time/tst-y2038-sizes.c b/time/tst-y2038-sizes.c new file mode 100644 index 0000000000..5f3bbd3c4b --- /dev/null +++ b/time/tst-y2038-sizes.c @@ -0,0 +1,47 @@ +/* Test for most important time related variables (structs) + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Defines necessary for Y2038 time support on ports with + __WORDSIZE == 32 and __TIMESIZE == 64. */ +#define _TIME_BITS 64 +#define _FILE_OFFSET_BITS 64 + +#include +#include + +static int +do_test (void) +{ + struct timespec t0; + time_t t; + +#if __TIMESIZE == 64 || defined __USE_TIME_BITS64 + TEST_COMPARE (sizeof(t), 8); + TEST_COMPARE (sizeof(t0), 16); + TEST_COMPARE (sizeof(t0.tv_sec), 8); + TEST_COMPARE (sizeof(t0.tv_nsec), 8); +#else + TEST_COMPARE (sizeof(t), 4); + TEST_COMPARE (sizeof(t0), 8); + TEST_COMPARE (sizeof(t0.tv_sec), 4); + TEST_COMPARE (sizeof(t0.tv_nsec), 4); +#endif + return 0; +} + +#include