[PATCH] Newlib: Update search.h functions for POSIX.1-2024
Mark Geisert <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Add type posix_tnode. Change certain uses of "void" to "posix_tnode" in both the prototypes and definitions of functions associated with <search.h>. (Necessary changes to Cygwin's /usr/include/search.h will follow in a separate patch to be sent to cygwin-patches.) Reported-by: Collin Funk <[email protected]> Addresses: https://cygwin.com/pipermail/cygwin/2025-April/258032.html Signed-off-by: Mark Geisert <[email protected]> Fixes: ec98d19a08c2 "* wininfo.h (wininfo::timer_active): Delete." --- newlib/libc/include/search.h | 10 ++++++---- newlib/libc/search/tdelete.c | 2 +- newlib/libc/search/tfind.c | 2 +- newlib/libc/search/tsearch.c | 2 +- newlib/libc/search/twalk.c | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/newlib/libc/include/search.h b/newlib/libc/include/search.h index ed321b0f6..70a1a20ae 100644 --- a/newlib/libc/include/search.h +++ b/newlib/libc/include/search.h @@ -36,6 +36,8 @@ typedef struct node { } node_t; #endif +typedef void posix_tnode; + struct hsearch_data { struct internal_head *htable; @@ -54,11 +56,11 @@ ENTRY *hsearch(ENTRY, ACTION); int hcreate_r(size_t, struct hsearch_data *); void hdestroy_r(struct hsearch_data *); int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); -void *tdelete(const void *__restrict, void **__restrict, __compar_fn_t); +void *tdelete(const void *__restrict, posix_tnode **__restrict, __compar_fn_t); void tdestroy (void *, void (*)(void *)); -void *tfind(const void *, void **, __compar_fn_t); -void *tsearch(const void *, void **, __compar_fn_t); -void twalk(const void *, void (*)(const void *, VISIT, int)); +posix_tnode *tfind(const void *, posix_tnode *const *, __compar_fn_t); +posix_tnode *tsearch(const void *, posix_tnode **, __compar_fn_t); +void twalk(const posix_tnode *, void (*)(const posix_tnode *, VISIT, int)); __END_DECLS #endif /* !_SEARCH_H_ */ diff --git a/newlib/libc/search/tdelete.c b/newlib/libc/search/tdelete.c index a595200db..b12158e41 100644 --- a/newlib/libc/search/tdelete.c +++ b/newlib/libc/search/tdelete.c @@ -27,7 +27,7 @@ __RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); /* delete node with given key */ void * tdelete (const void *__restrict vkey, /* key to be deleted */ - void **__restrict vrootp, /* address of the root of tree */ + posix_tnode **__restrict vrootp,/* address of the root of tree */ int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **)vrootp; diff --git a/newlib/libc/search/tfind.c b/newlib/libc/search/tfind.c index 670f41fca..8bebdac71 100644 --- a/newlib/libc/search/tfind.c +++ b/newlib/libc/search/tfind.c @@ -26,7 +26,7 @@ __RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); /* find a node, or return 0 */ void * tfind (const void *vkey, /* key to be found */ - void **vrootp, /* address of the tree root */ + posix_tnode *const *vrootp, /* address of the tree root */ int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **)vrootp; diff --git a/newlib/libc/search/tsearch.c b/newlib/libc/search/tsearch.c index 82d69447f..9be77f138 100644 --- a/newlib/libc/search/tsearch.c +++ b/newlib/libc/search/tsearch.c @@ -26,7 +26,7 @@ __RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $"); /* find or insert datum into search tree */ void * tsearch (const void *vkey, /* key to be located */ - void **vrootp, /* address of tree root */ + posix_tnode **vrootp, /* address of tree root */ int (*compar)(const void *, const void *)) { node_t *q; diff --git a/newlib/libc/search/twalk.c b/newlib/libc/search/twalk.c index 7aec6e4dd..26d037a5d 100644 --- a/newlib/libc/search/twalk.c +++ b/newlib/libc/search/twalk.c @@ -50,8 +50,8 @@ trecurse( /* Walk the nodes of a tree */ void -twalk (const void *vroot, /* Root of the tree to be walked */ - void (*action)(const void *, VISIT, int)) +twalk (const posix_tnode *vroot,/* Root of the tree to be walked */ + void (*action)(const posix_tnode *, VISIT, int)) { if (vroot != NULL && action != NULL) trecurse(vroot, action, 0); -- 2.45.1