From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.204]) by sourceware.org (Postfix) with ESMTPS id 40B123861002; Mon, 8 Mar 2021 06:35:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 40B123861002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=uniontech.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=chenli@uniontech.com Received: from localhost (unknown [192.168.167.16]) by regular1.263xmail.com (Postfix) with ESMTP id 2C50861D; Mon, 8 Mar 2021 14:35:09 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-SKE-CHECKED: 1 X-ABS-CHECKED: 1 Received: from chenli.uniontech.com (unknown [58.246.122.242]) by smtp.263.net (postfix) whith ESMTP id P32470T140679641057024S1615185308916507_; Mon, 08 Mar 2021 14:35:09 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: chenli@uniontech.com X-SENDER: chenli@uniontech.com X-LOGIN-NAME: chenli@uniontech.com X-FST-TO: gcc-patches@gcc.gnu.org X-SENDER-IP: 58.246.122.242 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 Date: Mon, 08 Mar 2021 14:35:08 +0800 Message-ID: <87ft16ywyr.wl-chenli@uniontech.com> From: Chen Li To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] skip testing time before epoch on mips User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 06:35:22 -0000 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] = {{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. 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_write_time.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.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 = bad_ec; + #ifndef __mips__ // A time before than the epoch time -= 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/last_write_time.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc index 536ab1f28f6..6fb490a6bc3 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/last_write_time.cc @@ -165,11 +165,13 @@ test02() VERIFY( !ec ); VERIFY( approx_equal(last_write_time(f.path), time) ); + #ifndef __mips__ ec = bad_ec; time -= 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