亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? heap_2.c

?? Este é um rtos free para a familia arm7
?? C
字號:
/*
	FreeRTOS V4.0.0 - Copyright (C) 2003-2006 Richard Barry.

	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 as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	FreeRTOS is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with FreeRTOS; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	A special exception to the GPL can be applied should you wish to distribute
	a combined work that includes FreeRTOS, without being obliged to provide
	the source code for any proprietary components.  See the licensing section
	of http://www.FreeRTOS.org for full details of how and when the exception
	can be applied.

	***************************************************************************
	See http://www.FreeRTOS.org for documentation, latest information, license
	and contact details.  Please ensure to read the configuration and relevant
	port sections of the online documentation.
	***************************************************************************
*/

/*
 * A sample implementation of pvPortMalloc() and vPortFree() that permits
 * allocated blocks to be freed, but does not combine adjacent free blocks
 * into a single larger block.
 *
 * See heap_1.c and heap_3.c for alternative implementations, and the memory
 * management pages of http://www.FreeRTOS.org for more information.
 */
#include <stdlib.h>

#include "FreeRTOS.h"
#include "task.h"

/* Setup the correct byte alignment mask for the defined byte alignment. */
#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

/* Allocate the memory for the heap.  The struct is used to force byte
alignment without using any non-portable code. */
static struct xRTOS_HEAP
{
	unsigned portLONG ulDummy;
	unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
} xHeap;

/* Define the linked list structure.  This is used to link free blocks in order
of their size. */
typedef struct A_BLOCK_LINK
{
	struct A_BLOCK_LINK *pxNextFreeBlock;	/*<< The next free block in the list. */
	size_t xBlockSize;						/*<< The size of the free block. */
} xBlockLink;


static const unsigned portSHORT  heapSTRUCT_SIZE	= ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );
#define heapMINIMUM_BLOCK_SIZE	( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )

/* Create a couple of list links to mark the start and end of the list. */
static xBlockLink xStart, xEnd;

/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */

/*
 * Insert a block into the list of free blocks - which is ordered by size of
 * the block.  Small blocks at the start of the list and large blocks at the end
 * of the list.
 */
#define prvInsertBlockIntoFreeList( pxBlockToInsert )								\
{																					\
xBlockLink *pxIterator;																\
size_t xBlockSize;																	\
																					\
	xBlockSize = pxBlockToInsert->xBlockSize;										\
																					\
	/* Iterate through the list until a block is found that has a larger size */	\
	/* than the block we are inserting. */											\
	for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock )	\
	{																				\
		/* There is nothing to do here - just iterate to the correct position. */	\
	}																				\
																					\
	/* Update the list to include the block being inserted in the correct */		\
	/* position. */																	\
	pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;					\
	pxIterator->pxNextFreeBlock = pxBlockToInsert;									\
}
/*-----------------------------------------------------------*/

#define prvHeapInit()																\
{																					\
xBlockLink *pxFirstFreeBlock;														\
																					\
	/* xStart is used to hold a pointer to the first item in the list of free */	\
	/* blocks.  The void cast is used to prevent compiler warnings. */				\
	xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap;								\
	xStart.xBlockSize = ( size_t ) 0;												\
																					\
	/* xEnd is used to mark the end of the list of free blocks. */					\
	xEnd.xBlockSize = configTOTAL_HEAP_SIZE;										\
	xEnd.pxNextFreeBlock = NULL;													\
																					\
	/* To start with there is a single free block that is sized to take up the		\
	entire heap space. */															\
	pxFirstFreeBlock = ( void * ) xHeap.ucHeap;										\
	pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE;							\
	pxFirstFreeBlock->pxNextFreeBlock = &xEnd;										\
}
/*-----------------------------------------------------------*/

