summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/CMakeLists.txt7
-rw-r--r--common/list.c10
-rw-r--r--common/log.c5
3 files changed, 13 insertions, 9 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index a40f096d..38767249 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -6,3 +6,10 @@ add_library(sway-common
6 readline.c 6 readline.c
7 stringop.c 7 stringop.c
8 ) 8 )
9
10if(Backtrace_FOUND)
11 set_target_properties(sway-common
12 PROPERTIES
13 COMPILE_FLAGS "-include ${Backtrace_HEADER}"
14 )
15endif()
diff --git a/common/list.c b/common/list.c
index d6f6f2ea..850c8569 100644
--- a/common/list.c
+++ b/common/list.c
@@ -50,14 +50,8 @@ void list_cat(list_t *list, list_t *source) {
50 } 50 }
51} 51}
52 52
53// pass the pointer of the object we care about to the comparison function 53void list_qsort(list_t* list, int compare(const void *left, const void *right)) {
54static int list_cmp(const void *l, const void *r, void *_cmp) { 54 qsort(list->items, list->length, sizeof(void *), compare);
55 int (*cmp)(const void *, const void *) = _cmp;
56 return cmp(*(void**)l, *(void**)r);
57}
58
59void list_sort(list_t *list, int compare(const void *left, const void *right)) {
60 qsort_r(list->items, list->length, sizeof(void *), list_cmp, compare);
61} 55}
62 56
63int list_seq_find(list_t *list, int compare(const void *item, const void *data), const void *data) { 57int list_seq_find(list_t *list, int compare(const void *item, const void *data), const void *data) {
diff --git a/common/log.c b/common/log.c
index 02aac4c1..f9242bf4 100644
--- a/common/log.c
+++ b/common/log.c
@@ -10,7 +10,6 @@
10#include <errno.h> 10#include <errno.h>
11#include <string.h> 11#include <string.h>
12#include <stringop.h> 12#include <stringop.h>
13#include <execinfo.h>
14 13
15int colored = 1; 14int colored = 1;
16log_importance_t loglevel_default = L_ERROR; 15log_importance_t loglevel_default = L_ERROR;
@@ -137,6 +136,7 @@ bool _sway_assert(bool condition, const char* format, ...) {
137} 136}
138 137
139void error_handler(int sig) { 138void error_handler(int sig) {
139#if SWAY_Backtrace_FOUND
140 int i; 140 int i;
141 int max_lines = 20; 141 int max_lines = 20;
142 void *array[max_lines]; 142 void *array[max_lines];
@@ -155,5 +155,8 @@ void error_handler(int sig) {
155 for (i = 0; (size_t)i < bt_len; i++) { 155 for (i = 0; (size_t)i < bt_len; i++) {
156 sway_log(L_ERROR, "Backtrace: %s", bt[i]); 156 sway_log(L_ERROR, "Backtrace: %s", bt[i]);
157 } 157 }
158#else
159 sway_log(L_ERROR, "Error: Signal %d.", sig);
160#endif
158 exit(1); 161 exit(1);
159} 162}