mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-22 22:22:05 +03:00
400c5e5c83
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
#ifndef _SEARCH_H
|
|
#define _SEARCH_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if __STDC_VERSION__ >= 199901L
|
|
#define __restrict restrict
|
|
#elif !defined(__GNUC__)
|
|
#define __restrict
|
|
#endif
|
|
|
|
|
|
#define __NEED_size_t
|
|
#include <bits/alltypes.h>
|
|
|
|
typedef enum { FIND, ENTER } ACTION;
|
|
typedef enum { preorder, postorder, endorder, leaf } VISIT;
|
|
|
|
typedef struct {
|
|
char *key;
|
|
void *data;
|
|
} ENTRY;
|
|
|
|
int hcreate(size_t);
|
|
void hdestroy(void);
|
|
ENTRY *hsearch(ENTRY, ACTION);
|
|
|
|
void insque(void *, void *);
|
|
void remque(void *);
|
|
|
|
void *lsearch(const void *, void *, size_t *, size_t,
|
|
int (*)(const void *, const void *));
|
|
void *lfind(const void *, const void *, size_t *, size_t,
|
|
int (*)(const void *, const void *));
|
|
|
|
void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *));
|
|
void *tfind(const void *, void *const *, int(*)(const void *, const void *));
|
|
void *tsearch(const void *, void **, int (*)(const void *, const void *));
|
|
void twalk(const void *, void (*)(const void *, VISIT, int));
|
|
|
|
#ifdef _GNU_SOURCE
|
|
struct qelem {
|
|
struct qelem *q_forw, *q_back;
|
|
char q_data[1];
|
|
};
|
|
|
|
void tdestroy(void *, void (*)(void *));
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|