*/\r
static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
\r
+/*\r
+ * A queue requires two blocks of memory; a structure to hold the queue state\r
+ * and a storage area to hold the items in the queue. The memory is assigned\r
+ * by prvAllocateQueueMemory(). If ppucQueueStorage is NULL then the queue\r
+ * storage will allocated dynamically, otherwise the buffer passed in\r
+ * ppucQueueStorage will be used. If pxStaticQueue is NULL then the queue\r
+ * structure will be allocated dynamically, otherwise the buffer pointed to by\r
+ * pxStaticQueue will be used.\r
+ */\r
+static Queue_t *prvAllocateQueueMemory( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t **ppucQueueStorage, StaticQueue_t *pxStaticQueue );\r
+\r
#if ( configUSE_QUEUE_SETS == 1 )\r
/*\r
* Checks to see if a queue is a member of a queue set, and if so, notifies\r
#if( ( configASSERT_DEFINED == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )\r
{\r
/* Sanity check that the size of the structure used to declare a\r
- variable of type DummyQueue_t or DummySemaphore_t equals the size of the\r
- real queue and semaphore structures. */\r
+ variable of type StaticQueue_t or StaticSemaphore_t equals the size of\r
+ the real queue and semaphore structures. */\r
volatile size_t xSize = sizeof( StaticQueue_t );\r
configASSERT( xSize == sizeof( Queue_t ) );\r
}\r
}\r
else\r
{\r
- /* The queue is one byte longer than asked for to make wrap checking\r
- easier/faster. */\r
- xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+ /* Allocate enough space to hold the maximum number of items that can be\r
+ in the queue at any time. */\r
+ xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
}\r
\r
#if( configSUPPORT_STATIC_ALLOCATION == 0 )\r
storage area. */\r
*ppucQueueStorage = ( ( uint8_t * ) pxNewQueue ) + sizeof( Queue_t );\r
}\r
- \r
+\r
/* The pxStaticQueue parameter is not used. Remove compiler warnings. */\r
( void ) pxStaticQueue;\r
}\r
/* The address of a statically allocated queue was passed in, use\r
it and note that the queue was not dynamically allocated so there is\r
no attempt to free it again should the queue be deleted. */\r
- pxNewQueue = ( Queue_t * ) pxStaticQueue;\r
+ pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */\r
pxNewQueue->ucStaticAllocationFlags = queueSTATICALLY_ALLOCATED_QUEUE_STRUCT;\r
}\r
\r
if( pxNewQueue != NULL )\r
{\r
- if( ( *ppucQueueStorage == NULL ) && ( xQueueSizeInBytes > 0 ) )\r
+ if( ( *ppucQueueStorage == NULL ) && ( xQueueSizeInBytes > ( size_t ) 0 ) )\r
{\r
/* A statically allocated queue storage area was not passed in,\r
so allocate the queue storage area dynamically. */\r
{\r
vPortFree( ( void * ) pxNewQueue );\r
}\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+\r
pxNewQueue = NULL;\r
}\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
}\r
else\r
{\r
\r
#if ( configUSE_MUTEXES == 1 )\r
\r
- QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )\r
+ QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue )\r
{\r
Queue_t *pxNewQueue;\r
+ const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0;\r
\r
/* Prevent compiler warnings about unused parameters if\r
configUSE_TRACE_FACILITY does not equal 1. */\r
( void ) ucQueueType;\r
\r
+ pxNewQueue = ( Queue_t * ) xQueueGenericCreate( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType );\r
+\r
/* Allocate the new queue structure. */\r
- pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) );\r
if( pxNewQueue != NULL )\r
{\r
- /* Information required for priority inheritance. */\r
+ /* xQueueGenericCreate() will set all the queue structure members\r
+ correctly for a generic queue, but this function is creating a\r
+ mutex. Overwrite those members that need to be set differently -\r
+ in particular the information required for priority inheritance. */\r
pxNewQueue->pxMutexHolder = NULL;\r
pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;\r
\r
- /* Queues used as a mutex no data is actually copied into or out\r
- of the queue. */\r
- pxNewQueue->pcWriteTo = NULL;\r
- pxNewQueue->u.pcReadFrom = NULL;\r
-\r
- /* Each mutex has a length of 1 (like a binary semaphore) and\r
- an item size of 0 as nothing is actually copied into or out\r
- of the mutex. */\r
- pxNewQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;\r
- pxNewQueue->uxLength = ( UBaseType_t ) 1U;\r
- pxNewQueue->uxItemSize = ( UBaseType_t ) 0U;\r
- pxNewQueue->xRxLock = queueUNLOCKED;\r
- pxNewQueue->xTxLock = queueUNLOCKED;\r
-\r
- #if ( configUSE_TRACE_FACILITY == 1 )\r
- {\r
- pxNewQueue->ucQueueType = ucQueueType;\r
- }\r
- #endif\r
-\r
- #if ( configUSE_QUEUE_SETS == 1 )\r
- {\r
- pxNewQueue->pxQueueSetContainer = NULL;\r
- }\r
- #endif\r
-\r
- /* Ensure the event queues start with the correct state. */\r
- vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );\r
- vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
+ /* In case this is a recursive mutex. */\r
+ pxNewQueue->u.uxRecursiveCallCount = 0;\r
\r
traceCREATE_MUTEX( pxNewQueue );\r
\r
uxRecursiveCallCount member. */\r
( pxMutex->u.uxRecursiveCallCount )--;\r
\r
- /* Have we unwound the call count? */\r
+ /* Has the recursive call count unwound to 0? */\r
if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 )\r
{\r
/* Return the mutex. This will automatically unblock any other\r
\r
#if ( configUSE_COUNTING_SEMAPHORES == 1 )\r
\r
- QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount )\r
+ QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue )\r
{\r
QueueHandle_t xHandle;\r
\r
configASSERT( uxMaxCount != 0 );\r
configASSERT( uxInitialCount <= uxMaxCount );\r
\r
- xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, NULL, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
+ xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
\r
if( xHandle != NULL )\r
{\r
freed. */\r
vPortFree( pxQueue->pcHead );\r
}\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
\r
if( ( pxQueue->ucStaticAllocationFlags & queueSTATICALLY_ALLOCATED_QUEUE_STRUCT ) == 0 )\r
{\r
free. */\r
vPortFree( pxQueue );\r
}\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
}\r
#endif\r
}\r
\r
#if ( configQUEUE_REGISTRY_SIZE > 0 )\r
\r
- const char *pcQueueGetQueueName( QueueHandle_t xQueue )\r
+ const char *pcQueueGetQueueName( QueueHandle_t xQueue ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
{\r
UBaseType_t ux;\r
- const char *pcReturn = NULL;\r
+ const char *pcReturn = NULL; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
\r
/* Note there is nothing here to protect against another task adding or\r
removing entries from the registry while it is being searched. */\r