diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Makefile | 3 | ||||
-rw-r--r-- | misc/search.h | 38 | ||||
-rw-r--r-- | misc/sys/cdefs.h | 14 |
3 files changed, 35 insertions, 20 deletions
diff --git a/misc/Makefile b/misc/Makefile index 52bf339309..9365fd2a1a 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -63,6 +63,9 @@ gpl2lgpl := error.c error.h tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent +CFLAGS-tsearch.c = $(exceptions) +CFLAGS-lsearch.c = $(exceptions) + include ../Rules $(objpfx)libbsd-compat.a: $(dep-dummy-lib); $(make-dummy-lib) diff --git a/misc/search.h b/misc/search.h index 2258ce9d3a..96b28e3f98 100644 --- a/misc/search.h +++ b/misc/search.h @@ -127,22 +127,22 @@ VISIT; /* Search for an entry matching the given KEY in the tree pointed to by *ROOTP and insert a new element if not found. */ -extern void *tsearch __P ((__const void *__key, void **__rootp, - __compar_fn_t compar)); -extern void *__tsearch __P ((__const void *__key, void **__rootp, +extern void *__tsearch __PMS ((__const void *__key, void **__rootp, + __compar_fn_t compar)); +extern void *tsearch __PMS ((__const void *__key, void **__rootp, __compar_fn_t compar)); /* Search for an entry matching the given KEY in the tree pointed to by *ROOTP. If no matching entry is available return NULL. */ -extern void *tfind __P ((__const void *__key, void *__const *__rootp, - __compar_fn_t compar)); -extern void *__tfind __P ((__const void *__key, void *__const *__rootp, +extern void *__tfind __PMS ((__const void *__key, void *__const *__rootp, + __compar_fn_t compar)); +extern void *tfind __PMS ((__const void *__key, void *__const *__rootp, __compar_fn_t compar)); /* Remove the element matching KEY from the tree pointed to by *ROOTP. */ -extern void *tdelete __P ((__const void *__key, void **__rootp, - __compar_fn_t compar)); -extern void *__tdelete __P ((__const void *__key, void **__rootp, +extern void *__tdelete __PMS ((__const void *__key, void **__rootp, + __compar_fn_t compar)); +extern void *tdelete __PMS ((__const void *__key, void **__rootp, __compar_fn_t compar)); #ifndef __ACTION_FN_T @@ -154,9 +154,8 @@ typedef void (*__action_fn_t) __P ((__const void *__nodep, /* Walk through the whole tree and call the ACTION callback for every node or leaf. */ -extern void twalk __P ((__const void *__root, __action_fn_t action)); - -extern void __twalk __P ((__const void *__root, __action_fn_t action)); +extern void __twalk __PMS ((__const void *__root, __action_fn_t action)); +extern void twalk __PMS ((__const void *__root, __action_fn_t action)); #ifdef __USE_GNU /* Callback type for function to free a tree node. If the keys are atomic @@ -164,21 +163,22 @@ extern void __twalk __P ((__const void *__root, __action_fn_t action)); typedef void (*__free_fn_t) __P ((void *__nodep)); /* Destroy the whole tree, call FREEFCT for each node or leaf. */ -extern void __tdestroy __P ((void *__root, __free_fn_t freefct)); -extern void tdestroy __P ((void *__root, __free_fn_t freefct)); +extern void __tdestroy __PMS ((void *__root, __free_fn_t freefct)); +extern void tdestroy __PMS ((void *__root, __free_fn_t freefct)); #endif /* Perform linear search for KEY by comparing by COMPAR in an array [BASE,BASE+NMEMB*SIZE). */ -extern void *lfind __P ((__const void *__key, __const void *__base, - size_t *__nmemb, size_t __size, - __compar_fn_t __compar)); +extern void *lfind __PMS ((__const void *__key, __const void *__base, + size_t *__nmemb, size_t __size, + __compar_fn_t __compar)); /* Perform linear search for KEY by comparing by COMPAR function in array [BASE,BASE+NMEMB*SIZE) and insert entry if not found. */ -extern void *lsearch __P ((__const void *__key, void *__base, size_t *__nmemb, - size_t __size, __compar_fn_t __compar)); +extern void *lsearch __PMS ((__const void *__key, void *__base, + size_t *__nmemb, size_t __size, + __compar_fn_t __compar)); __END_DECLS diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 1ced090251..096dc3d6c8 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -26,7 +26,17 @@ #ifdef __GNUC__ -# define __P(args) args /* GCC can always grok prototypes. */ +/* GCC can always grok prototypes. For C++ programs we add throw() + to help it optimize the function calls. But this works only with + gcc 2.8.x and egcs. */ +# if defined __cplusplus && __GNUC_MINOR__ >= 8 +# define __P(args) args throw () +# else +# define __P(args) args +# endif +/* This macro will be used for functions which might take C++ callback + functions. */ +# define __PMS(args) args # define __DOTS , ... #else /* Not GCC. */ @@ -36,6 +46,7 @@ # if (defined __STDC__ && __STDC__) || defined __cplusplus # define __P(args) args +# define __PMS(args) args # define __const const # define __signed signed # define __volatile volatile @@ -44,6 +55,7 @@ # else /* Not ANSI C or C++. */ # define __P(args) () /* No prototypes. */ +# define __PMS(args) () # define __const /* No ANSI C keywords. */ # define __signed # define __volatile |