mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 20:06:24 +08:00
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 <wenquan1@xiaomi.com>
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user