sim: drop core libiberty.h include
[deliverable/binutils-gdb.git] / sim / common / sim-io.c
index d1aab44fb76bdaa065689bdff7cd9226bbaf0aab..e09a4af7ba2e4dd66935971d09ab874b4914b47a 100644 (file)
@@ -1,6 +1,6 @@
 /* The common simulator framework for GDB, the GNU Debugger.
 
-   Copyright 2002 Free Software Foundation, Inc.
+   Copyright 2002-2021 Free Software Foundation, Inc.
 
    Contributed by Andrew Cagney and Red Hat.
 
@@ -8,7 +8,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "defs.h"
 
 #include "sim-main.h"
 #include "sim-io.h"
+#include "sim/callback.h"
 #include "targ-vals.h"
 
 #include <errno.h>
 #include <unistd.h>
 #endif
 
+#include <stdlib.h>
+
+#undef open
+
 /* Define the rate at which the simulator should poll the host
    for a quit. */
 #ifndef POLL_QUIT_INTERVAL
@@ -47,55 +52,54 @@ static int poll_quit_count = POLL_QUIT_INTERVAL;
 
 
 int
-sim_io_init(SIM_DESC sd)
+sim_io_init (SIM_DESC sd)
 {
   return STATE_CALLBACK (sd)->init (STATE_CALLBACK (sd));
 }
 
 
 int
-sim_io_shutdown(SIM_DESC sd)
+sim_io_shutdown (SIM_DESC sd)
 {
   return STATE_CALLBACK (sd)->shutdown (STATE_CALLBACK (sd));
 }
 
 
 int
-sim_io_unlink(SIM_DESC sd,
-             const char *f1)
+sim_io_unlink (SIM_DESC sd,
+              const char *f1)
 {
   return STATE_CALLBACK (sd)->unlink (STATE_CALLBACK (sd), f1);
 }
 
 
-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));
 }
 
 
 int
-sim_io_system(SIM_DESC sd, const char *s)
+sim_io_system (SIM_DESC sd, const char *s)
 {
   return STATE_CALLBACK (sd)->system (STATE_CALLBACK (sd), s);
 }
 
 
 int
-sim_io_rename(SIM_DESC sd,
-             const char *f1,
-             const char *f2)
+sim_io_rename (SIM_DESC sd,
+              const char *f1,
+              const char *f2)
 {
   return STATE_CALLBACK (sd)->rename (STATE_CALLBACK (sd), f1, f2);
 }
 
 
 int
