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