Mercurial > hg > octave-kai > gnulib-hg
changeset 17178:86c983ca0522
list, oset, xlist, xoset, xsublist: simplify via extern inline
* lib/gl_list.h, lib/gl_list.c (GL_LIST_INLINE):
* lib/gl_oset.c, lib/gl_oset.h (GL_OSET_INLINE):
* lib/gl_xlist.c, lib/gl_xlist.h (GL_XLIST_INLINE):
* lib/gl_xoset.c, lib/gl_xoset.h (GL_XOSET_INLINE):
* lib/gl_xsublist.c, lib/gl_xsublist.h (GL_XSUBLIST_INLINE):
New macro. Replace all uses of 'static inline' with it.
[HAVE_INLINE]: Implement functions as *_INLINE functions,
instead of as macros FOO that are defined to static inline
functions FOO_inline.
* lib/gl_list.c, lib/gl_oset.c, lib/gl_xlist.c, lib/gl_xoset.c:
* lib/gl_xsublist.c:
Reimplement from scratch, by defining the corresponding *_INLINE
macro and including the corresponding .h file. This is simpler.
* m4/gl_list.m4: Remove.
* modules/list, modules/oset, modules/xlist, modules/xoset:
(Files): Remove m4/gl_list.m4.
(configure.ac): Remove gl_LIST.
* modules/list, modules/oset, modules/xlist, modules/xoset:
* modules/xsublist:
(Depends-on): Depend on extern-inline, not inline.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 20 Nov 2012 22:25:07 -0800 |
parents | 902795f52835 |
children | bbfb83985261 |
files | ChangeLog lib/gl_list.c lib/gl_list.h lib/gl_oset.c lib/gl_oset.h lib/gl_xlist.c lib/gl_xlist.h lib/gl_xoset.c lib/gl_xoset.h lib/gl_xsublist.c lib/gl_xsublist.h m4/gl_list.m4 modules/list modules/oset modules/xlist modules/xoset modules/xsublist |
diffstat | 17 files changed, 129 insertions(+), 743 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ 2012-11-29 Paul Eggert <eggert@cs.ucla.edu> + list, oset, xlist, xoset, xsublist: simplify via extern inline + * lib/gl_list.h, lib/gl_list.c (GL_LIST_INLINE): + * lib/gl_oset.c, lib/gl_oset.h (GL_OSET_INLINE): + * lib/gl_xlist.c, lib/gl_xlist.h (GL_XLIST_INLINE): + * lib/gl_xoset.c, lib/gl_xoset.h (GL_XOSET_INLINE): + * lib/gl_xsublist.c, lib/gl_xsublist.h (GL_XSUBLIST_INLINE): + New macro. Replace all uses of 'static inline' with it. + [HAVE_INLINE]: Implement functions as *_INLINE functions, + instead of as macros FOO that are defined to static inline + functions FOO_inline. + * lib/gl_list.c, lib/gl_oset.c, lib/gl_xlist.c, lib/gl_xoset.c: + * lib/gl_xsublist.c: + Reimplement from scratch, by defining the corresponding *_INLINE + macro and including the corresponding .h file. This is simpler. + * modules/list, modules/oset, modules/xlist, modules/xoset: + (Files): Remove m4/gl_list.m4. + (configure.ac): Remove gl_LIST. + * m4/gl_list.m4: Remove. + * modules/list, modules/oset, modules/xlist, modules/xoset: + * modules/xsublist: + (Depends-on): Depend on extern-inline, not inline. + xalloc: better 'inline' * lib/xmalloc.c, lib/xalloc.h (XALLOC_INLINE): New macro. Replace all uses of 'static inline' with it.
--- a/lib/gl_list.c +++ b/lib/gl_list.c @@ -1,283 +1,3 @@ -/* Abstract sequential list data type. - Copyright (C) 2006-2012 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2006. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ +#define GL_LIST_INLINE _GL_EXTERN_INLINE #include "gl_list.h" - -#if !HAVE_INLINE - -/* Define all functions of this file as inline accesses to the - struct gl_list_implementation. - Use #define to avoid a warning because of extern vs. static. */ - -gl_list_t -gl_list_nx_create_empty (gl_list_implementation_t implementation, - gl_listelement_equals_fn equals_fn, - gl_listelement_hashcode_fn hashcode_fn, - gl_listelement_dispose_fn dispose_fn, - bool allow_duplicates) -{ - return implementation->nx_create_empty (implementation, equals_fn, - hashcode_fn, dispose_fn, - allow_duplicates); -} - -gl_list_t -gl_list_nx_create (gl_list_implementation_t implementation, - gl_listelement_equals_fn equals_fn, - gl_listelement_hashcode_fn hashcode_fn, - gl_listelement_dispose_fn dispose_fn, - bool allow_duplicates, - size_t count, const void **contents) -{ - return implementation->nx_create (implementation, equals_fn, hashcode_fn, - dispose_fn, allow_duplicates, count, - contents); -} - -size_t -gl_list_size (gl_list_t list) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->size (list); -} - -const void * -gl_list_node_value (gl_list_t list, gl_list_node_t node) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->node_value (list, node); -} - -int -gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, - const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->node_nx_set_value (list, node, elt); -} - -gl_list_node_t -gl_list_next_node (gl_list_t list, gl_list_node_t node) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->next_node (list, node); -} - -gl_list_node_t -gl_list_previous_node (gl_list_t list, gl_list_node_t node) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->previous_node (list, node); -} - -const void * -gl_list_get_at (gl_list_t list, size_t position) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->get_at (list, position); -} - -gl_list_node_t -gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->nx_set_at (list, position, elt); -} - -gl_list_node_t -gl_list_search (gl_list_t list, const void *elt) -{ - size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); - return ((const struct gl_list_impl_base *) list)->vtable - ->search_from_to (list, 0, size, elt); -} - -gl_list_node_t -gl_list_search_from (gl_list_t list, size_t start_index, const void *elt) -{ - size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); - return ((const struct gl_list_impl_base *) list)->vtable - ->search_from_to (list, start_index, size, elt); -} - -gl_list_node_t -gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->search_from_to (list, start_index, end_index, elt); -} - -size_t -gl_list_indexof (gl_list_t list, const void *elt) -{ - size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); - return ((const struct gl_list_impl_base *) list)->vtable - ->indexof_from_to (list, 0, size, elt); -} - -size_t -gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt) -{ - size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); - return ((const struct gl_list_impl_base *) list)->vtable - ->indexof_from_to (list, start_index, size, elt); -} - -size_t -gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->indexof_from_to (list, start_index, end_index, elt); -} - -gl_list_node_t -gl_list_nx_add_first (gl_list_t list, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->nx_add_first (list, elt); -} - -gl_list_node_t -gl_list_nx_add_last (gl_list_t list, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->nx_add_last (list, elt); -} - -gl_list_node_t -gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->nx_add_before (list, node, elt); -} - -gl_list_node_t -gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->nx_add_after (list, node, elt); -} - -gl_list_node_t -gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->nx_add_at (list, position, elt); -} - -bool -gl_list_remove_node (gl_list_t list, gl_list_node_t node) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->remove_node (list, node); -} - -bool -gl_list_remove_at (gl_list_t list, size_t position) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->remove_at (list, position); -} - -bool -gl_list_remove (gl_list_t list, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->remove_elt (list, elt); -} - -void -gl_list_free (gl_list_t list) -{ - ((const struct gl_list_impl_base *) list)->vtable->list_free (list); -} - -gl_list_iterator_t -gl_list_iterator (gl_list_t list) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->iterator (list); -} - -gl_list_iterator_t -gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->iterator_from_to (list, start_index, end_index); -} - -bool -gl_list_iterator_next (gl_list_iterator_t *iterator, - const void **eltp, gl_list_node_t *nodep) -{ - return iterator->vtable->iterator_next (iterator, eltp, nodep); -} - -void -gl_list_iterator_free (gl_list_iterator_t *iterator) -{ - iterator->vtable->iterator_free (iterator); -} - -gl_list_node_t -gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->sortedlist_search (list, compar, elt); -} - -gl_list_node_t -gl_sortedlist_search_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->sortedlist_search_from_to (list, compar, start_index, end_index, - elt); -} - -size_t -gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->sortedlist_indexof (list, compar, elt); -} - -size_t -gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->sortedlist_indexof_from_to (list, compar, start_index, end_index, - elt); -} - -gl_list_node_t -gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->sortedlist_nx_add (list, compar, elt); -} - -bool -gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) -{ - return ((const struct gl_list_impl_base *) list)->vtable - ->sortedlist_remove (list, compar, elt); -} - -#endif
--- a/lib/gl_list.h +++ b/lib/gl_list.h @@ -21,6 +21,11 @@ #include <stdbool.h> #include <stddef.h> +_GL_INLINE_HEADER_BEGIN +#ifndef GL_LIST_INLINE +# define GL_LIST_INLINE _GL_INLINE +#endif + #ifdef __cplusplus extern "C" { #endif @@ -539,14 +544,10 @@ bool allow_duplicates; }; -#if HAVE_INLINE +/* Define all functions of this file as accesses to the + struct gl_list_implementation. */ -/* Define all functions of this file as inline accesses to the - struct gl_list_implementation. - Use #define to avoid a warning because of extern vs. static. */ - -# define gl_list_nx_create_empty gl_list_nx_create_empty_inline -static inline gl_list_t +GL_LIST_INLINE gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, gl_listelement_hashcode_fn hashcode_fn, @@ -558,8 +559,7 @@ allow_duplicates); } -# define gl_list_nx_create gl_list_nx_create_inline -static inline gl_list_t +GL_LIST_INLINE gl_list_t gl_list_nx_create (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, gl_listelement_hashcode_fn hashcode_fn, @@ -572,24 +572,21 @@ contents); } -# define gl_list_size gl_list_size_inline -static inline size_t +GL_LIST_INLINE size_t gl_list_size (gl_list_t list) { return ((const struct gl_list_impl_base *) list)->vtable ->size (list); } -# define gl_list_node_value gl_list_node_value_inline -static inline const void * +GL_LIST_INLINE const void * gl_list_node_value (gl_list_t list, gl_list_node_t node) { return ((const struct gl_list_impl_base *) list)->vtable ->node_value (list, node); } -# define gl_list_node_nx_set_value gl_list_node_nx_set_value_inline -static inline int +GL_LIST_INLINE int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void *elt) { @@ -597,40 +594,35 @@ ->node_nx_set_value (list, node, elt); } -# define gl_list_next_node gl_list_next_node_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_next_node (gl_list_t list, gl_list_node_t node) { return ((const struct gl_list_impl_base *) list)->vtable ->next_node (list, node); } -# define gl_list_previous_node gl_list_previous_node_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_previous_node (gl_list_t list, gl_list_node_t node) { return ((const struct gl_list_impl_base *) list)->vtable ->previous_node (list, node); } -# define gl_list_get_at gl_list_get_at_inline -static inline const void * +GL_LIST_INLINE const void * gl_list_get_at (gl_list_t list, size_t position) { return ((const struct gl_list_impl_base *) list)->vtable ->get_at (list, position); } -# define gl_list_nx_set_at gl_list_nx_set_at_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_set_at (list, position, elt); } -# define gl_list_search gl_list_search_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_search (gl_list_t list, const void *elt) { size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); @@ -638,8 +630,7 @@ ->search_from_to (list, 0, size, elt); } -# define gl_list_search_from gl_list_search_from_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_search_from (gl_list_t list, size_t start_index, const void *elt) { size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); @@ -647,8 +638,7 @@ ->search_from_to (list, start_index, size, elt); } -# define gl_list_search_from_to gl_list_search_from_to_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt) { @@ -656,8 +646,7 @@ ->search_from_to (list, start_index, end_index, elt); } -# define gl_list_indexof gl_list_indexof_inline -static inline size_t +GL_LIST_INLINE size_t gl_list_indexof (gl_list_t list, const void *elt) { size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); @@ -665,8 +654,7 @@ ->indexof_from_to (list, 0, size, elt); } -# define gl_list_indexof_from gl_list_indexof_from_inline -static inline size_t +GL_LIST_INLINE size_t gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt) { size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); @@ -674,8 +662,7 @@ ->indexof_from_to (list, start_index, size, elt); } -# define gl_list_indexof_from_to gl_list_indexof_from_to_inline -static inline size_t +GL_LIST_INLINE size_t gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt) { @@ -683,118 +670,103 @@ ->indexof_from_to (list, start_index, end_index, elt); } -# define gl_list_nx_add_first gl_list_nx_add_first_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_first (list, elt); } -# define gl_list_nx_add_last gl_list_nx_add_last_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_last (list, elt); } -# define gl_list_nx_add_before gl_list_nx_add_before_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_before (list, node, elt); } -# define gl_list_nx_add_after gl_list_nx_add_after_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_after (list, node, elt); } -# define gl_list_nx_add_at gl_list_nx_add_at_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->nx_add_at (list, position, elt); } -# define gl_list_remove_node gl_list_remove_node_inline -static inline bool +GL_LIST_INLINE bool gl_list_remove_node (gl_list_t list, gl_list_node_t node) { return ((const struct gl_list_impl_base *) list)->vtable ->remove_node (list, node); } -# define gl_list_remove_at gl_list_remove_at_inline -static inline bool +GL_LIST_INLINE bool gl_list_remove_at (gl_list_t list, size_t position) { return ((const struct gl_list_impl_base *) list)->vtable ->remove_at (list, position); } -# define gl_list_remove gl_list_remove_inline -static inline bool +GL_LIST_INLINE bool gl_list_remove (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->remove_elt (list, elt); } -# define gl_list_free gl_list_free_inline -static inline void +GL_LIST_INLINE void gl_list_free (gl_list_t list) { ((const struct gl_list_impl_base *) list)->vtable->list_free (list); } -# define gl_list_iterator gl_list_iterator_inline -static inline gl_list_iterator_t +GL_LIST_INLINE gl_list_iterator_t gl_list_iterator (gl_list_t list) { return ((const struct gl_list_impl_base *) list)->vtable ->iterator (list); } -# define gl_list_iterator_from_to gl_list_iterator_from_to_inline -static inline gl_list_iterator_t +GL_LIST_INLINE gl_list_iterator_t gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index) { return ((const struct gl_list_impl_base *) list)->vtable ->iterator_from_to (list, start_index, end_index); } -# define gl_list_iterator_next gl_list_iterator_next_inline -static inline bool +GL_LIST_INLINE bool gl_list_iterator_next (gl_list_iterator_t *iterator, const void **eltp, gl_list_node_t *nodep) { return iterator->vtable->iterator_next (iterator, eltp, nodep); } -# define gl_list_iterator_free gl_list_iterator_free_inline -static inline void +GL_LIST_INLINE void gl_list_iterator_free (gl_list_iterator_t *iterator) { iterator->vtable->iterator_free (iterator); } -# define gl_sortedlist_search gl_sortedlist_search_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->sortedlist_search (list, compar, elt); } -# define gl_sortedlist_search_from_to gl_sortedlist_search_from_to_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_sortedlist_search_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -802,16 +774,14 @@ elt); } -# define gl_sortedlist_indexof gl_sortedlist_indexof_inline -static inline size_t +GL_LIST_INLINE size_t gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->sortedlist_indexof (list, compar, elt); } -# define gl_sortedlist_indexof_from_to gl_sortedlist_indexof_from_to_inline -static inline size_t +GL_LIST_INLINE size_t gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -819,26 +789,24 @@ elt); } -# define gl_sortedlist_nx_add gl_sortedlist_nx_add_inline -static inline gl_list_node_t +GL_LIST_INLINE gl_list_node_t gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->sortedlist_nx_add (list, compar, elt); } -# define gl_sortedlist_remove gl_sortedlist_remove_inline -static inline bool +GL_LIST_INLINE bool gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable ->sortedlist_remove (list, compar, elt); } -#endif - #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* _GL_LIST_H */
--- a/lib/gl_oset.c +++ b/lib/gl_oset.c @@ -1,96 +1,3 @@ -/* Abstract ordered set data type. - Copyright (C) 2006-2007, 2009-2012 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2006. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ +#define GL_OSET_INLINE _GL_EXTERN_INLINE #include "gl_oset.h" - -#if !HAVE_INLINE - -/* Define all functions of this file as inline accesses to the - struct gl_list_implementation. - Use #define to avoid a warning because of extern vs. static. */ - -gl_oset_t -gl_oset_nx_create_empty (gl_oset_implementation_t implementation, - gl_setelement_compar_fn compar_fn, - gl_setelement_dispose_fn dispose_fn) -{ - return implementation->nx_create_empty (implementation, compar_fn, - dispose_fn); -} - -size_t -gl_oset_size (gl_oset_t set) -{ - return ((const struct gl_oset_impl_base *) set)->vtable->size (set); -} - -bool -gl_oset_search (gl_oset_t set, const void *elt) -{ - return ((const struct gl_oset_impl_base *) set)->vtable->search (set, elt); -} - -bool -gl_oset_search_atleast (gl_oset_t set, - gl_setelement_threshold_fn threshold_fn, - const void *threshold, const void **eltp) -{ - return ((const struct gl_oset_impl_base *) set)->vtable - ->search_atleast (set, threshold_fn, threshold, eltp); -} - -int -gl_oset_nx_add (gl_oset_t set, const void *elt) -{ - return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt); -} - -bool -gl_oset_remove (gl_oset_t set, const void *elt) -{ - return ((const struct gl_oset_impl_base *) set)->vtable - ->remove_elt (set, elt); -} - -void -gl_oset_free (gl_oset_t set) -{ - ((const struct gl_oset_impl_base *) set)->vtable->oset_free (set); -} - -gl_oset_iterator_t -gl_oset_iterator (gl_oset_t set) -{ - return ((const struct gl_oset_impl_base *) set)->vtable->iterator (set); -} - -bool -gl_oset_iterator_next (gl_oset_iterator_t *iterator, const void **eltp) -{ - return iterator->vtable->iterator_next (iterator, eltp); -} - -void -gl_oset_iterator_free (gl_oset_iterator_t *iterator) -{ - iterator->vtable->iterator_free (iterator); -} - -#endif
--- a/lib/gl_oset.h +++ b/lib/gl_oset.h @@ -21,6 +21,11 @@ #include <stdbool.h> #include <stddef.h> +_GL_INLINE_HEADER_BEGIN +#ifndef GL_OSET_INLINE +# define GL_OSET_INLINE _GL_INLINE +#endif + #ifdef __cplusplus extern "C" { #endif @@ -197,14 +202,10 @@ gl_setelement_dispose_fn dispose_fn; }; -#if HAVE_INLINE +/* Define all functions of this file as accesses to the + struct gl_oset_implementation. */ -/* Define all functions of this file as inline accesses to the - struct gl_oset_implementation. - Use #define to avoid a warning because of extern vs. static. */ - -# define gl_oset_nx_create_empty gl_oset_nx_create_empty_inline -static inline gl_oset_t +GL_OSET_INLINE gl_oset_t gl_oset_nx_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn, gl_setelement_dispose_fn dispose_fn) @@ -213,22 +214,19 @@ dispose_fn); } -# define gl_oset_size gl_oset_size_inline -static inline size_t +GL_OSET_INLINE size_t gl_oset_size (gl_oset_t set) { return ((const struct gl_oset_impl_base *) set)->vtable->size (set); } -# define gl_oset_search gl_oset_search_inline -static inline bool +GL_OSET_INLINE bool gl_oset_search (gl_oset_t set, const void *elt) { return ((const struct gl_oset_impl_base *) set)->vtable->search (set, elt); } -# define gl_oset_search_atleast gl_oset_search_atleast_inline -static inline bool +GL_OSET_INLINE bool gl_oset_search_atleast (gl_oset_t set, gl_setelement_threshold_fn threshold_fn, const void *threshold, const void **eltp) @@ -237,53 +235,47 @@ ->search_atleast (set, threshold_fn, threshold, eltp); } -# define gl_oset_nx_add gl_oset_nx_add_inline -static inline int +GL_OSET_INLINE int gl_oset_nx_add (gl_oset_t set, const void *elt) { return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt); } -# define gl_oset_remove gl_oset_remove_inline -static inline bool +GL_OSET_INLINE bool gl_oset_remove (gl_oset_t set, const void *elt) { return ((const struct gl_oset_impl_base *) set)->vtable ->remove_elt (set, elt); } -# define gl_oset_free gl_oset_free_inline -static inline void +GL_OSET_INLINE void gl_oset_free (gl_oset_t set) { ((const struct gl_oset_impl_base *) set)->vtable->oset_free (set); } -# define gl_oset_iterator gl_oset_iterator_inline -static inline gl_oset_iterator_t +GL_OSET_INLINE gl_oset_iterator_t gl_oset_iterator (gl_oset_t set) { return ((const struct gl_oset_impl_base *) set)->vtable->iterator (set); } -# define gl_oset_iterator_next gl_oset_iterator_next_inline -static inline bool +GL_OSET_INLINE bool gl_oset_iterator_next (gl_oset_iterator_t *iterator, const void **eltp) { return iterator->vtable->iterator_next (iterator, eltp); } -# define gl_oset_iterator_free gl_oset_iterator_free_inline -static inline void +GL_OSET_INLINE void gl_oset_iterator_free (gl_oset_iterator_t *iterator) { iterator->vtable->iterator_free (iterator); } -#endif - #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* _GL_OSET_H */
--- a/lib/gl_xlist.c +++ b/lib/gl_xlist.c @@ -1,128 +1,3 @@ -/* Abstract sequential list data type, with out-of-memory checking. - Copyright (C) 2009-2012 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2009. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ +#define GL_XLIST_INLINE _GL_EXTERN_INLINE #include "gl_xlist.h" - -#if !HAVE_INLINE - -gl_list_t -gl_list_create_empty (gl_list_implementation_t implementation, - gl_listelement_equals_fn equals_fn, - gl_listelement_hashcode_fn hashcode_fn, - gl_listelement_dispose_fn dispose_fn, - bool allow_duplicates) -{ - gl_list_t result = - gl_list_nx_create_empty (implementation, equals_fn, hashcode_fn, dispose_fn, - allow_duplicates); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_t -gl_list_create (gl_list_implementation_t implementation, - gl_listelement_equals_fn equals_fn, - gl_listelement_hashcode_fn hashcode_fn, - gl_listelement_dispose_fn dispose_fn, - bool allow_duplicates, - size_t count, const void **contents) -{ - gl_list_t result = - gl_list_nx_create (implementation, equals_fn, hashcode_fn, dispose_fn, - allow_duplicates, count, contents); - if (result == NULL) - xalloc_die (); - return result; -} - -void -gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt) -{ - int result = gl_list_node_nx_set_value (list, node, elt); - if (result < 0) - xalloc_die (); -} - -gl_list_node_t -gl_list_set_at (gl_list_t list, size_t position, const void *elt) -{ - gl_list_node_t result = gl_list_nx_set_at (list, position, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_node_t -gl_list_add_first (gl_list_t list, const void *elt) -{ - gl_list_node_t result = gl_list_nx_add_first (list, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_node_t -gl_list_add_last (gl_list_t list, const void *elt) -{ - gl_list_node_t result = gl_list_nx_add_last (list, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_node_t -gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt) -{ - gl_list_node_t result = gl_list_nx_add_before (list, node, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_node_t -gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt) -{ - gl_list_node_t result = gl_list_nx_add_after (list, node, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_node_t -gl_list_add_at (gl_list_t list, size_t position, const void *elt) -{ - gl_list_node_t result = gl_list_nx_add_at (list, position, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -gl_list_node_t -gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, - const void *elt) -{ - gl_list_node_t result = gl_sortedlist_nx_add (list, compar, elt); - if (result == NULL) - xalloc_die (); - return result; -} - -#endif
--- a/lib/gl_xlist.h +++ b/lib/gl_xlist.h @@ -21,6 +21,11 @@ #include "gl_list.h" #include "xalloc.h" +_GL_INLINE_HEADER_BEGIN +#ifndef GL_XLIST_INLINE +# define GL_XLIST_INLINE _GL_INLINE +#endif + #ifdef __cplusplus extern "C" { #endif @@ -55,10 +60,7 @@ gl_listelement_compar_fn compar, const void *elt); -#if HAVE_INLINE - -# define gl_list_create_empty gl_list_create_empty_inline -static inline gl_list_t +GL_XLIST_INLINE gl_list_t gl_list_create_empty (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, gl_listelement_hashcode_fn hashcode_fn, @@ -73,8 +75,7 @@ return result; } -# define gl_list_create gl_list_create_inline -static inline gl_list_t +GL_XLIST_INLINE gl_list_t gl_list_create (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, gl_listelement_hashcode_fn hashcode_fn, @@ -90,8 +91,7 @@ return result; } -# define gl_list_node_set_value gl_list_node_set_value_inline -static inline void +GL_XLIST_INLINE void gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt) { int result = gl_list_node_nx_set_value (list, node, elt); @@ -99,8 +99,7 @@ xalloc_die (); } -# define gl_list_set_at gl_list_set_at_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_list_set_at (gl_list_t list, size_t position, const void *elt) { gl_list_node_t result = gl_list_nx_set_at (list, position, elt); @@ -109,8 +108,7 @@ return result; } -# define gl_list_add_first gl_list_add_first_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt) { gl_list_node_t result = gl_list_nx_add_first (list, elt); @@ -119,8 +117,7 @@ return result; } -# define gl_list_add_last gl_list_add_last_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt) { gl_list_node_t result = gl_list_nx_add_last (list, elt); @@ -129,8 +126,7 @@ return result; } -# define gl_list_add_before gl_list_add_before_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt) { gl_list_node_t result = gl_list_nx_add_before (list, node, elt); @@ -139,8 +135,7 @@ return result; } -# define gl_list_add_after gl_list_add_after_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt) { gl_list_node_t result = gl_list_nx_add_after (list, node, elt); @@ -149,8 +144,7 @@ return result; } -# define gl_list_add_at gl_list_add_at_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_list_add_at (gl_list_t list, size_t position, const void *elt) { gl_list_node_t result = gl_list_nx_add_at (list, position, elt); @@ -159,8 +153,7 @@ return result; } -# define gl_sortedlist_add gl_sortedlist_add_inline -static inline gl_list_node_t +GL_XLIST_INLINE gl_list_node_t gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { @@ -170,10 +163,10 @@ return result; } -#endif - #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* _GL_XLIST_H */
--- a/lib/gl_xoset.c +++ b/lib/gl_xoset.c @@ -1,46 +1,3 @@ -/* Abstract ordered set data type, with out-of-memory checking. - Copyright (C) 2009-2012 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2009. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ +#define GL_XOSET_INLINE _GL_EXTERN_INLINE #include "gl_xoset.h" - -#if !HAVE_INLINE - -gl_oset_t -gl_oset_create_empty (gl_oset_implementation_t implementation, - gl_setelement_compar_fn compar_fn, - gl_setelement_dispose_fn dispose_fn) -{ - gl_oset_t result = - gl_oset_nx_create_empty (implementation, compar_fn, dispose_fn); - if (result == NULL) - xalloc_die (); - return result; -} - -bool -gl_oset_add (gl_oset_t set, const void *elt) -{ - int result = gl_oset_nx_add (set, elt); - if (result < 0) - xalloc_die (); - return result; -} - -#endif
--- a/lib/gl_xoset.h +++ b/lib/gl_xoset.h @@ -21,6 +21,12 @@ #include "gl_oset.h" #include "xalloc.h" +_GL_INLINE_HEADER_BEGIN +#ifndef GL_XOSET_INLINE +# define GL_XOSET_INLINE _GL_INLINE +#endif + + #ifdef __cplusplus extern "C" { #endif @@ -33,10 +39,7 @@ gl_setelement_dispose_fn dispose_fn); extern bool gl_oset_add (gl_oset_t set, const void *elt); -#if HAVE_INLINE - -# define gl_oset_create_empty gl_oset_create_empty_inline -static inline gl_oset_t +GL_XOSET_INLINE gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn, gl_setelement_dispose_fn dispose_fn) @@ -48,8 +51,7 @@ return result; } -# define gl_oset_add gl_oset_add_inline -static inline bool +GL_XOSET_INLINE bool gl_oset_add (gl_oset_t set, const void *elt) { int result = gl_oset_nx_add (set, elt); @@ -58,10 +60,10 @@ return result; } -#endif - #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* _GL_XOSET_H */
--- a/lib/gl_xsublist.c +++ b/lib/gl_xsublist.c @@ -1,35 +1,3 @@ -/* Sequential list data type backed by another list, with out-of-memory - checking. - Copyright (C) 2009-2012 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2009. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ +#define GL_XSUBLIST_INLINE _GL_EXTERN_INLINE #include "gl_xsublist.h" - -#if !HAVE_INLINE - -gl_list_t -gl_sublist_create (gl_list_t whole_list, size_t start_index, size_t end_index) -{ - gl_list_t result = gl_sublist_nx_create (whole_list, start_index, end_index); - if (result == NULL) - xalloc_die (); - return result; -} - -#endif
--- a/lib/gl_xsublist.h +++ b/lib/gl_xsublist.h @@ -22,6 +22,11 @@ #include "gl_sublist.h" #include "xalloc.h" +_GL_INLINE_HEADER_BEGIN +#ifndef GL_XSUBLIST_INLINE +# define GL_XSUBLIST_INLINE _GL_INLINE +#endif + #ifdef __cplusplus extern "C" { #endif @@ -29,13 +34,7 @@ /* These functions are thin wrappers around the corresponding functions with _nx_ infix from gl_sublist.h. Upon out-of-memory, they invoke xalloc_die (), instead of returning an error indicator. */ -extern gl_list_t gl_sublist_create (gl_list_t whole_list, - size_t start_index, size_t end_index); - -#if HAVE_INLINE - -# define gl_sublist_create gl_sublist_create_inline -static inline gl_list_t +GL_XSUBLIST_INLINE gl_list_t gl_sublist_create (gl_list_t whole_list, size_t start_index, size_t end_index) { gl_list_t result = gl_sublist_nx_create (whole_list, start_index, end_index); @@ -44,10 +43,10 @@ return result; } -#endif - #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* _GL_XSUBLIST_H */
deleted file mode 100644 --- a/m4/gl_list.m4 +++ /dev/null @@ -1,10 +0,0 @@ -# gl_list.m4 serial 2 -dnl Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_LIST], -[ - AC_REQUIRE([gl_INLINE]) -])
--- a/modules/list +++ b/modules/list @@ -4,14 +4,12 @@ Files: lib/gl_list.h lib/gl_list.c -m4/gl_list.m4 Depends-on: -inline +extern-inline stdbool configure.ac: -gl_LIST Makefile.am: lib_SOURCES += gl_list.h gl_list.c
--- a/modules/oset +++ b/modules/oset @@ -4,14 +4,12 @@ Files: lib/gl_oset.h lib/gl_oset.c -m4/gl_list.m4 Depends-on: -inline +extern-inline stdbool configure.ac: -gl_LIST Makefile.am: lib_SOURCES += gl_oset.h gl_oset.c
--- a/modules/xlist +++ b/modules/xlist @@ -4,16 +4,14 @@ Files: lib/gl_xlist.h lib/gl_xlist.c -m4/gl_list.m4 Depends-on: list -inline +extern-inline stdbool xalloc-die configure.ac: -gl_LIST Makefile.am: lib_SOURCES += gl_xlist.h gl_xlist.c