diff --git a/options/glibc/generic/search.cpp b/options/glibc/generic/search.cpp new file mode 100644 index 0000000000..52a578f78e --- /dev/null +++ b/options/glibc/generic/search.cpp @@ -0,0 +1,14 @@ +#include +#include + +int hcreate_r(size_t num_entries, hsearch_data *htab) { + return mlibc::hcreate_r(num_entries, htab); +} + +void hdestroy_r(hsearch_data *htab) { + mlibc::hdestroy_r(htab); +} + +int hsearch_r(ENTRY item, ACTION action, ENTRY **ret, hsearch_data *htab) { + return mlibc::hsearch_r(item, action, ret, htab); +} diff --git a/options/glibc/include/bits/glibc/glibc_search.h b/options/glibc/include/bits/glibc/glibc_search.h new file mode 100644 index 0000000000..cb23bae73d --- /dev/null +++ b/options/glibc/include/bits/glibc/glibc_search.h @@ -0,0 +1,22 @@ +#ifndef _GLIBC_SEARCH_H +#define _GLIBC_SEARCH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __MLIBC_ABI_ONLY + +int hcreate_r(size_t num_entries, struct hsearch_data *htab); +void hdestroy_r(struct hsearch_data *htab); +int hsearch_r(ENTRY item, ACTION action, ENTRY **ret, struct hsearch_data *htab); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _GLIBC_SEARCH_H */ diff --git a/options/glibc/meson.build b/options/glibc/meson.build index 93bad857b2..b7f3e7cf69 100644 --- a/options/glibc/meson.build +++ b/options/glibc/meson.build @@ -19,6 +19,7 @@ libc_sources += files( 'generic/glibc-assert.cpp', 'generic/malloc.cpp', 'generic/sys-io.cpp', + 'generic/search.cpp' ) if not no_headers @@ -84,6 +85,7 @@ if not no_headers 'include/bits/glibc/glibc_assert.h', 'include/bits/glibc/glibc_malloc.h', 'include/bits/glibc/glibc_icmp6.h', + 'include/bits/glibc/glibc_search.h', subdir: 'bits/glibc' ) endif diff --git a/options/posix/include/search.h b/options/posix/include/search.h index 7d1c5ee3fe..95041a0ece 100644 --- a/options/posix/include/search.h +++ b/options/posix/include/search.h @@ -17,6 +17,10 @@ typedef enum { leaf } VISIT; +#if __MLIBC_GLIBC_OPTION && defined(_GNU_SOURCE) +#include +#endif + #ifndef __MLIBC_ABI_ONLY void *tsearch(const void *, void **, int(*compar)(const void *, const void *));