From f553fd131659202abd7374e9ee6c59fa37cef442 Mon Sep 17 00:00:00 2001 From: David Alessio Date: Sun, 10 Jul 2016 17:49:58 -0600 Subject: [PATCH] =?UTF-8?q?Recent=20enhancements=20to=20cmd=5Fps=20trips?= =?UTF-8?q?=20a=20floating=20point=20exception=20if=20LIBC=5FFLOATINGPOINT?= =?UTF-8?q?=20is=20not=20defined=20(at=20least=20on=20Cortex=20M4=20w/=20h?= =?UTF-8?q?ardfloat).=20=20I=E2=80=99m=20using=20a=20buildroot=20gcc=20con?= =?UTF-8?q?figured=20to=20support=20Cortex-M4F=20and=20the=20hard=20float?= =?UTF-8?q?=20ABI,=20target=20files=20are=20compiles=20with:=20-mcpu=3Dcor?= =?UTF-8?q?tex-m4=20-mthumb=20-mfpu=3Dfpv4-sp-d16=20-mfloat-abi=3Dhard.=20?= =?UTF-8?q?=20I=E2=80=99m=20not=20sure=20the=20best=20way=20to=20address?= =?UTF-8?q?=20this,=20but=20the=20attached=20patch=20file=20is=20the=20fir?= =?UTF-8?q?st=20that=20comes=20to=20mind.=20=20Note,=20I=20added=20the=20f?= =?UTF-8?q?loat=20qualifier=20=E2=80=98F=E2=80=99=20after=20a=20few=20cons?= =?UTF-8?q?tants=20to=20prevent=20the=20compiler=20from=20promoting=20the?= =?UTF-8?q?=20multiplication=20and=20division=20to=20double=20(expensive?= =?UTF-8?q?=20on=20M4F)=20then=20demoting=20to=20single=20float=20for=20th?= =?UTF-8?q?e=20store.=20=20(sorry,=20it=E2=80=99s=20one=20of=20my=20many?= =?UTF-8?q?=20pet=20peeves=20;)=20`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nshlib/nsh_proccmds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nshlib/nsh_proccmds.c b/nshlib/nsh_proccmds.c index 5a7dd93e5..ff168c692 100644 --- a/nshlib/nsh_proccmds.c +++ b/nshlib/nsh_proccmds.c @@ -455,17 +455,22 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, nsh_output(vtbl, "%6.6d ", stack_size); nsh_output(vtbl, "%6.6d ", stack_used); - stack_filled = 0.0; + stack_filled = 0.0F; if (stack_size && stack_used) { - stack_filled = (100.0 / stack_size * stack_used); + stack_filled = 100.0F * stack_used / stack_size; } /* Additionally print a "!" if the stack is filled more than 80% */ +#ifndef LIBC_FLOATINGPOINT + nsh_output(vtbl, "%5d%%%s ", (int)stack_filled, (stack_filled >= 80 ? "!" : " ")); +#else nsh_output(vtbl, "%5.1f%%%s ", (double)stack_filled, (stack_filled >= 80 ? "!" : " ")); #endif +#endif + #ifdef NSH_HAVE_CPULOAD /* Get the CPU load */