source: rtems/cpukit/libmisc/shell/main_cpuuse.c @ 506bfc8

5
Last change on this file since 506bfc8 was 506bfc8, checked in by Sebastian Huber <sebastian.huber@…>, on 06/21/16 at 11:30:15

Move printer initialization to separate header

The RTEMS print user need to know nothing about a particular printer
implementation. In particular get rid of the <stdio.h> include which
would be visible via <rtems.h>.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  CPUUSE Command Implementation
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.org/license/LICENSE.
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdio.h>
17#include <string.h>
18
19#include <rtems.h>
20#include <rtems/cpuuse.h>
21#include <rtems/printer.h>
22#include <rtems/shell.h>
23#include "internal.h"
24
25static int rtems_shell_main_cpuuse(
26  int   argc,
27  char *argv[]
28)
29{
30  /*
31   *  When invoked with no arguments, print the report.
32   */
33  if ( argc == 1 ) {
34    rtems_printer printer;
35    rtems_print_printer_fprintf(&printer, stdout);
36    rtems_cpu_usage_report_with_plugin(&printer);
37    return 0;
38  }
39
40  /*
41   *  When invoked with the single argument -r, reset the statistics.
42   */
43  if ( argc == 2 && !strcmp( argv[1], "-r" ) ) {
44    printf( "Resetting CPU Usage information\n" );
45    rtems_cpu_usage_reset();
46    return 0;
47  }
48
49  /*
50   *  OK.  The user did something wrong.
51   */
52  fprintf( stderr, "%s: [-r]\n", argv[0] );
53  return -1;
54}
55
56rtems_shell_cmd_t rtems_shell_CPUUSE_Command = {
57  "cpuuse",                                   /* name */
58  "[-r] print or reset per thread cpu usage", /* usage */
59  "rtems",                                    /* topic */
60  rtems_shell_main_cpuuse,                    /* command */
61  NULL,                                       /* alias */
62  NULL                                        /* next */
63};
Note: See TracBrowser for help on using the repository browser.