-sim_io_write_stdout(SIM_DESC sd,
-                   const char *buf,
-                   int len)
+sim_io_write_stdout (SIM_DESC sd,
+                    const char *buf,
+                    int len)
 {
   switch (CURRENT_STDIO) {
   case DO_USE_STDIO:
@@ -113,7 +117,7 @@ sim_io_write_stdout(SIM_DESC sd,
 
 
 void
-sim_io_flush_stdout(SIM_DESC sd)
+sim_io_flush_stdout (SIM_DESC sd)
 {
   switch (CURRENT_STDIO) {
   case DO_USE_STDIO:
@@ -129,9 +133,9 @@ sim_io_flush_stdout(SIM_DESC sd)
 
 
 int
-sim_io_write_stderr(SIM_DESC sd,
-                   const char *buf,
-                   int len)
+sim_io_write_stderr (SIM_DESC sd,
+                    const char *buf,
+                    int len)
 {
   switch (CURRENT_STDIO) {
   case DO_USE_STDIO:
@@ -149,7 +153,7 @@ sim_io_write_stderr(SIM_DESC sd,
 
 
 void
-sim_io_flush_stderr(SIM_DESC sd)
+sim_io_flush_stderr (SIM_DESC sd)
 {
   switch (CURRENT_STDIO) {
   case DO_USE_STDIO:
@@ -165,19 +169,19 @@ sim_io_flush_stderr(SIM_DESC sd)
 
 
 int
-sim_io_write(SIM_DESC sd,
-            int fd,
-            const char *buf,
-            int len)
+sim_io_write (SIM_DESC sd,
+             int fd,
+             const char *buf,
+             int len)
 {
   return STATE_CALLBACK (sd)->write (STATE_CALLBACK (sd), fd, buf, len);
 }
 
 
 int
-sim_io_read_stdin(SIM_DESC sd,
-                 char *buf,
-                 int len)
+sim_io_read_stdin (SIM_DESC sd,
+                  char *buf,
+                  int len)
 {
   switch (CURRENT_STDIO) {
   case DO_USE_STDIO:
@@ -195,123 +199,123 @@ sim_io_read_stdin(SIM_DESC sd,
 
 
 int
-sim_io_read(SIM_DESC sd, int fd,
-           char *buf,
-           int len)
+sim_io_read (SIM_DESC sd, int fd,
+            char *buf,
+            int len)
 {
   return STATE_CALLBACK (sd)->read (STATE_CALLBACK (sd), fd, buf, len);
 }
 
 
 int
-sim_io_open(SIM_DESC sd,
-           const char *name,
-           int flags)
+sim_io_open (SIM_DESC sd,
+            const char *name,
+            int flags)
 {
   return STATE_CALLBACK (sd)->open (STATE_CALLBACK (sd), name, flags);
 }
 
 
-int
-sim_io_lseek(SIM_DESC sd,
-            int fd,
-            long off,
-            int way)
+int64_t
+sim_io_lseek (SIM_DESC sd,
+             int fd,
+             int64_t off,
+             int way)
 {
   return STATE_CALLBACK (sd)->lseek (STATE_CALLBACK (sd), fd, off, way);
 }
 
 
 int
-sim_io_isatty(SIM_DESC sd,
-             int fd)
+sim_io_isatty (SIM_DESC sd,
+              int fd)
 {
   return STATE_CALLBACK (sd)->isatty (STATE_CALLBACK (sd), fd);
 }
 
 
 int
-sim_io_get_errno(SIM_DESC sd)
+sim_io_get_errno (SIM_DESC sd)
 {
   return STATE_CALLBACK (sd)->get_errno (STATE_CALLBACK (sd));
 }
 
 
 int
-sim_io_close(SIM_DESC sd,
-            int fd)
+sim_io_close (SIM_DESC sd,
+             int fd)
 {
   return STATE_CALLBACK (sd)->close (STATE_CALLBACK (sd), fd);
 }
 
 
 void
-sim_io_printf(SIM_DESC sd,
-             const char *fmt,
-             ...)
+sim_io_printf (SIM_DESC sd,
+              const char *fmt,
+              ...)
 {
   va_list ap;
-  va_start(ap, fmt);
+  va_start (ap, fmt);
   STATE_CALLBACK (sd)->vprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
-  va_end(ap);
+  va_end (ap);
 }
 
 
 void
-sim_io_vprintf(SIM_DESC sd,
-              const char *fmt,
-              va_list ap)
+sim_io_vprintf (SIM_DESC sd,
+               const char *fmt,
+               va_list ap)
 {
   STATE_CALLBACK (sd)->vprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
 }
 
 
 void
-sim_io_eprintf(SIM_DESC sd,
-             const char *fmt,
-             ...)
+sim_io_eprintf (SIM_DESC sd,
+              const char *fmt,
+              ...)
 {
   va_list ap;
-  va_start(ap, fmt);
+  va_start (ap, fmt);
   STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
-  va_end(ap);
+  va_end (ap);
 }
 
 
 void
-sim_io_evprintf(SIM_DESC sd,
-               const char *fmt,
-               va_list ap)
+sim_io_evprintf (SIM_DESC sd,
+                const char *fmt,
+                va_list ap)
 {
   STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
 }
 
 
 void
-sim_io_error(SIM_DESC sd,
-            const char *fmt,
-            ...)
+sim_io_error (SIM_DESC sd,
+             const char *fmt,
+             ...)
 {
   if (sd == NULL || STATE_CALLBACK (sd) == NULL) {
     va_list ap;
-    va_start(ap, fmt);
+    va_start (ap, fmt);
     vfprintf (stderr, fmt, ap);
-    va_end(ap);
+    va_end (ap);
     fprintf (stderr, "\n");
     abort ();
   }
   else {
     va_list ap;
-    va_start(ap, fmt);
+    va_start (ap, fmt);
     STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
-    va_end(ap);
+    va_end (ap);
     STATE_CALLBACK (sd)->error (STATE_CALLBACK (sd), "");
   }
 }
 
 
 void
-sim_io_poll_quit(SIM_DESC sd)
+sim_io_poll_quit (SIM_DESC sd)
 {
   if (STATE_CALLBACK (sd)->poll_quit != NULL && poll_quit_count-- < 0)
     {
@@ -389,3 +393,15 @@ sim_io_poll_read (SIM_DESC sd,
   return sim_io_read (sd, sim_io_fd, buf, sizeof_buf);
 #endif
 }
+
+int
+sim_io_stat (SIM_DESC sd, const char *path, struct stat *buf)
+{
+  return STATE_CALLBACK (sd)->to_stat (STATE_CALLBACK (sd), path, buf);
+}
+
+int
+sim_io_fstat (SIM_DESC sd, int fd, struct stat *buf)
+{
+  return STATE_CALLBACK (sd)->to_fstat (STATE_CALLBACK (sd), fd, buf);
+}
This page took 0.027819 seconds and 4 git commands to generate.