Changeset b97bc8bc in rtems


Ignore:
Timestamp:
05/07/14 16:27:19 (10 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
8fa3422
Parents:
0960fee
Message:

tests: Add locked_printf_plugin()

Add locked_vprintf(). Return an int just like printf(), etc.

Location:
testsuites/support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/support/include/test_support.h

    r0960fee rb97bc8bc  
    1010#ifndef __TEST_SUPPORT_h
    1111#define __TEST_SUPPORT_h
     12
     13#include <stdarg.h>
    1214
    1315#ifdef __cplusplus
     
    6668/*********************************************************************/
    6769/*********************************************************************/
    68 extern void locked_print_initialize(void);
    69 extern void locked_printf(const char *fmt, ...);
    70 extern void locked_printk(const char *fmt, ...);
     70
     71void locked_print_initialize(void);
     72
     73int locked_printf(const char *fmt, ...);
     74
     75int locked_vprintf(const char *fmt, va_list ap);
     76
     77int locked_printf_plugin(void *context, const char *fmt, ...);
     78
     79void locked_printk(const char *fmt, ...);
    7180
    7281#ifdef __cplusplus
  • testsuites/support/src/locked_print.c

    r0960fee rb97bc8bc  
    1212#endif
    1313
    14 #include <rtems.h>
    15 #include <rtems/system.h>
    16 #include <sys/types.h>
    17 #include <string.h>
    18 #include <stdarg.h>
    19 
     14#include "test_support.h"
    2015#include "tmacros.h"
    2116
     
    4641}
    4742
    48 void locked_printf(const char *fmt, ...) {
    49   va_list           ap;       /* points to each unnamed argument in turn */
     43int locked_vprintf(const char *fmt, va_list ap)
     44{
     45  int rv;
    5046  rtems_status_code sc;
    5147
     
    5753  } while (sc != RTEMS_SUCCESSFUL );
    5854
     55  rv = vprintf(fmt, ap);
     56
     57  /* Release the semaphore  */
     58  rtems_semaphore_release( locked_print_semaphore );
     59
     60  return rv;
     61}
     62
     63int locked_printf_plugin(void *context, const char *fmt, ...)
     64{
     65  int rv;
     66  va_list ap;
     67
     68  (void) context;
     69
     70  va_start(ap, fmt);
     71  rv = locked_vprintf(fmt, ap);
     72  va_end(ap);
     73
     74  return rv;
     75}
     76
     77int locked_printf(const char *fmt, ...)
     78{
     79  int               rv;
     80  va_list           ap;       /* points to each unnamed argument in turn */
    5981
    6082  va_start(ap, fmt); /* make ap point to 1st unnamed arg */
    61   vprintf(fmt, ap);
     83  rv = locked_vprintf(fmt, ap);
    6284  va_end(ap);        /* clean up when done */
    6385
    64   /* Release the semaphore  */
    65   sc = rtems_semaphore_release( locked_print_semaphore );
    66 }
     86  return rv;
     87}
    6788
    68 void locked_printk(const char *fmt, ...) {
     89void locked_printk(const char *fmt, ...)
     90{
    6991  va_list           ap;       /* points to each unnamed argument in turn */
    7092  rtems_status_code sc;
     
    83105
    84106  /* Release the semaphore  */
    85   sc = rtems_semaphore_release( locked_print_semaphore );
    86 } 
     107  rtems_semaphore_release( locked_print_semaphore );
     108}
Note: See TracChangeset for help on using the changeset viewer.