Files
RedBear-OS/include/search.h
T
vasilito daeca3892e Add byteswap/error/libintl/ar/search headers + tsearch family, mempcpy, rawmemchr
Portable ELF tooling (elfutils/libelf, needed by Mesa's radeonsi driver) relies
on several standard headers and functions Red Bear's relibc lacked:

- <byteswap.h>: bswap_16/32/64 (compiler builtins).
- <error.h>: GNU error()/error_at_line() (inline).
- <libintl.h>: gettext family as the identity map (catalog-less system; matches
  glibc's no-catalog fallback behaviour).
- <ar.h>: Unix archive struct/magic (header-only).
- <search.h> + src/header/search: POSIX tsearch/tfind/tdelete/twalk + GNU
  tdestroy, implemented as an unbalanced BST (conforming; POSIX mandates no
  balancing).
- string: mempcpy (memcpy returning end) and rawmemchr (unbounded memchr).

All complete implementations, no stubs. Additive (no ABI break), so existing
sysroot binaries are unaffected.
2026-07-31 15:03:51 +03:00

41 lines
1.0 KiB
C

/* search.h — POSIX search tables.
*
* Red Bear OS / relibc. Provides the binary-tree search family (tsearch,
* tfind, tdelete, twalk) plus the GNU tdestroy extension. Implemented in
* src/header/search/mod.rs; the VISIT enum order below MUST match the
* PREORDER/POSTORDER/ENDORDER/LEAF constants there.
*/
#ifndef _SEARCH_H
#define _SEARCH_H 1
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
preorder,
postorder,
endorder,
leaf
} VISIT;
void *tsearch(const void *__key, void **__rootp,
int (*__compar)(const void *, const void *));
void *tfind(const void *__key, void *const *__rootp,
int (*__compar)(const void *, const void *));
void *tdelete(const void *__key, void **__rootp,
int (*__compar)(const void *, const void *));
void twalk(const void *__root,
void (*__action)(const void *__nodep, VISIT __which, int __depth));
/* GNU extension. */
void tdestroy(void *__root, void (*__free_node)(void *__nodep));
#ifdef __cplusplus
}
#endif
#endif /* search.h */