Skip to content

Commit 60da503

Browse files
mgeiserttyan0
authored andcommitted
Newlib: Update search.h functions for POSIX.1-2024
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: ec98d19 "* wininfo.h (wininfo::timer_active): Delete." (cherry picked from commit 65d7818)
1 parent 4504d61 commit 60da503

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

newlib/libc/include/search.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ typedef struct node {
3636
} node_t;
3737
#endif
3838

39+
typedef void posix_tnode;
40+
3941
struct hsearch_data
4042
{
4143
struct internal_head *htable;
@@ -54,11 +56,11 @@ ENTRY *hsearch(ENTRY, ACTION);
5456
int hcreate_r(size_t, struct hsearch_data *);
5557
void hdestroy_r(struct hsearch_data *);
5658
int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
57-
void *tdelete(const void *__restrict, void **__restrict, __compar_fn_t);
59+
void *tdelete(const void *__restrict, posix_tnode **__restrict, __compar_fn_t);
5860
void tdestroy (void *, void (*)(void *));
59-
void *tfind(const void *, void **, __compar_fn_t);
60-
void *tsearch(const void *, void **, __compar_fn_t);
61-
void twalk(const void *, void (*)(const void *, VISIT, int));
61+
posix_tnode *tfind(const void *, posix_tnode *const *, __compar_fn_t);
62+
posix_tnode *tsearch(const void *, posix_tnode **, __compar_fn_t);
63+
void twalk(const posix_tnode *, void (*)(const posix_tnode *, VISIT, int));
6264
__END_DECLS
6365

6466
#endif /* !_SEARCH_H_ */

newlib/libc/search/tdelete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ __RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
2727
/* delete node with given key */
2828
void *
2929
tdelete (const void *__restrict vkey, /* key to be deleted */
30-
void **__restrict vrootp, /* address of the root of tree */
30+
posix_tnode **__restrict vrootp,/* address of the root of tree */
3131
int (*compar)(const void *, const void *))
3232
{
3333
node_t **rootp = (node_t **)vrootp;

newlib/libc/search/tfind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ __RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
2626
/* find a node, or return 0 */
2727
void *
2828
tfind (const void *vkey, /* key to be found */
29-
void **vrootp, /* address of the tree root */
29+
posix_tnode *const *vrootp, /* address of the tree root */
3030
int (*compar)(const void *, const void *))
3131
{
3232
node_t **rootp = (node_t **)vrootp;

newlib/libc/search/tsearch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ __RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $");
2626
/* find or insert datum into search tree */
2727
void *
2828
tsearch (const void *vkey, /* key to be located */
29-
void **vrootp, /* address of tree root */
29+
posix_tnode **vrootp, /* address of tree root */
3030
int (*compar)(const void *, const void *))
3131
{
3232
node_t *q;

newlib/libc/search/twalk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ trecurse(
5050

5151
/* Walk the nodes of a tree */
5252
void
53-
twalk (const void *vroot, /* Root of the tree to be walked */
54-
void (*action)(const void *, VISIT, int))
53+
twalk (const posix_tnode *vroot,/* Root of the tree to be walked */
54+
void (*action)(const posix_tnode *, VISIT, int))
5555
{
5656
if (vroot != NULL && action != NULL)
5757
trecurse(vroot, action, 0);

0 commit comments

Comments
 (0)