Mercurial > hg > octave-lyh > gnulib-hg
changeset 17198:8bfb14044fbb
list, oset, xlist, xoset: fix extern inline issue with C99
This was introduced by my recent changes for 'inline'.
Problem reported for gettext by Daiki Ueno in
<http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00000.html>.
* lib/gl_list.h (gl_list_nx_create_empty, gl_list_create)
(gl_list_nx_create, gl_list_size, gl_list_node_value)
(gl_list_node_set_value, gl_list_node_nx_set_value, gl_list_next_node)
(gl_list_previous_node, gl_list_get_at)
(gl_list_nx_set_at, gl_list_search, gl_list_search_from)
(gl_list_search_from_to, gl_list_indexof, gl_list_indexof_from)
(gl_list_indexof_from_to, gl_list_nx_add_first, gl_list_nx_add_last)
(gl_list_nx_add_before, gl_list_nx_add_after, gl_list_nx_add_at)
(gl_list_remove_node, gl_list_remove_at, gl_list_remove, gl_list_free)
(gl_list_iterator, gl_list_iterator_from_to, gl_list_iterator_next)
(gl_list_iterator_free, gl_sortedlist_search)
(gl_sortedlist_search_from_to, gl_sortedlist_indexof)
(gl_sortedlist_indexof_from_to, gl_sortedlist_add, gl_sortedlist_nx_add)
(gl_sortedlist_remove):
* lib/gl_oset.h (go_oset_nx_create_empty, gl_oset_size, gl_oset_search)
(gl_oset_search_atleast, gl_oset_nx_add, gl_oset_remove, gl_oset_free)
(gl_oset_iterator, gl_oset_iterator_next, gl_oset_iterator_free):
* lib/gl_xlist.h (gl_list_create_empty, gl_list_create)
(gl_list_node_set_value, gl_list_set_at, gl_list_add_first)
(gl_list_add_last, gl_list_add_before, gl_list_add_after)
(gl_list_add_at, gl_sortedlist_add):
* lib/gl_xoset.h (gl_oset_create_empty, gl_oset_add):
Wrap these extern decls inside "#if 0", because they are implemented
as inline functions, and extern inline is not what's wanted here.
It would simplify these .h files to remove the extern decls entirely,
although a downside would be less-clear separation between
specification and implementation.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 05 Dec 2012 13:20:25 -0800 |
parents | 5c365abf0f6f |
children | a7c288837223 |
files | ChangeLog lib/gl_list.h lib/gl_oset.h lib/gl_xlist.h lib/gl_xoset.h |
diffstat | 5 files changed, 97 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2012-12-05 Paul Eggert <eggert@cs.ucla.edu> + + list, oset, xlist, xoset: fix extern inline issue with C99 + This was introduced by my recent changes for 'inline'. + Problem reported for gettext by Daiki Ueno in + <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00000.html>. + * lib/gl_list.h (gl_list_nx_create_empty, gl_list_create) + (gl_list_nx_create, gl_list_size, gl_list_node_value) + (gl_list_node_set_value, gl_list_node_nx_set_value, gl_list_next_node) + (gl_list_previous_node, gl_list_get_at) + (gl_list_nx_set_at, gl_list_search, gl_list_search_from) + (gl_list_search_from_to, gl_list_indexof, gl_list_indexof_from) + (gl_list_indexof_from_to, gl_list_nx_add_first, gl_list_nx_add_last) + (gl_list_nx_add_before, gl_list_nx_add_after, gl_list_nx_add_at) + (gl_list_remove_node, gl_list_remove_at, gl_list_remove, gl_list_free) + (gl_list_iterator, gl_list_iterator_from_to, gl_list_iterator_next) + (gl_list_iterator_free, gl_sortedlist_search) + (gl_sortedlist_search_from_to, gl_sortedlist_indexof) + (gl_sortedlist_indexof_from_to, gl_sortedlist_add, gl_sortedlist_nx_add) + (gl_sortedlist_remove): + * lib/gl_oset.h (go_oset_nx_create_empty, gl_oset_size, gl_oset_search) + (gl_oset_search_atleast, gl_oset_nx_add, gl_oset_remove, gl_oset_free) + (gl_oset_iterator, gl_oset_iterator_next, gl_oset_iterator_free): + * lib/gl_xlist.h (gl_list_create_empty, gl_list_create) + (gl_list_node_set_value, gl_list_set_at, gl_list_add_first) + (gl_list_add_last, gl_list_add_before, gl_list_add_after) + (gl_list_add_at, gl_sortedlist_add): + * lib/gl_xoset.h (gl_oset_create_empty, gl_oset_add): + Wrap these extern decls inside "#if 0", because they are implemented + as inline functions, and extern inline is not what's wanted here. + It would simplify these .h files to remove the extern decls entirely, + although a downside would be less-clear separation between + specification and implementation. + 2012-11-29 Paul Eggert <eggert@cs.ucla.edu> sys_stat: no 'static inline'
--- a/lib/gl_list.h +++ b/lib/gl_list.h @@ -125,6 +125,8 @@ /* Type representing a list datatype implementation. */ typedef const struct gl_list_implementation * gl_list_implementation_t; +#if 0 /* Unless otherwise specified, these are defined inline below. */ + /* Create an empty list. IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST, GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST, @@ -134,13 +136,12 @@ DISPOSE_FN is an element disposal function or NULL. ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in the list. The implementation may verify this at runtime. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern 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); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, @@ -159,14 +160,13 @@ the list. The implementation may verify this at runtime. COUNT is the number of initial elements. CONTENTS[0..COUNT-1] is the initial contents. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern 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); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_t gl_list_nx_create (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, @@ -182,10 +182,9 @@ extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node); /* Replace the element value represented by a list node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt); -#endif /* Likewise. Return 0 upon success, -1 upon out-of-memory. */ extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void *elt) @@ -209,10 +208,9 @@ /* Replace the element at a given position in the list. POSITION must be >= 0 and < gl_list_size (list). Return its node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) @@ -258,9 +256,8 @@ /* Add an element as the first element of the list. Return its node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt) #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) @@ -270,9 +267,8 @@ /* Add an element as the last element of the list. Return its node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt) #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) @@ -282,10 +278,9 @@ /* Add an element before a given element node of the list. Return its node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, @@ -297,10 +292,9 @@ /* Add an element after a given element node of the list. Return its node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) @@ -311,10 +305,9 @@ /* Add an element at a given position in the list. POSITION must be >= 0 and <= gl_list_size (list). */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) @@ -340,6 +333,8 @@ (But this call does not free the elements of the list.) */ extern void gl_list_free (gl_list_t list); +#endif /* End of inline and gl_xlist.h-defined functions. */ + /* --------------------- gl_list_iterator_t Data Type --------------------- */ /* Functions for iterating through a list. */ @@ -359,6 +354,8 @@ size_t i; size_t j; } gl_list_iterator_t; +#if 0 /* These are defined inline below. */ + /* Create an iterator traversing a list. The list contents must not be modified while the iterator is in use, except for replacing or removing the last returned element. */ @@ -381,6 +378,8 @@ /* Free an iterator. */ extern void gl_list_iterator_free (gl_list_iterator_t *iterator); +#endif /* End of inline functions. */ + /* ---------------------- Sorted gl_list_t Data Type ---------------------- */ /* The following functions are for lists without duplicates where the @@ -390,6 +389,8 @@ NULL denotes pointer comparison. */ typedef int (*gl_listelement_compar_fn) (const void *elt1, const void *elt2); +#if 0 /* Unless otherwise specified, these are defined inline below. */ + /* Search whether an element is already in the list. The list is assumed to be sorted with COMPAR. Return its node if found, or NULL if not present in the list. @@ -439,11 +440,10 @@ /* Add an element at the appropriate position in the list. The list is assumed to be sorted with COMPAR. Return its node. */ -#if 0 /* declared in gl_xlist.h */ +/* declared in gl_xlist.h */ extern gl_list_node_t gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, @@ -462,6 +462,8 @@ gl_listelement_compar_fn compar, const void *elt); +#endif /* End of inline and gl_xlist.h-defined functions. */ + /* ------------------------ Implementation Details ------------------------ */ struct gl_list_implementation @@ -587,6 +589,9 @@ } GL_LIST_INLINE int +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, const void *elt) { @@ -616,6 +621,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -671,6 +679,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif gl_list_nx_add_first (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -678,6 +689,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif gl_list_nx_add_last (gl_list_t list, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -685,6 +699,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif 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 @@ -692,6 +709,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif 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 @@ -699,6 +719,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) { return ((const struct gl_list_impl_base *) list)->vtable @@ -790,6 +813,9 @@ } GL_LIST_INLINE gl_list_node_t +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif 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
--- a/lib/gl_oset.h +++ b/lib/gl_oset.h @@ -90,15 +90,16 @@ /* Type representing a ordered set datatype implementation. */ typedef const struct gl_oset_implementation * gl_oset_implementation_t; +#if 0 /* Unless otherwise specified, these are defined inline below. */ + /* Create an empty set. IMPLEMENTATION is one of GL_ARRAY_OSET, GL_AVLTREE_OSET, GL_RBTREE_OSET. COMPAR_FN is an element comparison function or NULL. DISPOSE_FN is an element disposal function or NULL. */ -#if 0 /* declared in gl_xoset.h */ +/* declared in gl_xoset.h */ extern gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn, gl_setelement_dispose_fn dispose_fn); -#endif /* Likewise. Return NULL upon out-of-memory. */ extern gl_oset_t gl_oset_nx_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn, @@ -123,9 +124,8 @@ /* Add an element to an ordered set. Return true if it was not already in the set and added, false otherwise. */ -#if 0 /* declared in gl_xoset.h */ +/* declared in gl_xoset.h */ extern bool gl_oset_add (gl_oset_t set, const void *elt); -#endif /* Likewise. Return -1 upon out-of-memory. */ extern int gl_oset_nx_add (gl_oset_t set, const void *elt) #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) @@ -141,6 +141,8 @@ (But this call does not free the elements of the set.) */ extern void gl_oset_free (gl_oset_t set); +#endif /* End of inline and gl_xlist.h-defined functions. */ + /* --------------------- gl_oset_iterator_t Data Type --------------------- */ /* Functions for iterating through an ordered set. */ @@ -160,6 +162,8 @@ size_t i; size_t j; } gl_oset_iterator_t; +#if 0 /* These are defined inline below. */ + /* Create an iterator traversing an ordered set. The set's contents must not be modified while the iterator is in use, except for removing the last returned element. */ @@ -173,6 +177,8 @@ /* Free an iterator. */ extern void gl_oset_iterator_free (gl_oset_iterator_t *iterator); +#endif /* End of inline functions. */ + /* ------------------------ Implementation Details ------------------------ */ struct gl_oset_implementation @@ -236,6 +242,9 @@ } GL_OSET_INLINE int +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + __attribute__ ((__warn_unused_result__)) +#endif gl_oset_nx_add (gl_oset_t set, const void *elt) { return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt);
--- a/lib/gl_xlist.h +++ b/lib/gl_xlist.h @@ -33,6 +33,7 @@ /* These functions are thin wrappers around the corresponding functions with _nx_ infix from gl_list.h. Upon out-of-memory, they invoke xalloc_die (), instead of returning an error indicator. */ +#if 0 /* These are defined inline below. */ extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation, gl_listelement_equals_fn equals_fn, gl_listelement_hashcode_fn hashcode_fn, @@ -59,6 +60,7 @@ extern gl_list_node_t gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt); +#endif GL_XLIST_INLINE gl_list_t gl_list_create_empty (gl_list_implementation_t implementation,
--- a/lib/gl_xoset.h +++ b/lib/gl_xoset.h @@ -34,10 +34,12 @@ /* These functions are thin wrappers around the corresponding functions with _nx_ infix from gl_oset.h. Upon out-of-memory, they invoke xalloc_die (), instead of returning an error indicator. */ +#if 0 /* These are defined inline below. */ extern gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation, gl_setelement_compar_fn compar_fn, gl_setelement_dispose_fn dispose_fn); extern bool gl_oset_add (gl_oset_t set, const void *elt); +#endif GL_XOSET_INLINE gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation,