From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by sourceware.org (Postfix) with ESMTPS id D43103857800; Mon, 8 Mar 2021 06:41:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D43103857800 Received: by mail-qk1-x72e.google.com with SMTP id n79so8330299qke.3; Sun, 07 Mar 2021 22:41:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tcaxzQtXKWocYuQEp4COFvIYnBXoUVetFRu+UjSrolo=; b=Av4yN4znmSnp09DVeL6ioxy0+0Snc+NLfHW8duj2d2Fw7XXI168G2rn3wV1S//pxX1 NfI9VrBYjstros4xmi79fChsy+WLD9CuLTBpwCNmCfbslL73SRA26BBzYHuwZ5uG0VoC SWB4J+QBlY0+OP0IKsmf5zyGACOtIamWIwuPnyp9s/tiDCQezCmEdGdzeQBUfelhCyaF Zj4ydoHxoZ1Fi4fMUuj7ORt17ZAYMEtLzuSvRjJ04B7aKfDtN052cydfMZ6B2JePt5bN r9VYiNJZU9GL28ydbRXfE+S0DBVVWj5h/1soUjByhtzS1T0I2wZpNF6llJErFLj13gbS 74tg== X-Gm-Message-State: AOAM5313dTmT2yYtsQCNSX5SxJt5d7ryMYdxalP7vpDEkgQ2u0qbnmQQ 7JhSQdpb0sbudb4EG4SGIdMp1DkZcY/uWH5hZR9be+XytnINcw== X-Google-Smtp-Source: ABdhPJwb6mQibAIwIXHoU2iWS0qOmwv+qJpw+sAWk1Q1YTyKYlqLl2DlBdKTTEUdPJCBZjWkR67w1QBWbkNwrla/sbE= X-Received: by 2002:a37:a48c:: with SMTP id n134mr19878123qke.490.1615185707460; Sun, 07 Mar 2021 22:41:47 -0800 (PST) MIME-Version: 1.0 References: <87ft16ywyr.wl-chenli@uniontech.com> In-Reply-To: <87ft16ywyr.wl-chenli@uniontech.com> From: YunQiang Su Date: Mon, 8 Mar 2021 14:41:36 +0800 Message-ID: Subject: Re: [PATCH] skip testing time before epoch on mips To: Chen Li Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 06:41:50 -0000 Chen Li =E4=BA=8E2021=E5=B9=B43=E6=9C=888=E6=97=A5= =E5=91=A8=E4=B8=80 =E4=B8=8B=E5=8D=882:35=E5=86=99=E9=81=93=EF=BC=9A > > > When execute libstdc++ testcases on mips, I notice that last_write_time > alawys failed, and the failed VERIFY is "VERIFY( > approx_equal(last_write_time(f.path), time) );" where testing time before > than epoch. > > Below is the minimal case: > > ``` > // gcc a.c > int main() > { > struct timespec times[2] =3D {{1, UTIME_OMIT}, {-1201, 985000000}= }; > utimensat(AT_FDCWD, "test", times, 0); > > } > ``` > > $ touch test && gcc a.c && ./a.out && stat test > File: test > Size: 0 Blocks: 0 IO Block: 4096 regular empty= file > Device: 805h/2053d Inode: 1056841 Links: 1 > Access: (0644/-rw-r--r--) Uid: ( 1000/ deepin) Gid: ( 1000/ deepin) > Access: 2021-03-08 13:52:55.966354501 +0800 > Modify: 2106-02-07 14:08:15.985000000 +0800 > Change: 2021-03-08 13:52:56.907782193 +0800 > Birth: - > > Undoubtedly, mtime's type is unsigned somewhere on mips. > It only has this problem on mips64. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D983769 > After debuging kernel, it turns out that mtime is always -1201 in > ext4_setattr, cp_new_stat, newlstat and etc, so the problem should not > occur in kernel space. > > go back to user space via copy_to_user, I finally found mips used > "unsigned int st_mtime_sec;" in struct kernel_stat, which is used to > receive -1201 from kernel. > > Maybe sparc also suffers from this problem, but I have no machine to > verify. > --- > .../testsuite/27_io/filesystem/operations/last_write_time.cc | 2 ++ > .../experimental/filesystem/operations/last_write_time.cc | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_writ= e_time.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_t= ime.cc > index 6ae64c482b6..72272d4e781 100644 > --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.= cc > +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.= cc > @@ -200,11 +200,13 @@ test02() > VERIFY( approx_equal(last_write_time(f.path), time) ); > > ec =3D bad_ec; > + #ifndef __mips__ > // A time before than the epoch > time -=3D chrono::milliseconds(1000 * 60 * 20 + 15); > last_write_time(f.path, time, ec); > VERIFY( !ec ); > VERIFY( approx_equal(last_write_time(f.path), time) ); > + #endif > } > > int > diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/la= st_write_time.cc b/libstdc++-v3/testsuite/experimental/filesystem/operation= s/last_write_time.cc > index 536ab1f28f6..6fb490a6bc3 100644 > --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/last_writ= e_time.cc > +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_writ= e_time.cc > @@ -165,11 +165,13 @@ test02() > VERIFY( !ec ); > VERIFY( approx_equal(last_write_time(f.path), time) ); > > + #ifndef __mips__ > ec =3D bad_ec; > time -=3D chrono::milliseconds(1000 * 60 * 10 + 15); > last_write_time(f.path, time, ec); > VERIFY( !ec ); > VERIFY( approx_equal(last_write_time(f.path), time) ); > + #endif > } > > int > -- > 2.30.0 > > > --=20 YunQiang Su