root/ompi/mca/pml/v/pml_v_output.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. V_OUTPUT_ERR
  2. V_OUTPUT
  3. V_OUTPUT_VERBOSE
  4. V_OUTPUT
  5. V_OUTPUT_VERBOSE

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

/* [<][>][^][v][top][bottom][index][help] */