source: rtems/cpukit/libcsupport/src/print_printf.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: 971 bytes
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Print Support
5 *  @ingroup libcsupport
6 */
7
8/*
9 * Copyright (c) 2016 Chris Johns <chrisj@rtems.org>
10 * All rights reserved.
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18  #include "config.h"
19#endif
20
21#include <rtems/print.h>
22
23#include <stdio.h>
24
25int rtems_vprintf(
26  const rtems_printer *printer,
27  const char          *format,
28  va_list              ap
29)
30{
31  int len = 0;
32  if ( rtems_print_printer_valid( printer ) ) {
33    len = printer->printer( printer->context, format, ap );
34  }
35  return len;
36}
37
38int rtems_printf(
39  const rtems_printer *printer,
40  const char          *format,
41  ...
42)
43{
44  int len = 0;
45  if ( rtems_print_printer_valid( printer ) ) {
46    va_list ap;
47    va_start( ap, format );
48    len = printer->printer( printer->context, format, ap );
49    va_end( ap );
50  }
51  return len;
52}
Note: See TracBrowser for help on using the repository browser.