]> git.sur5r.net Git - freertos/blobdiff - Source/queue.c
Tidy up the RL78 port layer.
[freertos] / Source / queue.c
index bd5ae20cf979e6fe2cb9f74f725af9289b5862fe..c2197b7c2e1188331db814ea94716cc6143d4a5c 100644 (file)
@@ -1,59 +1,78 @@
 /*\r
-       FreeRTOS.org V5.3.1 - Copyright (C) 2003-2009 Richard Barry.\r
-\r
-       This file is part of the FreeRTOS.org distribution.\r
-\r
-       FreeRTOS.org is free software; you can redistribute it and/or modify it\r
-       under the terms of the GNU General Public License (version 2) as published\r
-       by the Free Software Foundation and modified by the FreeRTOS exception.\r
-       **NOTE** The exception to the GPL is included to allow you to distribute a\r
-       combined work that includes FreeRTOS.org without being obliged to provide\r
-       the source code for any proprietary components.  Alternative commercial\r
-       license and support terms are also available upon request.  See the \r
-       licensing section of http://www.FreeRTOS.org for full details.\r
-\r
-       FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT\r
-       ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
-       FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-       more details.\r
-\r
-       You should have received a copy of the GNU General Public License along\r
-       with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
-       Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
-\r
-\r
-       ***************************************************************************\r
-       *                                                                         *\r
-       * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
-       *                                                                         *\r
-       * This is a concise, step by step, 'hands on' guide that describes both   *\r
-       * general multitasking concepts and FreeRTOS specifics. It presents and   *\r
-       * explains numerous examples that are written using the FreeRTOS API.     *\r
-       * Full source code for all the examples is provided in an accompanying    *\r
-       * .zip file.                                                              *\r
-       *                                                                         *\r
-       ***************************************************************************\r
-\r
-       1 tab == 4 spaces!\r
-\r
-       Please ensure to read the configuration and relevant port sections of the\r
-       online documentation.\r
-\r
-       http://www.FreeRTOS.org - Documentation, latest information, license and\r
-       contact details.\r
-\r
-       http://www.SafeRTOS.com - A version that is certified for use in safety\r
-       critical systems.\r
-\r
-       http://www.OpenRTOS.com - Commercial support, development, porting,\r
-       licensing and training services.\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+       \r
+\r
+       FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by:\r
+       Atollic AB - Atollic provides professional embedded systems development \r
+       tools for C/C++ development, code analysis and test automation.  \r
+       See http://www.atollic.com\r
+       \r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public\r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+    contact details.\r
+\r
+    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+    critical systems.\r
+\r
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
 */\r
 \r
 #include <stdlib.h>\r
 #include <string.h>\r
+\r
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
+all the API functions to use the MPU wrappers.  That should only be done when\r
+task.h is included from an application file. */\r
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
+\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
-#include "croutine.h"\r
+\r
+#if ( configUSE_CO_ROUTINES == 1 )\r
+       #include "croutine.h"\r
+#endif\r
+\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
 \r
 /*-----------------------------------------------------------\r
  * PUBLIC LIST API documented in list.h\r
@@ -77,9 +96,9 @@
 \r
 /* Semaphores do not actually store or copy data, so have an items size of\r
 zero. */\r
