xiaoxiang781216 commented on code in PR #6926: URL: https://github.com/apache/incubator-nuttx/pull/6926#discussion_r957362164
########## include/nuttx/list.h: ########## @@ -37,8 +37,67 @@ #define LIST_INITIAL_VALUE(list) { &(list), &(list) } #define LIST_INITIAL_CLEARED_VALUE { NULL, NULL } +#define list_in_list(item) ((item)->prev || (item)->next) +#define list_is_empty(list) ((list)->next == list) +#define list_is_clear(list) ((list)->next == NULL) + +#define list_initialize(list) \ + do \ + { \ + (list)->prev = (list)->next = (list); \ + } \ + while(0) + +#define list_clear_node(item) \ + do \ + { \ + (item)->prev = (item)->next = NULL; \ + } \ + while (0) + +#define list_peek_head(list) ((list)->next != (list) ? (list)->next : NULL) +#define list_peek_tail(list) ((list)->prev != (list) ? (list)->prev : NULL) + +#define list_prev(list, item) ((item)->prev != (list) ? (item)->prev : NULL) +#define list_prev_wrap(list, item) \ + ((item)->prev != (list) ? (item)->prev : \ + (item)->prev->prev != (list) ? (item)->prev->prev : NULL) + +#define list_next(list, item) ((item)->next != (list) ? (item)->next : NULL) +#define list_next_wrap(list, item) \ + ((item)->next != (list) ? (item)->next : \ + (item)->next->next != (list) ? (item)->next->next : NULL) + #define list_add_after(entry, new_entry) list_add_head(entry, new_entry) +#define list_add_head(list, item) \ + do \ + { \ + (item)->next = (list)->next; \ + (item)->prev = (list); \ + (list)->next->prev = (item); \ + (list)->next = (item); \ + } \ + while (0) + #define list_add_before(entry, new_entry) list_add_tail(entry, new_entry) +#define list_add_tail(list, item) \ + do \ + { \ + (item)->prev = (list)->prev; \ + (item)->next = (list); \ + (list)->prev->next = (item); \ + (list)->prev = (item); \ + } \ + while (0) + +#define list_delete(item) \ + do \ + { \ + (item)->next->prev = (item)->prev; \ + (item)->prev->next = (item)->next; \ + (item)->prev = (item)->next = 0; \ Review Comment: Done. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org