1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

musl compatability fixes

This commit is contained in:
Steffen Vogel 2020-11-11 21:23:53 +01:00
parent c7a2709d18
commit 1e8b6ac8f0
2 changed files with 12 additions and 17 deletions

View file

@ -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. */

View file

@ -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;
}
}