daily update
[deliverable/binutils-gdb.git] / sim / common / sim-options.c
index 397652cf53d3449415d5361782d63240eef56faa..2c19f43646741c8f5e51cee1f103347d61dfd794 100644 (file)
@@ -1,22 +1,21 @@
 /* Simulator option handling.
-   Copyright (C) 1996, 1997, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2004, 2007, 2008 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
 
 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, or (at your option)
-any later version.
+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,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 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.  */
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
 #ifdef HAVE_STRING_H
@@ -167,8 +166,8 @@ static const OPTION standard_options[] =
 
 #ifdef SIM_HAVE_FLATMEM
   { {"mem-size", required_argument, NULL, OPTION_MEM_SIZE},
-      'm', "MEMORY SIZE", "Specify memory size",
-      standard_option_handler },
+     'm', "<size>[in bytes, Kb (k suffix), Mb (m suffix) or Gb (g suffix)]",
+     "Specify memory size", standard_option_handler },
 #endif
 
   { {"do-command", required_argument, NULL, OPTION_DO_COMMAND},
@@ -381,7 +380,21 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
 #ifdef SIM_HAVE_FLATMEM
     case OPTION_MEM_SIZE:
       {
-       unsigned long ul = strtol (arg, NULL, 0);
+       char * endp;
+       unsigned long ul = strtol (arg, &endp, 0);
+
+       switch (* endp)
+         {
+         case 'k': case 'K': size <<= 10; break;
+         case 'm': case 'M': size <<= 20; break;
+         case 'g': case 'G': size <<= 30; break;
+         case ' ': case '\0': case '\t':  break;
+         default:
+           if (ul > 0)
+             sim_io_eprintf (sd, "Ignoring strange character at end of memory size: %c\n", * endp);
+           break;
+         }
+
        /* 16384: some minimal amount */
        if (! isdigit (arg[0]) || ul < 16384)
          {
This page took 0.023775 seconds and 4 git commands to generate.