diff --git a/common/lib/kernel/kernel.cpp b/common/lib/kernel/kernel.cpp
index 306acb709..c0d57fc0d 100644
--- a/common/lib/kernel/kernel.cpp
+++ b/common/lib/kernel/kernel.cpp
@@ -59,7 +59,7 @@ Version villas::kernel::getVersion()
int villas::kernel::get_cacheline_size()
{
-#if defined(__linux__) && defined(__x86_64__)
+#if defined(__linux__) && defined(__x86_64__) && defined(__GLIBC__)
return sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
#elif defined(__MACH__)
/* Open the command for reading. */
diff --git a/common/lib/list.cpp b/common/lib/list.cpp
index 09fca3b98..a72d20ddf 100644
--- a/common/lib/list.cpp
+++ b/common/lib/list.cpp
@@ -22,22 +22,15 @@
* along with this program. If not, see .
*********************************************************************************/
+#include
+#include
+
#include
#include
#include
#include
-#ifdef __APPLE__
-static int cmp_sort(void *thunk, const void *a, const void *b) {
-#else
-static int cmp_sort(const void *a, const void *b, void *thunk) {
-#endif
- cmp_cb_t cmp = (cmp_cb_t) thunk;
-
- return cmp(*(const void **) a, *(const void **) b);
-}
-
int vlist_init(struct vlist *l)
{
pthread_mutex_init(&l->lock, nullptr);
@@ -231,11 +224,13 @@ void vlist_sort(struct vlist *l, cmp_cb_t cmp)
assert(l->state == State::INITIALIZED);
-#ifdef __APPLE__
- qsort_r(l->array, l->length, sizeof(void *), (void *) cmp, cmp_sort);
-#else
- qsort_r(l->array, l->length, sizeof(void *), cmp_sort, (void *) cmp);
-#endif
+ auto array = std::vector(l->array, l->array + l->length);
+
+ std::sort(array.begin(), array.end(), [cmp](void *&a, void *&b) -> bool {
+ return cmp(a, b) < 0;
+ });
+
+ std::copy(array.begin(), array.end(), l->array);
pthread_mutex_unlock(&l->lock);
}
@@ -310,4 +305,4 @@ int vlist_init_and_push(struct vlist *l, void *p)
vlist_push(l, p);
return 0;
-}
\ No newline at end of file
+}