summaryrefslogtreecommitdiff
path: root/sim/common/sim-memopt.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-08-10 14:26:33 +0000
committerNick Clifton <nickc@redhat.com>2007-08-10 14:26:33 +0000
commit3b85b94cab35d02f2ee99e9413a38291dcdc8936 (patch)
treea307a94051723bbc6bdbed937fa3f6ae687399f5 /sim/common/sim-memopt.c
parent1c8ad5e38f206c9fdec6be89deb3a36b40436e6f (diff)
downloadgdb-3b85b94cab35d02f2ee99e9413a38291dcdc8936.tar.gz
* sim-memopt.c (memory_options): Mention that the memory-size switch accepts suffixes.
(parse_size): Handle a suffix on the size value. * sim-options.c (standard_options): Mention that the mem-size switch accepts suffixes. (standard_option_handler): Handle a suffix on the size value.
Diffstat (limited to 'sim/common/sim-memopt.c')
-rw-r--r--sim/common/sim-memopt.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/sim/common/sim-memopt.c b/sim/common/sim-memopt.c
index c7591b86790..0e73b9f2346 100644
--- a/sim/common/sim-memopt.c
+++ b/sim/common/sim-memopt.c
@@ -90,8 +90,8 @@ static const OPTION memory_options[] =
memory_option_handler },
{ {"memory-size", required_argument, NULL, OPTION_MEMORY_SIZE },
- '\0', "SIZE", "Add memory at address zero",
- memory_option_handler },
+ '\0', "<size>[in bytes, Kb (k suffix), Mb (m suffix) or Gb (g suffix)]",
+ "Add memory at address zero", memory_option_handler },
{ {"memory-fill", required_argument, NULL, OPTION_MEMORY_FILL },
'\0', "VALUE", "Fill subsequently added memory regions",
@@ -286,11 +286,28 @@ parse_size (char *chp,
address_word *nr_bytes,
unsigned *modulo)
{
- /* <nr_bytes> [ "%" <modulo> ] */
+ /* <nr_bytes>[K|M|G] [ "%" <modulo> ] */
*nr_bytes = strtoul (chp, &chp, 0);
- if (*chp == '%')
+ switch (*chp)
{
+ case '%':
*modulo = strtoul (chp + 1, &chp, 0);
+ break;
+ case 'g': case 'G': /* Gigabyte suffix. */
+ *nr_bytes <<= 10;
+ /* Fall through. */
+ case 'm': case 'M': /* Megabyte suffix. */
+ *nr_bytes <<= 10;
+ /* Fall through. */
+ case 'k': case 'K': /* Kilobyte suffix. */
+ *nr_bytes <<= 10;
+ /* Check for a modulo specifier after the suffix. */
+ ++ chp;
+ if (* chp == 'b' || * chp == 'B')
+ ++ chp;
+ if (* chp == '%')
+ *modulo = strtoul (chp + 1, &chp, 0);
+ break;
}
return chp;
}