-#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( 0 )\r
-#define queueDONT_BLOCK                                         ( ( portTickType ) 0 )\r
-#define queueMUTEX_GIVE_BLOCK_TIME              ( ( portTickType ) 0 )\r
+#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )\r
+#define queueDONT_BLOCK                                         ( ( portTickType ) 0U )\r
+#define queueMUTEX_GIVE_BLOCK_TIME              ( ( portTickType ) 0U )\r
 \r
 /*\r
  * Definition of the queue used by the scheduler.\r
@@ -87,11 +106,11 @@ zero. */
  */\r
 typedef struct QueueDefinition\r
 {\r
-       signed portCHAR *pcHead;                                /*< Points to the beginning of the queue storage area. */\r
-       signed portCHAR *pcTail;                                /*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */\r
+       signed char *pcHead;                            /*< Points to the beginning of the queue storage area. */\r
+       signed char *pcTail;                            /*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */\r
 \r
-       signed portCHAR *pcWriteTo;                             /*< Points to the free next place in the storage area. */\r
-       signed portCHAR *pcReadFrom;                    /*< Points to the last place that a queued item was read from. */\r
+       signed char *pcWriteTo;                         /*< Points to the free next place in the storage area. */\r
+       signed char *pcReadFrom;                        /*< Points to the last place that a queued item was read from. */\r
 \r
        xList xTasksWaitingToSend;                              /*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */\r
        xList xTasksWaitingToReceive;                   /*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */\r
@@ -118,32 +137,33 @@ typedef xQUEUE * xQueueHandle;
  * include the API header file (as it defines xQueueHandle differently).  These\r
  * functions are documented in the API header file.\r
  */\r
-xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize );\r
-signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
-unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue );\r
-void vQueueDelete( xQueueHandle xQueue );\r
-signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition );\r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
-xQueueHandle xQueueCreateMutex( void );\r
-xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount );\r
-portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime );\r
-portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex );\r
-signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
-signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
-signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue );\r
-signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue );\r
-unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue );\r
+xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
+unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;\r
+xQueueHandle xQueueCreateMutex( void ) PRIVILEGED_FUNCTION;\r
+xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;\r
+portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
+portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Co-routine queue functions differ from task queue functions.  Co-routines are\r
  * an optional component.\r
  */\r
 #if configUSE_CO_ROUTINES == 1\r
-       signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );\r
-       signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
-       signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );\r
-       signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );\r
+       signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) PRIVILEGED_FUNCTION;\r
+       signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;\r
+       signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
+       signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
 #endif\r
 \r
 /*\r
@@ -157,7 +177,7 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
        more user friendly. */\r
        typedef struct QUEUE_REGISTRY_ITEM\r
        {\r
-               signed portCHAR *pcQueueName;\r
+               signed char *pcQueueName;\r
                xQueueHandle xHandle;\r
        } xQueueRegistryItem;\r
 \r
@@ -168,8 +188,8 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
 \r
        /* Removes a queue from the registry by simply setting the pcQueueName\r
        member to NULL. */\r
-       static void vQueueUnregisterQueue( xQueueHandle xQueue );\r
-       void vQueueAddToRegistry( xQueueHandle xQueue, signed portCHAR *pcQueueName );\r
+       static void vQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
+       void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName ) PRIVILEGED_FUNCTION;\r
 #endif\r
 \r
 /*\r
@@ -180,53 +200,51 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
  * to indicate that a task may require unblocking.  When the queue in unlocked\r
  * these lock counts are inspected, and the appropriate action taken.\r
  */\r
-static void prvUnlockQueue( xQueueHandle pxQueue );\r
+static void prvUnlockQueue( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Uses a critical section to determine if there is any data in a queue.\r
  *\r
  * @return pdTRUE if the queue contains no items, otherwise pdFALSE.\r
  */\r
-static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue );\r
+static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Uses a critical section to determine if there is any space in a queue.\r
  *\r
  * @return pdTRUE if there is no space, otherwise pdFALSE;\r
  */\r
-static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue );\r
+static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Copies an item into the queue, either at the front of the queue or the\r
  * back of the queue.\r
  */\r
-static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition );\r
+static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Copies an item out of a queue.\r
  */\r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer );\r
+static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION;\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
  * Macro to mark a queue as locked.  Locking a queue prevents an ISR from\r
  * accessing the queue event lists.\r
  */\r
