OpenMPI  0.1.1
pml_v_output.h
1 /*
2  * Copyright (c) 2004-2007 The Trustees of the University of Tennessee.
3  * All rights reserved.
4  * $COPYRIGHT$
5  *
6  * Additional copyrights may follow
7  *
8  * $HEADER$
9  */
10 
11 #ifndef PML_V_OUTPUT_H_HAS_BEEN_INCLUDED
12 #define PML_V_OUTPUT_H_HAS_BEEN_INCLUDED
13 
14 #include "opal/util/output.h"
15 #include "opal_stdint.h"
16 #include <stdio.h>
17 #include "pml_v.h"
18 
19 BEGIN_C_DECLS
20 
21 int pml_v_output_open(char *output, int verbosity);
22 void pml_v_output_close(void);
23 
24 static inline void V_OUTPUT_ERR(const char *fmt, ... ) __opal_attribute_format__(__printf__, 1, 2);
25 static inline void V_OUTPUT_ERR(const char *fmt, ... )
26 {
27  va_list list;
28  char *str;
29  int ret;
30  va_start(list, fmt);
31  ret = vasprintf(&str, fmt, list);
32  assert(-1 != ret);
33  opal_output(0, "%s", str);
34  free(str);
35  va_end(list);
36 }
37 
38 /* Tricky stuff to define V_OUTPUT and V_OUTPUT_VERBOSE with variadic arguments
39  */
40 #if defined(ACCEPT_C99)
41 # define V_OUTPUT(ARGS...) \
42  OPAL_OUTPUT((pml_v_output, __VA_ARGS__))
43 # define V_OUTPUT_VERBOSE(V, ARGS...) \
44  OPAL_OUTPUT_VERBOSE((V, mca_pml_v.output, __VA_ARGS__))
45 
46 #elif defined(__GNUC__) && !defined(__STDC__)
47 # define V_OUTPUT(ARGS...) \
48  OPAL_OUTPUT((pml_v_output, ARGS))
49 # define V_OUTPUT_VERBOSE(V, ARGS...) \
50  OPAL_OUTPUT_VERBOSE((V, mca_pml_v.output, ARGS))
51 
52 #elif OPAL_ENABLE_DEBUG
53  /* No variadic macros available... So sad */
54 static inline void V_OUTPUT(const char* fmt, ... ) __opal_attribute_format__(__printf__, 1, 2);
55 static inline void V_OUTPUT(const char* fmt, ... )
56 {
57  va_list list;
58  char *str;
59  int ret;
60  va_start(list, fmt);
61  ret = vasprintf(&str, fmt, list);
62  assert(-1 != ret);
63  opal_output(mca_pml_v.output, "%s", str);
64  free(str);
65  va_end(list);
66 }
67 static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) __opal_attribute_format__(__printf__, 2, 3);
68 static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) {
69  va_list list;
70  char *str;
71  int ret;
72  va_start(list, fmt);
73  ret = vasprintf(&str, fmt, list);
74  assert(-1 != ret);
75  opal_output_verbose(V, mca_pml_v.output, "%s", str);
76  free(str);
77  va_end(list);
78 }
79 
80 #else /* !DEBUG */
81  /* Some compilers complain if we have ... and no corresponding va_start() */
82 static inline void V_OUTPUT(const char* fmt, ... ) {
83 #if defined(__PGI)
84  va_list list;
85  va_start(list, fmt);
86  va_end(list);
87 #endif
88 }
89 static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) {
90 #if defined(__PGI)
91  va_list list;
92  va_start(list, fmt);
93  va_end(list);
94 #endif
95 }
96 #endif /* DEBUG */
97 
98 END_C_DECLS
99 
100 #endif /* PML_V_OUTPUT_H_HAS_BEEN_INCLUDED */
OPAL_DECLSPEC void OPAL_DECLSPEC void opal_output_verbose(int verbose_level, int output_id, const char *format,...) __opal_attribute_format__(__printf__
Send output to a stream only if the passed verbosity level is high enough.
OPAL output stream facility.
OPAL_DECLSPEC void opal_output(int output_id, const char *format,...) __opal_attribute_format__(__printf__
Main function to send output to a stream.