/** * @file * memory pools lwIP internal implementations (do not use in application code) *//* ... *//* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels <adam@sics.se> * *//* ... */#ifndefLWIP_HDR_MEMP_PRIV_H#defineLWIP_HDR_MEMP_PRIV_H#include"lwip/opt.h"#ifdef__cplusplusextern"C"{#endif#include"lwip/mem.h"#include"lwip/priv/mem_priv.h"#ifMEMP_OVERFLOW_CHECK/* MEMP_SIZE: save space for struct memp and for sanity check */#defineMEMP_SIZE(LWIP_MEM_ALIGN_SIZE(sizeof(structmemp))+MEM_SANITY_REGION_BEFORE_ALIGNED)#defineMEMP_ALIGN_SIZE(x)(LWIP_MEM_ALIGN_SIZE(x)+MEM_SANITY_REGION_AFTER_ALIGNED)/* ... */#else/* MEMP_OVERFLOW_CHECK *//* No sanity checks * We don't need to preserve the struct memp while not allocated, so we * can save a little space and set MEMP_SIZE to 0. *//* ... */#defineMEMP_SIZE0#defineMEMP_ALIGN_SIZE(x)(LWIP_MEM_ALIGN_SIZE(x))/* ... */#endif/* MEMP_OVERFLOW_CHECK */#if!MEMP_MEM_MALLOC||MEMP_OVERFLOW_CHECKstructmemp{structmemp*next;#ifMEMP_OVERFLOW_CHECKconstchar*file;intline;/* ... */#endif/* MEMP_OVERFLOW_CHECK */...};/* ... */#endif/* !MEMP_MEM_MALLOC || MEMP_OVERFLOW_CHECK */#ifMEM_USE_POOLS&&MEMP_USE_CUSTOM_POOLS/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */typedefenum{/* Get the first (via: MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*//* ... */MEMP_POOL_HELPER_FIRST=((u8_t)#defineLWIP_MEMPOOL(name,num,size,desc)#defineLWIP_MALLOC_MEMPOOL_START1#defineLWIP_MALLOC_MEMPOOL(num,size)*MEMP_POOL_##size+0#defineLWIP_MALLOC_MEMPOOL_END#include"lwip/priv/memp_std.h"),/* Get the last (via: MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) *//* ... */MEMP_POOL_HELPER_LAST=((u8_t)#defineLWIP_MEMPOOL(name,num,size,desc)#defineLWIP_MALLOC_MEMPOOL_START#defineLWIP_MALLOC_MEMPOOL(num,size)0+MEMP_POOL_##size*#defineLWIP_MALLOC_MEMPOOL_END1#include"lwip/priv/memp_std.h")...}memp_pool_helper_t;/* The actual start and stop values are here (cast them over) We use this helper type and these defines so we can avoid using const memp_t values *//* ... */#defineMEMP_POOL_FIRST((memp_t)MEMP_POOL_HELPER_FIRST)#defineMEMP_POOL_LAST((memp_t)MEMP_POOL_HELPER_LAST)/* ... */#endif/* MEM_USE_POOLS && MEMP_USE_CUSTOM_POOLS *//** Memory pool descriptor */structmemp_desc{#ifdefined(LWIP_DEBUG)||MEMP_OVERFLOW_CHECK||LWIP_STATS_DISPLAY/** Textual description */constchar*desc;/* ... */#endif/* LWIP_DEBUG || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY */#ifMEMP_STATS/** Statistics */structstats_mem*stats;/* ... */#endif/** Element size */u16_tsize;#if!MEMP_MEM_MALLOC/** Number of elements */u16_tnum;/** Base address */u8_t*base;/** First free element of each pool. Elements form a linked list. */structmemp**tab;/* ... */#endif/* MEMP_MEM_MALLOC */...};#ifdefined(LWIP_DEBUG)||MEMP_OVERFLOW_CHECK||LWIP_STATS_DISPLAY#defineDECLARE_LWIP_MEMPOOL_DESC(desc)(desc),#else#defineDECLARE_LWIP_MEMPOOL_DESC(desc)#endif#ifMEMP_STATS#defineLWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name)staticstructstats_memname;#defineLWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name)&name,/* ... */#else#defineLWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name)#defineLWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name)/* ... */#endifvoidmemp_init_pool(conststructmemp_desc*desc);#ifMEMP_OVERFLOW_CHECKvoid*memp_malloc_pool_fn(conststructmemp_desc*desc,constchar*file,constintline);#definememp_malloc_pool(d)memp_malloc_pool_fn((d),__FILE__,__LINE__)/* ... */#elsevoid*memp_malloc_pool(conststructmemp_desc*desc);#endifvoidmemp_free_pool(conststructmemp_desc*desc,void*mem);#ifdef__cplusplus}extern "C" { ... }#endif/* ... */#endif/* LWIP_HDR_MEMP_PRIV_H */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.