-#define prvLockQueue( pxQueue )                                                        \\r
-{                                                                                                              \\r
-       taskENTER_CRITICAL();                                                           \\r
-       {                                                                                                       \\r
-               if( pxQueue->xRxLock == queueUNLOCKED )                 \\r
-               {                                                                                               \\r
-                       pxQueue->xRxLock = queueLOCKED_UNMODIFIED;      \\r
-               }                                                                                               \\r
-               if( pxQueue->xTxLock == queueUNLOCKED )                 \\r
-               {                                                                                               \\r
-                       pxQueue->xTxLock = queueLOCKED_UNMODIFIED;      \\r
-               }                                                                                               \\r
-       }                                                                                                       \\r
-       taskEXIT_CRITICAL();                                                            \\r
-}\r
+#define prvLockQueue( pxQueue )                                                                \\r
+       taskENTER_CRITICAL();                                                                   \\r
+       {                                                                                                               \\r
+               if( ( pxQueue )->xRxLock == queueUNLOCKED )                     \\r
+               {                                                                                                       \\r
+                       ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED;  \\r
+               }                                                                                                       \\r
+               if( ( pxQueue )->xTxLock == queueUNLOCKED )                     \\r
+               {                                                                                                       \\r
+                       ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED;  \\r
+               }                                                                                                       \\r
+       }                                                                                                               \\r
+       taskEXIT_CRITICAL()\r
 /*-----------------------------------------------------------*/\r
 \r
 \r
@@ -238,6 +256,7 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
 {\r
 xQUEUE *pxNewQueue;\r
 size_t xQueueSizeInBytes;\r
+xQueueHandle xReturn = NULL;\r
 \r
        /* Allocate the new queue structure. */\r
        if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )\r
@@ -249,15 +268,15 @@ size_t xQueueSizeInBytes;
                        longer than asked for to make wrap checking easier/faster. */\r
                        xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;\r
 \r
-                       pxNewQueue->pcHead = ( signed portCHAR * ) pvPortMalloc( xQueueSizeInBytes );\r
+                       pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes );\r
                        if( pxNewQueue->pcHead != NULL )\r
                        {\r
                                /* Initialise the queue members as described above where the\r
                                queue type is defined. */\r
                                pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize );\r
-                               pxNewQueue->uxMessagesWaiting = 0;\r
+                               pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
                                pxNewQueue->pcWriteTo = pxNewQueue->pcHead;\r
-                               pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - 1 ) * uxItemSize );\r
+                               pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - ( unsigned portBASE_TYPE ) 1U ) * uxItemSize );\r
                                pxNewQueue->uxLength = uxQueueLength;\r
                                pxNewQueue->uxItemSize = uxItemSize;\r
                                pxNewQueue->xRxLock = queueUNLOCKED;\r
@@ -268,8 +287,7 @@ size_t xQueueSizeInBytes;
                                vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
 \r
                                traceQUEUE_CREATE( pxNewQueue );\r
-\r
-                               return  pxNewQueue;\r
+                               xReturn = pxNewQueue;\r
                        }\r
                        else\r
                        {\r
@@ -279,9 +297,9 @@ size_t xQueueSizeInBytes;
                }\r
        }\r
 \r
-       /* Will only reach here if we could not allocate enough memory or no memory\r
-       was required. */\r
-       return NULL;\r
+       configASSERT( xReturn );\r
+\r
+       return xReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -307,9 +325,9 @@ size_t xQueueSizeInBytes;
                        /* 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 = 0;\r
-                       pxNewQueue->uxLength = 1;\r
-                       pxNewQueue->uxItemSize = 0;\r
+                       pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
+                       pxNewQueue->uxLength = ( unsigned portBASE_TYPE ) 1U;\r
+                       pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U;\r
                        pxNewQueue->xRxLock = queueUNLOCKED;\r
                        pxNewQueue->xTxLock = queueUNLOCKED;\r
 \r
@@ -318,7 +336,7 @@ size_t xQueueSizeInBytes;
                        vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
 \r
                        /* Start with the semaphore in the expected state. */\r
