sim: callback: convert time interface to 64-bit
authorMike Frysinger <vapier@gentoo.org>
Sat, 24 Apr 2021 18:35:14 +0000 (14:35 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 15 May 2021 01:05:36 +0000 (21:05 -0400)
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.

include/sim/ChangeLog
include/sim/callback.h
sim/arm/ChangeLog
sim/arm/armos.c
sim/common/ChangeLog
sim/common/callback.c
sim/common/sim-io.c
sim/common/sim-io.h
sim/common/syscall.c
sim/cris/ChangeLog
sim/cris/traps.c

index a70d8f06cf25f2d7e7e00051bdd46e64857e206d..393b7b8262e46c3a0446ef676097d23e6d67b153 100644 (file)
@@ -1,3 +1,9 @@
+2021-05-14  Mike Frysinger  <vapier@gentoo.org>
+
+       * callback.h: Include stdint.h.
+       (struct host_callback_struct): Change time return to int64_t.  Delete
+       2nd arg.
+
 2021-05-14  Mike Frysinger  <vapier@gentoo.org>
 
        * callback.h (p1, p2): Change PTR to void*.
index 87a61df085549fa6068d75afe6cc4135169f0b51..f40385e5761672c692f6e271fad4fe3bd8797f08 100644 (file)
@@ -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);
index 7124a6d0a3250241f4a6118368335b50b4fb8b80..5282e70a81a2430ee75ac21024c5906abef5a84d 100644 (file)
@@ -1,3 +1,7 @@
+2021-05-14  Mike Frysinger  <vapier@gentoo.org>
+
+       * armos.c (ARMul_OSHandleSWI): Delete 2nd arg to time callback.
+
 2021-05-14  Mike Frysinger  <vapier@gentoo.org>
 
        * armos.c: Update include path.
index 77b256fd5b3afb3c916fd96073227bf0166710ee..72bdf599718ae99f00f4b7c2e62d24ddd17195e3 100644 (file)
@@ -437,7 +437,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
     case SWI_Time:
       if (swi_mask & SWI_MASK_DEMON)
        {
-         state->Reg[0] = (ARMword) sim_callback->time (sim_callback, NULL);
+         state->Reg[0] = (ARMword) sim_callback->time (sim_callback);
          OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
        }
       else
@@ -592,7 +592,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
              break;
 
            case AngelSWI_Reason_Time:
-             state->Reg[0] = (ARMword) sim_callback->time (sim_callback, NULL);
+             state->Reg[0] = (ARMword) sim_callback->time (sim_callback);
              OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
              break;
 
@@ -781,7 +781,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
              break;
 
            case 17: /* Utime.  */
-             state->Reg[0] = state->Reg[1] = (ARMword) sim_callback->time (sim_callback, NULL);
+             state->Reg[0] = state->Reg[1] = (ARMword) sim_callback->time (sim_callback);
              OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
              break;
 
index ac804647c179fc8d18adca51d632f69e7f46dd43..879aac96a956f7b8d8ce947ba8dbfe2b3dc05e09 100644 (file)
@@ -1,3 +1,12 @@
+2021-05-14  Mike Frysinger  <vapier@gentoo.org>
+
+       * callback.c (os_time): Change return to int64_t.  Delete 2nd arg.
+       (os_fstat): Delete 2nd arg to time callback.
+       * sim-io.c (sim_io_time): Change return to int64_t.  Delete 2nd arg
+       to time callback.
+       * sim-io.h (sim_io_time): Change return to int64_t.
+       * syscall.c (cb_syscall): Delete 2nd arg to time callback.
+
 2021-05-14  Mike Frysinger  <vapier@gentoo.org>
 
        * callback.c (cb_host_to_target_stat): Change PTR to void*.
index 1b53823c4180ec49a6784ca56db2a274dbe535f8..fb5e86431cc21cfe11b8553c5b518716c21763d3 100644 (file)
@@ -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
index f418c3748cdca925c9efcc251d82777baa51fa76..e5da7f1fdaac7ddc5d23ab4d33f29c9b7fb6751c 100644 (file)
@@ -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));
 }
 
 
index f018538ce469689f445f52b6135993f78a999bc4..a091fd08e4694ecf9ec1b2a2207f0a9f75dfe0ed 100644 (file)
@@ -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 *);
 
index 258b3d694f4e4e3599e1259b014f68709bc66e40..0a1d3f4114da63da2b168fd8c336e1f30e5048f1 100644 (file)
@@ -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().  */
       }
index 81ae5e6f267d8615f91d57e4735adebc264a20fc..68cd0bfd52cfca5e28b32b46549219fbc9cc05a6 100644 (file)
@@ -1,3 +1,8 @@
+2021-05-14  Mike Frysinger  <vapier@gentoo.org>
+
+       * traps.c (cris_break_13_handler): Delete 2nd arg to time callback.
+       (cris_time): Change return to int64_t.  Delete 2nd arg.
+
 2021-05-04  Tom Tromey  <tromey@adacore.com>
 
        * mloop.in: Include <stdlib.h>.
index 1c8ca41d14eec8b64cf45bc87f3c7868ed53b164..483747fb4e097676934a36d2046d9eb209caced4 100644 (file)
@@ -2234,7 +2234,7 @@ cris_break_13_handler (SIM_CPU *current_cpu, USI callnum, USI arg1,
 
        case TARGET_SYS_time:
          {
-           retval = (int) (*cb->time) (cb, 0L);
+           retval = (int) (*cb->time) (cb);
 
            /* At time of this writing, CB_SYSCALL_time doesn't do the
               part of setting *arg1 to the return value.  */
@@ -3327,13 +3327,10 @@ cris_pipe_empty (host_callback *cb,
 
 /* We have a simulator-specific notion of time.  See TARGET_TIME.  */
 
-static long
-cris_time (host_callback *cb ATTRIBUTE_UNUSED, long *t)
+static int64_t
+cris_time (host_callback *cb ATTRIBUTE_UNUSED)
 {
-  long retval = TARGET_TIME (current_cpu_for_cb_callback);
-  if (t)
-    *t = retval;
-  return retval;
+  return TARGET_TIME (current_cpu_for_cb_callback);
 }
 
 /* Set target-specific callback data. */
This page took 0.032033 seconds and 4 git commands to generate.