sim: callback: convert FS interfaces to 64-bit
authorMike Frysinger <vapier@gentoo.org>
Sat, 24 Apr 2021 18:40:43 +0000 (14:40 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 15 May 2021 01:16:40 +0000 (21:16 -0400)
Rather than rely on off_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/common/ChangeLog
sim/common/callback.c
sim/common/sim-io.c
sim/common/sim-io.h

index 393b7b8262e46c3a0446ef676097d23e6d67b153..4fe3bc0240326eb92e7ac21b6e8a4f39f3b6179b 100644 (file)
@@ -1,3 +1,8 @@
+2021-05-14  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim/callback.h (struct host_callback_struct): Change lseek return and
+       3rd arg to int64_t.  Change truncate & ftruncate 3rd arg to int64_t.
+
 2021-05-14  Mike Frysinger  <vapier@gentoo.org>
 
        * callback.h: Include stdint.h.
index f40385e5761672c692f6e271fad4fe3bd8797f08..4c162bc145eaf494f46876a41de45d2e2c0f5cf3 100644 (file)
@@ -73,7 +73,7 @@ struct host_callback_struct
   int (*close) (host_callback *,int);
   int (*get_errno) (host_callback *);
   int (*isatty) (host_callback *, int);
-  int (*lseek) (host_callback *, int, long , int);
+  int64_t (*lseek) (host_callback *, int, int64_t, int);
   int (*open) (host_callback *, const char*, int mode);
   int (*read) (host_callback *,int,  char *, int);
   int (*read_stdin) ( host_callback *, char *, int);
@@ -89,8 +89,8 @@ struct host_callback_struct
   int (*to_stat) (host_callback *, const char *, struct stat *);
   int (*to_fstat) (host_callback *, int, struct stat *);
   int (*to_lstat) (host_callback *, const char *, struct stat *);
-  int (*ftruncate) (host_callback *, int, long);
-  int (*truncate) (host_callback *, const char *, long);
+  int (*ftruncate) (host_callback *, int, int64_t);
+  int (*truncate) (host_callback *, const char *, int64_t);
   int (*pipe) (host_callback *, int *);
 
   /* Called by the framework when a read call has emptied a pipe buffer.  */
index 879aac96a956f7b8d8ce947ba8dbfe2b3dc05e09..b360ebdd759ad97440d0ab50281e70c90c6f401d 100644 (file)
@@ -1,3 +1,11 @@
+2021-05-14  Mike Frysinger  <vapier@gentoo.org>
+
+       * callback.c (os_lseek): Change return and 3rd arg to int64_t.
+       (os_ftruncate): Change 3rd arg to int64_t.
+       (os_truncate): Change 3rd arg to int64_t.
+       * sim-io.c (sim_io_lseek): Change return and 3rd arg to int64_t.
+       * sim-io.h (sim_io_lseek): Likewise.
+
 2021-05-14  Mike Frysinger  <vapier@gentoo.org>
 
        * callback.c (os_time): Change return to int64_t.  Delete 2nd arg.
index fb5e86431cc21cfe11b8553c5b518716c21763d3..24ea47025e1bf9e7fdf740c70a67b50c066dd618 100644 (file)
@@ -205,10 +205,10 @@ os_isatty (host_callback *p, int fd)
   return result;
 }
 
-static int
-os_lseek (host_callback *p, int fd, long off, int way)
+static int64_t
+os_lseek (host_callback *p, int fd, int64_t off, int way)
 {
-  int result;
+  int64_t result;
 
   result = fdbad (p, fd);
   if (result)
@@ -519,7 +519,7 @@ os_lstat (host_callback *p, const char *file, struct stat *buf)
 }
 
 static int
-os_ftruncate (host_callback *p, int fd, long len)
+os_ftruncate (host_callback *p, int fd, int64_t len)
 {
   int result;
 
@@ -542,7 +542,7 @@ os_ftruncate (host_callback *p, int fd, long len)
 }
 
 static int
-os_truncate (host_callback *p, const char *file, long len)
+os_truncate (host_callback *p, const char *file, int64_t len)
 {
 #ifdef HAVE_TRUNCATE
   int result;
index e5da7f1fdaac7ddc5d23ab4d33f29c9b7fb6751c..edef26e8e12360b56e360dcc588b63b2121e3c09 100644 (file)
@@ -211,10 +211,10 @@ sim_io_open (SIM_DESC sd,
 }
 
 
-int
+int64_t
 sim_io_lseek (SIM_DESC sd,
              int fd,
-             long off,
+             int64_t off,
              int way)
 {
   return STATE_CALLBACK (sd)->lseek (STATE_CALLBACK (sd), fd, off, way);
index a091fd08e4694ecf9ec1b2a2207f0a9f75dfe0ed..a78e8f59d5408f02357adc52b0af4e713461a092 100644 (file)
@@ -53,7 +53,7 @@ int sim_io_read (SIM_DESC sd, int, char *, int);
 
 int sim_io_open (SIM_DESC sd, const char *, int);
 
-int sim_io_lseek (SIM_DESC sd, int, long, int);
+int64_t sim_io_lseek (SIM_DESC sd, int, int64_t, int);
 
 int sim_io_isatty (SIM_DESC sd, int);
 
This page took 0.031367 seconds and 4 git commands to generate.