void *pvPortMalloc( size_t xWantedSize )
{
xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE;
void *pvReturn = NULL;

	vTaskSuspendAll();
	{
		/* If this is the first call to malloc then the heap will require
		initialisation to setup the list of free blocks. */
		if( xHeapHasBeenInitialised == pdFALSE )
		{
			prvHeapInit();
			xHeapHasBeenInitialised = pdTRUE;
		}

		/* The wanted size is increased so it can contain a xBlockLink
		structure in addition to the requested amount of bytes. */
		if( xWantedSize > 0 )
		{
			xWantedSize += heapSTRUCT_SIZE;

			/* Ensure that blocks are always aligned to the required number of bytes. */
			if( xWantedSize & heapBYTE_ALIGNMENT_MASK )
			{
				/* Byte alignment required. */
				xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );
			}
		}

		if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_HEAP_SIZE ) )
		{
			/* Blocks are stored in byte order - traverse the list from the start
			(smallest) block until one of adequate size is found. */
			pxPreviousBlock = &xStart;
			pxBlock = xStart.pxNextFreeBlock;
			while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) )
			{
				pxPreviousBlock = pxBlock;
				pxBlock = pxBlock->pxNextFreeBlock;
			}

			/* If we found the end marker then a block of adequate size was not found. */
			if( pxBlock != &xEnd )
			{
				/* Return the memory space - jumping over the xBlockLink structure
				at its start. */
				pvReturn = ( void * ) ( ( ( unsigned portCHAR * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );

				/* This block is being returned for use so must be taken our of the
				list of free blocks. */
				pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;

				/* If the block is larger than required it can be split into two. */
				if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )
				{
					/* This block is to be split into two.  Create a new block
					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;			
					
					/* Insert the new block into the list of free blocks. */
					prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
				}
			}
		}
	}
	xTaskResumeAll();

	return pvReturn;
}
/*-----------------------------------------------------------*/

