2016-09-01 12:18:37 +00:00
|
|
|
#include <signal.h>
|
2015-08-08 21:01:22 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
2016-09-01 12:18:37 +00:00
|
|
|
#include "log.h"
|
2017-04-16 07:30:17 +00:00
|
|
|
|
2017-11-18 16:22:02 +00:00
|
|
|
void sway_terminate(int code);
|
2017-04-20 16:13:53 +00:00
|
|
|
|
2018-01-05 22:36:32 +00:00
|
|
|
void _sway_abort(const char *format, ...) {
|
2017-04-20 16:13:53 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
2018-07-09 21:54:30 +00:00
|
|
|
_wlr_vlog(WLR_ERROR, format, args);
|
2017-04-20 16:13:53 +00:00
|
|
|
va_end(args);
|
|
|
|
sway_terminate(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2018-01-05 22:36:32 +00:00
|
|
|
bool _sway_assert(bool condition, const char *format, ...) {
|
2015-08-18 21:38:34 +00:00
|
|
|
if (condition) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
2018-07-09 21:54:30 +00:00
|
|
|
_wlr_vlog(WLR_ERROR, format, args);
|
2015-08-18 21:38:34 +00:00
|
|
|
va_end(args);
|
|
|
|
|
2015-08-26 23:27:01 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
raise(SIGABRT);
|
|
|
|
#endif
|
|
|
|
|
2015-08-18 21:38:34 +00:00
|
|
|
return false;
|
|
|
|
}
|