mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
mm/iob: add support of nonblock iob_clone
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
+11
-2
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user