2007-07-28 03:11:00 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2007 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PML_V_OUTPUT_H_HAS_BEEN_INCLUDED
|
|
|
|
#define PML_V_OUTPUT_H_HAS_BEEN_INCLUDED
|
|
|
|
|
2009-02-14 05:26:12 +03:00
|
|
|
#include "opal/util/output.h"
|
2008-02-27 22:58:18 +03:00
|
|
|
#include "opal_stdint.h"
|
2007-08-16 09:52:30 +04:00
|
|
|
#include <stdio.h>
|
2008-06-10 00:38:44 +04:00
|
|
|
#include "pml_v.h"
|
2007-07-28 03:11:00 +04:00
|
|
|
|
2009-08-20 15:42:18 +04:00
|
|
|
BEGIN_C_DECLS
|
2007-07-28 03:11:00 +04:00
|
|
|
|
2007-08-14 21:17:12 +04:00
|
|
|
int pml_v_output_open(char *output, int verbosity);
|
|
|
|
void pml_v_output_close(void);
|
|
|
|
|
|
|
|
static inline void V_OUTPUT_ERR(const char *fmt, ... ) __opal_attribute_format__(__printf__, 1, 2);
|
|
|
|
static inline void V_OUTPUT_ERR(const char *fmt, ... )
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char *str;
|
|
|
|
int ret;
|
|
|
|
va_start(list, fmt);
|
|
|
|
ret = vasprintf(&str, fmt, list);
|
|
|
|
assert(-1 != ret);
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, str);
|
2007-08-14 21:17:12 +04:00
|
|
|
free(str);
|
|
|
|
va_end(list);
|
|
|
|
}
|
2007-07-28 03:11:00 +04:00
|
|
|
|
|
|
|
/* Tricky stuff to define V_OUTPUT and V_OUTPUT_VERBOSE with variadic arguments
|
|
|
|
*/
|
|
|
|
#if defined(ACCEPT_C99)
|
2007-08-16 09:52:30 +04:00
|
|
|
# define V_OUTPUT(ARGS...) \
|
2008-06-09 18:53:58 +04:00
|
|
|
OPAL_OUTPUT((pml_v_output, __VA_ARGS__))
|
2007-08-16 09:52:30 +04:00
|
|
|
# define V_OUTPUT_VERBOSE(V, ARGS...) \
|
2008-06-10 00:38:44 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((V, mca_pml_v.output, __VA_ARGS__))
|
2007-08-07 02:20:44 +04:00
|
|
|
|
2007-07-28 03:11:00 +04:00
|
|
|
#elif defined(__GNUC__) && !defined(__STDC__)
|
2007-08-16 09:52:30 +04:00
|
|
|
# define V_OUTPUT(ARGS...) \
|
2008-06-09 18:53:58 +04:00
|
|
|
OPAL_OUTPUT((pml_v_output, ARGS))
|
2007-08-16 09:52:30 +04:00
|
|
|
# define V_OUTPUT_VERBOSE(V, ARGS...) \
|
2008-06-10 00:38:44 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((V, mca_pml_v.output, ARGS))
|
2007-08-07 02:20:44 +04:00
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
#elif OPAL_ENABLE_DEBUG
|
2007-07-30 23:11:15 +04:00
|
|
|
/* No variadic macros available... So sad */
|
2007-08-14 21:17:12 +04:00
|
|
|
static inline void V_OUTPUT(const char* fmt, ... ) __opal_attribute_format__(__printf__, 1, 2);
|
|
|
|
static inline void V_OUTPUT(const char* fmt, ... )
|
|
|
|
{
|
2007-07-30 23:11:15 +04:00
|
|
|
va_list list;
|
|
|
|
char *str;
|
2007-07-31 23:33:39 +04:00
|
|
|
int ret;
|
2007-07-30 23:11:15 +04:00
|
|
|
va_start(list, fmt);
|
2007-07-31 23:33:39 +04:00
|
|
|
ret = vasprintf(&str, fmt, list);
|
|
|
|
assert(-1 != ret);
|
2008-06-10 00:38:44 +04:00
|
|
|
opal_output(mca_pml_v.output, str);
|
2007-07-30 23:11:15 +04:00
|
|
|
free(str);
|
|
|
|
va_end(list);
|
2007-07-28 03:11:00 +04:00
|
|
|
}
|
2007-08-14 21:17:12 +04:00
|
|
|
static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) __opal_attribute_format__(__printf__, 2, 3);
|
2007-07-31 23:33:39 +04:00
|
|
|
static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) {
|
2007-07-30 23:11:15 +04:00
|
|
|
va_list list;
|
|
|
|
char *str;
|
2007-07-31 23:33:39 +04:00
|
|
|
int ret;
|
2007-07-30 23:11:15 +04:00
|
|
|
va_start(list, fmt);
|
2007-07-31 23:33:39 +04:00
|
|
|
ret = vasprintf(&str, fmt, list);
|
|
|
|
assert(-1 != ret);
|
2008-06-10 00:38:44 +04:00
|
|
|
opal_output_verbose(V, mca_pml_v.output, str);
|
2007-07-30 23:11:15 +04:00
|
|
|
free(str);
|
|
|
|
va_end(list);
|
2007-07-28 03:11:00 +04:00
|
|
|
}
|
2007-08-07 02:20:44 +04:00
|
|
|
|
2007-07-30 23:11:15 +04:00
|
|
|
#else /* !DEBUG */
|
|
|
|
/* Some compilers complain if we have ... and no corresponding va_start() */
|
2007-07-31 23:33:39 +04:00
|
|
|
static inline void V_OUTPUT(const char* fmt, ... ) {
|
2007-07-28 03:11:00 +04:00
|
|
|
#if defined(__PGI)
|
2007-07-30 23:11:15 +04:00
|
|
|
va_list list;
|
|
|
|
va_start(list, fmt);
|
|
|
|
va_end(list);
|
2007-07-28 03:11:00 +04:00
|
|
|
#endif
|
|
|
|
}
|
2007-07-31 23:33:39 +04:00
|
|
|
static inline void V_OUTPUT_VERBOSE(int V, const char* fmt, ... ) {
|
2007-07-28 03:11:00 +04:00
|
|
|
#if defined(__PGI)
|
2007-07-30 23:11:15 +04:00
|
|
|
va_list list;
|
|
|
|
va_start(list, fmt);
|
|
|
|
va_end(list);
|
2007-07-28 03:11:00 +04:00
|
|
|
#endif
|
|
|
|
}
|
2007-07-30 23:11:15 +04:00
|
|
|
#endif /* DEBUG */
|
2007-07-28 03:11:00 +04:00
|
|
|
|
2009-08-20 15:42:18 +04:00
|
|
|
END_C_DECLS
|
2007-07-28 03:11:00 +04:00
|
|
|
|
|
|
|
#endif /* PML_V_OUTPUT_H_HAS_BEEN_INCLUDED */
|