From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 389173857708 for ; Thu, 11 Jan 2024 03:37:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 389173857708 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 389173857708 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704944274; cv=none; b=R3XWtwTt3YY4Z+DMckXitafdJSYCommDh59ZaiK9ruKFQWeMK8Yqydrl/SK/89GMriM/JlWVfEyUf++ZkPsq/uPyHve/wJ7LGTO5VYPfmxtIMNtAwIJ8FsK3cepLO52kd/xEbqJWxLfLw+Js8QolmDrButcFfChQnPILxg0MlWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704944274; c=relaxed/simple; bh=wPD9bSis8YFdXoCma0nlC8zsHZigTjAnd4IcgoTauNo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=E49d7kRVEq0klJdfJ3c8OE62Fg3d8hcHh6wEW1sSSN0PnH1h1/UZzOoDTjhJWlEWBM1viAxwOakb1Rf4znmbluXs3CI2aRTVgYwqsgFBMcCavAsbhc1gm5vrnL9vfGmZ2fS/Epq/dwFkOP+06ykZqjQmNUJJD6S5wrum7MWEpbU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 9449C343228; Thu, 11 Jan 2024 03:37:52 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 2/5] sim: m32r: migrate ftime() to clock_gettime() Date: Wed, 10 Jan 2024 22:37:44 -0500 Message-ID: <20240111033747.17795-2-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111033747.17795-1-vapier@gentoo.org> References: <20240111033747.17795-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The ftime() function has been deprecated since POSIX-1-2004, and removed in POSIX.1-2008. It's also been deprecated/removed in glibc since 2.33. POSIX has always said the function is not portable, and its return value, timezone, and dstflag fields are unspecified. Even if Linux/glibc & m32r had defined behavior, those aren't the host for the sim runtime. So let's stop using the function and switch to clock_gettime. gnulib already has detection support for it, and it's been around since at least POSIX-1-2004. --- sim/m32r/traps.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c index b779e0c3b9f5..c5191989d7fd 100644 --- a/sim/m32r/traps.c +++ b/sim/m32r/traps.c @@ -386,17 +386,20 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num) case TARGET_LINUX_SYS_ftime: { struct timeb t; + struct timespec ts; - result = ftime (&t); + result = clock_gettime (CLOCK_REALTIME, &ts); errcode = errno; if (result != 0) break; - t.time = H2T_4 (t.time); - t.millitm = H2T_2 (t.millitm); - t.timezone = H2T_2 (t.timezone); - t.dstflag = H2T_2 (t.dstflag); + t.time = H2T_4 (ts.tv_sec); + t.millitm = H2T_2 (ts.tv_nsec / 1000000); + /* POSIX.1-2001 says the contents of the timezone and dstflag + members of tp after a call to ftime() are unspecified. */ + t.timezone = H2T_2 (0); + t.dstflag = H2T_2 (0); if ((s.write_mem) (cb, &s, arg1, (char *) &t, sizeof(t)) != sizeof(t)) { -- 2.43.0