7#include "../../include/lammp/lmmp.h"
22 return "ASSERT_FAILURE";
24 return "DEBUG_ASSERT_FAILURE";
26 return "PARAM_ASSERT_FAILURE";
28 return "MEMORY_ALLOC_FAILURE";
30 return "MEMORY_FREE_FAILURE";
32 return "OUT_OF_BOUNDS";
36 return "UNEXPECTED_ERROR";
38 return "UNKNOWN_TYPE";
46 fn(type, msg, func, line);
48 fprintf(stderr,
"LAMMP abort at [%s]:%d\n", func, line);
49 fprintf(stderr,
"Abort type: %s, abort msg: \n%s\n",
type_to_str(type), msg);
static const char * type_to_str(lmmp_error_t type)
lmmp_abort_fn lmmp_set_abort_fn(lmmp_abort_fn func)
设置 LAMMP 全局退出函数(所有线程均生效)
void lmmp_abort(lmmp_error_t type, const char *msg, const char *func, int line)
LAMMP 全局退出函数,内部错误或断言失败时调用,若设置了全局退出函数,则会调用该函数,否则会调用默认的退出函数。
static atomic_uintptr_t lmmp_abort_func
void(* lmmp_abort_fn)(lmmp_error_t type, const char *msg, const char *func, int line)
LAMMP 全局退出函数指针类型
@ LAMMP_ERROR_MEMORY_ALLOC_FAILURE
@ LAMMP_ERROR_DEBUG_ASSERT_FAILURE
@ LAMMP_ERROR_UNEXPECTED_ERROR
@ LAMMP_ERROR_MEMORY_LEAK
@ LAMMP_ERROR_ASSERT_FAILURE
@ LAMMP_ERROR_PARAM_ASSERT_FAILURE
@ LAMMP_ERROR_MEMORY_FREE_FAILURE
@ LAMMP_ERROR_OUT_OF_BOUNDS