Commit d24bc4a4 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

musl compatability fixes

parent 013af9cb
......@@ -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. */
......
......@@ -22,22 +22,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <array>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <villas/list.h>
#include <villas/utils.hpp>
#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<void *>(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
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment