SUNphi  1.0
MinimalCrash.hpp
Go to the documentation of this file.
1 #ifndef _MINIMAL_CRASH_HPP
2 #define _MINIMAL_CRASH_HPP
3 
4 /// \file MinimalCrash.hpp
5 ///
6 /// \brief Minimal version of the crasher
7 ///
8 /// This file can be included in place of Crasher.hpp, in case the
9 /// former cannot be included due to missing requirements, e.g. in
10 /// presence of routine from which the actual crasher depends, such as
11 /// threads or MPI. The actual crasher is called in the cpp file
12 
13 #include <cstring>
14 #include <errno.h>
15 
16 namespace SUNphi
17 {
18  /// Wraps the actual crasher through the old-style C variadic function
19  ///
20  /// We cannot use variadic template version here, as the crash cannot be called directly here, since "Logger.hpp" is expected
21  void minimalCrash(const char* path, ///< File where the crash happened
22  const int line, ///< Line number where the crash happened
23  const char* funcName, ///< Function where the crash happened
24  const char* format, ///< Formatting string
25  ...);
26 
27  /// Initialize the minimal crasher
28 #define MINIMAL_CRASH(...)
29  minimalCrash(__FILE__,__LINE__,__PRETTY_FUNCTION__,__VA_ARGS__)
30 
31  /// Minimal crash with stdlib error
32 #define MINIMAL_CRASH_STDLIBERR(STRING)
33  MINIMAL_CRASH(__FILE__,__LINE__,__PRETTY_FUNCTION__,STRING " stdliberr: %s",strerror(errno))
34 }
35 
36 #endif
#define MINIMAL_CRASH(...)
Initialize the minimal crasher.
void minimalCrash(const char *path, const int line, const char *funcName, const char *format,...)
Definition: SUNphi.cpp:53