Browse Source

compat: add lfind

Fixes android build with NDK 17 as lfind is not always available.
pull/77/head
Victorien Le Couviour--Tuffet 8 years ago
committed by Thomas Guillem
parent
commit
cf9bd77c67
  1. 19
      compat/lfind.c
  2. 2
      configure.ac
  3. 2
      include/vlc_fixups.h

19
compat/lfind.c

@ -0,0 +1,19 @@
/*****************************************************************************
* lfind.c : implement lfind
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
void *lfind(const void *key, const void *base, size_t *nmemb,
size_t size, int(*cmp)(const void *, const void *))
{
for (int i = 0; i < *nmemb; ++i)
{
const void *elem = base + i * size;
if (!cmp(key, elem))
return elem;
}
return NULL;
}

2
configure.ac

@ -581,7 +581,7 @@ need_libc=false
dnl Check for usual libc functions
AC_CHECK_FUNCS([accept4 daemon fcntl flock fstatvfs fork getenv getpwuid_r isatty memalign mkostemp mmap open_memstream newlocale openat pipe2 pread posix_fadvise posix_madvise posix_memalign setlocale stricmp strnicmp strptime uselocale])
AC_REPLACE_FUNCS([aligned_alloc atof atoll dirfd fdopendir flockfile fsync getdelim getpid lldiv memrchr nrand48 poll recvmsg rewind sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr strsep strtof strtok_r strtoll swab tdestroy tfind timegm timespec_get strverscmp pathconf])
AC_REPLACE_FUNCS([aligned_alloc atof atoll dirfd fdopendir flockfile fsync getdelim getpid lfind lldiv memrchr nrand48 poll recvmsg rewind sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr strsep strtof strtok_r strtoll swab tdestroy tfind timegm timespec_get strverscmp pathconf])
AC_REPLACE_FUNCS([gettimeofday])
AC_CHECK_FUNC(fdatasync,,
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])

2
include/vlc_fixups.h

@ -486,6 +486,8 @@ void *tsearch( const void *key, void **rootp, int(*cmp)(const void *, const void
void *tfind( const void *key, const void **rootp, int(*cmp)(const void *, const void *) );
void *tdelete( const void *key, void **rootp, int(*cmp)(const void *, const void *) );
void twalk( const void *root, void(*action)(const void *nodep, VISIT which, int depth) );
void *lfind( const void *key, const void *base, size_t *nmemb,
size_t size, int(*cmp)(const void *, const void *) );
#endif /* HAVE_SEARCH_H */
#ifndef HAVE_TDESTROY
void tdestroy( void *root, void (*free_node)(void *nodep) );

Loading…
Cancel
Save