bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'inline' changes pushed


From: Paul Eggert
Subject: Re: 'inline' changes pushed
Date: Wed, 05 Dec 2012 13:24:05 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

I pushed into gnulib the following patch, which fixes the bug for me.
Thanks for reporting the problem.

-----

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.
diff --git a/lib/gl_list.h b/lib/gl_list.h
index 3158c9c..4cea41c 100644
--- a/lib/gl_list.h
+++ b/lib/gl_list.h
@@ -125,6 +125,8 @@ struct gl_list_implementation;
 /* 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 @@ typedef const struct gl_list_implementation * 
gl_list_implementation_t;
    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 @@ extern gl_list_t gl_list_nx_create_empty 
(gl_list_implementation_t implementatio
    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 size_t gl_list_size (gl_list_t list);
 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 @@ extern const void * gl_list_get_at (gl_list_t list, size_t 
position);
 /* 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 @@ extern size_t gl_list_indexof_from_to (gl_list_t list,

 /* 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 @@ extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, 
const void *elt)

 /* 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 @@ extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, 
const void *elt)

 /* 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 @@ extern gl_list_node_t gl_list_nx_add_before (gl_list_t 
list,

 /* 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 @@ extern gl_list_node_t gl_list_nx_add_after (gl_list_t 
list, gl_list_node_t node,

 /* 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 @@ extern bool gl_list_remove (gl_list_t list, const void 
*elt);
    (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 @@ typedef struct
   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 @@ extern bool gl_list_iterator_next (gl_list_iterator_t 
*iterator,
 /* 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 @@ extern void gl_list_iterator_free (gl_list_iterator_t 
*iterator);
    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 @@ extern size_t gl_sortedlist_indexof_from_to (gl_list_t 
list,
 /* 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 @@ extern bool gl_sortedlist_remove (gl_list_t list,
                                   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_node_value (gl_list_t list, gl_list_node_t node)
 }

 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_get_at (gl_list_t list, size_t position)
 }

 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_indexof_from_to (gl_list_t list, size_t 
start_index, size_t end_index,
 }

 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_nx_add_first (gl_list_t list, const void *elt)
 }

 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_nx_add_last (gl_list_t list, const void *elt)
 }

 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_nx_add_before (gl_list_t list, gl_list_node_t node, 
const void *elt)
 }

 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_nx_add_after (gl_list_t list, gl_list_node_t node, 
const void *elt)
 }

 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_sortedlist_indexof_from_to (gl_list_t list, 
gl_listelement_compar_fn compar,
 }

 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
diff --git a/lib/gl_oset.h b/lib/gl_oset.h
index 882cd34..e160cb7 100644
--- a/lib/gl_oset.h
+++ b/lib/gl_oset.h
@@ -90,15 +90,16 @@ struct gl_oset_implementation;
 /* 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 @@ extern bool gl_oset_search_atleast (gl_oset_t set,

 /* 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 @@ extern bool gl_oset_remove (gl_oset_t set, const void *elt);
    (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 @@ typedef struct
   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 @@ extern bool gl_oset_iterator_next (gl_oset_iterator_t 
*iterator,
 /* 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_search_atleast (gl_oset_t set,
 }

 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);
diff --git a/lib/gl_xlist.h b/lib/gl_xlist.h
index 32fae11..250eb7f 100644
--- a/lib/gl_xlist.h
+++ b/lib/gl_xlist.h
@@ -33,6 +33,7 @@ extern "C" {
 /* 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_list_add_at (gl_list_t list, size_t 
position,
 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,
diff --git a/lib/gl_xoset.h b/lib/gl_xoset.h
index 38da077..8b772f3 100644
--- a/lib/gl_xoset.h
+++ b/lib/gl_xoset.h
@@ -34,10 +34,12 @@ extern "C" {
 /* 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,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]