Skip to content

Commit 1e32b23

Browse files
devprodestactions-usertony-josi-aws
authored
Alternative function for potential optimization of data copying in stream buffers (#1233)
* Added the ability to use an alternative function to copy data in stream buffers. Useful for optimization in systems that allow DMA to be used only in some memory areas. * Uncrustify: triggered by comment. * Revert "Uncrustify: triggered by comment." This reverts commit 22105bc. * Fix formatting --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: tony-josi-aws <[email protected]>
1 parent da065eb commit 1e32b23

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

source/FreeRTOS_Stream_Buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer,
293293
const size_t uxFirst = FreeRTOS_min_size_t( uxLength - uxNextHead, uxCount );
294294

295295
/* Write as many bytes as can be written in the first write. */
296-
( void ) memcpy( &( pxBuffer->ucArray[ uxNextHead ] ), pucData, uxFirst );
296+
( void ) pvPortMemCpyStreamBuffer( &( pxBuffer->ucArray[ uxNextHead ] ), pucData, uxFirst );
297297

298298
/* If the number of bytes written was less than the number that
299299
* could be written in the first write... */
300300
if( uxCount > uxFirst )
301301
{
302302
/* ...then write the remaining bytes to the start of the
303303
* buffer. */
304-
( void ) memcpy( pxBuffer->ucArray, &( pucData[ uxFirst ] ), uxCount - uxFirst );
304+
( void ) pvPortMemCpyStreamBuffer( pxBuffer->ucArray, &( pucData[ uxFirst ] ), uxCount - uxFirst );
305305
}
306306
}
307307

@@ -394,14 +394,14 @@ size_t uxStreamBufferGet( StreamBuffer_t * const pxBuffer,
394394

395395
/* Obtain the number of bytes it is possible to obtain in the first
396396
* read. */
397-
( void ) memcpy( pucData, &( pxBuffer->ucArray[ uxNextTail ] ), uxFirst );
397+
( void ) pvPortMemCpyStreamBuffer( pucData, &( pxBuffer->ucArray[ uxNextTail ] ), uxFirst );
398398

399399
/* If the total number of wanted bytes is greater than the number
400400
* that could be read in the first read... */
401401
if( uxCount > uxFirst )
402402
{
403403
/* ...then read the remaining bytes from the start of the buffer. */
404-
( void ) memcpy( &( pucData[ uxFirst ] ), pxBuffer->ucArray, uxCount - uxFirst );
404+
( void ) pvPortMemCpyStreamBuffer( &( pucData[ uxFirst ] ), pxBuffer->ucArray, uxCount - uxFirst );
405405
}
406406
}
407407

source/include/FreeRTOSIPConfigDefaults.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,10 +2151,33 @@ STATIC_ASSERT( ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME <= portMAX_DELAY );
21512151
#define vPortFreeSocket( ptr ) vPortFree( ptr )
21522152
#endif
21532153

2154+
/*===========================================================================*/
2155+
/* SOCKET CONFIG */
2156+
/*===========================================================================*/
2157+
/*---------------------------------------------------------------------------*/
2158+
/*===========================================================================*/
2159+
/*---------------------------------------------------------------------------*/
2160+
/*===========================================================================*/
2161+
/* STREAM BUFFER CONFIG */
2162+
/*===========================================================================*/
2163+
2164+
/*---------------------------------------------------------------------------*/
2165+
2166+
/*
2167+
* pvPortMemCpyStreamBuffer
2168+
*
2169+
* Function to copy data into the stream buffer when sending
2170+
* and copy data from the stream buffer when receiving.
2171+
*/
2172+
2173+
#ifndef pvPortMemCpyStreamBuffer
2174+
#define pvPortMemCpyStreamBuffer( dst, src, count ) memcpy( dst, src, count )
2175+
#endif
2176+
21542177
/*---------------------------------------------------------------------------*/
21552178

21562179
/*===========================================================================*/
2157-
/* SOCKET CONFIG */
2180+
/* STREAM BUFFER CONFIG */
21582181
/*===========================================================================*/
21592182
/*---------------------------------------------------------------------------*/
21602183
/*===========================================================================*/

0 commit comments

Comments
 (0)