From cbe1d3378699700f07c66f23d560dfe2b96f32ad Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 1 Jul 2016 08:59:46 -1000 Subject: [PATCH] Allow stack usage to be disabled on contrained systems --- nshlib/Kconfig | 7 +++++++ nshlib/nsh_proccmds.c | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/nshlib/Kconfig b/nshlib/Kconfig index e6a8055d5..f9083b65f 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -403,6 +403,13 @@ config NSH_DISABLE_PS default y if !FS_PROCFS || FS_PROCFS_EXCLUDE_PROCESS default n if FS_PROCFS && !FS_PROCFS_EXCLUDE_PROCESS +config NSH_DISABLE_PSSTACKUSAGE + bool "Disable ps stack usage" + depends on !NSH_DISABLE_PS + default n + ---help--- + Disable to save space and not pull in floating point routines + config NSH_DISABLE_PING bool "Disable ping" default n diff --git a/nshlib/nsh_proccmds.c b/nshlib/nsh_proccmds.c index 11330e0ef..4d36f65f7 100644 --- a/nshlib/nsh_proccmds.c +++ b/nshlib/nsh_proccmds.c @@ -71,6 +71,9 @@ # undef HAVE_GROUPID #endif +#if defined(CONFIG_STACK_COLORATION) && !defined(CONFIG_NSH_DISABLE_PSSTACKUSAGE) +# define PS_HAVE_STACKUSAGE +#endif /**************************************************************************** * Private Types ****************************************************************************/ @@ -266,7 +269,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, FAR char *nextline; int ret; int i; -#ifdef CONFIG_STACK_COLORATION +#ifdef PS_HAVE_STACKUSAGE int stack_size; int stack_used; float stack_filled; @@ -387,7 +390,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, nsh_output(vtbl, "%-8s ", status.td_sigmask); #endif -#ifdef CONFIG_STACK_COLORATION +#ifdef PS_HAVE_STACKUSAGE /* Get the StackSize and StackUsed */ stack_size = 0; @@ -463,7 +466,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, /* Additionally print a "!" if the stack is filled more than 80% */ - nsh_output(vtbl, "%5.1f%%%s ", stack_filled, (stack_filled >= 80 ? "!" : " ")); + nsh_output(vtbl, "%5.1f%%%s ", (double)stack_filled, (stack_filled >= 80 ? "!" : " ")); #endif #ifdef NSH_HAVE_CPULOAD @@ -567,7 +570,7 @@ int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) #ifndef CONFIG_DISABLE_SIGNALS nsh_output(vtbl, "%-8s ", "SIGMASK"); #endif -#ifdef CONFIG_STACK_COLORATION +#ifdef PS_HAVE_STACKUSAGE nsh_output(vtbl, "%6s ", "STACK"); nsh_output(vtbl, "%6s ", "USED"); nsh_output(vtbl, "%7s ", "FILLED");