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