void vPortFree( void *pv )
{
unsigned portCHAR *puc = ( unsigned portCHAR * ) pv;
xBlockLink *pxLink;

	if( pv )
	{
		/* The memory being freed will have an xBlockLink structure immediately
		before it. */
		puc -= heapSTRUCT_SIZE;

		/* This casting is to keep the compiler from issuing warnings. */
		pxLink = ( void * ) puc;

		vTaskSuspendAll();
		{				
			/* Add this block to the list of free blocks. */
			prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) );
		}
		xTaskResumeAll();
	}
}
/*-----------------------------------------------------------*/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区四区在线免费观看 | 国产美女精品一区二区三区| 欧美亚洲动漫精品| 日韩电影在线观看电影| 欧美老年两性高潮| 九九九精品视频| 久久精品夜色噜噜亚洲aⅴ| 国产.精品.日韩.另类.中文.在线.播放| 国产欧美日本一区二区三区| eeuss鲁片一区二区三区在线观看| 亚洲欧美另类小说视频| 一本大道av伊人久久综合| 一区二区三区日本| 3751色影院一区二区三区| 黄页视频在线91| 国产精品国产精品国产专区不蜜| av亚洲精华国产精华精华| 亚洲一区自拍偷拍| 欧美一级精品大片| 粉嫩av一区二区三区在线播放| 中文字幕日韩av资源站| 欧美丰满美乳xxx高潮www| 韩国三级电影一区二区| 亚洲欧美一区二区三区极速播放| 91久久精品一区二区二区| 美国十次综合导航| 亚洲一卡二卡三卡四卡五卡| 欧美一区午夜视频在线观看| 国产mv日韩mv欧美| 丝袜美腿高跟呻吟高潮一区| 日本一区二区三区高清不卡| 欧美性受xxxx| 国产91富婆露脸刺激对白 | 亚洲国产精品综合小说图片区| 欧美一区日韩一区| 一本一道久久a久久精品| 久久国产尿小便嘘嘘尿| 一区二区三区美女视频| 久久久91精品国产一区二区精品 | 日本一道高清亚洲日美韩| 国产女主播视频一区二区| 欧美日韩久久一区二区| 成人免费黄色大片| 麻豆一区二区三| 亚洲综合丝袜美腿| 中文无字幕一区二区三区| 日韩欧美色电影| 欧美视频三区在线播放| 成人性色生活片| 看电视剧不卡顿的网站| 亚洲一区在线电影| 最新欧美精品一区二区三区| 久久综合九色综合97婷婷| 欧美精品久久一区| 色av一区二区| av中文一区二区三区| 国产激情精品久久久第一区二区| 三级影片在线观看欧美日韩一区二区 | 亚洲日本va在线观看| 久久久国际精品| 精品福利一二区| 日韩小视频在线观看专区| 欧美日韩国产另类不卡| 欧美亚洲国产怡红院影院| 91在线观看污| 99精品1区2区| 成av人片一区二区| 国v精品久久久网| 国产毛片一区二区| 国产一区美女在线| 国产在线精品免费av| 老司机午夜精品99久久| 日韩国产欧美在线观看| 亚洲第一成年网| 性做久久久久久| 午夜亚洲福利老司机| 亚洲国产精品天堂| 性欧美大战久久久久久久久| 日韩理论片中文av| 亚洲精品国产一区二区精华液 | 91精品综合久久久久久| 日韩一区二区三区在线| 日韩欧美你懂的| 亚洲天堂网中文字| 亚洲色图视频网站| 亚洲手机成人高清视频| 亚洲精品成人天堂一二三| 一区二区三区国产精品| 亚洲一区二区三区四区中文字幕| 亚洲国产成人精品视频| 天天亚洲美女在线视频| 免费视频一区二区| 国产精品一区一区| 成人短视频下载| 日本道色综合久久| 欧美精品黑人性xxxx| 精品三级在线观看| 中文字幕免费在线观看视频一区| 国产精品超碰97尤物18| 一区二区三区四区在线免费观看 | 日韩三级.com| 久久精品一级爱片| 亚洲精品老司机| 日韩精品色哟哟| 国产99精品国产| 欧美亚洲国产一区在线观看网站| 欧美一区二区三区的| 国产天堂亚洲国产碰碰| 一区二区三区中文字幕电影 | 精品成人免费观看| 中文字幕永久在线不卡| 婷婷成人综合网| 国产精品自拍三区| 色综合色狠狠综合色| 日韩欧美中文字幕公布| 国产精品久久久久aaaa| 午夜电影一区二区三区| 国产伦理精品不卡| 欧美日韩国产一级片| 亚洲精品在线观看网站| 1024精品合集| 美女国产一区二区| 一本一道久久a久久精品| 日韩免费观看高清完整版| 国产精品久久久久久久第一福利 | 久久亚洲二区三区| 亚洲综合清纯丝袜自拍| 国产一区二区在线免费观看| 在线一区二区观看| 国产性做久久久久久| 五月婷婷综合在线| av午夜一区麻豆| wwww国产精品欧美| 亚洲图片欧美综合| 大胆欧美人体老妇| 日韩美女视频19| 久久精品国产亚洲5555| 欧美亚洲国产怡红院影院| 欧美国产精品一区二区三区| 日本欧美一区二区| 欧美三级韩国三级日本一级| 日本一区二区三区dvd视频在线| 日韩电影免费在线| 色先锋资源久久综合| 国产日产亚洲精品系列| 美国欧美日韩国产在线播放| 在线精品视频免费播放| 国产精品久久久久久久久搜平片 | 亚洲国产精品自拍| 99久免费精品视频在线观看| 欧美成人艳星乳罩| 日本成人中文字幕在线视频| 欧洲国产伦久久久久久久| 国产精品国产三级国产aⅴ入口| 狠狠色狠狠色综合日日91app| 在线播放国产精品二区一二区四区 | 亚洲视频一二三区| 国产成人免费视频一区| 精品成人在线观看| 日日夜夜免费精品| 在线观看91视频| 亚洲免费在线播放| 99久久久久久| 亚洲三级小视频| 99精品视频在线观看免费| 国产精品久久久久毛片软件| 夫妻av一区二区| 国产精品乱码人人做人人爱| 国产1区2区3区精品美女| 日本一区二区免费在线观看视频| 国产成人在线影院| 中文字幕亚洲一区二区av在线 | 一区二区三区四区视频精品免费 | 日本特黄久久久高潮| 日韩一级二级三级精品视频| 视频一区二区不卡| 日韩欧美激情一区| 国产一区久久久| 国产精品毛片久久久久久久| 不卡在线视频中文字幕| 一区二区三区美女| 91精品午夜视频| 国产麻豆精品在线观看| 亚洲国产精品99久久久久久久久 | 亚洲一区二区三区爽爽爽爽爽| 在线观看视频一区二区欧美日韩| 亚洲成av人片一区二区三区| 日韩一本二本av| 国产69精品一区二区亚洲孕妇| 中文字幕在线播放不卡一区| 欧美色综合网站| 蜜桃视频一区二区| 国产精品污污网站在线观看 | 91精品免费在线| 精品在线你懂的| 欧美激情一区在线| 欧亚一区二区三区| 加勒比av一区二区| 亚洲丝袜自拍清纯另类| 欧美日韩一区二区在线观看视频|