Skip to content

Commit

Permalink
use std::terminate or std::abort instead of exit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Feb 9, 2024
1 parent 3a65374 commit b0a0bc8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/thallium/bulk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class bulk {
~bulk() noexcept {
if(m_bulk != HG_BULK_NULL) {
hg_return_t ret = margo_bulk_free(m_bulk);
MARGO_ASSERT_TERMINATE(ret, margo_bulk_free, -1);
MARGO_ASSERT_TERMINATE(ret, margo_bulk_free);
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/thallium/callable_remote_procedure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class callable_remote_procedure_with_context {
~callable_remote_procedure_with_context() {
if(m_handle != HG_HANDLE_NULL) {
hg_return_t ret = margo_destroy(m_handle);
MARGO_ASSERT_TERMINATE(ret, margo_destroy, -1);
MARGO_ASSERT_TERMINATE(ret, margo_destroy);
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/thallium/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ inline endpoint::~endpoint() {
auto engine_impl = m_engine_impl.lock();
if(!engine_impl) return;
hg_return_t ret = margo_addr_free(engine_impl->m_mid, m_addr);
MARGO_ASSERT_TERMINATE(ret, margo_addr_free, -1);
MARGO_ASSERT_TERMINATE(ret, margo_addr_free);
}
}

Expand Down
7 changes: 4 additions & 3 deletions include/thallium/margo_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <exception>
#include <iostream>
#include <cstdlib>
#include <margo.h>
#include <sstream>
#include <stdexcept>
Expand Down Expand Up @@ -98,15 +99,15 @@ inline const char* translate_margo_error_code(hg_return_t ret) {
} \
} while(0)

#define MARGO_ASSERT_TERMINATE(__ret__, __fun__, __failcode__) \
#define MARGO_ASSERT_TERMINATE(__ret__, __fun__) \
do { \
if(__ret__ != HG_SUCCESS) { \
std::stringstream msg; \
msg << "Function returned "; \
msg << translate_margo_error_code(__ret__); \
std::cerr << #__fun__ << ":" << __FILE__ << ":" << __LINE__ \
<< ": " << msg.str(); \
exit(__failcode__); \
std::terminate(); \
} \
} while(0)

Expand All @@ -115,7 +116,7 @@ inline const char* translate_margo_error_code(hg_return_t ret) {
if(!(__cond__)) { \
std::cerr << "Condition " << #__cond__ << " failed (" << __FILE__ \
<< __LINE__ << "), " << __msg__ << std::endl; \
exit(-1); \
std::abort(); \
} \
} while(0)
} // namespace thallium
Expand Down
2 changes: 1 addition & 1 deletion include/thallium/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class request_with_context {
*/
~request_with_context() {
hg_return_t ret = margo_destroy(m_handle);
MARGO_ASSERT_TERMINATE(ret, margo_destroy, -1);
MARGO_ASSERT_TERMINATE(ret, margo_destroy);
}

/**
Expand Down

0 comments on commit b0a0bc8

Please sign in to comment.