diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-03-25 20:58:16 +0700 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2019-03-27 08:56:21 +0100 |
commit | 72ea919a485722d4cf77086792809635efce45c5 (patch) | |
tree | d933d191355721877524d8d2333fe4bc28298fcb /include | |
parent | c0fcedc9689650265cd790d1389d3d992efa7f43 (diff) |
core/linuxlist.h: fix and unify Doxygen documentation
- drop incorrect \ref and \a references;
- add missing documentation to LLIST_HEAD_INIT;
- document parameter 'member' of llist_entry();
- turn @argument naming into a valid \param format;
- fix 'type *' vs llist_head loop counter confusion;
- capitalize and dot-terminate all sentences.
Change-Id: Iac67bdb9d5fbf7c222d04858967337f2428d6a94
Diffstat (limited to 'include')
-rw-r--r-- | include/osmocom/core/linuxlist.h | 195 |
1 files changed, 96 insertions, 99 deletions
diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h index 77913104..d040d903 100644 --- a/include/osmocom/core/linuxlist.h +++ b/include/osmocom/core/linuxlist.h @@ -23,11 +23,10 @@ static inline void prefetch(const void *x) {;} -/*! cast a member of a structure out to the containing structure - * - * \param[in] ptr the pointer to the member. - * \param[in] type the type of the container struct this is embedded in. - * \param[in] member the name of the member within the struct. +/*! Cast a member of a structure out to the containing structure. + * \param[in] ptr the pointer to the member. + * \param[in] type the type of the container struct this is embedded in. + * \param[in] member the name of the member within the struct. */ #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ @@ -48,22 +47,26 @@ struct llist_head { struct llist_head *next, *prev; }; +/*! Define a new llist_head pointing to a given llist_head. + * \param[in] name another llist_head to be pointed. + */ #define LLIST_HEAD_INIT(name) { &(name), &(name) } -/*! define a statically-initialized \ref llist_head - * \param[in] name Variable name - * - * This is a helper macro that will define a named variable of type - * \ref llist_head and initialize it */ +/*! Define a statically-initialized variable of type llist_head. + * \param[in] name variable (symbol) name. + */ #define LLIST_HEAD(name) \ struct llist_head name = LLIST_HEAD_INIT(name) -/*! initialize a \ref llist_head to point back to self */ +/*! Initialize a llist_head to point back to itself. + * \param[in] ptr llist_head to be initialized. + */ #define INIT_LLIST_HEAD(ptr) do { \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0) -/*! Insert a new entry between two known consecutive entries. +/* + * Insert a new entry between two known consecutive entries. * * This is only for internal llist manipulation where we know * the prev/next entries already! @@ -78,9 +81,9 @@ static inline void __llist_add(struct llist_head *_new, prev->next = _new; } -/*! add a new entry into a linked list (at head) - * \param _new New entry to be added - * \param head \ref llist_head to add it after +/*! Add a new entry into a linked list (at head). + * \param _new the entry to be added. + * \param head llist_head to prepend the element to. * * Insert a new entry after the specified head. * This is good for implementing stacks. @@ -90,9 +93,9 @@ static inline void llist_add(struct llist_head *_new, struct llist_head *head) __llist_add(_new, head, head->next); } -/*! add a new entry into a linked list (at tail) - * \param _new New entry to be added - * \param head Head of linked list to whose tail we shall add \a _new +/*! Add a new entry into a linked list (at tail). + * \param _new the entry to be added. + * \param head llist_head to append the element to. * * Insert a new entry before the specified head. * This is useful for implementing queues. @@ -115,8 +118,8 @@ static inline void __llist_del(struct llist_head * prev, struct llist_head * nex prev->next = next; } -/*! Delete entry from linked list - * \param entry The element to delete from the llist +/*! Delete a single entry from a linked list. + * \param entry the element to delete. * * Note: llist_empty on entry does not return true after this, the entry is * in an undefined state. @@ -128,8 +131,8 @@ static inline void llist_del(struct llist_head *entry) entry->prev = (struct llist_head *)LLIST_POISON2; } -/*! Delete entry from linked list and reinitialize it - * \param entry The element to delete from the list +/*! Delete a single entry from a linked list and reinitialize it. + * \param entry the element to delete and reinitialize. */ static inline void llist_del_init(struct llist_head *entry) { @@ -137,9 +140,9 @@ static inline void llist_del_init(struct llist_head *entry) INIT_LLIST_HEAD(entry); } -/*! Delete from one llist and add as another's head - * \param llist The entry to move - * \param head The head that will precede our entry +/*! Delete from one llist and add as another's head. + * \param llist the entry to move. + * \param head the head that will precede our entry. */ static inline void llist_move(struct llist_head *llist, struct llist_head *head) { @@ -147,9 +150,9 @@ static inline void llist_move(struct llist_head *llist, struct llist_head *head) llist_add(llist, head); } -/*! Delete from one llist and add as another's tail - * \param llist The entry to move - * \param head The head that will follow our entry +/*! Delete from one llist and add as another's tail. + * \param llist the entry to move. + * \param head the head that will follow our entry. */ static inline void llist_move_tail(struct llist_head *llist, struct llist_head *head) @@ -158,9 +161,9 @@ static inline void llist_move_tail(struct llist_head *llist, llist_add_tail(llist, head); } -/*! Test whether a linked list is empty - * \param[in] head The llist to test. - * \returns 1 if the list is empty, 0 otherwise +/*! Test whether a linked list is empty. + * \param[in] head the llist to test. + * \returns 1 if the list is empty, 0 otherwise. */ static inline int llist_empty(const struct llist_head *head) { @@ -181,9 +184,9 @@ static inline void __llist_splice(struct llist_head *llist, at->prev = last; } -/*! Join two llists - * \param llist The new linked list to add - * \param head The place to add \a llist in the other list +/*! Join two linked lists. + * \param llist the new linked list to add. + * \param head the place to add llist within the other list. */ static inline void llist_splice(struct llist_head *llist, struct llist_head *head) { @@ -191,11 +194,11 @@ static inline void llist_splice(struct llist_head *llist, struct llist_head *hea __llist_splice(llist, head); } -/*! join two llists and reinitialise the emptied llist. - * \param llist The new linked list to add. - * \param head The place to add it in the first llist. +/*! Join two llists and reinitialise the emptied llist. + * \param llist the new linked list to add. + * \param head the place to add it within the first llist. * - * The llist at @llist is reinitialised + * The llist is reinitialised. */ static inline void llist_splice_init(struct llist_head *llist, struct llist_head *head) @@ -206,15 +209,15 @@ static inline void llist_splice_init(struct llist_head *llist, } } -/*! Get the struct containing this list entry - * \param ptr The \ref llist_head pointer - * \param type The type of the struct this is embedded in - * \param @member The name of the \ref llist_head within the struct +/*! Get the struct containing this list entry. + * \param ptr the llist_head pointer. + * \param type the type of the struct this is embedded in. + * \param member the name of the llist_head within the struct. */ #define llist_entry(ptr, type, member) \ container_of(ptr, type, member) -/*! Get the first element from a list +/*! Get the first element from a linked list. * \param ptr the list head to take the element from. * \param type the type of the struct this is embedded in. * \param member the name of the list_head within the struct. @@ -224,7 +227,7 @@ static inline void llist_splice_init(struct llist_head *llist, #define llist_first_entry(ptr, type, member) \ llist_entry((ptr)->next, type, member) -/*! Get the last element from a list +/*! Get the last element from a list. * \param ptr the list head to take the element from. * \param type the type of the struct this is embedded in. * \param member the name of the llist_head within the struct. @@ -234,7 +237,7 @@ static inline void llist_splice_init(struct llist_head *llist, #define llist_last_entry(ptr, type, member) \ llist_entry((ptr)->prev, type, member) -/*! Get the first element from a list, or NULL +/*! Get the first element from a list, or NULL. * \param ptr the list head to take the element from. * \param type the type of the struct this is embedded in. * \param member the name of the list_head within the struct. @@ -244,17 +247,17 @@ static inline void llist_splice_init(struct llist_head *llist, #define llist_first_entry_or_null(ptr, type, member) \ (!llist_empty(ptr) ? llist_first_entry(ptr, type, member) : NULL) -/*! Iterate over a linked list - * \param pos The \ref llist_head to use as a loop counter - * \param head The head of the list over which to iterate +/*! Iterate over a linked list. + * \param pos the llist_head to use as a loop counter. + * \param head the head of the list over which to iterate. */ #define llist_for_each(pos, head) \ for (pos = (head)->next, prefetch(pos->next); pos != (head); \ pos = pos->next, prefetch(pos->next)) -/*! Iterate over a llist (no prefetch) - * \param pos The \ref llist_head to use as a loop counter - * \param head The head of the list over which to iterate +/*! Iterate over a linked list (no prefetch). + * \param pos the llist_head to use as a loop counter. + * \param head the head of the list over which to iterate. * * This variant differs from llist_for_each() in that it's the * simplest possible llist iteration code, no prefetching is done. @@ -264,27 +267,27 @@ static inline void llist_splice_init(struct llist_head *llist, #define __llist_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) -/*! Iterate over a llist backwards - * \param pos The \ref llist_head to use as a loop counter - * \param head The head of the list over which to iterate +/*! Iterate over a linked list backwards. + * \param pos the llist_head to use as a loop counter. + * \param head the head of the list over which to iterate. */ #define llist_for_each_prev(pos, head) \ for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ pos = pos->prev, prefetch(pos->prev)) -/*! Iterate over a list; safe against removal of llist entry - * \param pos The \ref llist_head to use as a loop counter - * \param n Another \ref llist_head to use as temporary storage - * \param head The head of the list over which to iterate +/*! Iterate over a linked list, safe against removal of llist entry. + * \param pos the llist_head to use as a loop counter. + * \param n another llist_head to use as temporary storage. + * \param head the head of the list over which to iterate. */ #define llist_for_each_safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) -/*! Iterate over llist of given type - * \param pos The 'type *' to use as a loop counter - * \param head The head of the list over which to iterate - * \param member The name of the \ref llist_head within struct \a pos +/*! Iterate over a linked list of a given type. + * \param pos the 'type *' to use as a loop counter. + * \param head the head of the list over which to iterate. + * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry(pos, head, member) \ for (pos = llist_entry((head)->next, typeof(*pos), member), \ @@ -293,10 +296,10 @@ static inline void llist_splice_init(struct llist_head *llist, pos = llist_entry(pos->member.next, typeof(*pos), member), \ prefetch(pos->member.next)) -/*! Iterate backwards over llist of given type. - * \param pos The 'type *' to use as a loop counter - * \param head The head of the list over which to iterate - * \param member The name of the \ref llist_head within struct \a pos +/*! Iterate backwards over a linked list of a given type. + * \param pos the 'type *' to use as a loop counter. + * \param head the head of the list over which to iterate. + * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry_reverse(pos, head, member) \ for (pos = llist_entry((head)->prev, typeof(*pos), member), \ @@ -305,11 +308,11 @@ static inline void llist_splice_init(struct llist_head *llist, pos = llist_entry(pos->member.prev, typeof(*pos), member), \ prefetch(pos->member.prev)) -/*! iterate over llist of given type continuing after existing - * point - * \param pos The 'type *' to use as a loop counter - * \param head The head of the list over which to iterate - * \param member The name of the \ref llist_head within struct \a pos +/*! Iterate over a linked list of a given type, + * continuing after an existing point. + * \param pos the 'type *' to use as a loop counter. + * \param head the head of the list over which to iterate. + * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry_continue(pos, head, member) \ for (pos = llist_entry(pos->member.next, typeof(*pos), member), \ @@ -318,12 +321,12 @@ static inline void llist_splice_init(struct llist_head *llist, pos = llist_entry(pos->member.next, typeof(*pos), member), \ prefetch(pos->member.next)) -/*! iterate over llist of given type, safe against removal of - * non-consecutive(!) llist entries - * \param pos The 'type *' to use as a loop counter - * \param n Another type * to use as temporary storage - * \param head The head of the list over which to iterate - * \param member The name of the \ref llist_head within struct \a pos +/*! Iterate over llist of given type, safe against removal of + * non-consecutive(!) llist entries. + * \param pos the 'type *' to use as a loop counter. + * \param n another 'type *' to use as temporary storage. + * \param head the head of the list over which to iterate. + * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry_safe(pos, n, head, member) \ for (pos = llist_entry((head)->next, typeof(*pos), member), \ @@ -331,10 +334,9 @@ static inline void llist_splice_init(struct llist_head *llist, &pos->member != (head); \ pos = n, n = llist_entry(n->member.next, typeof(*n), member)) -/** - * llist_for_each_rcu - iterate over an rcu-protected llist - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. +/*! Iterate over an rcu-protected llist. + * \param pos the llist_head to use as a loop counter. + * \param head the head of the list over which to iterate. */ #define llist_for_each_rcu(pos, head) \ for (pos = (head)->next, prefetch(pos->next); pos != (head); \ @@ -344,22 +346,19 @@ static inline void llist_splice_init(struct llist_head *llist, for (pos = (head)->next; pos != (head); \ pos = pos->next, ({ smp_read_barrier_depends(); 0;})) -/** - * llist_for_each_safe_rcu - iterate over an rcu-protected llist safe - * against removal of llist entry - * @pos: the &struct llist_head to use as a loop counter. - * @n: another &struct llist_head to use as temporary storage - * @head: the head for your llist. +/*! Iterate over an rcu-protected llist, safe against removal of llist entry. + * \param pos the llist_head to use as a loop counter. + * \param n another llist_head to use as temporary storage. + * \param head the head of the list over which to iterate. */ #define llist_for_each_safe_rcu(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, ({ smp_read_barrier_depends(); 0;}), n = pos->next) -/** - * llist_for_each_entry_rcu - iterate over rcu llist of given type - * @pos: the type * to use as a loop counter. - * @head: the head for your llist. - * @member: the name of the llist_struct within the struct. +/*! Iterate over an rcu-protected llist of a given type. + * \param pos the 'type *' to use as a loop counter. + * \param head the head of the list over which to iterate. + * \param member the name of the llist_struct within the struct. */ #define llist_for_each_entry_rcu(pos, head, member) \ for (pos = llist_entry((head)->next, typeof(*pos), member), \ @@ -370,18 +369,16 @@ static inline void llist_splice_init(struct llist_head *llist, prefetch(pos->member.next)) -/** - * llist_for_each_continue_rcu - iterate over an rcu-protected llist - * continuing after existing point. - * @pos: the &struct llist_head to use as a loop counter. - * @head: the head for your llist. +/*! Iterate over an rcu-protected llist, continuing after existing point. + * \param pos the llist_head to use as a loop counter. + * \param head the head of the list over which to iterate. */ #define llist_for_each_continue_rcu(pos, head) \ for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \ (pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next)) -/*! count nr of llist items by iterating. - * \param head The llist head to count items of. +/*! Count number of llist items by iterating. + * \param head the llist head to count items of. * \returns Number of items. * * This function is not efficient, mostly useful for small lists and non time |