From: richardbarry Date: Tue, 29 Sep 2009 20:07:44 +0000 (+0000) Subject: Remove the portBYTE_ALIGNMENT_MASK definitions as they are now in the common portable... X-Git-Tag: V6.0.0~45 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4f098493b8fee5986d0eae11ea04831cc3e7b37d;p=freertos Remove the portBYTE_ALIGNMENT_MASK definitions as they are now in the common portable.h file. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@883 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/portable/MemMang/heap_1.c b/Source/portable/MemMang/heap_1.c index 3289ff92c..0f4a38e7b 100644 --- a/Source/portable/MemMang/heap_1.c +++ b/Source/portable/MemMang/heap_1.c @@ -54,30 +54,16 @@ * management pages of http://www.FreeRTOS.org for more information. */ #include -#include "FreeRTOS.h" -#include "task.h" - -/* Setup the correct byte alignment mask for the defined byte alignment. */ - -#if portBYTE_ALIGNMENT == 8 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 ) -#endif -#if portBYTE_ALIGNMENT == 4 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 ) -#endif +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE -#if portBYTE_ALIGNMENT == 2 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 ) -#endif - -#if portBYTE_ALIGNMENT == 1 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 ) -#endif +#include "FreeRTOS.h" +#include "task.h" -#ifndef heapBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" -#endif +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* Allocate the memory for the heap. The struct is used to force byte alignment without using any non-portable code. */ @@ -100,10 +86,10 @@ void *pvReturn = NULL; /* Ensure that blocks are always aligned to the required number of bytes. */ #if portBYTE_ALIGNMENT != 1 - if( xWantedSize & heapBYTE_ALIGNMENT_MASK ) + if( xWantedSize & portBYTE_ALIGNMENT_MASK ) { /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) ); + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); } #endif diff --git a/Source/portable/MemMang/heap_2.c b/Source/portable/MemMang/heap_2.c index b8524a655..a3808df1c 100644 --- a/Source/portable/MemMang/heap_2.c +++ b/Source/portable/MemMang/heap_2.c @@ -3,14 +3,14 @@ This file is part of the FreeRTOS distribution. - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the Free Software Foundation and modified by the FreeRTOS exception. **NOTE** The exception to the GPL is included to allow you to distribute a - combined work that includes FreeRTOS without being obliged to provide the - source code for proprietary components outside of the FreeRTOS kernel. - Alternative commercial license and support terms are also available upon - request. See the licensing section of http://www.FreeRTOS.org for full + combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + Alternative commercial license and support terms are also available upon + request. See the licensing section of http://www.FreeRTOS.org for full license details. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT @@ -24,10 +24,10 @@ *************************************************************************** - * * - * Looking for a quick start? Then check out the FreeRTOS eBook! * - * See http://www.FreeRTOS.org/Documentation for details * - * * + * * + * Looking for a quick start? Then check out the FreeRTOS eBook! * + * See http://www.FreeRTOS.org/Documentation for details * + * * *************************************************************************** 1 tab == 4 spaces! @@ -55,30 +55,15 @@ */ #include +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + #include "FreeRTOS.h" #include "task.h" -/* Setup the correct byte alignment mask for the defined byte alignment. */ - -#if portBYTE_ALIGNMENT == 8 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 ) -#endif - -#if portBYTE_ALIGNMENT == 4 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 ) -#endif - -#if portBYTE_ALIGNMENT == 2 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 ) -#endif - -#if portBYTE_ALIGNMENT == 1 - #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 ) -#endif - -#ifndef heapBYTE_ALIGNMENT_MASK - #error "Invalid portBYTE_ALIGNMENT definition" -#endif +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* Allocate the memory for the heap. The struct is used to force byte alignment without using any non-portable code. */ @@ -88,7 +73,7 @@ static union xRTOS_HEAP volatile portDOUBLE dDummy; #else volatile unsigned portLONG ulDummy; - #endif + #endif unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ]; } xHeap; @@ -179,10 +164,10 @@ void *pvReturn = NULL; xWantedSize += heapSTRUCT_SIZE; /* Ensure that blocks are always aligned to the required number of bytes. */ - if( xWantedSize & heapBYTE_ALIGNMENT_MASK ) + if( xWantedSize & portBYTE_ALIGNMENT_MASK ) { /* Byte alignment required. */ - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) ); + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); } } @@ -216,12 +201,12 @@ void *pvReturn = NULL; following the number of bytes requested. The void cast is used to prevent byte alignment warnings from the compiler. */ pxNewBlockLink = ( void * ) ( ( ( unsigned portCHAR * ) pxBlock ) + xWantedSize ); - + /* Calculate the sizes of two blocks split from the single block. */ - pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; - pxBlock->xBlockSize = xWantedSize; - + pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; + pxBlock->xBlockSize = xWantedSize; + /* Insert the new block into the list of free blocks. */ prvInsertBlockIntoFreeList( ( pxNewBlockLink ) ); } @@ -239,7 +224,7 @@ void *pvReturn = NULL; } } #endif - + return pvReturn; } /*-----------------------------------------------------------*/ @@ -259,7 +244,7 @@ xBlockLink *pxLink; pxLink = ( void * ) puc; vTaskSuspendAll(); - { + { /* Add this block to the list of free blocks. */ prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) ); } diff --git a/Source/portable/MemMang/heap_3.c b/Source/portable/MemMang/heap_3.c index f5ca60151..7ff08b648 100644 --- a/Source/portable/MemMang/heap_3.c +++ b/Source/portable/MemMang/heap_3.c @@ -59,9 +59,16 @@ #include +/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining +all the API functions to use the MPU wrappers. That should only be done when +task.h is included from an application file. */ +#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE + #include "FreeRTOS.h" #include "task.h" +#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE + /*-----------------------------------------------------------*/ void *pvPortMalloc( size_t xWantedSize )