-                       xQueueGenericSend( pxNewQueue, NULL, 0, queueSEND_TO_BACK );\r
+                       xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );\r
 \r
                        traceCREATE_MUTEX( pxNewQueue );\r
                }\r
@@ -327,6 +345,7 @@ size_t xQueueSizeInBytes;
                        traceCREATE_MUTEX_FAILED();\r
                }\r
 \r
+               configASSERT( pxNewQueue );\r
                return pxNewQueue;\r
        }\r
 \r
@@ -339,6 +358,8 @@ size_t xQueueSizeInBytes;
        {\r
        portBASE_TYPE xReturn;\r
 \r
+               configASSERT( pxMutex );\r
+\r
                /* If this is the task that holds the mutex then pxMutexHolder will not\r
                change outside of this task.  If this task does not hold the mutex then\r
                pxMutexHolder can never coincidentally equal the tasks handle, and as\r
@@ -361,7 +382,7 @@ size_t xQueueSizeInBytes;
                        {\r
                                /* Return the mutex.  This will automatically unblock any other\r
                                task that might be waiting to access the mutex. */\r
-                xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
+                               xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
                        }\r
 \r
                        xReturn = pdPASS;\r
@@ -386,6 +407,8 @@ size_t xQueueSizeInBytes;
        {\r
        portBASE_TYPE xReturn;\r
 \r
+               configASSERT( pxMutex );\r
+\r
                /* Comments regarding mutual exclusion as per those within\r
                xQueueGiveMutexRecursive(). */\r
 \r
@@ -398,7 +421,7 @@ size_t xQueueSizeInBytes;
                }\r
                else\r
                {\r
-            xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE );\r
+                       xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE );\r
 \r
                        /* pdPASS will only be returned if we successfully obtained the mutex,\r
                        we may have blocked to reach here. */\r
@@ -406,6 +429,10 @@ size_t xQueueSizeInBytes;
                        {\r
                                ( pxMutex->uxRecursiveCallCount )++;\r
                        }\r
+                       else\r
+                       {\r
+                               traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex );\r
+                       }\r
                }\r
 \r
                return xReturn;\r
@@ -433,6 +460,7 @@ size_t xQueueSizeInBytes;
                        traceCREATE_COUNTING_SEMAPHORE_FAILED();\r
                }\r
 \r
+               configASSERT( pxHandle );\r
                return pxHandle;\r
        }\r
 \r
@@ -444,16 +472,18 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const
 signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
 xTimeOutType xTimeOut;\r
 \r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+\r
        /* This function relaxes the coding standard somewhat to allow return\r
        statements within the function itself.  This is done in the interest\r
        of execution time efficiency. */\r
-\r
        for( ;; )\r
        {\r
                taskENTER_CRITICAL();\r
                {\r
-                       /* Is there room on the queue now?  To be running we must be\r
-                       the highest priority task wanting to access the queue. */\r
+                       /* Is there room on the queue now?  To be running we must be\r
+                       the highest priority task wanting to access the queue. */\r
                        if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                        {\r
                                traceQUEUE_SEND( pxQueue );\r
@@ -469,11 +499,14 @@ xTimeOutType xTimeOut;
                                                our own so yield immediately.  Yes it is ok to do\r
                                                this from within the critical section - the kernel\r
                                                takes care of that. */\r
-                                               taskYIELD();\r
+                                               portYIELD_WITHIN_API();\r
                                        }\r
                                }\r
 \r
                                taskEXIT_CRITICAL();\r
+\r
+                               /* Return to the original privilege level before exiting the\r
+                               function. */\r
                                return pdPASS;\r
                        }\r
                        else\r
@@ -483,6 +516,9 @@ xTimeOutType xTimeOut;
                                        /* The queue was full and no block time is specified (or\r
                                        the block time has expired) so leave now. */\r
                                        taskEXIT_CRITICAL();\r
+\r
+                                       /* Return to the original privilege level before exiting\r
+                                       the function. */\r
                                        traceQUEUE_SEND_FAILED( pxQueue );\r
                                        return errQUEUE_FULL;\r
                                }\r
@@ -506,7 +542,7 @@ xTimeOutType xTimeOut;
                /* Update the timeout state to see if it has expired yet. */\r
                if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
                {\r
-                       if( prvIsQueueFull( pxQueue ) )\r
+                       if( prvIsQueueFull( pxQueue ) != pdFALSE )\r
                        {\r
                                traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
@@ -523,9 +559,9 @@ xTimeOutType xTimeOut;
                                task is already in a ready list before it yields - in which\r
                                case the yield will not cause a context switch unless there\r
                                is also a higher priority task in the pending ready list. */\r
-                               if( !xTaskResumeAll() )\r
+                               if( xTaskResumeAll() == pdFALSE )\r
                                {\r
-                                       taskYIELD();\r
+                                       portYIELD_WITHIN_API();\r
                                }\r
                        }\r
                        else\r
@@ -540,6 +576,9 @@ xTimeOutType xTimeOut;
                        /* The timeout has expired. */\r
                        prvUnlockQueue( pxQueue );\r
                        ( void ) xTaskResumeAll();\r
+\r
+                       /* Return to the original privilege level before exiting the\r
+                       function. */\r
                        traceQUEUE_SEND_FAILED( pxQueue );\r
                        return errQUEUE_FULL;\r
                }\r
@@ -554,12 +593,15 @@ xTimeOutType xTimeOut;
        signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
        xTimeOutType xTimeOut;\r
 \r
