From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EzWkHQYNnmBzEgAAWB0awg (envelope-from ) for ; Fri, 14 May 2021 01:39:18 -0400 Received: by simark.ca (Postfix, from userid 112) id 69A031F11C; Fri, 14 May 2021 01:39:18 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9CEBE1E01F for ; Fri, 14 May 2021 01:39:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA7553892471; Fri, 14 May 2021 05:39:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA7553892471 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620970757; bh=RCTTDMWYJu+8lcPDJgng8P2e9A5C3HXFsoaCYhrm9l0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qC6uIEKgQGkxGxcZ6GkDwUTW/fOcDtdvUDo+/OlJEYesg2mmEyPnxtRHJD2aAhItT 6TQuWn+OGfqzSMKXKlMaslS3ktvu63kpWsaNn0XMoJzg+YX6+xbAhIkch+7zPnC8lf Y/MAQH5o1hpFbSfi4/Fnbd//tBzlmDCapgIMkJLA= Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 12F443892471 for ; Fri, 14 May 2021 05:39:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 12F443892471 Received: from vapier.lan (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id EED75340E04 for ; Fri, 14 May 2021 05:39:12 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 5/6 v2] sim: callback: convert time interface to 64-bit Date: Fri, 14 May 2021 01:39:11 -0400 Message-Id: <20210514053911.15521-1-vapier@gentoo.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210424184144.23736-5-vapier@gentoo.org> References: <20210424184144.23736-5-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" PR sim/27705 Rather than rely on time_t being the right size between the host & target, have the interface always be 64-bit. We can figure out if we need to truncate when actually outputting it to the right target. --- v2: - delete the pointer arg and always return the value directly include/sim/callback.h | 3 ++- sim/common/callback.c | 10 +++++----- sim/common/sim-io.c | 7 +++---- sim/common/sim-io.h | 2 +- sim/common/syscall.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/sim/callback.h b/include/sim/callback.h index 87a61df08554..f40385e57616 100644 --- a/include/sim/callback.h +++ b/include/sim/callback.h @@ -47,6 +47,7 @@ #include #include +#include /* Needed for enum bfd_endian. */ #include "bfd.h" @@ -78,7 +79,7 @@ struct host_callback_struct int (*read_stdin) ( host_callback *, char *, int); int (*rename) (host_callback *, const char *, const char *); int (*system) (host_callback *, const char *); - long (*time) (host_callback *, long *); + int64_t (*time) (host_callback *); int (*unlink) (host_callback *, const char *); int (*write) (host_callback *,int, const char *, int); int (*write_stdout) (host_callback *, const char *, int); diff --git a/sim/common/callback.c b/sim/common/callback.c index 1b53823c4180..fb5e86431cc2 100644 --- a/sim/common/callback.c +++ b/sim/common/callback.c @@ -420,12 +420,12 @@ os_system (host_callback *p, const char *s) return result; } -static long -os_time (host_callback *p, long *t) +static int64_t +os_time (host_callback *p) { - long result; + int64_t result; - result = time (t); + result = time (NULL); p->last_errno = errno; return result; } @@ -466,7 +466,7 @@ os_fstat (host_callback *p, int fd, struct stat *buf) if (p->ispipe[fd]) { #if defined (HAVE_STRUCT_STAT_ST_ATIME) || defined (HAVE_STRUCT_STAT_ST_CTIME) || defined (HAVE_STRUCT_STAT_ST_MTIME) - time_t t = (*p->time) (p, NULL); + time_t t = (*p->time) (p); #endif /* We have to fake the struct stat contents, since the pipe is diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c index f418c3748cdc..e5da7f1fdaac 100644 --- a/sim/common/sim-io.c +++ b/sim/common/sim-io.c @@ -68,11 +68,10 @@ sim_io_unlink (SIM_DESC sd, } -long -sim_io_time (SIM_DESC sd, - long *t) +int64_t +sim_io_time (SIM_DESC sd) { - return STATE_CALLBACK (sd)->time (STATE_CALLBACK (sd), t); + return STATE_CALLBACK (sd)->time (STATE_CALLBACK (sd)); } diff --git a/sim/common/sim-io.h b/sim/common/sim-io.h index f018538ce469..a091fd08e469 100644 --- a/sim/common/sim-io.h +++ b/sim/common/sim-io.h @@ -31,7 +31,7 @@ int sim_io_shutdown (SIM_DESC sd); int sim_io_unlink (SIM_DESC sd, const char *); -long sim_io_time (SIM_DESC sd, long *); +int64_t sim_io_time (SIM_DESC sd); int sim_io_system (SIM_DESC sd, const char *); diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 258b3d694f4e..0a1d3f4114da 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -588,7 +588,7 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) We might also want gettimeofday or times, but if system calls can be built on others, we can keep the number we have to support here down. */ - time_t t = (*cb->time) (cb, (time_t *) 0); + time_t t = (*cb->time) (cb); result = t; /* It is up to target code to process the argument to time(). */ } -- 2.31.1