Re: [rtems commit] libmisc/shell: Remove the need for -lm when linking from the ping command.

2014-10-03 Thread Gedare Bloom
On Fri, Oct 3, 2014 at 6:48 PM, Chris Johns  wrote:
> Module:rtems
> Branch:master
> Commit:56ed56a641b69be42f5a38046307b33096014c84
> Changeset: 
> http://git.rtems.org/rtems/commit/?id=56ed56a641b69be42f5a38046307b33096014c84
>
> Author:Chris Johns 
> Date:  Sat Oct  4 08:55:12 2014 +1000
>
> libmisc/shell: Remove the need for -lm when linking from the ping command.
>
> Remove the use of sqrt and so the need to link to -lm.
> Clean up some warnings.
>
> ---
>
>  cpukit/libmisc/shell/main_ping.c |   17 -
>  1 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/cpukit/libmisc/shell/main_ping.c 
> b/cpukit/libmisc/shell/main_ping.c
> index a13d726..f13f241 100644
> --- a/cpukit/libmisc/shell/main_ping.c
> +++ b/cpukit/libmisc/shell/main_ping.c
> @@ -86,7 +86,9 @@ __FBSDID("$FreeBSD$");
>  #include 
>  //#include 
>  #include 
> +#if !defined(__rtems__)
>  #include 
> +#endif
>  #include 
>  #include 
>  #include 
> @@ -333,7 +335,6 @@ static char *pr_ntime(n_time);
>  static void pr_icmph(struct icmp *);
>  static void pr_iph(struct ip *);
>  static void pr_retip(struct ip *);
> -static void status(int);
>  static void stopit(int);
>  static void tvsub(struct timeval *, struct timeval *);
>
> @@ -358,7 +359,7 @@ static void g_pr_pack(char *, int, struct sockaddr_in *, 
> struct timeval *, rtems
>  #define usage() g_usage(globals)
>  static void g_usage(rtems_shell_globals_t* globals) __dead2;
>
> -void
> +static void
>  rtems_shell_ping_exit (rtems_shell_globals_t* globals, int code)
>  {
>globals->exit_code = code;
> @@ -1581,14 +1582,14 @@ tvsub(out, in)
>   * Print out statistics when SIGINFO is received.
>   */
>
> +#if !defined(__rtems__)
>  static void
>  status(sig)
> int sig __unused;
>  {
> -#if !__rtems__
> siginfo_p = 1;
> -#endif
>  }
> +#endif
>
>  static void
>  g_check_status(globals)
> @@ -1638,10 +1639,16 @@ g_finish(globals)
> if (nreceived && timing) {
> double n = nreceived + nrepeats;
> double avg = tsum / n;
> +#if defined(__rtems__)
> +   (void) printf(
> +   "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f ms\n",
Remove "/stddev"?

> +   tmin, avg, tmax);
> +#else
> double vari = tsumsq / n - avg * avg;
> (void)printf(
> "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f 
> ms\n",
> tmin, avg, tmax, sqrt(vari));
> +#endif
> }
> if (nreceived)
> exit(0);
> @@ -1917,7 +1924,7 @@ g_fill(bp, patp, globals)
> u_int ii, jj, kk;
>
> for (cp = patp; *cp; cp++) {
> -   if (!isxdigit(*cp))
> +   if (!isxdigit((int)*cp))
> errx(&globals->exit_jmp, EX_USAGE,
> "patterns must be specified as hex digits");
>
>
> ___
> vc mailing list
> v...@rtems.org
> http://lists.rtems.org/mailman/listinfo/vc
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [rtems commit] libmisc/shell: Remove the need for -lm when linking from the ping command.

2014-10-03 Thread Gedare Bloom
On Fri, Oct 3, 2014 at 8:04 PM, Gedare Bloom  wrote:
> On Fri, Oct 3, 2014 at 6:48 PM, Chris Johns  wrote:
>> Module:rtems
>> Branch:master
>> Commit:56ed56a641b69be42f5a38046307b33096014c84
>> Changeset: 
>> http://git.rtems.org/rtems/commit/?id=56ed56a641b69be42f5a38046307b33096014c84
>>
>> Author:Chris Johns 
>> Date:  Sat Oct  4 08:55:12 2014 +1000
>>
>> libmisc/shell: Remove the need for -lm when linking from the ping command.
>>
>> Remove the use of sqrt and so the need to link to -lm.
>> Clean up some warnings.
>>
>> ---
>>
>>  cpukit/libmisc/shell/main_ping.c |   17 -
>>  1 files changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/cpukit/libmisc/shell/main_ping.c 
>> b/cpukit/libmisc/shell/main_ping.c
>> index a13d726..f13f241 100644
>> --- a/cpukit/libmisc/shell/main_ping.c
>> +++ b/cpukit/libmisc/shell/main_ping.c
>> @@ -86,7 +86,9 @@ __FBSDID("$FreeBSD$");
>>  #include 
>>  //#include 
>>  #include 
>> +#if !defined(__rtems__)
>>  #include 
>> +#endif
>>  #include 
>>  #include 
>>  #include 
>> @@ -333,7 +335,6 @@ static char *pr_ntime(n_time);
>>  static void pr_icmph(struct icmp *);
>>  static void pr_iph(struct ip *);
>>  static void pr_retip(struct ip *);
>> -static void status(int);
>>  static void stopit(int);
>>  static void tvsub(struct timeval *, struct timeval *);
>>
>> @@ -358,7 +359,7 @@ static void g_pr_pack(char *, int, struct sockaddr_in *, 
>> struct timeval *, rtems
>>  #define usage() g_usage(globals)
>>  static void g_usage(rtems_shell_globals_t* globals) __dead2;
>>
>> -void
>> +static void
>>  rtems_shell_ping_exit (rtems_shell_globals_t* globals, int code)
>>  {
>>globals->exit_code = code;
>> @@ -1581,14 +1582,14 @@ tvsub(out, in)
>>   * Print out statistics when SIGINFO is received.
>>   */
>>
>> +#if !defined(__rtems__)
>>  static void
>>  status(sig)
>> int sig __unused;
>>  {
>> -#if !__rtems__
>> siginfo_p = 1;
>> -#endif
>>  }
>> +#endif
>>
>>  static void
>>  g_check_status(globals)
>> @@ -1638,10 +1639,16 @@ g_finish(globals)
>> if (nreceived && timing) {
>> double n = nreceived + nrepeats;
>> double avg = tsum / n;
>> +#if defined(__rtems__)
>> +   (void) printf(
>> +   "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f ms\n",
> Remove "/stddev"?
Actually, I'd suggest to just print the variance as it can be computed
relatively cheaply (compared to sqrt).

>
>> +   tmin, avg, tmax);
>> +#else
>> double vari = tsumsq / n - avg * avg;
>> (void)printf(
>> "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f 
>> ms\n",
>> tmin, avg, tmax, sqrt(vari));
>> +#endif
>> }
>> if (nreceived)
>> exit(0);
>> @@ -1917,7 +1924,7 @@ g_fill(bp, patp, globals)
>> u_int ii, jj, kk;
>>
>> for (cp = patp; *cp; cp++) {
>> -   if (!isxdigit(*cp))
>> +   if (!isxdigit((int)*cp))
>> errx(&globals->exit_jmp, EX_USAGE,
>> "patterns must be specified as hex digits");
>>
>>
>> ___
>> vc mailing list
>> v...@rtems.org
>> http://lists.rtems.org/mailman/listinfo/vc
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [rtems commit] libmisc/shell: Remove the need for -lm when linking from the ping command.

2014-10-03 Thread Chris Johns

On 4/10/2014 10:05 am, Gedare Bloom wrote:

On Fri, Oct 3, 2014 at 8:04 PM, Gedare Bloom  wrote:

On Fri, Oct 3, 2014 at 6:48 PM, Chris Johns  wrote:

Module:rtems
Branch:master
Commit:56ed56a641b69be42f5a38046307b33096014c84
Changeset: 
http://git.rtems.org/rtems/commit/?id=56ed56a641b69be42f5a38046307b33096014c84

Author:Chris Johns 
Date:  Sat Oct  4 08:55:12 2014 +1000

libmisc/shell: Remove the need for -lm when linking from the ping command.

Remove the use of sqrt and so the need to link to -lm.
Clean up some warnings.

  static void
  g_check_status(globals)
@@ -1638,10 +1639,16 @@ g_finish(globals)
 if (nreceived && timing) {
 double n = nreceived + nrepeats;
 double avg = tsum / n;
+#if defined(__rtems__)
+   (void) printf(
+   "round-trip min/avg/max/stddev = %.3f/%.3f/%.3f ms\n",

Remove "/stddev"?

Actually, I'd suggest to just print the variance as it can be computed
relatively cheaply (compared to sqrt).



Ah yes I can change this. There is another step to remove the use of 
floating point which Pavel raised and I think is a great idea. This is 
just a simple clean up while that can be done.


Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel