Merge PR#385 - Freebsd fixes

This commit is contained in:
Jaroslav Kysela 2014-05-07 17:22:25 +02:00
commit 7acb452120
4 changed files with 35 additions and 2 deletions

View file

@ -642,7 +642,7 @@ void
idnode_set_sort
( idnode_set_t *is, idnode_sort_t *sort )
{
qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, (void*)sort);
tvh_qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, (void*)sort);
}
void

View file

@ -110,7 +110,10 @@ void tsfile_add_file ( const char *path )
{
tsfile_input_t *mi;
mpegts_mux_t *mm;
char *uuid = NULL, *tok, *tmp = strdupa(path);
char *uuid = NULL, *tok;
char tmp[strlen(path) + 1];
strcpy(tmp, path);
/* Pull UUID from info */
if ((tok = strstr(tmp, "::"))) {

View file

@ -657,6 +657,8 @@ qsort_r(void *base, size_t nmemb, size_t size,
int (*cmp)(const void *, const void *, void *), void *aux);
#endif /* ENABLE_QSORT_R */
void tvh_qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg);
/* printing */
#ifndef __WORDSIZE
# if ULONG_MAX == 0xffffffffffffffff

View file

@ -168,3 +168,31 @@ qsort_r(void *base, size_t nmemb, size_t size,
qsort(base, nmemb, size, qsort_r_wrap);
}
#endif /* ENABLE_QSORT_R */
#if defined(PLATFORM_FREEBSD)
struct tvh_qsort_data {
void *arg;
int (*compar)(const void *, const void *, void *);
};
static int
tvh_qsort_swap(void *arg, const void *a, const void *b)
{
struct tvh_qsort_data *data = arg;
return data->compar(a, b, data->arg);
}
#endif /* PLATFORM_FREEBSD */
void
tvh_qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)
{
#if defined(PLATFORM_FREEBSD)
struct tvh_qsort_data swap_arg = {arg, compar};
qsort_r(base, nmemb, size, &swap_arg, tvh_qsort_swap);
#else
qsort_r(base, nmemb, size, compar, arg);
#endif
}