+               configASSERT( pxQueue );\r
+               configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+\r
                for( ;; )\r
                {\r
                        taskENTER_CRITICAL();\r
                        {\r
-                               /* Is there room on the queue now?  To be running we must be\r
-                               the highest priority task wanting to access the queue. */\r
+                               /* Is there room on the queue now?  To be running we must be\r
+                               the highest priority task wanting to access the queue. */\r
                                if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
                                {\r
                                        traceQUEUE_SEND( pxQueue );\r
@@ -573,7 +615,7 @@ xTimeOutType xTimeOut;
                                                {\r
                                                        /* The unblocked task has a priority higher than\r
                                                        our own so yield immediately. */\r
-                                                       taskYIELD();\r
+                                                       portYIELD_WITHIN_API();\r
                                                }\r
                                        }\r
 \r
@@ -600,11 +642,11 @@ xTimeOutType xTimeOut;
                        {\r
                                if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
                                {\r
-                                       if( prvIsQueueFull( pxQueue ) )\r
+                                       if( prvIsQueueFull( pxQueue ) != pdFALSE )\r
                                        {\r
                                                traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
                                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
-                                               taskYIELD();\r
+                                               portYIELD_WITHIN_API();\r
                                        }\r
                                }\r
                                else\r
@@ -627,7 +669,10 @@ xTimeOutType xTimeOut;
        {\r
        signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
        xTimeOutType xTimeOut;\r
-       signed portCHAR *pcOriginalReadPosition;\r
+       signed char *pcOriginalReadPosition;\r
+\r
+               configASSERT( pxQueue );\r
+               configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
 \r
                for( ;; )\r
                {\r
@@ -662,7 +707,7 @@ xTimeOutType xTimeOut;
                                                {\r
                                                        if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
                                                        {\r
-                                                               taskYIELD();\r
+                                                               portYIELD_WITHIN_API();\r
                                                        }\r
                                                }\r
                                        }\r
@@ -676,14 +721,14 @@ xTimeOutType xTimeOut;
 \r
                                                /* The data is being left in the queue, so see if there are\r
                                                any other tasks waiting for the data. */\r
-                                               if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                                                {\r
                                                        /* Tasks that are removed from the event list will get added to\r
                                                        the pending ready list as the scheduler is still suspended. */\r
                                                        if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                        {\r
                                                                /* The task waiting has a higher priority than this task. */\r
-                                                               taskYIELD();\r
+                                                               portYIELD_WITHIN_API();\r
                                                        }\r
                                                }\r
 \r
@@ -713,7 +758,7 @@ xTimeOutType xTimeOut;
                        {\r
                                if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
                                {\r
-                                       if( prvIsQueueEmpty( pxQueue ) )\r
+                                       if( prvIsQueueEmpty( pxQueue ) != pdFALSE )\r
                                        {\r
                                                traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
 \r
@@ -729,7 +774,7 @@ xTimeOutType xTimeOut;
                                                #endif\r
 \r
                                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
-                                               taskYIELD();\r
+                                               portYIELD_WITHIN_API();\r
                                        }\r
                                }\r
                                else\r
@@ -752,6 +797,10 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
 signed portBASE_TYPE xReturn;\r
 unsigned portBASE_TYPE uxSavedInterruptStatus;\r
 \r
+       configASSERT( pxQueue );\r
+       configASSERT( pxHigherPriorityTaskWoken );\r
+       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+\r
        /* Similar to xQueueGenericSend, except we don't block if there is no room\r
        in the queue.  Also we don't directly wake a task that was blocked on a\r
        queue read, instead we return a flag to say whether a context switch is\r
@@ -769,7 +818,7 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                        be done when the queue is unlocked later. */\r
                        if( pxQueue->xTxLock == queueUNLOCKED )\r
                        {\r
-                               if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                                {\r
                                        if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                        {\r
@@ -804,7 +853,10 @@ signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pv
 {\r
 signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
 xTimeOutType xTimeOut;\r
-signed portCHAR *pcOriginalReadPosition;\r
+signed char *pcOriginalReadPosition;\r
+\r
+       configASSERT( pxQueue );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
 \r
        /* This function relaxes the coding standard somewhat to allow return\r
        statements within the function itself.  This is done in the interest\r
@@ -814,8 +866,8 @@ signed portCHAR *pcOriginalReadPosition;
        {\r
                taskENTER_CRITICAL();\r
                {\r
-                       /* Is there data in the queue now?  To be running we must be\r
-                       the highest priority task wanting to access the queue. */\r
+                       /* Is there data in the queue now?  To be running we must be\r
+                       the highest priority task wanting to access the queue. */\r
                        if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
                        {\r
                                /* Remember our read position in case we are just peeking. */\r
@@ -845,7 +897,7 @@ signed portCHAR *pcOriginalReadPosition;
                                        {\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
                                                {\r
-                                                       taskYIELD();\r
+                                                       portYIELD_WITHIN_API();\r
                                                }\r
                                        }\r
                                }\r
@@ -859,14 +911,14 @@ signed portCHAR *pcOriginalReadPosition;
 \r
                                        /* The data is being left in the queue, so see if there are\r
                                        any other tasks waiting for the data. */\r
-                                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                                        {\r
                                                /* Tasks that are removed from the event list will get added to\r
                                                the pending ready list as the scheduler is still suspended. */\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                {\r
                                                        /* The task waiting has a higher priority than this task. */\r
-                                                       taskYIELD();\r
+                                                       portYIELD_WITHIN_API();\r
                                                }\r
                                        }\r
 \r
@@ -905,7 +957,7 @@ signed portCHAR *pcOriginalReadPosition;
                /* Update the timeout state to see if it has expired yet. */\r
                if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )\r
                {\r
-                       if( prvIsQueueEmpty( pxQueue ) )\r
+                       if( prvIsQueueEmpty( pxQueue ) != pdFALSE )\r
                        {\r
                                traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
 \r
@@ -924,9 +976,9 @@ signed portCHAR *pcOriginalReadPosition;
 \r
                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
                                prvUnlockQueue( pxQueue );\r
-                               if( !xTaskResumeAll() )\r
+                               if( xTaskResumeAll() == pdFALSE )\r
                                {\r
-                                       taskYIELD();\r
+                                       portYIELD_WITHIN_API();\r
                                }\r
                        }\r
                        else\r
@@ -952,6 +1004,10 @@ signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pv
 signed portBASE_TYPE xReturn;\r
 unsigned portBASE_TYPE uxSavedInterruptStatus;\r
 \r
+       configASSERT( pxQueue );\r
+       configASSERT( pxTaskWoken );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+\r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
                /* We cannot block from an ISR, so check there is data available. */\r
@@ -967,7 +1023,7 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                        that an ISR has removed data while the queue was locked. */\r
                        if( pxQueue->xRxLock == queueUNLOCKED )\r
                        {\r
-                               if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )\r
+                               if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                                {\r
                                        if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
                                        {\r
@@ -1002,6 +1058,8 @@ unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue )
 {\r
 unsigned portBASE_TYPE uxReturn;\r
 \r
+       configASSERT( pxQueue );\r
+\r
        taskENTER_CRITICAL();\r
                uxReturn = pxQueue->uxMessagesWaiting;\r
        taskEXIT_CRITICAL();\r
@@ -1014,6 +1072,8 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
 {\r
 unsigned portBASE_TYPE uxReturn;\r
 \r
+       configASSERT( pxQueue );\r
+\r
        uxReturn = pxQueue->uxMessagesWaiting;\r
 \r
        return uxReturn;\r
@@ -1022,6 +1082,8 @@ unsigned portBASE_TYPE uxReturn;
 \r
 void vQueueDelete( xQueueHandle pxQueue )\r
 {\r
+       configASSERT( pxQueue );\r
+\r
        traceQUEUE_DELETE( pxQueue );\r
        vQueueUnregisterQueue( pxQueue );\r
        vPortFree( pxQueue->pcHead );\r
@@ -1039,7 +1101,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
                        {\r
                                /* The mutex is no longer being held. */\r
                                vTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );\r
-                pxQueue->pxMutexHolder = NULL;\r
+                               pxQueue->pxMutexHolder = NULL;\r
                        }\r
                }\r
                #endif\r
@@ -1096,7 +1158,7 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
                {\r
                        /* Data was posted while the queue was locked.  Are any tasks\r
                        blocked waiting for data to become available? */\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                        {\r
                                /* Tasks that are removed from the event list will get added to\r
                                the pending ready list as the scheduler is still suspended. */\r
@@ -1124,7 +1186,7 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
        {\r
                while( pxQueue->xRxLock > queueLOCKED_UNMODIFIED )\r
                {\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                        {\r
                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
                                {\r
@@ -1161,6 +1223,7 @@ signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue )
 {\r
 signed portBASE_TYPE xReturn;\r
 \r
+       configASSERT( pxQueue );\r
        xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );\r
 \r
        return xReturn;\r
@@ -1183,6 +1246,7 @@ signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue )
 {\r
 signed portBASE_TYPE xReturn;\r
 \r
+       configASSERT( pxQueue );\r
        xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength );\r
 \r
        return xReturn;\r
@@ -1199,7 +1263,7 @@ signed portBASE_TYPE xReturn;
        between the check to see if the queue is full and blocking on the queue. */\r
        portDISABLE_INTERRUPTS();\r
        {\r
-               if( prvIsQueueFull( pxQueue ) )\r
+               if( prvIsQueueFull( pxQueue ) != pdFALSE )\r
                {\r
                        /* The queue is full - do we want to block or just leave without\r
                        posting? */\r
@@ -1231,7 +1295,7 @@ signed portBASE_TYPE xReturn;
                        xReturn = pdPASS;\r
 \r
                        /* Were any co-routines waiting for data to become available? */\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                        {\r
                                /* In this instance the co-routine could be placed directly\r
                                into the ready list as we are within a critical section.\r
@@ -1306,7 +1370,7 @@ signed portBASE_TYPE xReturn;
                        xReturn = pdPASS;\r
 \r
                        /* Were any co-routines waiting for space to become available? */\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                        {\r
                                /* In this instance the co-routine could be placed directly\r
                                into the ready list as we are within a critical section.\r
@@ -1343,9 +1407,9 @@ signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvIt
 \r
                /* We only want to wake one co-routine per ISR, so check that a\r
                co-routine has not already been woken. */\r
-               if( !xCoRoutinePreviouslyWoken )\r
+               if( xCoRoutinePreviouslyWoken == pdFALSE )\r
                {\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
                        {\r
                                if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                {\r
@@ -1378,9 +1442,9 @@ signed portBASE_TYPE xReturn;
                --( pxQueue->uxMessagesWaiting );\r
                memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
-               if( !( *pxCoRoutineWoken ) )\r
+               if( ( *pxCoRoutineWoken ) == pdFALSE )\r
                {\r
-                       if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )\r
+                       if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                        {\r
                                if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )\r
                                {\r
@@ -1403,13 +1467,13 @@ signed portBASE_TYPE xReturn;
 \r
 #if configQUEUE_REGISTRY_SIZE > 0\r
 \r
-       void vQueueAddToRegistry( xQueueHandle xQueue, signed portCHAR *pcQueueName )\r
+       void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName )\r
        {\r
        unsigned portBASE_TYPE ux;\r
 \r
                /* See if there is an empty space in the registry.  A NULL name denotes\r
                a free slot. */\r
-               for( ux = 0; ux < configQUEUE_REGISTRY_SIZE; ux++ )\r
+               for( ux = ( unsigned portBASE_TYPE ) 0U; ux < ( unsigned portBASE_TYPE ) configQUEUE_REGISTRY_SIZE; ux++ )\r
                {\r
                        if( xQueueRegistry[ ux ].pcQueueName == NULL )\r
                        {\r
@@ -1422,7 +1486,7 @@ signed portBASE_TYPE xReturn;
        }\r
 \r
 #endif\r
-       /*-----------------------------------------------------------*/\r
+/*-----------------------------------------------------------*/\r
 \r
 #if configQUEUE_REGISTRY_SIZE > 0\r
 \r
@@ -1432,7 +1496,7 @@ signed portBASE_TYPE xReturn;
 \r
                /* See if the handle of the queue being unregistered in actually in the\r
                registry. */\r
-               for( ux = 0; ux < configQUEUE_REGISTRY_SIZE; ux++ )\r
+               for( ux = ( unsigned portBASE_TYPE ) 0U; ux < ( unsigned portBASE_TYPE ) configQUEUE_REGISTRY_SIZE; ux++ )\r
                {\r
                        if( xQueueRegistry[ ux ].xHandle == xQueue )\r
                        {\r
@@ -1441,6 +1505,37 @@ signed portBASE_TYPE xReturn;
                                break;\r
                        }\r
                }\r
+\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if configUSE_TIMERS == 1\r
+\r
+       void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait )\r
+       {\r
+               /* This function should not be called by application code hence the\r
+               'Restricted' in its name.  It is not part of the public API.  It is\r
+               designed for use by kernel code, and has special calling requirements.\r
+               It can result in vListInsert() being called on a list that can only\r
+               possibly ever have one item in it, so the list will be fast, but even\r
+               so it should be called with the scheduler locked and not from a critical\r
+               section. */\r
+\r
+               /* Only do anything if there are no messages in the queue.  This function\r
+               will not actually cause the task to block, just place it on a blocked\r
+               list.  It will not block until the scheduler is unlocked - at which\r
+               time a yield will be performed.  If an item is added to the queue while\r
+               the queue is locked, and the calling task blocks on the queue, then the\r
+               calling task will be immediately unblocked when the queue is unlocked. */\r
+               prvLockQueue( pxQueue );\r
+               if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0U )\r
+               {\r
+                       /* There is nothing in the queue, block for the specified period. */\r
+                       vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
+               }\r
+               prvUnlockQueue( pxQueue );\r
        }\r
 \r
 #endif\r