|
||||
Warning, cross-references for /kernel/include/lwip/memp.h need to be fixed.
0001 /* 0002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 0003 * All rights reserved. 0004 * 0005 * Redistribution and use in source and binary forms, with or without modification, 0006 * are permitted provided that the following conditions are met: 0007 * 0008 * 1. Redistributions of source code must retain the above copyright notice, 0009 * this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright notice, 0011 * this list of conditions and the following disclaimer in the documentation 0012 * and/or other materials provided with the distribution. 0013 * 3. The name of the author may not be used to endorse or promote products 0014 * derived from this software without specific prior written permission. 0015 * 0016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 0017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 0018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 0019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 0021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 0024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 0025 * OF SUCH DAMAGE. 0026 * 0027 * This file is part of the lwIP TCP/IP stack. 0028 * 0029 * Author: Adam Dunkels <adam@sics.se> 0030 * 0031 */ 0032 0033 #ifndef __LWIP_MEMP_H__ 0034 #define __LWIP_MEMP_H__ 0035 0036 #include "lwip/opt.h" 0037 0038 #ifdef __cplusplus 0039 extern "C" { 0040 #endif 0041 0042 /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ 0043 typedef enum { 0044 #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, 0045 #include "lwip/memp_std.h" 0046 MEMP_MAX 0047 } memp_t; 0048 0049 #if MEM_USE_POOLS 0050 /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ 0051 typedef enum { 0052 /* Get the first (via: 0053 MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ 0054 MEMP_POOL_HELPER_FIRST = ((u8_t) 0055 #define LWIP_MEMPOOL(name,num,size,desc) 0056 #define LWIP_MALLOC_MEMPOOL_START 1 0057 #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 0058 #define LWIP_MALLOC_MEMPOOL_END 0059 #include "lwip/memp_std.h" 0060 ) , 0061 /* Get the last (via: 0062 MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ 0063 MEMP_POOL_HELPER_LAST = ((u8_t) 0064 #define LWIP_MEMPOOL(name,num,size,desc) 0065 #define LWIP_MALLOC_MEMPOOL_START 0066 #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * 0067 #define LWIP_MALLOC_MEMPOOL_END 1 0068 #include "lwip/memp_std.h" 0069 ) 0070 } memp_pool_helper_t; 0071 0072 /* The actual start and stop values are here (cast them over) 0073 We use this helper type and these defines so we can avoid using const memp_t values */ 0074 #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) 0075 #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) 0076 #endif /* MEM_USE_POOLS */ 0077 0078 #if MEMP_MEM_MALLOC || MEM_USE_POOLS 0079 extern const u16_t memp_sizes[MEMP_MAX]; 0080 #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ 0081 0082 #if MEMP_MEM_MALLOC 0083 0084 #include "mem.h" 0085 0086 #define memp_init() 0087 #define memp_malloc(type) mem_malloc(memp_sizes[type]) 0088 #define memp_free(type, mem) mem_free(mem) 0089 0090 #else /* MEMP_MEM_MALLOC */ 0091 0092 #if MEM_USE_POOLS 0093 /** This structure is used to save the pool one element came from. */ 0094 struct memp_malloc_helper 0095 { 0096 memp_t poolnr; 0097 }; 0098 #endif /* MEM_USE_POOLS */ 0099 0100 void memp_init(void); 0101 0102 #if MEMP_OVERFLOW_CHECK 0103 void *memp_malloc_fn(memp_t type, const char* file, const int line); 0104 #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) 0105 #else 0106 void *memp_malloc(memp_t type); 0107 #endif 0108 void memp_free(memp_t type, void *mem); 0109 0110 #endif /* MEMP_MEM_MALLOC */ 0111 0112 #ifdef __cplusplus 0113 } 0114 #endif 0115 0116 #endif /* __LWIP_MEMP_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |