mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
list: fix portability issues of list_sort() os BSD-based systems
This commit is contained in:
parent
37aea20df8
commit
fc95c7c70a
1 changed files with 9 additions and 1 deletions
|
@ -41,10 +41,14 @@ static int cmp_contains(const void *a, const void *b) {
|
|||
return a == b ? 0 : 1;
|
||||
}
|
||||
|
||||
#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(*(void **) a, *(void **) b);
|
||||
return cmp(*(const void **) a, *(const void **) b);
|
||||
}
|
||||
|
||||
int list_init(struct list *l)
|
||||
|
@ -193,7 +197,11 @@ void list_sort(struct list *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
|
||||
|
||||
pthread_mutex_unlock(&l->lock);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue