This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8f9f31fb69ff01dcf74f532fd3c88ca57815be41 Author: wenquan1 <[email protected]> AuthorDate: Thu Sep 25 15:06:56 2025 +0800 mm/iob:support iob queue concat to another iob queue add interface support to merge iob queues, providing support for subsequent features. Signed-off-by: wenquan1 <[email protected]> --- include/nuttx/mm/iob.h | 13 +++++++++++++ mm/iob/iob_add_queue.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h index e6bf0ecc23e..4c3c2710264 100644 --- a/include/nuttx/mm/iob.h +++ b/include/nuttx/mm/iob.h @@ -405,6 +405,19 @@ int iob_add_queue(FAR struct iob_s *iob, FAR struct iob_queue_s *iobq); int iob_tryadd_queue(FAR struct iob_s *iob, FAR struct iob_queue_s *iobq); #endif /* CONFIG_IOB_NCHAINS > 0 */ +/**************************************************************************** + * Name: iob_concat_queue + * + * Description: + * Concatenate iob_s queue src to dest + * + ****************************************************************************/ + +#if CONFIG_IOB_NCHAINS > 0 +int iob_concat_queue(FAR struct iob_queue_s *dest, + FAR struct iob_queue_s *src); +#endif /* CONFIG_IOB_NCHAINS > 0 */ + /**************************************************************************** * Name: iob_remove_queue * diff --git a/mm/iob/iob_add_queue.c b/mm/iob/iob_add_queue.c index 7d0d1538650..adeef0f1584 100644 --- a/mm/iob/iob_add_queue.c +++ b/mm/iob/iob_add_queue.c @@ -131,4 +131,45 @@ int iob_tryadd_queue(FAR struct iob_s *iob, FAR struct iob_queue_s *iobq) return iob_add_queue_internal(iob, iobq, qentry); } + +/**************************************************************************** + * Name: iob_concat_queue + * + * Description: + * Concatenate iob_s queue src to dest + * + ****************************************************************************/ + +int iob_concat_queue(FAR struct iob_queue_s *dest, + FAR struct iob_queue_s *src) +{ + FAR struct iob_qentry_s *qentry; + FAR struct iob_qentry_s *tailq; + + /* Detach the list from the queue head so first for safety (should be safe + * anyway). + */ + + qentry = src->qh_head; + tailq = src->qh_tail; + src->qh_head = NULL; + src->qh_tail = NULL; + + if (qentry) + { + if (!dest->qh_head) + { + dest->qh_head = qentry; + dest->qh_tail = tailq; + } + else + { + DEBUGASSERT(dest->qh_tail); + dest->qh_tail->qe_flink = qentry; + dest->qh_tail = tailq; + } + } + + return 0; +} #endif /* CONFIG_IOB_NCHAINS > 0 */
