Manage objfiles with shared_ptr
[deliverable/binutils-gdb.git] / sim / common / nrun.c
index a50ae06aeccba1ff7babc13b7fb84dba72a8cb06..ed6a94873e6c20b164da8429458682ac87d5ee7a 100644 (file)
@@ -1,5 +1,5 @@
 /* New version of run front end support for simulators.
-   Copyright (C) 1997, 2004, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 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
@@ -14,7 +14,22 @@ 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, see <http://www.gnu.org/licenses/>.  */
 
+/* Need to be before general includes, to pick up e.g. _GNU_SOURCE.  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <signal.h>
+
+/* For strsignal.  */
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+
 #include "sim-main.h"
 
 #include "bfd.h"
@@ -32,7 +47,7 @@ static void usage (void);
 
 extern host_callback default_callback;
 
-static char *myname;
+static const char *myname;
 
 static SIM_DESC sd;
 
@@ -49,7 +64,7 @@ cntrl_c (int sig)
 int
 main (int argc, char **argv)
 {
-  char *name;
+  const char *name;
   char **prog_argv = NULL;
   struct bfd *prog_bfd;
   enum sim_stop reason;
@@ -57,9 +72,7 @@ main (int argc, char **argv)
   int single_step = 0;
   RETSIGTYPE (*prev_sigint) ();
 
-  myname = argv[0] + strlen (argv[0]);
-  while (myname > argv[0] && myname[-1] != '/')
-    --myname;
+  myname = lbasename (argv[0]);
 
   /* INTERNAL: When MYNAME is `step', single step the simulator
      instead of allowing it to run free.  The sole purpose of this
@@ -84,7 +97,7 @@ main (int argc, char **argv)
   /* We can't set the endianness in the callback structure until
      sim_config is called, which happens in sim_open.  */
   default_callback.target_endian
-    = (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN
+    = (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
        ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE);
 
   /* Was there a program to run?  */
This page took 0.026519 seconds and 4 git commands to generate.