]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/arm/armos.c
sim: formally assume unistd.h always exists (via gnulib)
[thirdparty/binutils-gdb.git] / sim / arm / armos.c
index c49036f1224246e257e339818efd0539b6b7e9d3..9cf238ac8e25a110a23cef3dbb2514bdd3cadd32 100644 (file)
    fun, and definign VAILDATE will define SWI 1 to enter SVC mode, and SWI
    0x11 to halt the emulator.  */
 
-#include "config.h"
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #include "ansidecl.h"
+#include "libiberty.h"
 
 #include <time.h>
 #include <errno.h>
 #include <limits.h>
 #include <string.h>
-#include "targ-vals.h"
-
-#ifndef TARGET_O_BINARY
-#define TARGET_O_BINARY 0
-#endif
-
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>            /* For SEEK_SET etc.  */
-#endif
 
 #include "armdefs.h"
 #include "armos.h"
@@ -53,7 +48,7 @@
 /* For RDIError_BreakpointReached.  */
 #include "dbg_rdi.h"
 
-#include "gdb/callback.h"
+#include "sim/callback.h"
 extern host_callback *sim_callback;
 
 extern unsigned ARMul_OSInit       (ARMul_State *);
@@ -185,7 +180,17 @@ ARMul_OSInit (ARMul_State * state)
    return TRUE;
 }
 
-static int translate_open_mode[] =
+/* These are libgloss defines, but seem to be common across all supported ARM
+   targets at the moment.  These should get moved to the callback open_map.  */
+#define TARGET_O_BINARY 0
+#define TARGET_O_APPEND 0x8
+#define TARGET_O_CREAT 0x200
+#define TARGET_O_RDONLY 0x0
+#define TARGET_O_RDWR 0x2
+#define TARGET_O_TRUNC 0x400
+#define TARGET_O_WRONLY 0x1
+
+static const int translate_open_mode[] =
 {
   TARGET_O_RDONLY,             /* "r"   */
   TARGET_O_RDONLY + TARGET_O_BINARY,   /* "rb"  */
@@ -260,7 +265,10 @@ SWIopen (ARMul_State * state, ARMword name, ARMword SWIflags)
     return;
 
   /* Now we need to decode the Demon open mode.  */
-  flags = translate_open_mode[SWIflags];
+  if (SWIflags >= ARRAY_SIZE (translate_open_mode))
+    flags = 0;
+  else
+    flags = translate_open_mode[SWIflags];
 
   /* Filename ":tt" is special: it denotes stdin/out.  */
   if (strcmp (buf, ":tt") == 0)
@@ -289,8 +297,8 @@ SWIread (ARMul_State * state, ARMword f, ARMword ptr, ARMword len)
     {
       sim_callback->printf_filtered
        (sim_callback,
-        "sim: Unable to read 0x%ulx bytes - out of memory\n",
-        len);
+        "sim: Unable to read 0x%lx bytes - out of memory\n",
+        (long)len);
       return;
     }
 
@@ -433,7 +441,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
@@ -588,7 +596,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;
 
@@ -777,7 +785,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;