source: rtems/testsuites/support/src/locked_print.c @ e071c183

4.115
Last change on this file since e071c183 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <rtems.h>
15#include <rtems/system.h>
16#include <sys/types.h>
17#include <string.h>
18#include <stdarg.h>
19
20#include "tmacros.h"
21
22static rtems_id locked_print_semaphore;      /* synchronisation semaphore */
23
24void locked_print_initialize(void)
25{
26  rtems_status_code sc;
27  static            bool initted = false;
28
29  if ( initted )
30    return;
31
32  initted = true;
33
34  /* Create/verify synchronisation semaphore */
35  sc = rtems_semaphore_create(
36    rtems_build_name ('S', 'E', 'M', '1'),
37    1,                                             
38    RTEMS_LOCAL                   |
39    RTEMS_SIMPLE_BINARY_SEMAPHORE |
40    RTEMS_PRIORITY,
41    1,
42    &locked_print_semaphore
43  );
44  directive_failed( sc, "rtems_semaphore_create" );
45}
46
47void locked_printf(const char *fmt, ...) {
48  va_list           ap;       /* points to each unnamed argument in turn */
49  rtems_status_code sc;
50
51  locked_print_initialize();
52
53  /* Lock semaphore without releasing the cpu */
54  do {
55    sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
56  } while (sc != RTEMS_SUCCESSFUL );
57
58
59  va_start(ap, fmt); /* make ap point to 1st unnamed arg */
60  vprintf(fmt, ap);
61  va_end(ap);        /* clean up when done */
62
63  /* Release the semaphore  */
64  sc = rtems_semaphore_release( locked_print_semaphore );
65}
66
67void locked_printk(const char *fmt, ...) {
68  va_list           ap;       /* points to each unnamed argument in turn */
69  rtems_status_code sc;
70
71
72  locked_print_initialize();
73
74  /* Lock semaphore without releasing the cpu */
75  do {
76    sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
77  } while (sc != RTEMS_SUCCESSFUL );
78
79  va_start(ap, fmt); /* make ap point to 1st unnamed arg */
80  vprintk(fmt, ap);
81  va_end(ap);        /* clean up when done */
82
83  /* Release the semaphore  */
84  sc = rtems_semaphore_release( locked_print_semaphore );
85}
Note: See TracBrowser for help on using the repository browser.