Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
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	[thread overview]
Message-ID: <20210514053911.15521-1-vapier@gentoo.org> (raw)
In-Reply-To: <20210424184144.23736-5-vapier@gentoo.org>

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 <ansidecl.h>
 #include <stdarg.h>
+#include <stdint.h>
 /* Needed for enum bfd_endian.  */
 #include "bfd.h"
 \f
@@ -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


  parent reply	other threads:[~2021-05-14  5:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24 18:41 [PATCH 1/6] gdb: callback: always include necessary headers Mike Frysinger via Gdb-patches
2021-04-24 18:41 ` [PATCH 2/6] gdb: callback: use ATTRIBUTE_NORETURN Mike Frysinger via Gdb-patches
2021-04-24 18:41 ` [PATCH 3/6] gdb: callback: inline PTR define Mike Frysinger via Gdb-patches
2021-04-24 18:41 ` [PATCH 4/6] sim: callback: inline wrap helper Mike Frysinger via Gdb-patches
2021-04-24 18:41 ` [PATCH 5/6] sim: callback: convert time interface to 64-bit Mike Frysinger via Gdb-patches
2021-04-24 21:11   ` Tom Tromey
2021-04-24 22:36     ` Mike Frysinger via Gdb-patches
2021-05-14  5:39   ` Mike Frysinger via Gdb-patches [this message]
2021-05-14 14:00     ` [PATCH 5/6 v2] " Tom Tromey
2021-04-24 18:41 ` [PATCH 6/6] sim: callback: convert FS interfaces " Mike Frysinger via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514053911.15521-1-vapier@gentoo.org \
    --to=gdb-patches@sourceware.org \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox