mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
adding back files to be reviewed
This commit is contained in:
parent
ae28233110
commit
bc09d1ef55
1244 changed files with 301904 additions and 0 deletions
71
include/openmc/error.h
Normal file
71
include/openmc/error.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef OPENMC_ERROR_H
|
||||
#define OPENMC_ERROR_H
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
#define UNREACHABLE() (void)0
|
||||
#endif
|
||||
|
||||
namespace openmc {
|
||||
|
||||
inline void
|
||||
set_errmsg(const char* message)
|
||||
{
|
||||
std::strcpy(openmc_err_msg, message);
|
||||
}
|
||||
|
||||
inline void
|
||||
set_errmsg(const std::string& message)
|
||||
{
|
||||
std::strcpy(openmc_err_msg, message.c_str());
|
||||
}
|
||||
|
||||
inline void
|
||||
set_errmsg(const std::stringstream& message)
|
||||
{
|
||||
std::strcpy(openmc_err_msg, message.str().c_str());
|
||||
}
|
||||
|
||||
[[noreturn]] void fatal_error(const std::string& message, int err=-1);
|
||||
|
||||
[[noreturn]] inline
|
||||
void fatal_error(const std::stringstream& message)
|
||||
{
|
||||
fatal_error(message.str());
|
||||
}
|
||||
|
||||
[[noreturn]] inline
|
||||
void fatal_error(const char* message)
|
||||
{
|
||||
fatal_error(std::string{message, std::strlen(message)});
|
||||
}
|
||||
|
||||
void warning(const std::string& message);
|
||||
|
||||
inline
|
||||
void warning(const std::stringstream& message)
|
||||
{
|
||||
warning(message.str());
|
||||
}
|
||||
|
||||
void write_message(const std::string& message, int level=0);
|
||||
|
||||
inline
|
||||
void write_message(const std::stringstream& message, int level)
|
||||
{
|
||||
write_message(message.str(), level);
|
||||
}
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
extern "C" void abort_mpi(int code);
|
||||
#endif
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_ERROR_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue