Module: xenomai-3 Branch: master Commit: b151d3ba663ec5abd008ff2f3f4ce6b3ce9d02b2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b151d3ba663ec5abd008ff2f3f4ce6b3ce9d02b2
Author: Philippe Gerum <r...@xenomai.org> Date: Thu Aug 13 17:07:42 2015 +0200 copperplate/init: disambiguate --mem-pool-size argument The value passed to --mem-pool-size used to represent kilobytes, which is at odds with the byte unit required by the mem_pool_size tunable. --mem-pool-size now accepts a unit K|M|G suffix to values, defaulting to bytes. For backward compatibility, any non-suffixed value below 65536 is interpreted as a count of kilobytes, not bytes, e.g. --mem-pool-size=8192 will create a 8M heap for the application. This conversion is noisy, to call for a parameter update asap, unless --no-sanity is in effect. If you need a tiny heap size below 64k, pass a kilobyte value with a 'K' suffix. --- lib/copperplate/init.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/copperplate/init.c b/lib/copperplate/init.c index c84d8a2..d24673d 100644 --- a/lib/copperplate/init.c +++ b/lib/copperplate/init.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#include <ctype.h> #include <pwd.h> #include <errno.h> #include <getopt.h> @@ -193,9 +194,24 @@ static int copperplate_init(void) static int copperplate_parse_option(int optnum, const char *optarg) { + size_t memsz; + switch (optnum) { case mempool_opt: - __copperplate_setup_data.mem_pool = atoi(optarg) * 1024; + memsz = get_mem_size(optarg); + if (memsz == 0) + return -EINVAL; + /* + * Emulate former sloppy syntax: values below 64k are + * likely to represent kilobytes, not bytes. + */ + if (isdigit(optarg[strlen(optarg)-1]) && + memsz < 64 * 1024) { + memsz *= 1024; + if (__base_setup_data.no_sanity == 0) + warning("--mem-pool-size=<size[K|M|G]>, using %Zu bytes", memsz); + } + __copperplate_setup_data.mem_pool = memsz; break; case session_opt: __copperplate_setup_data.session_label = strdup(optarg); @@ -216,7 +232,7 @@ static int copperplate_parse_option(int optnum, const char *optarg) static void copperplate_help(void) { - fprintf(stderr, "--mem-pool-size=<sizeK> size of the main heap (kbytes)\n"); + fprintf(stderr, "--mem-pool-size=<size[K|M|G]> size of the main heap\n"); fprintf(stderr, "--no-registry suppress object registration\n"); fprintf(stderr, "--shared-registry enable public access to registry\n"); fprintf(stderr, "--registry-root=<path> root path of registry\n"); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git