source: rtems/cpukit/libmisc/shell/main_top.c @ 24d0ee57

5
Last change on this file since 24d0ee57 was 24d0ee57, checked in by Chris Johns <chrisj@…>, on 05/20/16 at 08:39:50

cpukit, testsuite: Add rtems_printf and rtems_printer support.

This change adds rtems_printf and related functions and wraps the
RTEMS print plugin support into a user API. All references to the
plugin are removed and replaced with the rtems_printer interface.

Printk and related functions are made to return a valid number of
characters formatted and output.

The function attribute to check printf functions has been added
to rtems_printf and printk. No changes to remove warrnings are part
of this patch set.

The testsuite has been moved over to the rtems_printer. The testsuite
has a mix of rtems_printer access and direct print control via the
tmacros.h header file. The support for begink/endk has been removed
as it served no purpose and only confused the code base. The testsuite
has not been refactored to use rtems_printf. This is future work.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  TOP Command Implementation
3 *
4 *  COPYRIGHT (c) 2014.
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/shell.h>
22#include "internal.h"
23
24static int rtems_shell_main_top(
25  int   argc,
26  char *argv[]
27)
28{
29  /*
30   *  When invoked with no arguments, print the report.
31   */
32  if ( argc == 1 ) {
33    rtems_printer printer;
34    rtems_print_printer_fprintf(&printer, stdout);
35    rtems_cpu_usage_top_with_plugin(&printer);
36    return 0;
37  }
38
39  /*
40   *  When invoked with the single argument -r, reset the statistics.
41   */
42  if ( argc == 2 && !strcmp( argv[1], "-r" ) ) {
43    printf( "Resetting CPU Usage information\n" );
44    rtems_cpu_usage_reset();
45    return 0;
46  }
47
48  /*
49   *  OK.  The user did something wrong.
50   */
51  fprintf( stderr, "%s: [-r]\n", argv[0] );
52  return -1;
53}
54
55rtems_shell_cmd_t rtems_shell_TOP_Command = {
56  "top",                                      /* name */
57  "[-r] print or reset per thread cpu usage", /* usage */
58  "rtems",                                    /* topic */
59  rtems_shell_main_top,                       /* command */
60  NULL,                                       /* alias */
61  NULL                                        /* next */
62};
Note: See TracBrowser for help on using the repository browser.