sim: mn10300: tweak engine halt hook
[deliverable/binutils-gdb.git] / sim / common / syscall.c
index ab2bbf7a6bd181cdbb038883be75a7c6a9fb4656..4e76d2008a30d3287a6594b51fdfdadbde0c7015 100644 (file)
@@ -1,6 +1,5 @@
 /* Remote target system call support.
-   Copyright 1997-1998, 2002, 2004, 2007-2012 Free Software Foundation,
-   Inc.
+   Copyright 1997-2021 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
 
    This file is part of GDB.
    tree, nor should it live in the gdb source tree.  K&R C must be
    supported.  */
 
-#ifdef HAVE_CONFIG_H
-#include "cconfig.h"
-#endif
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #include "ansidecl.h"
 #include "libiberty.h"
 #include <stdarg.h>
 #include <stdio.h>
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
 #include <string.h>
-#elif defined (HAVE_STRINGS_H)
-#include <strings.h>
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -47,7 +40,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "gdb/callback.h"
+#include "sim/callback.h"
 #include "targ-vals.h"
 
 #ifndef ENOSYS
@@ -77,12 +70,8 @@ char *simulator_sysroot = "";
    The result is 0 for success or a host errno value.  */
 
 int
-cb_get_string (cb, sc, buf, buflen, addr)
-     host_callback *cb;
-     CB_SYSCALL *sc;
-     char *buf;
-     int buflen;
-     TADDR addr;
+cb_get_string (host_callback *cb, CB_SYSCALL *sc, char *buf, int buflen,
+              TADDR addr)
 {
   char *p, *pend;
 
@@ -111,11 +100,7 @@ cb_get_string (cb, sc, buf, buflen, addr)
    If an error occurs, no buffer is left malloc'd.  */
 
 static int
-get_path (cb, sc, addr, bufp)
-     host_callback *cb;
-     CB_SYSCALL *sc;
-     TADDR addr;
-     char **bufp;
+get_path (host_callback *cb, CB_SYSCALL *sc, TADDR addr, char **bufp)
 {
   char *buf = xmalloc (MAX_PATH_LEN);
   int result;
@@ -148,9 +133,7 @@ get_path (cb, sc, addr, bufp)
 /* Perform a system call on behalf of the target.  */
 
 CB_RC
-cb_syscall (cb, sc)
-     host_callback *cb;
-     CB_SYSCALL *sc;
+cb_syscall (host_callback *cb, CB_SYSCALL *sc)
 {
   TWORD result = 0, errcode = 0;
 
@@ -251,7 +234,7 @@ cb_syscall (cb, sc)
 #endif /* wip */
 
     case CB_SYS_exit :
-      /* Caller must catch and handle.  */
+      /* Caller must catch and handle; see sim_syscall as an example.  */
       break;
 
     case CB_SYS_open :
@@ -466,7 +449,7 @@ cb_syscall (cb, sc)
            result = -1;
            goto FinishSyscall;
          }
-       result = (*cb->stat) (cb, path, &statbuf);
+       result = (*cb->to_stat) (cb, path, &statbuf);
        free (path);
        if (result < 0)
          goto ErrorFinish;
@@ -499,7 +482,7 @@ cb_syscall (cb, sc)
        struct stat statbuf;
        TADDR addr = sc->arg2;
 
-       result = (*cb->fstat) (cb, sc->arg1, &statbuf);
+       result = (*cb->to_fstat) (cb, sc->arg1, &statbuf);
        if (result < 0)
          goto ErrorFinish;
        buflen = cb_host_to_target_stat (cb, NULL, NULL);
@@ -537,7 +520,7 @@ cb_syscall (cb, sc)
            result = -1;
            goto FinishSyscall;
          }
-       result = (*cb->lstat) (cb, path, &statbuf);
+       result = (*cb->to_lstat) (cb, path, &statbuf);
        free (path);
        if (result < 0)
          goto ErrorFinish;
@@ -595,13 +578,17 @@ cb_syscall (cb, sc)
       }
       break;
 
+    case CB_SYS_getpid:
+      result = getpid ();
+      break;
+
     case CB_SYS_time :
       {
        /* FIXME: May wish to change CB_SYS_time to something else.
           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().  */
       }
This page took 0.026268 seconds and 4 git commands to generate.