Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sherckuith 0:479ce5546098 1 /*
sherckuith 0:479ce5546098 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
sherckuith 0:479ce5546098 3 * All rights reserved.
sherckuith 0:479ce5546098 4 *
sherckuith 0:479ce5546098 5 * Redistribution and use in source and binary forms, with or without modification,
sherckuith 0:479ce5546098 6 * are permitted provided that the following conditions are met:
sherckuith 0:479ce5546098 7 *
sherckuith 0:479ce5546098 8 * 1. Redistributions of source code must retain the above copyright notice,
sherckuith 0:479ce5546098 9 * this list of conditions and the following disclaimer.
sherckuith 0:479ce5546098 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
sherckuith 0:479ce5546098 11 * this list of conditions and the following disclaimer in the documentation
sherckuith 0:479ce5546098 12 * and/or other materials provided with the distribution.
sherckuith 0:479ce5546098 13 * 3. The name of the author may not be used to endorse or promote products
sherckuith 0:479ce5546098 14 * derived from this software without specific prior written permission.
sherckuith 0:479ce5546098 15 *
sherckuith 0:479ce5546098 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
sherckuith 0:479ce5546098 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sherckuith 0:479ce5546098 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
sherckuith 0:479ce5546098 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
sherckuith 0:479ce5546098 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
sherckuith 0:479ce5546098 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
sherckuith 0:479ce5546098 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
sherckuith 0:479ce5546098 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
sherckuith 0:479ce5546098 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
sherckuith 0:479ce5546098 25 * OF SUCH DAMAGE.
sherckuith 0:479ce5546098 26 *
sherckuith 0:479ce5546098 27 * This file is part of the lwIP TCP/IP stack.
sherckuith 0:479ce5546098 28 *
sherckuith 0:479ce5546098 29 * Author: Adam Dunkels <adam@sics.se>
sherckuith 0:479ce5546098 30 *
sherckuith 0:479ce5546098 31 */
sherckuith 0:479ce5546098 32
sherckuith 0:479ce5546098 33 #ifndef __LWIP_MEMP_H__
sherckuith 0:479ce5546098 34 #define __LWIP_MEMP_H__
sherckuith 0:479ce5546098 35
sherckuith 0:479ce5546098 36 #include "lwip/opt.h"
sherckuith 0:479ce5546098 37
sherckuith 0:479ce5546098 38 #ifdef __cplusplus
sherckuith 0:479ce5546098 39 extern "C" {
sherckuith 0:479ce5546098 40 #endif
sherckuith 0:479ce5546098 41
sherckuith 0:479ce5546098 42 /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
sherckuith 0:479ce5546098 43 typedef enum {
sherckuith 0:479ce5546098 44 #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
sherckuith 0:479ce5546098 45 #include "lwip/memp_std.h"
sherckuith 0:479ce5546098 46 MEMP_MAX
sherckuith 0:479ce5546098 47 } memp_t;
sherckuith 0:479ce5546098 48
sherckuith 0:479ce5546098 49 #if MEM_USE_POOLS
sherckuith 0:479ce5546098 50 /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
sherckuith 0:479ce5546098 51 typedef enum {
sherckuith 0:479ce5546098 52 /* Get the first (via:
sherckuith 0:479ce5546098 53 MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
sherckuith 0:479ce5546098 54 MEMP_POOL_HELPER_FIRST = ((u8_t)
sherckuith 0:479ce5546098 55 #define LWIP_MEMPOOL(name,num,size,desc)
sherckuith 0:479ce5546098 56 #define LWIP_MALLOC_MEMPOOL_START 1
sherckuith 0:479ce5546098 57 #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
sherckuith 0:479ce5546098 58 #define LWIP_MALLOC_MEMPOOL_END
sherckuith 0:479ce5546098 59 #include "lwip/memp_std.h"
sherckuith 0:479ce5546098 60 ) ,
sherckuith 0:479ce5546098 61 /* Get the last (via:
sherckuith 0:479ce5546098 62 MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
sherckuith 0:479ce5546098 63 MEMP_POOL_HELPER_LAST = ((u8_t)
sherckuith 0:479ce5546098 64 #define LWIP_MEMPOOL(name,num,size,desc)
sherckuith 0:479ce5546098 65 #define LWIP_MALLOC_MEMPOOL_START
sherckuith 0:479ce5546098 66 #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
sherckuith 0:479ce5546098 67 #define LWIP_MALLOC_MEMPOOL_END 1
sherckuith 0:479ce5546098 68 #include "lwip/memp_std.h"
sherckuith 0:479ce5546098 69 )
sherckuith 0:479ce5546098 70 } memp_pool_helper_t;
sherckuith 0:479ce5546098 71
sherckuith 0:479ce5546098 72 /* The actual start and stop values are here (cast them over)
sherckuith 0:479ce5546098 73 We use this helper type and these defines so we can avoid using const memp_t values */
sherckuith 0:479ce5546098 74 #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
sherckuith 0:479ce5546098 75 #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
sherckuith 0:479ce5546098 76 #endif /* MEM_USE_POOLS */
sherckuith 0:479ce5546098 77
sherckuith 0:479ce5546098 78 #if MEMP_MEM_MALLOC || MEM_USE_POOLS
sherckuith 0:479ce5546098 79 extern const u16_t memp_sizes[MEMP_MAX];
sherckuith 0:479ce5546098 80 #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
sherckuith 0:479ce5546098 81
sherckuith 0:479ce5546098 82 #if MEMP_MEM_MALLOC
sherckuith 0:479ce5546098 83
sherckuith 0:479ce5546098 84 #include "mem.h"
sherckuith 0:479ce5546098 85
sherckuith 0:479ce5546098 86 #define memp_init()
sherckuith 0:479ce5546098 87 #define memp_malloc(type) mem_malloc(memp_sizes[type])
sherckuith 0:479ce5546098 88 #define memp_free(type, mem) mem_free(mem)
sherckuith 0:479ce5546098 89
sherckuith 0:479ce5546098 90 #else /* MEMP_MEM_MALLOC */
sherckuith 0:479ce5546098 91
sherckuith 0:479ce5546098 92 #if MEM_USE_POOLS
sherckuith 0:479ce5546098 93 /** This structure is used to save the pool one element came from. */
sherckuith 0:479ce5546098 94 struct memp_malloc_helper
sherckuith 0:479ce5546098 95 {
sherckuith 0:479ce5546098 96 memp_t poolnr;
sherckuith 0:479ce5546098 97 };
sherckuith 0:479ce5546098 98 #endif /* MEM_USE_POOLS */
sherckuith 0:479ce5546098 99
sherckuith 0:479ce5546098 100 void memp_init(void);
sherckuith 0:479ce5546098 101
sherckuith 0:479ce5546098 102 #if MEMP_OVERFLOW_CHECK
sherckuith 0:479ce5546098 103 void *memp_malloc_fn(memp_t type, const char* file, const int line);
sherckuith 0:479ce5546098 104 #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
sherckuith 0:479ce5546098 105 #else
sherckuith 0:479ce5546098 106 void *memp_malloc(memp_t type);
sherckuith 0:479ce5546098 107 #endif
sherckuith 0:479ce5546098 108 void memp_free(memp_t type, void *mem);
sherckuith 0:479ce5546098 109
sherckuith 0:479ce5546098 110 #endif /* MEMP_MEM_MALLOC */
sherckuith 0:479ce5546098 111
sherckuith 0:479ce5546098 112 #ifdef __cplusplus
sherckuith 0:479ce5546098 113 }
sherckuith 0:479ce5546098 114 #endif
sherckuith 0:479ce5546098 115
sherckuith 0:479ce5546098 116 #endif /* __LWIP_MEMP_H__ */