mm/iob: add support of nonblock iob_clone

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-12-13 16:08:27 +08:00 committed by Xiang Xiao
parent 80fa70da4e
commit d6d56c3372
3 changed files with 15 additions and 5 deletions

View File

@ -267,7 +267,8 @@ Public Function Prototypes
buffer starting at ``offset`` in the I/O buffer, returning that
actual number of bytes copied out.
.. c:function:: int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled)
.. c:function:: int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, \
bool throttled, bool block);
Duplicate (and pack) the data in ``iob1`` in
``iob2``. ``iob2`` must be empty.

View File

@ -464,8 +464,8 @@ unsigned int iob_tailroom(FAR struct iob_s *iob);
*
****************************************************************************/
int iob_clone(FAR struct iob_s *iob1,
FAR struct iob_s *iob2, bool throttled);
int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2,
bool throttled, bool block);
/****************************************************************************
* Name: iob_concat

View File

@ -53,7 +53,8 @@
*
****************************************************************************/
int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled)
int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2,
bool throttled, bool block)
{
FAR uint8_t *src;
FAR uint8_t *dest;
@ -145,7 +146,15 @@ int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled)
* destination I/O buffer chain.
*/
next = iob_alloc(throttled);
if (block)
{
next = iob_alloc(throttled);
}
else
{
next = iob_tryalloc(throttled);
}
if (!next)
{
ioberr("ERROR: Failed to allocate an I/O buffer\n");